clan-app: Add automatic debug console in debug mode
This commit is contained in:
@@ -5,7 +5,6 @@ from typing import Any, ClassVar
|
||||
import gi
|
||||
|
||||
from clan_app import assets
|
||||
from clan_app.singletons.toast import InfoToast, ToastOverlay
|
||||
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
@@ -90,11 +89,6 @@ class MainApplication(Adw.Application):
|
||||
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
||||
log.debug("Debug logging enabled")
|
||||
|
||||
if "debug" in options:
|
||||
ToastOverlay.use().add_toast_unique(
|
||||
InfoToast("Debug logging enabled").toast, "info.debugging.enabled"
|
||||
)
|
||||
|
||||
if "content-uri" in options:
|
||||
self.content_uri = options["content-uri"]
|
||||
log.debug(f"Setting content uri to {self.content_uri}")
|
||||
|
||||
@@ -26,9 +26,10 @@ class WebExecutor(GObject.Object):
|
||||
# settings.
|
||||
settings.set_property("enable-developer-extras", True)
|
||||
self.webview.set_settings(settings)
|
||||
# Fixme. This filtering is incomplete, it only triggers if a user clicks a link
|
||||
# FIXME: This filtering is incomplete, it only triggers if a user clicks a link
|
||||
self.webview.connect("decide-policy", self.on_decide_policy)
|
||||
|
||||
# For when the page is fully loaded
|
||||
self.webview.connect("load-changed", self.on_load_changed)
|
||||
self.manager: WebKit.UserContentManager = (
|
||||
self.webview.get_user_content_manager()
|
||||
)
|
||||
@@ -45,6 +46,14 @@ class WebExecutor(GObject.Object):
|
||||
self.api.overwrite_fn(open_file)
|
||||
self.api.check_signature(self.jschema_api.signatures)
|
||||
|
||||
def on_load_changed(
|
||||
self, webview: WebKit.WebView, load_event: WebKit.LoadEvent
|
||||
) -> None:
|
||||
if load_event == WebKit.LoadEvent.FINISHED:
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
inspector = webview.get_inspector()
|
||||
inspector.show()
|
||||
|
||||
def on_decide_policy(
|
||||
self,
|
||||
webview: WebKit.WebView,
|
||||
|
||||
Reference in New Issue
Block a user