[gnome-shell] Adapt to mutter moving to GSettings



commit a9ab8784c4cab3d602beb6c84423198be9c0f846
Author: Florian MÃllner <fmuellner gnome org>
Date:   Mon Jun 27 03:54:26 2011 +0200

    Adapt to mutter moving to GSettings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663429

 configure.ac                        |    4 --
 data/Makefile.am                    |    9 ---
 data/gnome-shell.schemas            |  100 -----------------------------------
 data/org.gnome.shell.gschema.xml.in |   36 +++++++++++++
 js/ui/altTab.js                     |    6 +-
 js/ui/lookingGlass.js               |    1 -
 js/ui/main.js                       |   19 ++-----
 js/ui/status/accessibility.js       |   54 +++++++++----------
 js/ui/windowManager.js              |   26 +++++-----
 js/ui/workspace.js                  |    9 ++--
 src/main.c                          |   20 ++++----
 11 files changed, 97 insertions(+), 187 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1304baa..d15b88a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,10 +36,6 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
 
 PKG_PROG_PKG_CONFIG([0.22])
 
-# GConf stuff
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-AM_GCONF_SOURCE_2
-
 GLIB_GSETTINGS
 
 # Get a value to substitute into gnome-shell.in
diff --git a/data/Makefile.am b/data/Makefile.am
index eaec30b..287b99d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -60,23 +60,14 @@ gschemas.compiled: $(gsettings_SCHEMAS:.xml=.valid)
 all-local: gschemas.compiled
 
 
-# GConf schemas: provide defaults for keys from Metacity we are overriding
-gconfschemadir  = @GCONF_SCHEMA_FILE_DIR@
-gconfschema_DATA = gnome-shell.schemas
-
 shadersdir = $(pkgdatadir)/shaders
 shaders_DATA = \
 	shaders/dim-window.glsl
 
-install-data-local:
-	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(gconfschema_DATA)
-
-
 
 EXTRA_DIST =						\
 	gnome-shell.desktop.in.in			\
 	$(menu_DATA)					\
-	$(gconfschema_DATA)				\
 	$(shaders_DATA)					\
 	org.gnome.shell.gschema.xml.in
 
diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in
index ea822ee..a6438f0 100644
--- a/data/org.gnome.shell.gschema.xml.in
+++ b/data/org.gnome.shell.gschema.xml.in
@@ -142,4 +142,40 @@
       </_description>
     </key>
   </schema>
