[evolution] Shell: Make it possible to show webkit://gpu information



commit 0f0f6d7b271f2d23aaac1adac1725772aa2d1ce2
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jan 6 10:15:10 2021 +0100

    Shell: Make it possible to show webkit://gpu information
    
    This adds a menu Help->Show WebKit GPU information item, which opens
    webkit://gpu page in the WebKitWebView of the current shell window.
    The menu option is shown only if webkit-developer-mode is set
    in the org.gnome.evolution.shell GSettings.

 data/ui/evolution-shell.ui         |  1 +
 src/shell/e-shell-window-actions.c | 51 ++++++++++++++++++++++++++++++++++++++
 src/shell/e-shell-window-actions.h |  2 ++
 3 files changed, 54 insertions(+)
---
diff --git a/data/ui/evolution-shell.ui b/data/ui/evolution-shell.ui
index 75b467bcc4..ccb626da06 100644
--- a/data/ui/evolution-shell.ui
+++ b/data/ui/evolution-shell.ui
@@ -81,6 +81,7 @@
       <menuitem action='shortcuts'/>
       <separator/>
       <menuitem action='submit-bug'/>
+      <menuitem action='show-webkit-gpu'/>
       <separator/>
       <menuitem action='about'/>
     </menu>
diff --git a/src/shell/e-shell-window-actions.c b/src/shell/e-shell-window-actions.c
index c3eeaa7efb..a4d0829720 100644
--- a/src/shell/e-shell-window-actions.c
+++ b/src/shell/e-shell-window-actions.c
@@ -657,6 +657,45 @@ action_submit_bug_cb (GtkAction *action,
        }
 }
 
+static WebKitWebView *
+shell_window_actions_find_webview (GtkContainer *container)
+{
+       GList *children, *link;
+       WebKitWebView *webview = NULL;
+
+       if (!container)
+               return NULL;
+
+       children = gtk_container_get_children (container);
+
+       for (link = children; link && !webview; link = g_list_next (link)) {
+               GtkWidget *child = link->data;
+
+               if (WEBKIT_IS_WEB_VIEW (child))
+                       webview = WEBKIT_WEB_VIEW (child);
+               else if (GTK_IS_CONTAINER (child))
+                       webview = shell_window_actions_find_webview (GTK_CONTAINER (child));
+       }
+
+       g_list_free (children);
+
+       return webview;
+}
+
+static void
+action_show_webkit_gpu_cb (GtkAction *action,
+                          EShellWindow *shell_window)
+{
+       WebKitWebView *webview;
+
+       webview = shell_window_actions_find_webview (GTK_CONTAINER (shell_window));
+
+       if (webview)
+               webkit_web_view_load_uri (webview, "webkit://gpu");
+       else
+               g_message ("%s: No WebKitWebView found", G_STRFUNC);
+}
+
 static void
 action_switcher_cb (GtkRadioAction *action,
                     GtkRadioAction *current,
@@ -1024,6 +1063,13 @@ static GtkActionEntry shell_entries[] = {
          N_("Show keyboard shortcuts"),
          G_CALLBACK (action_shortcuts_cb) },
 
+       { "show-webkit-gpu",
+         NULL,
+         N_("Show _WebKit GPU information"),
+         NULL,
+         N_("Show WebKit GPU information page in the preview panel"),
+         G_CALLBACK (action_show_webkit_gpu_cb) },
+
        { "submit-bug",
          NULL,
          N_("Submit _Bug Report…"),
@@ -1329,6 +1375,7 @@ e_shell_window_actions_init (EShellWindow *shell_window)
 {
        GtkActionGroup *action_group;
        EFocusTracker *focus_tracker;
+       GSettings *settings;
        GtkUIManager *ui_manager;
        gchar *path;
 
@@ -1463,6 +1510,10 @@ e_shell_window_actions_init (EShellWindow *shell_window)
        if (path == NULL)
                gtk_action_set_visible (ACTION (SUBMIT_BUG), FALSE);
        g_free (path);
+
+       settings = e_util_ref_settings ("org.gnome.evolution.shell");
+       gtk_action_set_visible (ACTION (SHOW_WEBKIT_GPU), g_settings_get_boolean (settings, 
"webkit-developer-mode"));
+       g_object_unref (settings);
 }
 
 GtkWidget *
diff --git a/src/shell/e-shell-window-actions.h b/src/shell/e-shell-window-actions.h
index 3d55c7fe15..65aed59e6b 100644
--- a/src/shell/e-shell-window-actions.h
+++ b/src/shell/e-shell-window-actions.h
@@ -90,6 +90,8 @@
        E_SHELL_WINDOW_ACTION ((window), "show-taskbar")
 #define E_SHELL_WINDOW_ACTION_SHOW_TOOLBAR(window) \
        E_SHELL_WINDOW_ACTION ((window), "show-toolbar")
+#define E_SHELL_WINDOW_ACTION_SHOW_WEBKIT_GPU(window) \
+       E_SHELL_WINDOW_ACTION ((window), "show-webkit-gpu")
 #define E_SHELL_WINDOW_ACTION_SUBMIT_BUG(window) \
        E_SHELL_WINDOW_ACTION ((window), "submit-bug")
 #define E_SHELL_WINDOW_ACTION_SWITCHER_INITIAL(window) \


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