[epiphany/pgriffis/web-extension/open-inspector: 5/5] WebExtensions: Add easy button to open web-inspector for background page
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/pgriffis/web-extension/open-inspector: 5/5] WebExtensions: Add easy button to open web-inspector for background page
- Date: Sun, 10 Jul 2022 16:35:05 +0000 (UTC)
commit 7827c2b472cfe249f624658bf4dc1387208065b4
Author: Patrick Griffis <pgriffis igalia com>
Date: Sat Jul 9 20:46:10 2022 -0500
WebExtensions: Add easy button to open web-inspector for background page
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1169>
src/ephy-web-extension-dialog.c | 19 ++++++++++++++++++-
src/webextension/ephy-web-extension-manager.c | 12 ++++++++++++
src/webextension/ephy-web-extension-manager.h | 3 +++
3 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/src/ephy-web-extension-dialog.c b/src/ephy-web-extension-dialog.c
index 5d2facf10..32d6a9e69 100644
--- a/src/ephy-web-extension-dialog.c
+++ b/src/ephy-web-extension-dialog.c
@@ -99,6 +99,16 @@ on_remove_button_clicked (GtkButton *button,
gtk_window_present (GTK_WINDOW (dialog));
}
+static void
+on_inspector_button_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ EphyWebExtension *web_extension = EPHY_WEB_EXTENSION (user_data);
+ EphyWebExtensionManager *manager = ephy_web_extension_manager_get_default ();
+
+ ephy_web_extension_manager_open_inspector (manager, web_extension);
+}
+
static void
toggle_state_set_cb (GtkSwitch *widget,
gboolean state,
@@ -196,10 +206,17 @@ create_row (EphyWebExtensionDialog *self,
g_object_set_data (G_OBJECT (sub_row), "web_extension", web_extension);
}
- /* Remove button */
+ /* Action buttons */
sub_row = hdy_action_row_new ();
gtk_container_add (GTK_CONTAINER (row), sub_row);
+ button = gtk_button_new_with_mnemonic (_("Open _Inspector"));
+ gtk_widget_set_valign (GTK_WIDGET (button), GTK_ALIGN_CENTER);
+ gtk_widget_set_tooltip_text (button, _("Open Inspector for debugging Background Page"));
+ g_object_bind_property (toggle, "active", button, "sensitive", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+ g_signal_connect (button, "clicked", G_CALLBACK (on_inspector_button_clicked), web_extension);
+ gtk_container_add (GTK_CONTAINER (sub_row), button);
+
button = gtk_button_new_with_mnemonic (_("_Remove"));
gtk_widget_set_valign (GTK_WIDGET (button), GTK_ALIGN_CENTER);
dzl_gtk_widget_add_style_class (button, "destructive-action");
diff --git a/src/webextension/ephy-web-extension-manager.c b/src/webextension/ephy-web-extension-manager.c
index f5a026d60..4d37b2f80 100644
--- a/src/webextension/ephy-web-extension-manager.c
+++ b/src/webextension/ephy-web-extension-manager.c
@@ -338,6 +338,18 @@ ephy_web_extension_manager_get_web_extensions (EphyWebExtensionManager *self)
return self->web_extensions;
}
+void
+ephy_web_extension_manager_open_inspector (EphyWebExtensionManager *self,
+ EphyWebExtension *web_extension)
+{
+ WebKitWebView *background_page = ephy_web_extension_manager_get_background_web_view (self, web_extension);
+
+ if (!background_page)
+ return;
+
+ webkit_web_inspector_show (webkit_web_view_get_inspector (background_page));
+}
+
/**
* Installs/Adds all web_extensions to new EphyWindow.
*/
diff --git a/src/webextension/ephy-web-extension-manager.h b/src/webextension/ephy-web-extension-manager.h
index b7bc91627..77e1adba9 100644
--- a/src/webextension/ephy-web-extension-manager.h
+++ b/src/webextension/ephy-web-extension-manager.h
@@ -112,4 +112,7 @@ void ephy_web_extension_manager_append_context_menu
gboolean
is_audio,
gboolean
is_video);
+void ephy_web_extension_manager_open_inspector
(EphyWebExtensionManager *self,
+ EphyWebExtension
*web_extension);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]