+
+  <schema id="org.gnome.shell.overrides" path="/org/gnome/shell/overrides/">
+    <key name="attach-modal-dialogs" type="b">
+      <default>true</default>
+      <summary>Attach modal dialog to the parent window</summary>
+      <description>
+        This key overrides the key in org.gnome.mutter when running
+        GNOME Shell.
+      </description>
+    </key>
+
+    <key name="button-layout" type="s">
+      <default>":close"</default>
+      <summary>Arrangement of buttons on the titlebar</summary>
+      <description>
+        This key overrides the key in org.gnome.desktop.wm.preferences when
+        running GNOME Shell.
+      </description>
+    </key>
+
+    <key name="edge-tiling" type="b">
+      <default>true</default>
+      <summary>Enable edge tiling when dropping windows on screen edges</summary>
+      <description>
+        This key overrides the key in org.gnome.mutter when running GNOME Shell.
+      </description>
+    </key>
+
+    <key name="workspaces-only-on-primary" type="b">
+      <default>true</default>
+      <summary>Workspaces only on primary monitor</summary>
+      <description>
+        This key overrides the key in org.gnome.mutter when running GNOME Shell.
+      </description>
+    </key>
+  </schema>
 </schemalist>
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 20bad20..5aaa8d4 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -199,7 +199,7 @@ AltTabPopup.prototype = {
         this.actor.get_allocation_box();
 
         // Make the initial selection
-        if (binding == 'switch_group') {
+        if (binding == 'switch-group') {
             if (backward) {
                 this._select(0, this._appIcons[0].cachedWindows.length - 1);
             } else {
@@ -208,9 +208,9 @@ AltTabPopup.prototype = {
                 else
                     this._select(0, 0);
             }
-        } else if (binding == 'switch_group_backward') {
+        } else if (binding == 'switch-group-backward') {
             this._select(0, this._appIcons[0].cachedWindows.length - 1);
-        } else if (binding == 'switch_windows_backward') {
+        } else if (binding == 'switch-windows-backward') {
             this._select(this._appIcons.length - 1);
         } else if (this._appIcons.length == 1) {
             this._select(0);
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index aa73220..495b987 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -2,7 +2,6 @@
 
 const Clutter = imports.gi.Clutter;
 const Cogl = imports.gi.Cogl;
-const GConf = imports.gi.GConf;
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
diff --git a/js/ui/main.js b/js/ui/main.js
index 6bd5f59..6849292 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -4,7 +4,6 @@ const Clutter = imports.gi.Clutter;
 const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
-const GConf = imports.gi.GConf;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
@@ -135,13 +134,13 @@ function _initUserSession() {
 
     let shellwm = global.window_manager;
 
-    shellwm.takeover_keybinding('panel_run_dialog');
-    shellwm.connect('keybinding::panel_run_dialog', function () {
+    shellwm.takeover_keybinding('panel-run-dialog');
+    shellwm.connect('keybinding::panel-run-dialog', function () {
        getRunDialog().open();
     });
 
-    shellwm.takeover_keybinding('panel_main_menu');
-    shellwm.connect('keybinding::panel_main_menu', function () {
+    shellwm.takeover_keybinding('panel-main-menu');
+    shellwm.connect('keybinding::panel-main-menu', function () {
         overview.toggle();
     });
 
@@ -577,16 +576,6 @@ function _globalKeyPressHandler(actor, event) {
     // This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType
     let action = global.display.get_keybinding_action(keyCode, modifierState);
 
-    // The screenshot action should always be available (even if a
-    // modal dialog is present)
-    if (action == Meta.KeyBindingAction.COMMAND_SCREENSHOT) {
-        let gconf = GConf.Client.get_default();
-        let command = gconf.get_string('/apps/metacity/keybinding_commands/command_screenshot');
-        if (command != null && command != '')
-            Util.spawnCommandLine(command);
-        return true;
-    }
-
     // Other bindings are only available to the user session when the overview is up and
     // no modal dialog is present.
     if (global.session_type == Shell.SessionType.USER && (!overview.visible || modalCount > 1))
diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js
index 15fe8c9..0c6ef7c 100644
--- a/js/ui/status/accessibility.js
+++ b/js/ui/status/accessibility.js
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
-const GConf = imports.gi.GConf;
+const DBus = imports.dbus;
+const GDesktopEnums = imports.gi.GDesktopEnums;
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
@@ -29,8 +30,8 @@ const DPI_FACTOR_LARGE   = 1.25;
 const DPI_FACTOR_LARGER  = 1.5;
 const DPI_FACTOR_LARGEST = 2.0;
 
-const KEY_META_DIR       = '/apps/metacity/general';
-const KEY_VISUAL_BELL = KEY_META_DIR + '/visual_bell';
+const WM_SCHEMA            = 'org.gnome.desktop.wm.preferences';
+const KEY_VISUAL_BELL_TYPE = 'visual-bell-type';
 
 const DESKTOP_INTERFACE_SCHEMA = 'org.gnome.desktop.interface';
 const KEY_GTK_THEME      = 'gtk-theme';
@@ -49,10 +50,6 @@ ATIndicator.prototype = {
     _init: function() {
         PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null);
 
-        let client = GConf.Client.get_default();
-        client.add_dir(KEY_META_DIR, GConf.ClientPreloadType.PRELOAD_ONELEVEL, null);
-        client.notify_add(KEY_META_DIR, Lang.bind(this, this._keyChanged), null, null);
-
         let highContrast = this._buildHCItem();
         this.menu.addMenuItem(highContrast);
 
@@ -71,7 +68,7 @@ ATIndicator.prototype = {
                                                                    'screen-keyboard-enabled');
         this.menu.addMenuItem(screenKeyboard);
 
-        let visualBell = this._buildItemGConf(_("Visual Alerts"), client, KEY_VISUAL_BELL);
+        let visualBell = this._buildVisualBellItem();
         this.menu.addMenuItem(visualBell);
 
         let stickyKeys = this._buildItem(_("Sticky Keys"), A11Y_SCHEMA, KEY_STICKY_KEYS_ENABLED);
@@ -101,22 +98,6 @@ ATIndicator.prototype = {
         return widget;
     },
 
-    _buildItemGConf: function(string, client, key) {
-        function on_get() {
-            return client.get_bool(key);
-        }
-        let widget = this._buildItemExtended(string,
-            client.get_bool(key),
-            client.key_is_writable(key),
-            function(enabled) {
-                client.set_bool(key, enabled);
-            });
-        this.connect('gconf-changed', function() {
-            widget.setToggleState(client.get_bool(key));
-        });
-        return widget;
-    },
-
     _buildItem: function(string, schema, key) {
         let settings = new Gio.Settings({ schema: schema });
         let widget = this._buildItemExtended(string,
@@ -131,6 +112,27 @@ ATIndicator.prototype = {
         return widget;
     },
 
+    _buildVisualBellItem: function() {
+        let settings = new Gio.Settings({ schema: WM_SCHEMA });
+        let currentValue = settings.get_enum(KEY_VISUAL_BELL_TYPE);
+        let visualBellItem = this._buildItemExtended(
+            _("Visual Alerts"),
+            currentValue != GDesktopEnums.VisualBellType.NONE,
+            settings.is_writable(KEY_VISUAL_BELL_TYPE),
+            function(enabled) {
+                if (enabled)
+                    settings.set_enum(KEY_VISUAL_BELL_TYPE,
+                                      GDesktopEnums.VisualBellType.FULLSCREEN_FLASH);
+                else
+                    settings.reset(KEY_VISUAL_BELL_TYPE);
+            });
+        settings.connect('changed::' + KEY_VISUAL_BELL_TYPE, function() {
+            let value = settings.get_enum(KEY_VISUAL_BELL_TYPE);
+            visualBellItem.setToggleState(value != GDesktopEnums.VisualBellType.NONE);
+        });
+        return visualBellItem;
+    },
+
     _buildHCItem: function() {
         let settings = new Gio.Settings({ schema: DESKTOP_INTERFACE_SCHEMA });
         let gtkTheme = settings.get_string(KEY_GTK_THEME);
@@ -190,10 +192,6 @@ ATIndicator.prototype = {
             widget.setToggleState(active);
         });
         return widget;
-    },
-
-    _keyChanged: function() {
-        this.emit('gconf-changed');
     }
 };
 Signals.addSignalMethods(ATIndicator.prototype);
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index d827b22..b9b4181 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -121,15 +121,15 @@ WindowManager.prototype = {
         this._shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
 
         this._workspaceSwitcherPopup = null;
-        this.setKeybindingHandler('switch_to_workspace_left', Lang.bind(this, this._showWorkspaceSwitcher));
-        this.setKeybindingHandler('switch_to_workspace_right', Lang.bind(this, this._showWorkspaceSwitcher));
-        this.setKeybindingHandler('switch_to_workspace_up', Lang.bind(this, this._showWorkspaceSwitcher));
-        this.setKeybindingHandler('switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher));
-        this.setKeybindingHandler('switch_windows', Lang.bind(this, this._startAppSwitcher));
-        this.setKeybindingHandler('switch_group', Lang.bind(this, this._startAppSwitcher));
-        this.setKeybindingHandler('switch_windows_backward', Lang.bind(this, this._startAppSwitcher));
-        this.setKeybindingHandler('switch_group_backward', Lang.bind(this, this._startAppSwitcher));
-        this.setKeybindingHandler('switch_panels', Lang.bind(this, this._startA11ySwitcher));
+        this.setKeybindingHandler('switch-to-workspace-left', Lang.bind(this, this._showWorkspaceSwitcher));
+        this.setKeybindingHandler('switch-to-workspace-right', Lang.bind(this, this._showWorkspaceSwitcher));
+        this.setKeybindingHandler('switch-to-workspace-up', Lang.bind(this, this._showWorkspaceSwitcher));
+        this.setKeybindingHandler('switch-to-workspace-down', Lang.bind(this, this._showWorkspaceSwitcher));
+        this.setKeybindingHandler('switch-windows', Lang.bind(this, this._startAppSwitcher));
+        this.setKeybindingHandler('switch-group', Lang.bind(this, this._startAppSwitcher));
+        this.setKeybindingHandler('switch-windows-backward', Lang.bind(this, this._startAppSwitcher));
+        this.setKeybindingHandler('switch-group-backward', Lang.bind(this, this._startAppSwitcher));
+        this.setKeybindingHandler('switch-panels', Lang.bind(this, this._startA11ySwitcher));
 
         Main.overview.connect('showing', Lang.bind(this, function() {
             for (let i = 0; i < this._dimmedWindows.length; i++)
@@ -556,15 +556,15 @@ WindowManager.prototype = {
         if (this._workspaceSwitcherPopup == null)
             this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
 
-        if (binding == 'switch_to_workspace_up')
+        if (binding == 'switch-to-workspace-up')
             this.actionMoveWorkspaceUp();
-        else if (binding == 'switch_to_workspace_down')
+        else if (binding == 'switch-to-workspace-down')
             this.actionMoveWorkspaceDown();
         // left/right would effectively act as synonyms for up/down if we enabled them;
         // but that could be considered confusing.
-        // else if (binding == 'switch_to_workspace_left')
+        // else if (binding == 'switch-to-workspace-left')
         //   this.actionMoveWorkspaceLeft();
-        // else if (binding == 'switch_to_workspace_right')
+        // else if (binding == 'switch-to-workspace-right')
         //   this.actionMoveWorkspaceRight();
     },
 
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index cf22acd..97b0893 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Clutter = imports.gi.Clutter;
-const GConf = imports.gi.GConf;
+const Gio = imports.gi.Gio;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
@@ -28,7 +28,8 @@ const CLOSE_BUTTON_FADE_TIME = 0.1;
 
 const DRAGGING_WINDOW_OPACITY = 100;
 
-const BUTTON_LAYOUT_KEY = '/desktop/gnome/shell/windows/button_layout';
+const BUTTON_LAYOUT_SCHEMA = 'org.gnome.shell.overrides';
+const BUTTON_LAYOUT_KEY = 'button-layout';
 
 // Define a layout scheme for small window counts. For larger
 // counts we fall back to an algorithm. We need more schemes here
@@ -527,8 +528,8 @@ WindowOverlay.prototype = {
         let button = this.closeButton;
         let title = this.title;
 
-        let gconf = GConf.Client.get_default();
-        let layout = gconf.get_string(BUTTON_LAYOUT_KEY);
+        let settings = new Gio.Settings({ schema: BUTTON_LAYOUT_SCHEMA });
+        let layout = settings.get_string(BUTTON_LAYOUT_KEY);
         let rtl = St.Widget.get_default_direction() == St.TextDirection.RTL;
 
         let split = layout.split(":");
diff --git a/src/main.c b/src/main.c
index 6cc66f8..81cdce9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,6 +33,8 @@ extern GType gnome_shell_plugin_get_type (void);
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
 
+#define OVERRIDES_SCHEMA "org.gnome.shell.overrides"
+
 static gboolean is_gdm_mode = FALSE;
 
 #define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
@@ -309,16 +311,14 @@ shell_fonts_init (void)
 static void
 shell_prefs_init (void)
 {
-  meta_prefs_override_preference_location ("/apps/mutter/general/attach_modal_dialogs",
-                                           "/desktop/gnome/shell/windows/attach_modal_dialogs");
-  meta_prefs_override_preference_location ("/apps/mutter/general/workspaces_only_on_primary",
-                                           "/desktop/gnome/shell/windows/workspaces_only_on_primary");
-  meta_prefs_override_preference_location ("/apps/metacity/general/button_layout",
-                                           "/desktop/gnome/shell/windows/button_layout");
-  meta_prefs_override_preference_location ("/apps/metacity/general/edge_tiling",
-                                           "/desktop/gnome/shell/windows/edge_tiling");
-  meta_prefs_override_preference_location ("/apps/metacity/general/theme",
-                                           "/desktop/gnome/shell/windows/theme");
+  meta_prefs_override_preference_schema ("attach-modal-dialogs",
+                                         OVERRIDES_SCHEMA);
+  meta_prefs_override_preference_schema ("workspaces-only-on-primary",
+                                         OVERRIDES_SCHEMA);
+  meta_prefs_override_preference_schema ("button-layout",
+                                         OVERRIDES_SCHEMA);
+  meta_prefs_override_preference_schema ("edge-tiling",
+                                         OVERRIDES_SCHEMA);
 }
 
 /* This is an IBus workaround. The flow of events with IBus is that every time



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