[epiphany/mcatanzaro/view-source-context-menu] Hide view page source context menu items when required



commit 68c8b9197f4371309b7c070cff79ac86136668f9
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Jan 11 14:53:33 2020 -0600

    Hide view page source context menu items when required
    
    Doesn't make sense to allow view page source or inspect element when we
    are already on a view source page.
    
    Fixes #1046

 src/ephy-window.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 59f0e661f..e074c8536 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1491,6 +1491,7 @@ populate_context_menu (WebKitWebView       *web_view,
   char *search_selection_action_name = NULL;
   char *open_selection_action_name = NULL;
   const char *selected_text = NULL;
+  const char *uri = NULL;
 
   if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
                               EPHY_PREFS_LOCKDOWN_CONTEXT_MENU))
@@ -1771,12 +1772,15 @@ populate_context_menu (WebKitWebView       *web_view,
     add_action_to_context_menu (context_menu, window_action_group,
                                 "save-as", window);
 
-    webkit_context_menu_append (context_menu,
-                                webkit_context_menu_item_new_separator ());
-    add_action_to_context_menu (context_menu, window_action_group,
-                                "page-source", window);
-    webkit_context_menu_append (context_menu,
-                                webkit_context_menu_item_new_from_stock_action 
(WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT));
+    uri = webkit_web_view_get_uri (web_view);
+    if (uri && !strstr (uri, "ephy-src")) {
+      webkit_context_menu_append (context_menu,
+                                  webkit_context_menu_item_new_separator ());
+      add_action_to_context_menu (context_menu, window_action_group,
+                                  "page-source", window);
+      webkit_context_menu_append (context_menu,
+                                  webkit_context_menu_item_new_from_stock_action 
(WEBKIT_CONTEXT_MENU_ACTION_INSPECT_ELEMENT));
+    }
   }
 
   return GDK_EVENT_PROPAGATE;


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