clan-app: added header files
This commit is contained in:
@@ -3,17 +3,39 @@ import sys
|
|||||||
|
|
||||||
from clan_cli.profiler import profile
|
from clan_cli.profiler import profile
|
||||||
|
|
||||||
from clan_app.app import MainApplication
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
from urllib.parse import quote
|
from clan_cli.custom_logger import setup_logging
|
||||||
|
|
||||||
from clan_app.deps.webview.webview import Webview
|
from clan_app.deps.webview.webview import Webview
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
@profile
|
@profile
|
||||||
def main(argv: list[str] = sys.argv) -> int:
|
def main(argv: list[str] = sys.argv) -> int:
|
||||||
|
parser = argparse.ArgumentParser(description="Clan App")
|
||||||
|
parser.add_argument("--content-uri", type=str, help="The URI of the content to display")
|
||||||
|
parser.add_argument("--debug", action="store_true", help="Enable debug mode")
|
||||||
|
args = parser.parse_args(argv[1:])
|
||||||
|
|
||||||
|
if args.debug:
|
||||||
|
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
|
||||||
|
setup_logging(logging.DEBUG, root_log_name="clan_cli")
|
||||||
|
else:
|
||||||
|
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
||||||
|
|
||||||
|
log.debug("Debug mode enabled")
|
||||||
|
|
||||||
|
if args.content_uri:
|
||||||
|
content_uri = args.content_uri
|
||||||
|
else:
|
||||||
|
site_index: Path = Path(os.getenv("WEBUI_PATH", ".")).resolve() / "index.html"
|
||||||
|
content_uri = f"file://{site_index}"
|
||||||
|
|
||||||
|
site_index: Path = Path(os.getenv("WEBUI_PATH", ".")).resolve() / "index.html"
|
||||||
|
content_uri = f"file://{site_index}"
|
||||||
|
|
||||||
html = """
|
html = """
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
@@ -21,8 +43,9 @@ def main(argv: list[str] = sys.argv) -> int:
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
webview = Webview()
|
webview = Webview()
|
||||||
webview.navigate(f"data:text/html,{quote(html)}")
|
webview.navigate(f"data:text/html,{quote(html)}")
|
||||||
|
#webview.navigate(content_uri)
|
||||||
webview.run()
|
webview.run()
|
||||||
app = MainApplication()
|
|
||||||
return app.run(argv)
|
|
||||||
|
|||||||
@@ -34,14 +34,6 @@ def _get_lib_names():
|
|||||||
|
|
||||||
def _be_sure_libraries():
|
def _be_sure_libraries():
|
||||||
"""Ensure libraries exist and return paths."""
|
"""Ensure libraries exist and return paths."""
|
||||||
if getattr(sys, 'frozen', False):
|
|
||||||
if hasattr(sys, '_MEIPASS'):
|
|
||||||
base_dir = Path(sys._MEIPASS)
|
|
||||||
else:
|
|
||||||
base_dir = Path(sys.executable).parent / '_internal'
|
|
||||||
else:
|
|
||||||
base_dir = Path(__file__).parent
|
|
||||||
from ctypes.util import find_library
|
|
||||||
|
|
||||||
lib_dir = os.environ.get("WEBVIEW_LIB_DIR")
|
lib_dir = os.environ.get("WEBVIEW_LIB_DIR")
|
||||||
if not lib_dir:
|
if not lib_dir:
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ mkShell {
|
|||||||
ruff
|
ruff
|
||||||
gtk4
|
gtk4
|
||||||
clang
|
clang
|
||||||
|
webview-wrapper.dev
|
||||||
webview-wrapper
|
webview-wrapper
|
||||||
gtk4.dev # has the demo called 'gtk4-widget-factory'
|
gtk4.dev # has the demo called 'gtk4-widget-factory'
|
||||||
libadwaita.devdoc # has the demo called 'adwaita-1-demo'
|
libadwaita.devdoc # has the demo called 'adwaita-1-demo'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ pkgs }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
pname = "webview";
|
pname = "webview";
|
||||||
@@ -22,7 +22,6 @@ pkgs.stdenv.mkDerivation {
|
|||||||
gtk4
|
gtk4
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
meta = with pkgs.lib; {
|
meta = with pkgs.lib; {
|
||||||
description = "Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows)";
|
description = "Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows)";
|
||||||
homepage = "https://github.com/webview/webview";
|
homepage = "https://github.com/webview/webview";
|
||||||
|
|||||||
Reference in New Issue
Block a user