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.
This commit is contained in:
Florian Müllner 2014-09-13 16:27:20 +02:00
parent 276df8f18d
commit f10cb02cbf

View File

@ -53,7 +53,6 @@
#define KEY_GNOME_ANIMATIONS "enable-animations" #define KEY_GNOME_ANIMATIONS "enable-animations"
#define KEY_GNOME_CURSOR_THEME "cursor-theme" #define KEY_GNOME_CURSOR_THEME "cursor-theme"
#define KEY_XKB_OPTIONS "xkb-options" #define KEY_XKB_OPTIONS "xkb-options"
#define KEY_XSETTINGS_OVERRIDES "overrides"
#define KEY_OVERLAY_KEY "overlay-key" #define KEY_OVERLAY_KEY "overlay-key"
#define KEY_WORKSPACES_ONLY_ON_PRIMARY "workspaces-only-on-primary" #define KEY_WORKSPACES_ONLY_ON_PRIMARY "workspaces-only-on-primary"
@ -132,9 +131,9 @@ static void bindings_changed (GSettings *settings,
gchar *key, gchar *key,
gpointer data); gpointer data);
static void xsettings_overrides_changed (GSettings *settings, static void shell_shows_app_menu_changed (GtkSettings *settings,
gchar *key, GParamSpec *pspec,
gpointer data); gpointer data);
static void update_cursor_size (GtkSettings *settings, static void update_cursor_size (GtkSettings *settings,
GParamSpec *pspec, GParamSpec *pspec,
@ -947,24 +946,6 @@ queue_changed (MetaPreference pref)
/* Initialisation. */ /* 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 void
meta_prefs_init (void) meta_prefs_init (void)
{ {
@ -996,15 +977,9 @@ meta_prefs_init (void)
G_CALLBACK (settings_changed), NULL); G_CALLBACK (settings_changed), NULL);
g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_INTERFACE), settings); g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_INTERFACE), settings);
settings = get_xsettings_settings (); g_signal_connect (gtk_settings_get_default (),
if (settings) "notify::gtk-shell-shows-app-menu",
{ G_CALLBACK (shell_shows_app_menu_changed), NULL);
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-cursor-theme-size", g_signal_connect (gtk_settings_get_default (), "notify::gtk-cursor-theme-size",
G_CALLBACK (update_cursor_size), NULL); G_CALLBACK (update_cursor_size), NULL);
@ -1030,6 +1005,7 @@ meta_prefs_init (void)
handle_preference_init_int (); handle_preference_init_int ();
update_cursor_size (gtk_settings_get_default (), NULL, NULL); update_cursor_size (gtk_settings_get_default (), NULL, NULL);
shell_shows_app_menu_changed (gtk_settings_get_default (), NULL, NULL);
init_bindings (); init_bindings ();
} }
@ -1231,38 +1207,21 @@ bindings_changed (GSettings *settings,
g_strfreev (strokes); 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 static void
xsettings_overrides_changed (GSettings *settings, shell_shows_app_menu_changed (GtkSettings *settings,
gchar *key, GParamSpec *pspec,
gpointer data) gpointer data)
{ {
GVariant *value;
GVariantDict overrides;
int shell_shows_app_menu = 1; int shell_shows_app_menu = 1;
gboolean changed = FALSE; gboolean changed = FALSE;
if (!g_settings_get_boolean (settings, "active")) g_object_get (settings,
goto out; "gtk-shell-shows-app-menu", &shell_shows_app_menu,
NULL);
value = g_settings_get_value (settings, KEY_XSETTINGS_OVERRIDES);
g_variant_dict_init (&overrides, value);
g_variant_unref (value);
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); changed = (show_fallback_app_menu == !!shell_shows_app_menu);
out:
show_fallback_app_menu = !shell_shows_app_menu; show_fallback_app_menu = !shell_shows_app_menu;
if (changed) if (changed)