[mutter] prefs: Show fallback app menu based on XSetting



commit f10cb02cbfebf31dfaf266c0eb74595bc86ecd68
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Sep 13 16:27:20 2014 +0200

    prefs: Show fallback app menu based on XSetting
    
    Going through GSD's settings was done in context of patches that
    did not land; it is simpler and more consistent with GTK+ to use
    the corresponding XSetting instead.

 src/core/prefs.c |   67 ++++++++++-------------------------------------------
 1 files changed, 13 insertions(+), 54 deletions(-)
---
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 1c8c489..9d01d00 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -53,7 +53,6 @@
 #define KEY_GNOME_ANIMATIONS "enable-animations"
 #define KEY_GNOME_CURSOR_THEME "cursor-theme"
 #define KEY_XKB_OPTIONS "xkb-options"
-#define KEY_XSETTINGS_OVERRIDES "overrides"
 
 #define KEY_OVERLAY_KEY "overlay-key"
 #define KEY_WORKSPACES_ONLY_ON_PRIMARY "workspaces-only-on-primary"
@@ -132,9 +131,9 @@ static void bindings_changed (GSettings      *settings,
                               gchar          *key,
                               gpointer        data);
 
-static void xsettings_overrides_changed (GSettings  *settings,
-                                         gchar      *key,
-                                         gpointer    data);
+static void shell_shows_app_menu_changed (GtkSettings *settings,
+                                          GParamSpec  *pspec,
+                                          gpointer     data);
 
 static void update_cursor_size (GtkSettings *settings,
                                 GParamSpec *pspec,
@@ -947,24 +946,6 @@ queue_changed (MetaPreference pref)
 /* Initialisation.                                                          */
 /****************************************************************************/
 
-static GSettings *
-get_xsettings_settings (void)
-{
-  GSettings *settings = NULL;
-  GSettingsSchema *schema;
-
-  schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (),
-                                            SCHEMA_XSETTINGS, FALSE);
-
-  if (schema)
-    {
-      settings = g_settings_new_full (schema, NULL, NULL);
-      g_settings_schema_unref (schema);
-    }
-
-  return settings;
-}
-
 void
 meta_prefs_init (void)
 {
@@ -996,15 +977,9 @@ meta_prefs_init (void)
                     G_CALLBACK (settings_changed), NULL);
   g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_INTERFACE), settings);
 
-  settings = get_xsettings_settings ();
-  if (settings)
-    {
-      g_signal_connect (settings, "changed::" KEY_XSETTINGS_OVERRIDES,
-                        G_CALLBACK (xsettings_overrides_changed), NULL);
-      g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_XSETTINGS), settings);
-
-      xsettings_overrides_changed (settings, KEY_XSETTINGS_OVERRIDES, NULL);
-    }
+  g_signal_connect (gtk_settings_get_default (),
+                    "notify::gtk-shell-shows-app-menu",
+                    G_CALLBACK (shell_shows_app_menu_changed), NULL);
 
   g_signal_connect (gtk_settings_get_default (), "notify::gtk-cursor-theme-size",
                     G_CALLBACK (update_cursor_size), NULL);
@@ -1030,6 +1005,7 @@ meta_prefs_init (void)
   handle_preference_init_int ();
 
   update_cursor_size (gtk_settings_get_default (), NULL, NULL);
+  shell_shows_app_menu_changed (gtk_settings_get_default (), NULL, NULL);
 
   init_bindings ();
 }
@@ -1231,38 +1207,21 @@ bindings_changed (GSettings *settings,
   g_strfreev (strokes);
 }
 
-/* The fallback app menu should be enabled if either we are not
- * showing the app menu (e.g. when using the default plugin) or
- * with a corresponding XSettings override; we ignore the former
- * and assume that we always show the app menu, not least
- * because we rely on the compositor implementation to display
- * the fallback ...
- */
 static void
-xsettings_overrides_changed (GSettings  *settings,
-                             gchar      *key,
-                             gpointer    data)
+shell_shows_app_menu_changed (GtkSettings *settings,
+                              GParamSpec *pspec,
+                              gpointer data)
 {
-  GVariant *value;
-  GVariantDict overrides;
   int shell_shows_app_menu = 1;
   gboolean changed = FALSE;
 
-  if (!g_settings_get_boolean (settings, "active"))
-    goto out;
-
-  value = g_settings_get_value (settings, KEY_XSETTINGS_OVERRIDES);
-
-  g_variant_dict_init (&overrides, value);
-  g_variant_unref (value);
+  g_object_get (settings,
+                "gtk-shell-shows-app-menu", &shell_shows_app_menu,
+                NULL);
 
-  g_variant_dict_lookup (&overrides,
-                         "Gtk/ShellShowsAppMenu", "i", &shell_shows_app_menu);
-  g_variant_dict_clear (&overrides);
 
   changed = (show_fallback_app_menu == !!shell_shows_app_menu);
 
-out:
   show_fallback_app_menu = !shell_shows_app_menu;
 
   if (changed)


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