[devhelp] App: use gtk_application_prefers_app_menu()



commit 012475cdfa6bebccc0176c844b10621da1e7cb06
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Dec 15 15:15:53 2017 +0100

    App: use gtk_application_prefers_app_menu()
    
    _dh_app_has_app_menu() has been implemented by commit 0aba006d, in 2013.
    gtk_application_prefers_app_menu() has been added in GTK+ 3.14, released
    in September 2014. So it's probably better to use the latter, to
    simplify the code.

 src/dh-app.c    |   25 +------------------------
 src/dh-app.h    |    2 --
 src/dh-window.c |    4 +++-
 3 files changed, 4 insertions(+), 27 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index 394deb6..659fda1 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -67,29 +67,6 @@ peek_assistant (DhApp *app)
         return NULL;
 }
 
-gboolean
-_dh_app_has_app_menu (DhApp *app)
-{
-        GtkSettings *gtk_settings;
-        gboolean show_app_menu;
-        gboolean show_menubar;
-
-        g_return_val_if_fail (DH_IS_APP (app), FALSE);
-
-        /* We have three cases:
-         * - GNOME 3: show-app-menu true, show-menubar false -> use the app menu
-         * - Unity, OSX: show-app-menu and show-menubar true -> use the normal menu
-         * - Other WM, Windows: show-app-menu and show-menubar false -> use the normal menu
-         */
-        gtk_settings = gtk_settings_get_default ();
-        g_object_get (G_OBJECT (gtk_settings),
-                      "gtk-shell-shows-app-menu", &show_app_menu,
-                      "gtk-shell-shows-menubar", &show_menubar,
-                      NULL);
-
-        return show_app_menu && !show_menubar;
-}
-
 /******************************************************************************/
 /* Application action activators */
 
@@ -389,7 +366,7 @@ dh_app_startup (GApplication *application)
                                          app_entries, G_N_ELEMENTS (app_entries),
                                          app);
 
-        if (_dh_app_has_app_menu (app)) {
+        if (gtk_application_prefers_app_menu (GTK_APPLICATION (app))) {
                 GtkBuilder *builder;
                 GError *error = NULL;
 
diff --git a/src/dh-app.h b/src/dh-app.h
index 45ba059..1456738 100644
--- a/src/dh-app.h
+++ b/src/dh-app.h
@@ -49,8 +49,6 @@ GtkWindow *     dh_app_peek_first_window        (DhApp *app);
 
 void            dh_app_new_window               (DhApp *app);
 
-gboolean        _dh_app_has_app_menu            (DhApp *app);
-
 G_END_DECLS
 
 #endif /* DH_APP_H */
diff --git a/src/dh-window.c b/src/dh-window.c
index 10f2ec9..b65b73c 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -653,6 +653,7 @@ static void
 dh_window_init (DhWindow *window)
 {
         DhWindowPrivate *priv;
+        GtkApplication *app;
         DhSettings    *settings;
         GtkAccelGroup *accel_group;
         GClosure      *closure;
@@ -663,7 +664,8 @@ dh_window_init (DhWindow *window)
         priv = dh_window_get_instance_private (window);
         priv->selected_search_link = NULL;
 
-        if (!_dh_app_has_app_menu (DH_APP (g_application_get_default ()))) {
+        app = GTK_APPLICATION (g_application_get_default ());
+        if (!gtk_application_prefers_app_menu (app)) {
                 gtk_menu_button_set_menu_model (priv->gear_menu_button, priv->gear_app_menu);
         }
 


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