From 2799327c84c8ca74fe6b271349e27d7911f3b815 Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Wed, 5 May 2010 23:05:42 +0200 Subject: [PATCH] Migrate to GSettings Use GSettings for all Shell configuration. GConf is kept to read configuration from external programs (Metacity, Nautilus and Magnifier), but ShellGConf is removed because it's mostly useless for the few calls we still have. Also get rid of unused GConf code in ShellAppSystem. A basic GConf schema is still used to override Metacity defaults and configure Magnifier in a system-wide fashion. GConf is also used as GSettings backend via the GSETTINGS_BACKEND environment variable. All of this will be removed when these programs have been ported to GSettings and able to use dconf. GLib 2.25.9 is required. Schemas are converted to the new XML format, and compiled at build time in data/ so that the Shell can be run from the source tree. This also requires setting the GSETTINGS_SCHEMA_DIR environment variable both when running installed or from source tree, in src/gnome-shell.in and src/gnome-shell-clock-preferences.in. https://bugzilla.gnome.org/show_bug.cgi?id=617917 --- .gitignore | 3 + configure.ac | 6 +- data/Makefile.am | 27 +- data/gnome-shell.schemas | 233 +-------------- data/org.gnome.shell.gschema.xml.in | 158 +++++++++++ js/prefs/clockPreferences.js | 31 +- js/ui/appFavorites.js | 11 +- js/ui/calendar.js | 11 +- js/ui/extensionSystem.js | 2 +- js/ui/lookingGlass.js | 11 +- js/ui/magnifier.js | 49 ++-- js/ui/main.js | 17 +- js/ui/panel.js | 23 +- js/ui/placeDisplay.js | 11 +- js/ui/runDialog.js | 17 +- js/ui/workspacesView.js | 18 +- po/POTFILES.in | 1 + src/Makefile.am | 6 +- src/gnome-shell-clock-preferences.in | 4 + src/gnome-shell.in | 8 +- src/shell-app-system.c | 7 - src/shell-app-usage.c | 59 ++-- src/shell-gconf.c | 410 --------------------------- src/shell-gconf.h | 95 ------- src/shell-global.c | 28 ++ src/shell-global.h | 2 + tools/build/gnome-shell.modules | 7 + 27 files changed, 369 insertions(+), 886 deletions(-) create mode 100644 data/org.gnome.shell.gschema.xml.in delete mode 100644 src/shell-gconf.c delete mode 100644 src/shell-gconf.h diff --git a/.gitignore b/.gitignore index ed0ebf3a9..413fb08f7 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ data/gnome-shell.desktop data/gnome-shell.desktop.in data/gnome-shell-clock-preferences.desktop data/gnome-shell-clock-preferences.desktop.in +data/gschemas.compiled +data/org.gnome.shell.gschema.xml +data/org.gnome.shell.gschema.valid intltool-extract.in intltool-merge.in intltool-update.in diff --git a/configure.ac b/configure.ac index 34df13bbf..863f751ad 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,8 @@ PKG_PROG_PKG_CONFIG([0.22]) AC_PATH_PROG(GCONFTOOL, gconftool-2, no) AM_GCONF_SOURCE_2 +GLIB_GSETTINGS + # Get a value to substitute into gnome-shell.in AM_PATH_PYTHON([2.5]) AC_SUBST(PYTHON) @@ -60,9 +62,11 @@ GOBJECT_INTROSPECTION_MIN_VERSION=0.6.11 GJS_MIN_VERSION=0.7 MUTTER_MIN_VERSION=2.31.2 GTK_MIN_VERSION=2.18.0 +GIO_MIN_VERSION=2.25.9 # Collect more than 20 libraries for a prize! -PKG_CHECK_MODULES(MUTTER_PLUGIN, gio-unix-2.0 dbus-glib-1 +PKG_CHECK_MODULES(MUTTER_PLUGIN, gio-2.0 >= $GIO_MIN_VERSION + gio-unix-2.0 dbus-glib-1 gtk+-2.0 >= $GTK_MIN_VERSION mutter-plugins >= $MUTTER_MIN_VERSION gjs-gi-1.0 >= $GJS_MIN_VERSION diff --git a/data/Makefile.am b/data/Makefile.am index 2dc4199fb..579ee8ef4 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -46,9 +46,21 @@ dist_theme_DATA = \ theme/ws-switch-arrow-left.svg \ theme/ws-switch-arrow-right.svg +gsettings_SCHEMAS = org.gnome.shell.gschema.xml +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ -schemadir = @GCONF_SCHEMA_FILE_DIR@ -schema_DATA = gnome-shell.schemas +# We need to compile schemas at make time +# to run from source tree +gschemas.compiled: org.gnome.shell.gschema.xml + $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=. . + +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 menudir = $(sysconfdir)/xdg/menus @@ -56,16 +68,21 @@ menu_DATA = \ gs-applications.menu install-data-local: - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schema_DATA) + GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(gconfschema_DATA) + + EXTRA_DIST = \ gnome-shell.desktop.in.in \ gnome-shell-clock-preferences.desktop.in.in \ $(menu_DATA) \ - $(schema_DATA) + $(gconfschema_DATA) \ + org.gnome.shell.gschema.xml.in CLEANFILES = \ gnome-shell.desktop.in \ gnome-shell-clock-preferences.desktop.in \ - $(desktop_DATA) + $(desktop_DATA) \ + $(gsettings_SCHEMAS) \ + gschemas.compiled diff --git a/data/gnome-shell.schemas b/data/gnome-shell.schemas index 434986fa5..17373a5b9 100644 --- a/data/gnome-shell.schemas +++ b/data/gnome-shell.schemas @@ -1,223 +1,7 @@ - - /schemas/desktop/gnome/shell/development_tools - /desktop/gnome/shell/development_tools - gnome-shell - bool - true - - Enable internal tools useful for developers and testers from Alt-F2 - - Allows access to internal debugging and monitoring tools using - the Alt-F2 dialog. - - - - - - /schemas/desktop/gnome/shell/app_monitor/enable_monitoring - /desktop/gnome/shell/app_monitor/enable_monitoring - gnome-shell - bool - true - - Whether to collect stats about applications usage - - The shell normally monitors active applications in order to present the most used ones (e.g. in launchers). While this data will be kept private, you may want to disable this for privacy reasons. Please note that doing so won't remove already saved data. - - - - - - /schemas/desktop/gnome/shell/favorite_apps - /desktop/gnome/shell/favorite_apps - gnome-shell - list - string - [mozilla-firefox.desktop,evolution.desktop,openoffice.org-writer.desktop] - - List of desktop file IDs for favorite applications - - The applications corresponding to these identifiers will be displayed in the favorites area. - - - - - - /schemas/desktop/gnome/shell/run_dialog/history - /desktop/gnome/shell/run_dialog/history - gnome-shell - list - string - [] - - History for command (Alt-F2) dialog - - - - - /schemas/desktop/gnome/shell/clock/format - /desktop/gnome/shell/clock/format - gnome-shell - string - - - 24-hour - - - Hour format - - This key specifies the hour format used by the panel clock. - Possible values are "12-hour", "24-hour", "unix" and "custom". - If set to "unix", the clock will display time in seconds since Epoch, - i.e. 1970-01-01. - If set to "custom", the clock will display time according to the format - specified in the custom_format key. - Note that if set to either "unix" or "custom", the show_date and - show_seconds keys are ignored. - - - - - - /schemas/desktop/gnome/shell/clock/custom_format - /desktop/gnome/shell/clock/custom_format - gnome-shell - string - - - Custom format of the clock - - This key specifies the format used by the panel clock when the - format key is set to "custom". You can use conversion specifiers - understood by strftime() to obtain a specific format. See the - strftime() manual for more information. - - - - - - /schemas/desktop/gnome/shell/clock/show_seconds - /desktop/gnome/shell/clock/show_seconds - gnome-shell - bool - false - - Show time with seconds - - If true and format is either "12-hour" or "24-hour", - display seconds in time. - - - - - - /schemas/desktop/gnome/shell/clock/show_date - /desktop/gnome/shell/clock/show_date - gnome-shell - bool - false - - Show date in clock - - If true and format is either "12-hour" or "24-hour", - display date in the clock, in addition to time. - - - - - - /schemas/desktop/gnome/shell/disabled_extensions - /desktop/gnome/shell/disabled_extensions - gnome-shell - list - string - [] - - Uuids of extensions to disable - - GNOME Shell extensions have a uuid property; this key lists extensions which should not be loaded. - - - - - - /schemas/desktop/gnome/shell/recorder/framerate - /desktop/gnome/shell/recorder/framerate - gnome-shell - int - 15 - - Framerate used for recording screencasts. - - The framerate of the resulting screencast recordered by GNOME Shell's screencast recorder in frames-per-second. - - - - - - /schemas/desktop/gnome/shell/recorder/pipeline - /desktop/gnome/shell/recorder/pipeline - gnome-shell - string - - - The gstreamer pipeline used to encode the screencast - - Sets the GStreamer pipeline used to encode recordings. It follows the syntax used for gst-launch. - The pipeline should have an unconnected sink pad where the recorded video is recorded. It will - normally have a unconnected source pad; output from that pad will be written into the output file. - However the pipeline can also take care of its own output - this might be used to send the output to an icecast server via shout2send or similar. - When unset or set to an empty value, the default pipeline will be used. This is currently 'videorate ! theoraenc ! oggmux' and records to Ogg Theora. - - - - - - /schemas/desktop/gnome/shell/recorder/file_extension - /desktop/gnome/shell/recorder/file_extension - gnome-shell - string - ogv - - File extension used for storing the screencast - - The filename for recorded screencasts will be a unique filename based on the current date, and use this extension. - It should be changed when recording to a different container format. - - - - - - /schemas/desktop/gnome/shell/overview/workspaces_view - /desktop/gnome/shell/overview/workspaces_view - gnome-shell - string - single - - Overview workspace view mode - - The selected workspace view mode in the overview. - Supported values are "single" and "grid". - - - - + /schemas/desktop/gnome/shell/windows/button_layout /desktop/gnome/shell/windows/button_layout @@ -438,20 +222,5 @@ - - - /schemas/desktop/gnome/shell/calendar/show_weekdate - /desktop/gnome/shell/calendar/show_weekdate - gnome-shell - bool - false - - Show the week date in the calendar - - If true, display the ISO week date in the calendar. - - - - diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in new file mode 100644 index 000000000..085db60c4 --- /dev/null +++ b/data/org.gnome.shell.gschema.xml.in @@ -0,0 +1,158 @@ + + + + true + <_summary> + Enable internal tools useful for developers and testers from Alt-F2 + + <_description> + Allows access to internal debugging and monitoring tools + using the Alt-F2 dialog. + + + + [] + <_summary>Uuids of extensions to disable + <_description> + GNOME Shell extensions have a uuid property; + this key lists extensions which should not be loaded. + + + + true + <_summary>Whether to collect stats about applications usage + <_description> + The shell normally monitors active applications in order to present + the most used ones (e.g. in launchers). While this data will be + kept private, you may want to disable this for privacy reasons. + Please note that doing so won't remove already saved data. + + + + [ 'mozilla-firefox.desktop', 'evolution.desktop', 'openoffice.org-writer.desktop' ] + <_summary>List of desktop file IDs for favorite applications + <_description> + The applications corresponding to these identifiers + will be displayed in the favorites area. + + + + [] + <_summary>History for command (Alt-F2) dialog + + + 'single' + <_summary>Overview workspace view mode + <_description> + The selected workspace view mode in the overview. + Supported values are "single" and "grid". + + + + + + + + + + + + + + false + <_summary>Show the week date in the calendar + <_description> + If true, display the ISO week date in the calendar. + + + + + + + + + "12-hour" + + <_summary>Hour format + <_description> + This key specifies the hour format used by the panel clock. + Possible values are "12-hour", "24-hour", "unix" and "custom". If set + to "unix", the clock will display time in seconds since Epoch, + i.e. 1970-01-01. If set to "custom", the clock will display time + according to the format specified in the custom_format key. Note that + if set to either "unix" or "custom", the show_date and show_seconds + keys are ignored. + + + + + + + + + + '' + <_summary>Custom format of the clock + <_description> + This key specifies the format used by the panel clock when the format + key is set to "custom". You can use conversion specifiers understood + by strftime() to obtain a specific format. See the strftime() manual + for more information. + + + + false + <_summary>Show time with seconds + <_description> + If true and format is either "12-hour" or "24-hour", display seconds in time. + + + + false + <_summary>Show date in clock + <_description> + If true and format is either "12-hour" or "24-hour", + display date in the clock, in addition to time. + + + + + + + 15 + <_summary>Framerate used for recording screencasts. + <_description> + The framerate of the resulting screencast recordered + by GNOME Shell's screencast recorder in frames-per-second. + + + + '' + <_summary>The gstreamer pipeline used to encode the screencast + <_description> + Sets the GStreamer pipeline used to encode recordings. + It follows the syntax used for gst-launch. The pipeline should have + an unconnected sink pad where the recorded video is recorded. It will + normally have a unconnected source pad; output from that pad + will be written into the output file. However the pipeline can also + take care of its own output - this might be used to send the output + to an icecast server via shout2send or similar. When unset or set + to an empty value, the default pipeline will be used. This is currently + 'videorate ! theoraenc ! oggmux' and records to Ogg Theora. + + + + 'ogv' + <_summary>File extension used for storing the screencast + <_description> + The filename for recorded screencasts will be a unique filename + based on the current date, and use this extension. It should be + changed when recording to a different container format. + + + + diff --git a/js/prefs/clockPreferences.js b/js/prefs/clockPreferences.js index 180358bad..f35d8e250 100644 --- a/js/prefs/clockPreferences.js +++ b/js/prefs/clockPreferences.js @@ -1,18 +1,17 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ +const Gio = imports.gi.Gio; const GLib = imports.gi.GLib; const Gtk = imports.gi.Gtk; -const GConf = imports.gi.GConf; const Lang = imports.lang; const Signals = imports.signals; const Gettext = imports.gettext; -const GCONF_DIR = '/desktop/gnome/shell/clock'; -const FORMAT_KEY = GCONF_DIR + '/format'; -const SHOW_DATE_KEY = GCONF_DIR + '/show_date'; -const SHOW_SECONDS_KEY = GCONF_DIR + '/show_seconds'; +const FORMAT_KEY = 'format'; +const SHOW_DATE_KEY = 'show-date'; +const SHOW_SECONDS_KEY = 'show-seconds'; function ClockPreferences(uiFile) { @@ -34,25 +33,25 @@ ClockPreferences.prototype = { delete builder; - this._gconf = GConf.Client.get_default(); - this._gconf.add_dir(GCONF_DIR, GConf.ClientPreloadType.PRELOAD_NONE); - this._notifyId = this._gconf.notify_add(GCONF_DIR, + this._settings = new Gio.Settings({ schema: 'org.gnome.shell.clock' }); + this._notifyId = this._settings.connect('changed', Lang.bind(this, this._updateDialog)); this._12hrRadio.connect('toggled', Lang.bind(this, function() { let format = this._12hrRadio.active ? '12-hour' : '24-hour'; - this._gconf.set_string(FORMAT_KEY, format); + this._settings.set_string(FORMAT_KEY, format); })); this._dateCheck.connect('toggled', Lang.bind(this, function() { - this._gconf.set_bool(SHOW_DATE_KEY, this._dateCheck.active); + this._settings.set_boolean(SHOW_DATE_KEY, + this._dateCheck.active); })); this._secondsCheck.connect('toggled', Lang.bind(this, function() { - this._gconf.set_bool(SHOW_SECONDS_KEY, - this._secondsCheck.active); + this._settings.set_boolean(SHOW_SECONDS_KEY, + this._secondsCheck.active); })); this._updateDialog(); @@ -63,17 +62,17 @@ ClockPreferences.prototype = { }, _updateDialog: function() { - let format = this._gconf.get_string(FORMAT_KEY); + let format = this._settings.get_string(FORMAT_KEY); this._12hrRadio.active = (format == "12-hour"); this._24hrRadio.active = (format == "24-hour"); - this._dateCheck.active = this._gconf.get_bool(SHOW_DATE_KEY); - this._secondsCheck.active = this._gconf.get_bool(SHOW_SECONDS_KEY); + this._dateCheck.active = this._settings.get_boolean(SHOW_DATE_KEY); + this._secondsCheck.active = this._settings.get_boolean(SHOW_SECONDS_KEY); }, _onResponse: function() { this._dialog.destroy(); - this._gconf.notify_remove(this._notifyId); + this._settings.disconnect(this._notifyId); this.emit('destroy'); } }; diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js index 16728f769..d916b96b8 100644 --- a/js/ui/appFavorites.js +++ b/js/ui/appFavorites.js @@ -13,12 +13,11 @@ function AppFavorites() { } AppFavorites.prototype = { - FAVORITE_APPS_KEY: 'favorite_apps', + FAVORITE_APPS_KEY: 'favorite-apps', _init: function() { this._favorites = {}; - this._gconf = Shell.GConf.get_default(); - this._gconf.connect('changed::' + this.FAVORITE_APPS_KEY, Lang.bind(this, this._onFavsChanged)); + global.settings.connect('changed::' + this.FAVORITE_APPS_KEY, Lang.bind(this, this._onFavsChanged)); this._reload(); }, @@ -28,7 +27,7 @@ AppFavorites.prototype = { }, _reload: function() { - let ids = Shell.GConf.get_default().get_string_list('favorite_apps'); + let ids = global.settings.get_strv(this.FAVORITE_APPS_KEY); let appSys = Shell.AppSystem.get_default(); let apps = ids.map(function (id) { return appSys.get_app(id); @@ -75,7 +74,7 @@ AppFavorites.prototype = { let ids = this._getIds(); ids.push(appId); - this._gconf.set_string_list(this.FAVORITE_APPS_KEY, ids); + global.settings.set_strv(this.FAVORITE_APPS_KEY, ids); this._favorites[appId] = app; return true; }, @@ -96,7 +95,7 @@ AppFavorites.prototype = { return false; let ids = this._getIds().filter(function (id) { return id != appId; }); - this._gconf.set_string_list(this.FAVORITE_APPS_KEY, ids); + global.settings.set_strv(this.FAVORITE_APPS_KEY, ids); return true; }, diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 080ab1ded..6afbc1c79 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -1,6 +1,7 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Clutter = imports.gi.Clutter; +const Gio = imports.gi.Gio; const Lang = imports.lang; const St = imports.gi.St; const Pango = imports.gi.Pango; @@ -10,7 +11,7 @@ const Gettext_gtk20 = imports.gettext.domain('gtk20'); const MSECS_IN_DAY = 24 * 60 * 60 * 1000; const MSECS_IN_WEEK = MSECS_IN_DAY * 7; const WEEKDATE_HEADER_WIDTH_DIGITS = 3; -const SHOW_WEEKDATE_KEY = 'calendar/show_weekdate'; +const SHOW_WEEKDATE_KEY = 'show-weekdate'; function _sameDay(dateA, dateB) { return (dateA.getDate() == dateB.getDate() && @@ -48,10 +49,10 @@ Calendar.prototype = { this._weekStart = NaN; this._weekdate = NaN; this._digitWidth = NaN; - this._gconf = Shell.GConf.get_default(); + this._settings = new Gio.Settings({ schema: 'org.gnome.shell.calendar' }); - this._gconf.connect('changed', Lang.bind(this, this._onSettingsChange)); - this._useWeekdate = this._gconf.get_boolean(SHOW_WEEKDATE_KEY); + this._settings.connect('changed::' + SHOW_WEEKDATE_KEY, Lang.bind(this, this._onSettingsChange)); + this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY); let weekStartString = Gettext_gtk20.gettext('calendar:week_start:0'); if (weekStartString.indexOf('calendar:week_start:') == 0) { @@ -201,7 +202,7 @@ Calendar.prototype = { }, _onSettingsChange: function() { - this._useWeekdate = this._gconf.get_boolean(SHOW_WEEKDATE_KEY); + this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY); this._buildHeader(); this._update(); }, diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 8031bfeb8..fa88421f5 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -127,7 +127,7 @@ function init() { global.logError('' + e); } - disabledExtensions = Shell.GConf.get_default().get_string_list('disabled_extensions'); + disabledExtensions = global.settings.get_strv('disabled-extensions', -1); } function _loadExtensionsIn(dir, type) { diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 39241c20c..ea046ab0f 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -1,6 +1,7 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const Clutter = imports.gi.Clutter; +const GConf = imports.gi.GConf; const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; const Pango = imports.gi.Pango; @@ -582,10 +583,10 @@ LookingGlass.prototype = { vertical: true, visible: false }); - let gconf = Shell.GConf.get_default(); - gconf.watch_directory('/desktop/gnome/interface'); - gconf.connect('changed::/desktop/gnome/interface/monospace_font_name', - Lang.bind(this, this._updateFont)); + let gconf = GConf.Client.get_default(); + gconf.add_dir('/desktop/gnome/interface', GConf.ClientPreloadType.PRELOAD_NONE); + gconf.notify_add('/desktop/gnome/interface/monospace_font_name', + Lang.bind(this, this._updateFont)); this._updateFont(); Main.uiGroup.add_actor(this.actor); @@ -696,7 +697,7 @@ LookingGlass.prototype = { }, _updateFont: function() { - let gconf = Shell.GConf.get_default(); + let gconf = GConf.Client.get_default(); let fontName = gconf.get_string('/desktop/gnome/interface/monospace_font_name'); // This is mishandled by the scanner - should by Pango.FontDescription_from_string(fontName); // https://bugzilla.gnome.org/show_bug.cgi?id=595889 diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index d9643a292..518b33e55 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -1,6 +1,7 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ const DBus = imports.dbus; +const GConf = imports.gi.GConf; const Gtk = imports.gi.Gtk; const Gdk = imports.gi.Gdk; const Clutter = imports.gi.Clutter; @@ -461,7 +462,7 @@ Magnifier.prototype = { }, _gConfInit: function(zoomRegion) { - let gConf = Shell.GConf.get_default(); + let gConf = GConf.Client.get_default(); if (zoomRegion) { // Mag factor is accurate to two decimal places. let aPref = parseFloat(gConf.get_float(MAG_FACTOR_KEY).toFixed(2)); @@ -472,42 +473,42 @@ Magnifier.prototype = { if (aPref) zoomRegion.setScreenPosition(aPref); - zoomRegion.setLensMode(gConf.get_boolean(LENS_MODE_KEY)); - zoomRegion.setClampScrollingAtEdges(!gConf.get_boolean(CLAMP_MODE_KEY)); + zoomRegion.setLensMode(gConf.get_bool(LENS_MODE_KEY)); + zoomRegion.setClampScrollingAtEdges(!gConf.get_bool(CLAMP_MODE_KEY)); aPref = gConf.get_int(MOUSE_TRACKING_KEY); if (aPref) zoomRegion.setMouseTrackingMode(aPref); } - let showCrosshairs = gConf.get_boolean(SHOW_CROSS_HAIRS_KEY); + let showCrosshairs = gConf.get_bool(SHOW_CROSS_HAIRS_KEY); let thickness = gConf.get_int(CROSS_HAIRS_THICKNESS_KEY); let color = gConf.get_string(CROSS_HAIRS_COLOR_KEY); let opacity = gConf.get_int(CROSS_HAIRS_OPACITY_KEY); let length = gConf.get_int(CROSS_HAIRS_LENGTH_KEY); - let clip = gConf.get_boolean(CROSS_HAIRS_CLIP_KEY); + let clip = gConf.get_bool(CROSS_HAIRS_CLIP_KEY); this.addCrosshairs(thickness, color, opacity, length, clip); this.setCrosshairsVisible(showCrosshairs); - gConf.watch_directory(A11Y_MAG_PREFS_DIR); - gConf.connect('changed::' + SHOW_KEY, Lang.bind(this, this._updateShowHide)); - gConf.connect('changed::' + SCREEN_POSITION_KEY, Lang.bind(this, this._updateScreenPosition)); - gConf.connect('changed::' + MAG_FACTOR_KEY, Lang.bind(this, this._updateMagFactor)); - gConf.connect('changed::' + LENS_MODE_KEY, Lang.bind(this, this._updateLensMode)); - gConf.connect('changed::' + CLAMP_MODE_KEY, Lang.bind(this, this._updateClampMode)); - gConf.connect('changed::' + MOUSE_TRACKING_KEY, Lang.bind(this, this._updateMouseTrackingMode)); - gConf.connect('changed::' + SHOW_CROSS_HAIRS_KEY, Lang.bind(this, this._updateShowCrosshairs)); - gConf.connect('changed::' + CROSS_HAIRS_THICKNESS_KEY, Lang.bind(this, this._updateCrosshairsThickness)); - gConf.connect('changed::' + CROSS_HAIRS_COLOR_KEY, Lang.bind(this, this._updateCrosshairsColor)); - gConf.connect('changed::' + CROSS_HAIRS_OPACITY_KEY, Lang.bind(this, this._updateCrosshairsOpacity)); - gConf.connect('changed::' + CROSS_HAIRS_LENGTH_KEY, Lang.bind(this, this._updateCrosshairsLength)); - gConf.connect('changed::' + CROSS_HAIRS_CLIP_KEY, Lang.bind(this, this._updateCrosshairsClip)); + gConf.add_dir(A11Y_MAG_PREFS_DIR, GConf.ClientPreloadType.PRELOAD_ONELEVEL); + gConf.notify_add(SHOW_KEY, Lang.bind(this, this._updateShowHide)); + gConf.notify_add(SCREEN_POSITION_KEY, Lang.bind(this, this._updateScreenPosition)); + gConf.notify_add(MAG_FACTOR_KEY, Lang.bind(this, this._updateMagFactor)); + gConf.notify_add(LENS_MODE_KEY, Lang.bind(this, this._updateLensMode)); + gConf.notify_add(CLAMP_MODE_KEY, Lang.bind(this, this._updateClampMode)); + gConf.notify_add(MOUSE_TRACKING_KEY, Lang.bind(this, this._updateMouseTrackingMode)); + gConf.notify_add(SHOW_CROSS_HAIRS_KEY, Lang.bind(this, this._updateShowCrosshairs)); + gConf.notify_add(CROSS_HAIRS_THICKNESS_KEY, Lang.bind(this, this._updateCrosshairsThickness)); + gConf.notify_add(CROSS_HAIRS_COLOR_KEY, Lang.bind(this, this._updateCrosshairsColor)); + gConf.notify_add(CROSS_HAIRS_OPACITY_KEY, Lang.bind(this, this._updateCrosshairsOpacity)); + gConf.notify_add(CROSS_HAIRS_LENGTH_KEY, Lang.bind(this, this._updateCrosshairsLength)); + gConf.notify_add(CROSS_HAIRS_CLIP_KEY, Lang.bind(this, this._updateCrosshairsClip)); - return gConf.get_boolean(SHOW_KEY); + return gConf.get_bool(SHOW_KEY); }, _updateShowHide: function() { let gConf = Shell.GConf.get_default(); - this.setActive(gConf.get_boolean(SHOW_KEY)); + this.setActive(gConf.get_bool(SHOW_KEY)); }, _updateScreenPosition: function() { @@ -535,7 +536,7 @@ Magnifier.prototype = { // Applies only to the first zoom region. if (this._zoomRegions.length) { let gConf = Shell.GConf.get_default(); - this._zoomRegions[0].setLensMode(gConf.get_boolean(LENS_MODE_KEY)); + this._zoomRegions[0].setLensMode(gConf.get_bool(LENS_MODE_KEY)); } }, @@ -544,7 +545,7 @@ Magnifier.prototype = { if (this._zoomRegions.length) { let gConf = Shell.GConf.get_default(); this._zoomRegions[0].setClampScrollingAtEdges( - !gConf.get_boolean(CLAMP_MODE_KEY) + !gConf.get_bool(CLAMP_MODE_KEY) ); } }, @@ -561,7 +562,7 @@ Magnifier.prototype = { _updateShowCrosshairs: function() { let gConf = Shell.GConf.get_default(); - this.setCrosshairsVisible(gConf.get_boolean(SHOW_CROSS_HAIRS_KEY)); + this.setCrosshairsVisible(gConf.get_bool(SHOW_CROSS_HAIRS_KEY)); }, _updateCrosshairsThickness: function() { @@ -586,7 +587,7 @@ Magnifier.prototype = { _updateCrosshairsClip: function() { let gConf = Shell.GConf.get_default(); - this.setCrosshairsClip(gConf.get_boolean(CROSS_HAIRS_CLIP_KEY)); + this.setCrosshairsClip(gConf.get_bool(CROSS_HAIRS_CLIP_KEY)); } }; diff --git a/js/ui/main.js b/js/ui/main.js index b54ee207d..77930a710 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -11,6 +11,7 @@ const DBus = imports.dbus; 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; @@ -133,7 +134,9 @@ function start() { _startDate = new Date(); - global.screen.connect('toggle-recording', function() { + let recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' }); + + global.screen.connect('toggle-recording', function(recorderSettings) { if (recorder == null) { recorder = new Shell.Recorder({ stage: global.stage }); } @@ -141,11 +144,11 @@ function start() { if (recorder.is_recording()) { recorder.pause(); } else { - //read the parameters from GConf always in case they have changed - let gconf = Shell.GConf.get_default(); - recorder.set_framerate(gconf.get_int('recorder/framerate')); - recorder.set_filename('shell-%d%u-%c.' + gconf.get_string('recorder/file_extension')); - let pipeline = gconf.get_string('recorder/pipeline'); + // read the parameters from GSettings always in case they have changed + recorder.set_framerate(recorderSettings.get_int('framerate')); + recorder.set_filename('shell-%d%u-%c.' + recorderSettings.get_string('file-extension')); + let pipeline = recorderSettings.get_string('pipeline'); + if (!pipeline.match(/^\s*$/)) recorder.set_pipeline(pipeline); else @@ -296,7 +299,7 @@ function _globalKeyPressHandler(actor, event) { let symbol = event.get_key_symbol(); if (symbol == Clutter.Print) { // We want to be able to take screenshots of the shell at all times - let gconf = Shell.GConf.get_default(); + let gconf = GConf.Client.get_default(); let command = gconf.get_string('/apps/metacity/keybinding_commands/command_screenshot'); if (command != null && command != '') { let [ok, len, args] = GLib.shell_parse_argv(command); diff --git a/js/ui/panel.js b/js/ui/panel.js index 40d607e98..48dabc825 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -2,6 +2,8 @@ const Cairo = imports.cairo; const Clutter = imports.gi.Clutter; +const GConf = imports.gi.GConf; +const Gio = imports.gi.Gio; const Gtk = imports.gi.Gtk; const Lang = imports.lang; const Mainloop = imports.mainloop; @@ -40,10 +42,10 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = { 'gnome-power-manager': 'battery' }; -const CLOCK_FORMAT_KEY = 'clock/format'; -const CLOCK_CUSTOM_FORMAT_KEY = 'clock/custom_format'; -const CLOCK_SHOW_DATE_KEY = 'clock/show_date'; -const CLOCK_SHOW_SECONDS_KEY = 'clock/show_seconds'; +const CLOCK_FORMAT_KEY = 'format'; +const CLOCK_CUSTOM_FORMAT_KEY = 'custom-format'; +const CLOCK_SHOW_DATE_KEY = 'show-date'; +const CLOCK_SHOW_SECONDS_KEY = 'show-seconds'; function AnimatedIcon(name, size) { this._init(name, size); @@ -521,8 +523,8 @@ ClockButton.prototype = { this._calendarPopup = null; - let gconf = Shell.GConf.get_default(); - gconf.connect('changed', Lang.bind(this, this._updateClock)); + this._clockSettings = new Gio.Settings({ schema: 'org.gnome.shell.clock' }); + this._clockSettings.connect('changed', Lang.bind(this, this._updateClock)); // Start the clock this._updateClock(); @@ -580,10 +582,9 @@ ClockButton.prototype = { }, _updateClock: function() { - let gconf = Shell.GConf.get_default(); - let format = gconf.get_string(CLOCK_FORMAT_KEY); - let showDate = gconf.get_boolean(CLOCK_SHOW_DATE_KEY); - let showSeconds = gconf.get_boolean(CLOCK_SHOW_SECONDS_KEY); + let format = this._clockSettings.get_string(CLOCK_FORMAT_KEY); + let showDate = this._clockSettings.get_boolean(CLOCK_SHOW_DATE_KEY); + let showSeconds = this._clockSettings.get_boolean(CLOCK_SHOW_SECONDS_KEY); let clockFormat; switch (format) { @@ -595,7 +596,7 @@ ClockButton.prototype = { case 'custom': // force updates every second showSeconds = true; - clockFormat = gconf.get_string(CLOCK_CUSTOM_FORMAT_KEY); + clockFormat = this._clockSettings.get_string(CLOCK_CUSTOM_FORMAT_KEY); break; case '24-hour': if (showDate) diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js index 452c8e19d..1689cf59a 100644 --- a/js/ui/placeDisplay.js +++ b/js/ui/placeDisplay.js @@ -2,6 +2,7 @@ const Clutter = imports.gi.Clutter; const Pango = imports.gi.Pango; +const GConf = imports.gi.GConf; const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; const Shell = imports.gi.Shell; @@ -120,13 +121,13 @@ function PlacesManager() { PlacesManager.prototype = { _init: function() { - let gconf = Shell.GConf.get_default(); - gconf.watch_directory(NAUTILUS_PREFS_DIR); + let gconf = GConf.Client.get_default(); + gconf.add_dir(NAUTILUS_PREFS_DIR, GConf.ClientPreloadType.PRELOAD_NONE); this._defaultPlaces = []; this._mounts = []; this._bookmarks = []; - this._isDesktopHome = gconf.get_boolean(DESKTOP_IS_HOME_KEY); + this._isDesktopHome = gconf.get_bool(DESKTOP_IS_HOME_KEY); let homeFile = Gio.file_new_for_path (GLib.get_home_dir()); let homeUri = homeFile.get_uri(); @@ -225,7 +226,7 @@ PlacesManager.prototype = { this._reloadBookmarks(); - gconf.connect('changed::' + DESKTOP_IS_HOME_KEY, Lang.bind(this, this._updateDesktopMenuVisibility)); + gconf.notify_add(DESKTOP_IS_HOME_KEY, Lang.bind(this, this._updateDesktopMenuVisibility)); }, @@ -336,7 +337,7 @@ PlacesManager.prototype = { }, _updateDesktopMenuVisibility: function() { - let gconf = Shell.GConf.get_default(); + let gconf = GConf.Client.get_default(); this._isDesktopHome = gconf.get_boolean(DESKTOP_IS_HOME_KEY); if (this._isDesktopHome) diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index 726d38280..8aeb1800d 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -18,7 +18,7 @@ const Tweener = imports.ui.tweener; const MAX_FILE_DELETED_BEFORE_INVALID = 10; -const HISTORY_KEY = 'run_dialog/history'; +const HISTORY_KEY = 'command-history'; const HISTORY_LIMIT = 512; const DIALOG_FADE_TIME = 0.1; @@ -179,17 +179,16 @@ RunDialog.prototype = { _init : function() { this._isOpen = false; - this._gconf = Shell.GConf.get_default(); - this._gconf.connect('changed::development_tools', Lang.bind(this, function () { - this._enableInternalCommands = this._gconf.get_boolean('development_tools'); + global.settings.connect('changed::development-tools', Lang.bind(this, function () { + this._enableInternalCommands = global.settings.get_boolean('development-tools'); })); - this._enableInternalCommands = this._gconf.get_boolean('development_tools'); + this._enableInternalCommands = global.settings.get_boolean('development-tools'); - this._history = this._gconf.get_string_list(HISTORY_KEY); + this._history = global.settings.get_strv(HISTORY_KEY); this._historyIndex = -1; - this._gconf.connect('changed::' + HISTORY_KEY, Lang.bind(this, function() { - this._history = this._gconf.get_string_list(HISTORY_KEY); + global.settings.connect('changed::' + HISTORY_KEY, Lang.bind(this, function() { + this._history = global.settings.get_strv(HISTORY_KEY); this._historyIndex = this._history.length; })); @@ -327,7 +326,7 @@ RunDialog.prototype = { if (this._history.length > HISTORY_LIMIT) { this._history.splice(0, this._history.length - HISTORY_LIMIT); } - this._gconf.set_string_list(HISTORY_KEY, this._history); + global.settings.set_strv(HISTORY_KEY, this._history); }, _run : function(input, inTerminal) { diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index 2683d1d74..1f2e315c3 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -26,13 +26,13 @@ const WORKSPACE_SWITCH_TIME = 0.25; // Note that mutter has a compile-time limit of 36 const MAX_WORKSPACES = 16; -// The values here are also used for gconf, and the key and value +// The values here are also used for GSettings, and the key and value // names must match const WorkspacesViewType = { SINGLE: 'single', GRID: 'grid' }; -const WORKSPACES_VIEW_KEY = 'overview/workspaces_view'; +const WORKSPACES_VIEW_KEY = 'workspaces-view'; const WORKSPACE_DRAGGING_SCALE = 0.85; const WORKSPACE_SHADOW_SCALE = (1 - WORKSPACE_DRAGGING_SCALE) / 2; @@ -1429,9 +1429,7 @@ WorkspacesControls.prototype = { this.actor = new St.BoxLayout({ style_class: 'workspaces-bar' }); this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); - this._gconf = Shell.GConf.get_default(); - - let view = this._gconf.get_string(WORKSPACES_VIEW_KEY).toUpperCase(); + let view = global.settings.get_string(WORKSPACES_VIEW_KEY).toUpperCase(); if (view in WorkspacesViewType) this._currentViewType = WorkspacesViewType[view]; else @@ -1528,7 +1526,7 @@ WorkspacesControls.prototype = { this._toggleViewButton.set_style_class_name('workspace-controls switch-single'); this._currentViewType = view; - this._gconf.set_string(WORKSPACES_VIEW_KEY, view); + global.settings.set_string(WORKSPACES_VIEW_KEY, view); }, _onDestroy: function() { @@ -1590,8 +1588,8 @@ WorkspacesManager.prototype = { this.controlsBar.actor.connect('destroy', Lang.bind(this, this._onDestroy)); this._viewChangedId = - Shell.GConf.get_default().connect('changed::' + WORKSPACES_VIEW_KEY, - Lang.bind(this, this._updateView)); + global.settings.connect('changed::' + WORKSPACES_VIEW_KEY, + Lang.bind(this, this._updateView)); this._nWorkspacesNotifyId = global.screen.connect('notify::n-workspaces', Lang.bind(this, this._workspacesChanged)); @@ -1600,7 +1598,7 @@ WorkspacesManager.prototype = { _updateView: function() { let viewType, newView; - let view = Shell.GConf.get_default().get_string(WORKSPACES_VIEW_KEY).toUpperCase(); + let view = global.settings.get_string(WORKSPACES_VIEW_KEY).toUpperCase(); if (view in WorkspacesViewType) viewType = WorkspacesViewType[view]; else @@ -1678,7 +1676,7 @@ WorkspacesManager.prototype = { if (this._nWorkspacesNotifyId > 0) global.screen.disconnect(this._nWorkspacesNotifyId); if (this._viewChangedId > 0) - Shell.GConf.get_default().disconnect(this._viewChangedId); + global.settings.disconnect(this._viewChangedId); for (let w = 0; w < this._workspaces.length; w++) { this._workspaces[w].disconnectAll(); this._workspaces[w].destroy(); diff --git a/po/POTFILES.in b/po/POTFILES.in index 8100ca364..352d6b8bb 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ data/gnome-shell.desktop.in.in data/gnome-shell-clock-preferences.desktop.in.in +data/org.gnome.shell.gschema.xml.in [type: gettext/glade]data/clock-preferences.ui js/ui/appDisplay.js js/ui/appFavorites.js diff --git a/src/Makefile.am b/src/Makefile.am index 42ca0a01d..b063722a8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,7 @@ bin_SCRIPTS = gnome-shell gnome-shell-clock-preferences gnome-shell: gnome-shell.in $(AM_V_GEN) sed -e "s|@MUTTER_BIN_DIR[@]|$(MUTTER_BIN_DIR)|" \ + -e "s|@datadir[@]|$(datadir)|" \ -e "s|@GJS_JS_DIR[@]|$(GJS_JS_DIR)|" \ -e "s|@GJS_JS_NATIVE_DIR[@]|$(GJS_JS_NATIVE_DIR)|" \ -e "s|@libexecdir[@]|$(libexecdir)|" \ @@ -25,7 +26,8 @@ CLEANFILES += gnome-shell EXTRA_DIST += gnome-shell.in gnome-shell-clock-preferences: gnome-shell-clock-preferences.in - $(AM_V_GEN) sed -e "s|@pkgdatadir[@]|$(pkgdatadir)|" \ + $(AM_V_GEN) sed -e "s|@datadir[@]|$(datadir)|" \ + -e "s|@pkgdatadir[@]|$(pkgdatadir)|" \ -e "s|@localedir[@]|$(datadir)/locale|" \ -e "s|@GJS_CONSOLE[@]|$(GJS_CONSOLE)|" \ $< > $@ && chmod a+x $@ @@ -65,7 +67,6 @@ shell_public_headers_h = \ shell-doc-system.h \ shell-drawing.h \ shell-embedded-window.h \ - shell-gconf.h \ shell-generic-container.h \ shell-gtk-embed.h \ shell-process.h \ @@ -99,7 +100,6 @@ libgnome_shell_la_SOURCES = \ shell-doc-system.c \ shell-drawing.c \ shell-embedded-window.c \ - shell-gconf.c \ shell-generic-container.c \ shell-gtk-embed.c \ shell-process.c \ diff --git a/src/gnome-shell-clock-preferences.in b/src/gnome-shell-clock-preferences.in index 9c471ab91..8ed2aa9bc 100644 --- a/src/gnome-shell-clock-preferences.in +++ b/src/gnome-shell-clock-preferences.in @@ -5,15 +5,19 @@ then scriptDir="`dirname $0`" uiDir="$scriptDir/../data" jsDir="$scriptDir/../js" + schemaDir="$scriptDir/../data" else uiDir="@pkgdatadir@" jsDir="@pkgdatadir@/js" + schemaDir="@datadir@/glib-2.0/schemas" fi progName="`basename $0`" localeDir="@localedir@" uiFile="$uiDir/clock-preferences.ui" export GJS_PATH="$jsDir" +export GSETTINGS_BACKEND="gconf" +export GSETTINGS_SCHEMA_DIR="$schemaDir" @GJS_CONSOLE@ -c "const ClockPreferences = imports.prefs.clockPreferences; ClockPreferences.main({ progName: '$progName', diff --git a/src/gnome-shell.in b/src/gnome-shell.in index ad95c55dc..01f99170d 100644 --- a/src/gnome-shell.in +++ b/src/gnome-shell.in @@ -155,13 +155,17 @@ def start_shell(perf_output=None): # Set up environment env = dict(os.environ) env.update({'GNOME_SHELL_JS' : '@GJS_JS_DIR@:@GJS_JS_NATIVE_DIR@:' + js_dir, + 'GSETTINGS_BACKEND' : 'gconf', 'PATH' : '@MUTTER_BIN_DIR@:' + os.environ.get('PATH', ''), 'XDG_CONFIG_DIRS' : '@sysconfdir@/xdg:' + (os.environ.get('XDG_CONFIG_DIRS') or '/etc/xdg'), 'GNOME_DISABLE_CRASH_DIALOG' : '1'}) if running_from_source_tree: - env.update({'GNOME_SHELL_DATADIR' : data_dir, - 'GI_TYPELIB_PATH' : typelib_dir}) + env.update({'GNOME_SHELL_DATADIR' : data_dir, + 'GI_TYPELIB_PATH' : typelib_dir, + 'GSETTINGS_SCHEMA_DIR' : data_dir }) + else: + env.update({'GSETTINGS_SCHEMA_DIR' : os.path.join('@datadir@', 'glib-2.0', 'schemas')}) jhbuild_gconf_source = os.path.join('@sysconfdir@', 'gconf/2/path.jhbuild') if os.path.exists(jhbuild_gconf_source): diff --git a/src/shell-app-system.c b/src/shell-app-system.c index c0ebc7fce..f2813ea47 100644 --- a/src/shell-app-system.c +++ b/src/shell-app-system.c @@ -8,8 +8,6 @@ #include #include #include -#include -#include #include #include "shell-app-private.h" @@ -20,8 +18,6 @@ #define GMENU_I_KNOW_THIS_IS_UNSTABLE #include -#define SHELL_APP_FAVORITES_KEY "/desktop/gnome/shell/favorite_apps" - /* Vendor prefixes are something that can be preprended to a .desktop * file name. Undo this. */ @@ -197,7 +193,6 @@ static void shell_app_system_init (ShellAppSystem *self) { ShellAppSystemPrivate *priv; - GConfClient *client; self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_APP_SYSTEM, @@ -223,8 +218,6 @@ shell_app_system_init (ShellAppSystem *self) gmenu_tree_add_monitor (priv->settings_tree, on_tree_changed_cb, self); reread_menus (self); - - client = gconf_client_get_default (); } static void diff --git a/src/shell-app-usage.c b/src/shell-app-usage.c index 2cddffaca..6126dc096 100644 --- a/src/shell-app-usage.c +++ b/src/shell-app-usage.c @@ -9,9 +9,8 @@ #include #include #include +#include #include -#include -#include #include #include "shell-app-usage.h" @@ -43,8 +42,7 @@ * minutes to signify idle. */ -#define APP_MONITOR_GCONF_DIR SHELL_GCONF_DIR"/app_monitor" -#define ENABLE_MONITORING_KEY APP_MONITOR_GCONF_DIR"/enable_monitoring" +#define ENABLE_MONITORING_KEY "enable-app-monitoring" #define FOCUS_TIME_MIN_SECONDS 7 /* Need 7 continuous seconds of focus */ @@ -87,11 +85,10 @@ struct _ShellAppUsage GFile *configfile; DBusGProxy *session_proxy; GdkDisplay *display; - GConfClient *gconf_client; gulong last_idle; guint idle_focus_change_id; guint save_id; - guint gconf_notify; + guint settings_notify; gboolean currently_idle; gboolean enable_monitoring; @@ -133,10 +130,9 @@ static void restore_from_file (ShellAppUsage *self); static void update_enable_monitoring (ShellAppUsage *self); -static void on_enable_monitoring_key_changed (GConfClient *client, - guint connexion_id, - GConfEntry *entry, - gpointer self); +static void on_enable_monitoring_key_changed (GSettings *settings, + const gchar *key, + ShellAppUsage *self); static long get_time (void) @@ -381,10 +377,13 @@ on_session_status_changed (DBusGProxy *proxy, static void shell_app_usage_init (ShellAppUsage *self) { + ShellGlobal *global; char *shell_userdata_dir, *path; DBusGConnection *session_bus; ShellWindowTracker *tracker; + global = shell_global_get (); + self->app_usages_for_context = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy); tracker = shell_window_tracker_get_default (); @@ -411,24 +410,26 @@ shell_app_usage_init (ShellAppUsage *self) g_free (path); restore_from_file (self); - self->gconf_client = gconf_client_get_default (); - gconf_client_add_dir (self->gconf_client, APP_MONITOR_GCONF_DIR, - GCONF_CLIENT_PRELOAD_NONE, NULL); - self->gconf_notify = - gconf_client_notify_add (self->gconf_client, ENABLE_MONITORING_KEY, - on_enable_monitoring_key_changed, self, NULL, NULL); + + self->settings_notify = g_signal_connect (shell_global_get_settings (global), + "changed::" ENABLE_MONITORING_KEY, + G_CALLBACK (on_enable_monitoring_key_changed), + self); update_enable_monitoring (self); } static void shell_app_usage_finalize (GObject *object) { + ShellGlobal *global; ShellAppUsage *self = SHELL_APP_USAGE (object); if (self->save_id > 0) g_source_remove (self->save_id); - gconf_client_notify_remove (self->gconf_client, self->gconf_notify); - g_object_unref (self->gconf_client); + + global = shell_global_get (); + g_signal_handler_disconnect (shell_global_get_settings (global), + self->settings_notify); g_object_unref (self->configfile); @@ -896,17 +897,12 @@ out: static void update_enable_monitoring (ShellAppUsage *self) { - GConfValue *value; + ShellGlobal *global; gboolean enable; - value = gconf_client_get (self->gconf_client, ENABLE_MONITORING_KEY, NULL); - if (value) - { - enable = gconf_value_get_bool (value); - gconf_value_free (value); - } - else /* Schema is not present, set default value by hand to avoid getting FALSE */ - enable = TRUE; + global = shell_global_get (); + enable = g_settings_get_boolean (shell_global_get_settings (global), + ENABLE_MONITORING_KEY); /* Be sure not to start the timers if they were already set */ if (enable && !self->enable_monitoring) @@ -931,12 +927,11 @@ update_enable_monitoring (ShellAppUsage *self) /* Called when the ENABLE_MONITORING_KEY boolean has changed */ static void -on_enable_monitoring_key_changed (GConfClient *client, - guint connexion_id, - GConfEntry *entry, - gpointer self) +on_enable_monitoring_key_changed (GSettings *settings, + const gchar *key, + ShellAppUsage *self) { - update_enable_monitoring ((ShellAppUsage *) self); + update_enable_monitoring (self); } /** diff --git a/src/shell-gconf.c b/src/shell-gconf.c deleted file mode 100644 index 30485d4ad..000000000 --- a/src/shell-gconf.c +++ /dev/null @@ -1,410 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -#include "config.h" - -#include "shell-gconf.h" - -#include -#include - -/** - * ShellGConf: - * - * A wrapper around #GConfClient that cleans up some of its - * non-gjs-bindable bits and makes a few gnome-shell-specific - * assumptions. - * - * For all #ShellGConf methods that take a GConf key path as an - * argument, you can pass either a full path (eg, - * "/desktop/gnome/shell/sidebar/visible"), or just a relative path - * starting from the root of the gnome-shell GConf key hierarchy (eg, - * "sidebar/visible"). - */ - -struct _ShellGConf -{ - GObject parent; - - GConfClient *client; -}; - -G_DEFINE_TYPE (ShellGConf, shell_gconf, G_TYPE_OBJECT); - -/* Signals */ -enum -{ - CHANGED, - - LAST_SIGNAL -}; - -static guint shell_gconf_signals [LAST_SIGNAL] = { 0 }; - -static void gconf_value_changed (GConfClient *client, const char *key, - GConfValue *new_value, gpointer user_data); - -static void -shell_gconf_init (ShellGConf *gconf) -{ - GConfValue *val; - - gconf->client = gconf_client_get_default (); - gconf_client_add_dir (gconf->client, SHELL_GCONF_DIR, - GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - - val = gconf_client_get (gconf->client, - SHELL_GCONF_DIR "/development_tools", NULL); - if (!val) - { - g_error ("GNOME Shell GConf schemas not found.\n" - "This generally indicates a building or packaging problem."); - } - gconf_value_free (val); - - g_signal_connect (gconf->client, "value_changed", - G_CALLBACK (gconf_value_changed), gconf); -} - -static void -shell_gconf_finalize (GObject *object) -{ - ShellGConf *gconf = SHELL_GCONF (object); - - g_signal_handlers_disconnect_by_func (gconf->client, - gconf_value_changed, gconf); - g_object_unref (gconf->client); - - G_OBJECT_CLASS (shell_gconf_parent_class)->finalize (object); -} - -static void -shell_gconf_class_init (ShellGConfClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->finalize = shell_gconf_finalize; - - /** - * ShellGConf::changed: - * @gconf: the #ShellGConf - * - * Emitted when a key in a watched directory is changed. The signal - * detail indicates which key changed. Eg, connect to - * "changed::sidebar/visible" to be notified when "sidebar/visible" - * changes. For gnome-shell's own GConf keys, the signal detail will - * be the relative path from the top of the gnome-shell GConf - * hierarchy ("/desktop/gnome/shell"). If you want to be notified - * about the value of a non-gnome-shell key, you must first call - * shell_gconf_watch_directory(), and then use the full GConf key path - * as the signal detail. - */ - shell_gconf_signals[CHANGED] = - g_signal_new ("changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - G_STRUCT_OFFSET (ShellGConfClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -/** - * shell_gconf_get_default: - * - * Gets the default #ShellGConf - * - * Return value: (transfer none): the default #ShellGConf - */ -ShellGConf * -shell_gconf_get_default (void) -{ - static ShellGConf *gconf = NULL; - - if (!gconf) - gconf = g_object_new (SHELL_TYPE_GCONF, NULL); - - return gconf; -} - -/** - * shell_gconf_watch_directory: - * @gconf: a #ShellGConf - * @directory: the path of a GConf directory to watch for changes in - * - * Adds @directory to the list of directories to watch; you must call - * this before connecting to #ShellGConf::changed for a key outside of - * the gnome-shell GConf tree. - */ -void -shell_gconf_watch_directory (ShellGConf *gconf, const char *directory) -{ - gconf_client_add_dir (gconf->client, directory, - GCONF_CLIENT_PRELOAD_NONE, NULL); -} - -static void -gconf_value_changed (GConfClient *client, const char *key, - GConfValue *new_value, gpointer user_data) -{ - ShellGConf *gconf = user_data; - GQuark detail; - - if (g_str_has_prefix (key, SHELL_GCONF_DIR "/")) - key += strlen (SHELL_GCONF_DIR "/"); - - /* This will create a lot of junk quarks, but it's the best we - * can do with gjs's current callback support. - */ - detail = g_quark_from_string (key); - g_signal_emit (gconf, shell_gconf_signals[CHANGED], detail); -} - -static char * -resolve_key (const char *key) -{ - if (*key == '/') - return g_strdup (key); - else - return g_build_filename (SHELL_GCONF_DIR, key, NULL); -} - - -#define SIMPLE_GETTER(NAME, TYPE, GCONF_GETTER) \ -TYPE \ -NAME (ShellGConf *gconf, const char *key, GError **error) \ -{ \ - char *get_key = resolve_key (key); \ - TYPE value; \ - \ - value = GCONF_GETTER (gconf->client, get_key, error); \ - g_free (get_key); \ - return value; \ -} - -#define LIST_GETTER(NAME, ELEMENT_TYPE) \ -GSList * \ -NAME (ShellGConf *gconf, const char *key, GError **error) \ -{ \ - char *get_key = resolve_key (key); \ - GSList *value; \ - \ - value = gconf_client_get_list (gconf->client, get_key, \ - ELEMENT_TYPE, error); \ - g_free (get_key); \ - return value; \ -} - -/** - * shell_gconf_get_boolean: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be boolean-valued. - * - * Return value: @key's value. If an error occurs, @error will be set - * and the return value is undefined. - **/ -SIMPLE_GETTER(shell_gconf_get_boolean, gboolean, gconf_client_get_bool) - -/** - * shell_gconf_get_int: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be integer-valued. - * - * Return value: @key's value. If an error occurs, @error will be set - * and the return value is undefined. - **/ -SIMPLE_GETTER(shell_gconf_get_int, int, gconf_client_get_int) - -/** - * shell_gconf_get_float: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be float-valued. - * - * Return value: @key's value. If an error occurs, @error will be set - * and the return value is undefined. - **/ -SIMPLE_GETTER(shell_gconf_get_float, float, gconf_client_get_float) - -/** - * shell_gconf_get_string: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be string-valued. - * - * Return value: (transfer full): @key's value, or %NULL if an error - * occurs. - **/ -SIMPLE_GETTER(shell_gconf_get_string, char *, gconf_client_get_string) - -/** - * shell_gconf_get_boolean_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be boolean-list-valued. - * - * Return value: (element-type gboolean) (transfer full): @key's - * value, or %NULL if an error occurs. - **/ -LIST_GETTER(shell_gconf_get_boolean_list, GCONF_VALUE_BOOL) - -/** - * shell_gconf_get_int_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be integer-list-valued. - * - * Return value: (element-type int) (transfer full): @key's - * value, or %NULL if an error occurs. - **/ -LIST_GETTER(shell_gconf_get_int_list, GCONF_VALUE_INT) - -/** - * shell_gconf_get_float_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be float-list-valued. - * - * Return value: (element-type float) (transfer full): @key's - * value, or %NULL if an error occurs. - **/ -LIST_GETTER(shell_gconf_get_float_list, GCONF_VALUE_FLOAT) - -/** - * shell_gconf_get_string_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @error: a #GError, which will be set on error - * - * Gets the value of @key, which must be string-list-valued. - * - * Return value: (element-type utf8) (transfer full): @key's - * value, or %NULL if an error occurs. - **/ -LIST_GETTER(shell_gconf_get_string_list, GCONF_VALUE_STRING) - - -#define SIMPLE_SETTER(NAME, TYPE, GCONF_SETTER) \ -void \ -NAME (ShellGConf *gconf, const char *key, TYPE value, GError **error) \ -{ \ - char *set_key = resolve_key (key); \ - \ - GCONF_SETTER (gconf->client, set_key, value, error); \ - g_free (set_key); \ -} - -#define LIST_SETTER(NAME, ELEMENT_TYPE) \ -void \ -NAME (ShellGConf *gconf, const char *key, \ - GSList *value, GError **error) \ -{ \ - char *set_key = resolve_key (key); \ - \ - gconf_client_set_list (gconf->client, set_key, ELEMENT_TYPE, \ - value, error); \ - g_free (set_key); \ -} - -/** - * shell_gconf_set_boolean: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -SIMPLE_SETTER(shell_gconf_set_boolean, gboolean, gconf_client_set_bool) - -/** - * shell_gconf_set_int: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -SIMPLE_SETTER(shell_gconf_set_int, int, gconf_client_set_int) - -/** - * shell_gconf_set_float: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -SIMPLE_SETTER(shell_gconf_set_float, float, gconf_client_set_float) - -/** - * shell_gconf_set_string: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -SIMPLE_SETTER(shell_gconf_set_string, const char *, gconf_client_set_string) - -/** - * shell_gconf_set_boolean_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: (transfer none) (element-type gboolean): value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -LIST_SETTER(shell_gconf_set_boolean_list, GCONF_VALUE_BOOL) - -/** - * shell_gconf_set_int_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: (transfer none): value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -LIST_SETTER(shell_gconf_set_int_list, GCONF_VALUE_INT) - -/** - * shell_gconf_set_float_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: (transfer none) (element-type float): value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -LIST_SETTER(shell_gconf_set_float_list, GCONF_VALUE_FLOAT) - -/** - * shell_gconf_set_string_list: - * @gconf: a #ShellGConf - * @key: a GConf key (as described in the #ShellGConf docs) - * @value: (transfer none) (element-type utf8): value to set @key to - * @error: a #GError, which will be set on error - * - * Sets the value of @key to @value. - **/ -LIST_SETTER(shell_gconf_set_string_list, GCONF_VALUE_STRING) diff --git a/src/shell-gconf.h b/src/shell-gconf.h deleted file mode 100644 index e8b1905e7..000000000 --- a/src/shell-gconf.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -#ifndef SHELL_GCONF_H -#define SHELL_GCONF_H - -#include - -G_BEGIN_DECLS - -typedef struct _ShellGConf ShellGConf; -typedef struct _ShellGConfClass ShellGConfClass; - -#define SHELL_TYPE_GCONF (shell_gconf_get_type ()) -#define SHELL_GCONF(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SHELL_TYPE_GCONF, ShellGConf)) -#define SHELL_GCONF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_GCONF, ShellGConfClass)) -#define SHELL_IS_GCONF(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), SHELL_TYPE_GCONF)) -#define SHELL_IS_GCONF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_GCONF)) -#define SHELL_GCONF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_GCONF, ShellGConfClass)) - -struct _ShellGConfClass -{ - GObjectClass parent_class; - - /* signals */ - void (*changed) (ShellGConf *gconf); -}; - -#define SHELL_GCONF_DIR "/desktop/gnome/shell" - -GType shell_gconf_get_type (void) G_GNUC_CONST; -ShellGConf *shell_gconf_get_default (void); - -void shell_gconf_watch_directory (ShellGConf *gconf, - const char *directory); - -gboolean shell_gconf_get_boolean (ShellGConf *gconf, - const char *key, - GError **error); -int shell_gconf_get_int (ShellGConf *gconf, - const char *key, - GError **error); -float shell_gconf_get_float (ShellGConf *gconf, - const char *key, - GError **error); -char *shell_gconf_get_string (ShellGConf *gconf, - const char *key, - GError **error); -GSList *shell_gconf_get_boolean_list (ShellGConf *gconf, - const char *key, - GError **error); -GSList *shell_gconf_get_int_list (ShellGConf *gconf, - const char *key, - GError **error); -GSList *shell_gconf_get_float_list (ShellGConf *gconf, - const char *key, - GError **error); -GSList *shell_gconf_get_string_list (ShellGConf *gconf, - const char *key, - GError **error); - -void shell_gconf_set_boolean (ShellGConf *gconf, - const char *key, - gboolean value, - GError **error); -void shell_gconf_set_int (ShellGConf *gconf, - const char *key, - int value, - GError **error); -void shell_gconf_set_float (ShellGConf *gconf, - const char *key, - float value, - GError **error); -void shell_gconf_set_string (ShellGConf *gconf, - const char *key, - const char *value, - GError **error); -void shell_gconf_set_boolean_list (ShellGConf *gconf, - const char *key, - GSList *value, - GError **error); -void shell_gconf_set_int_list (ShellGConf *gconf, - const char *key, - GSList *value, - GError **error); -void shell_gconf_set_float_list (ShellGConf *gconf, - const char *key, - GSList *value, - GError **error); -void shell_gconf_set_string_list (ShellGConf *gconf, - const char *key, - GSList *value, - GError **error); - -#endif - diff --git a/src/shell-global.c b/src/shell-global.c index 25afb7ba9..fa3f9224e 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -50,6 +50,7 @@ struct _ShellGlobal { GjsContext *js_context; MutterPlugin *plugin; ShellWM *wm; + GSettings *settings; const char *datadir; const char *imagedir; const char *userdatadir; @@ -75,6 +76,7 @@ enum { PROP_STAGE, PROP_WINDOW_GROUP, PROP_WINDOW_MANAGER, + PROP_SETTINGS, PROP_DATADIR, PROP_IMAGEDIR, PROP_USERDATADIR, @@ -140,6 +142,9 @@ shell_global_get_property(GObject *object, case PROP_WINDOW_MANAGER: g_value_set_object (value, global->wm); break; + case PROP_SETTINGS: + g_value_set_object (value, global->settings); + break; case PROP_DATADIR: g_value_set_string (value, global->datadir); break; @@ -181,6 +186,8 @@ shell_global_init (ShellGlobal *global) /* Ensure config dir exists for later use */ global->userdatadir = g_build_filename (g_get_user_data_dir (), "gnome-shell", NULL); g_mkdir_with_parents (global->userdatadir, 0700); + + global->settings = g_settings_new ("org.gnome.shell"); global->grab_notifier = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); g_signal_connect (global->grab_notifier, "grab-notify", G_CALLBACK (grab_notify), global); @@ -261,6 +268,13 @@ shell_global_class_init (ShellGlobalClass *klass) "Window management interface", SHELL_TYPE_WM, G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, + PROP_SETTINGS, + g_param_spec_object ("settings", + "Settings", + "GSettings instance for gnome-shell configuration", + G_TYPE_SETTINGS, + G_PARAM_READABLE)); g_object_class_install_property (gobject_class, PROP_DATADIR, g_param_spec_string ("datadir", @@ -1284,6 +1298,20 @@ shell_get_event_state (ClutterEvent *event) return state & CLUTTER_MODIFIER_MASK; } +/** + * shell_global_get_settings: + * @global: A #ShellGlobal + * + * Get the global GSettings instance. + * + * Return value: (transfer none) The GSettings object (transfer none). + */ +GSettings * +shell_global_get_settings (ShellGlobal *global) +{ + return global->settings; +} + static void shell_popup_menu_position_func (GtkMenu *menu, int *x, diff --git a/src/shell-global.h b/src/shell-global.h index 81df16def..a801238ff 100644 --- a/src/shell-global.h +++ b/src/shell-global.h @@ -89,6 +89,8 @@ void shell_global_get_pointer (ShellGlobal *global, int *y, ClutterModifierType *mods); +GSettings *shell_global_get_settings (ShellGlobal *global); + ClutterModifierType shell_get_event_state (ClutterEvent *event); void shell_popup_menu (GtkMenu *menu, int button, guint32 time, diff --git a/tools/build/gnome-shell.modules b/tools/build/gnome-shell.modules index 978399e85..cb487f75a 100644 --- a/tools/build/gnome-shell.modules +++ b/tools/build/gnome-shell.modules @@ -12,6 +12,9 @@ + + + @@ -83,6 +86,9 @@ + + + @@ -103,6 +109,7 @@ +