[epiphany] Provide the Inspect Element menu item again



commit c87401f28cb8ef3a645dfd5a687be6ddbbfe6790
Author: Gustavo Noronha Silva <gns gnome org>
Date:   Tue Oct 27 08:09:57 2009 -0200

    Provide the Inspect Element menu item again
    
    WebKit now provides API to start the web inspector, so we can restore
    the menu item.
    
    Bug #599473

 data/ui/epiphany-ui.xml |    8 ++++++++
 src/ephy-window.c       |    9 +++++++++
 src/popup-commands.c    |   21 +++++++++++++++++++++
 src/popup-commands.h    |    3 +++
 4 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml
index 1f3dcac..5be9e4f 100644
--- a/data/ui/epiphany-ui.xml
+++ b/data/ui/epiphany-ui.xml
@@ -117,6 +117,8 @@
 		<menuitem name="SaveImageAsIP" action="SaveImageAs"/>
 		<menuitem name="SetImageAsBackgroundIP" action="SetImageAsBackground"/>
 		<menuitem name="CopyImageLocationIP" action="CopyImageLocation"/>
+		<separator />
+		<menuitem name="InspectElementIP" action="InspectElement"/>
 	</popup>
 
 	<popup name="EphyDocumentPopup" action="PopupAction">
@@ -134,6 +136,8 @@
 		<menuitem name="SaveImageAsDP" action="SaveImageAs"/>
 		<menuitem name="SetImageAsBackgroundDP" action="SetImageAsBackground"/>
 		<menuitem name="CopyImageLocationDP" action="CopyImageLocation"/>
+		<separator />
+		<menuitem name="InspectElementDP" action="InspectElement"/>
 	</popup>
 
 	<popup name="EphyLinkPopup" action="PopupAction">
@@ -152,6 +156,8 @@
 		<menuitem name="SaveImageAsLP" action="SaveImageAs"/>
 		<menuitem name="SetImageAsBackgroundLP" action="SetImageAsBackground"/>
 		<menuitem name="CopyImageLocationLP" action="CopyImageLocation"/>
+		<separator />
+		<menuitem name="InspectElementLP" action="InspectElement"/>
 	</popup>
 
 	<popup name="EphyEmailLinkPopup" action="PopupAction">
@@ -164,6 +170,8 @@
 		<menuitem name="SaveImageAsELP" action="SaveImageAs"/>
 		<menuitem name="SetImageAsBackgroundELP" action="SetImageAsBackground"/>
 		<menuitem name="CopyImageLocationELP" action="CopyImageLocation"/>
+		<separator />
+		<menuitem name="InspectElementELP" action="InspectElement"/>
 	</popup>
 
 	<popup name="EphyNotebookPopup" action="NotebookPopupAction">
diff --git a/src/ephy-window.c b/src/ephy-window.c
index df0c7df..a734e94 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -345,6 +345,10 @@ static const GtkActionEntry ephy_popups_entries [] = {
 	  NULL, NULL },
 	{ "StopImageAnimation", NULL, N_("St_op Animation"), NULL,
 	  NULL, NULL },
+
+	/* Inspector */
+	{ "InspectElement", NULL, N_("Inspect _Element"), NULL,
+	  NULL, G_CALLBACK (popup_cmd_inspect_element) },
 };
 
 static const struct
@@ -1119,6 +1123,7 @@ update_popup_actions_visibility (EphyWindow *window,
 {
 	GtkAction *action;
 	GtkActionGroup *action_group;
+	gboolean inspector_enabled;
 
 	action_group = window->priv->popups_action_group;
 
@@ -1133,6 +1138,10 @@ update_popup_actions_visibility (EphyWindow *window,
 
 	action = gtk_action_group_get_action (action_group, "OpenFrame");
 	gtk_action_set_visible (action, is_frame);
+
+	inspector_enabled = eel_gconf_get_boolean (CONF_WEB_INSPECTOR_ENABLED);
+	action = gtk_action_group_get_action (action_group, "InspectElement");
+	gtk_action_set_visible (action, inspector_enabled);
 }
 
 static void
diff --git a/src/popup-commands.c b/src/popup-commands.c
index cbaf1e4..755817e 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -521,3 +521,24 @@ popup_cmd_open_image (GtkAction *action,
 	g_value_unset (&value);
 	g_free (scheme);
 }
+
+void
+popup_cmd_inspect_element (GtkAction *action, EphyWindow *window)
+{
+	EphyEmbedEvent *event;
+	EphyEmbed *embed;
+	WebKitWebInspector *inspector;
+	guint x, y;
+
+	embed = ephy_embed_container_get_active_child
+		(EPHY_EMBED_CONTAINER (window));
+
+	event = ephy_window_get_context_event (window);
+	g_return_if_fail (event != NULL);
+
+	inspector = webkit_web_view_get_inspector
+		(EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
+
+	ephy_embed_event_get_coords (event, &x, &y);
+	webkit_web_inspector_inspect_coordinates (inspector, (gdouble)x, (gdouble)y);
+}
diff --git a/src/popup-commands.h b/src/popup-commands.h
index b1531bd..ddfc676 100644
--- a/src/popup-commands.h
+++ b/src/popup-commands.h
@@ -65,3 +65,6 @@ void popup_cmd_download_link		(GtkAction *action,
 
 void popup_cmd_save_image_as		(GtkAction *action,
 					 EphyWindow *window);
+
+void popup_cmd_inspect_element		(GtkAction *action,
+					 EphyWindow *window);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]