From c87401f28cb8ef3a645dfd5a687be6ddbbfe6790 Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Tue, 27 Oct 2009 08:09:57 -0200 Subject: 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(+) diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml index 1f3dcaceb..5be9e4f26 100644 --- a/data/ui/epiphany-ui.xml +++ b/data/ui/epiphany-ui.xml @@ -117,6 +117,8 @@ + + @@ -134,6 +136,8 @@ + + @@ -152,6 +156,8 @@ + + @@ -164,6 +170,8 @@ + + diff --git a/src/ephy-window.c b/src/ephy-window.c index df0c7dfb1..a734e94f9 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 cbaf1e46b..755817e82 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 b1531bd5f..ddfc67632 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); -- cgit v1.2.3