From b34dc27b7b191e56cbf640a963435d6e68982608 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 2 Oct 2012 20:05:07 +0200 Subject: migrate to gsettings --- NEWS | 2 + capplet/gsm-properties-dialog.c | 47 +++---- capplet/main.c | 2 - configure.ac | 29 +---- data/Makefile.am | 28 +---- data/mate-session.schemas.in.in | 101 --------------- data/org.mate.session.gschema.xml.in.in | 47 +++++++ mate-session/Makefile.am | 6 - mate-session/README | 2 +- mate-session/gsm-autostart-app.c | 104 ++++++++------- mate-session/gsm-inhibit-dialog.c | 2 - mate-session/gsm-manager.c | 216 ++++++++------------------------ mate-session/gsm-mateconf.c | 143 --------------------- mate-session/gsm-mateconf.h | 31 ----- mate-session/main.c | 81 +++++------- po/POTFILES.in | 1 - 16 files changed, 224 insertions(+), 618 deletions(-) delete mode 100644 data/mate-session.schemas.in.in create mode 100644 data/org.mate.session.gschema.xml.in.in delete mode 100644 mate-session/gsm-mateconf.c delete mode 100644 mate-session/gsm-mateconf.h diff --git a/NEWS b/NEWS index 8b13789..9af912d 100644 --- a/NEWS +++ b/NEWS @@ -1 +1,3 @@ +1.5.0 + * Migrate to gsettings (dropped mateconf) diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c index b3a8e74..4ac4500 100644 --- a/capplet/gsm-properties-dialog.c +++ b/capplet/gsm-properties-dialog.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include "gsm-properties-dialog.h" #include "gsm-app-dialog.h" @@ -54,8 +54,8 @@ #define STARTUP_APP_ICON "system-run" -#define SPC_MATECONF_CONFIG_PREFIX "/apps/mate-session/options" -#define SPC_MATECONF_AUTOSAVE_KEY SPC_MATECONF_CONFIG_PREFIX "/auto_save_session" +#define SPC_CONFIG_SCHEMA "org.mate.session" +#define SPC_AUTOSAVE_KEY "auto-save-session" struct GsmPropertiesDialogPrivate { @@ -71,6 +71,8 @@ struct GsmPropertiesDialogPrivate GtkWidget *remember_toggle; GspAppManager *manager; + + GSettings *settings; }; enum { @@ -458,15 +460,14 @@ on_row_activated (GtkTreeView *tree_view, } static void -on_autosave_value_notify (MateConfClient *client, - guint id, - MateConfEntry *entry, +on_autosave_value_notify (GSettings *settings, + gchar *key, GsmPropertiesDialog *dialog) { gboolean gval; gboolean bval; - gval = mateconf_value_get_bool (entry->value); + gval = g_settings_get_boolean (settings, key); bval = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->remember_toggle)); if (bval != gval) { @@ -478,18 +479,15 @@ static void on_autosave_value_toggled (GtkToggleButton *button, GsmPropertiesDialog *dialog) { - MateConfClient *client; gboolean gval; gboolean bval; - client = mateconf_client_get_default (); - gval = mateconf_client_get_bool (client, SPC_MATECONF_AUTOSAVE_KEY, NULL); + gval = g_settings_get_boolean (dialog->priv->settings, SPC_AUTOSAVE_KEY); bval = gtk_toggle_button_get_active (button); if (gval != bval) { - mateconf_client_set_bool (client, SPC_MATECONF_AUTOSAVE_KEY, bval, NULL); + g_settings_set_boolean (dialog->priv->settings, SPC_AUTOSAVE_KEY, bval); } - g_object_unref (client); } static void @@ -508,7 +506,6 @@ setup_dialog (GsmPropertiesDialog *dialog) GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkTreeSelection *selection; - MateConfClient *client; GtkTargetList *targetlist; gtk_dialog_add_buttons (GTK_DIALOG (dialog), @@ -655,19 +652,18 @@ setup_dialog (GsmPropertiesDialog *dialog) G_CALLBACK (on_edit_app_clicked), dialog); - client = mateconf_client_get_default (); + + dialog->priv->settings = g_settings_new (SPC_CONFIG_SCHEMA); + button = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml, CAPPLET_REMEMBER_WIDGET_NAME)); dialog->priv->remember_toggle = button; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), - mateconf_client_get_bool (client, SPC_MATECONF_AUTOSAVE_KEY, NULL)); - mateconf_client_notify_add (client, - SPC_MATECONF_AUTOSAVE_KEY, - (MateConfClientNotifyFunc)on_autosave_value_notify, - dialog, - NULL, - NULL); - g_object_unref (client); + g_settings_get_boolean (dialog->priv->settings, SPC_AUTOSAVE_KEY)); + g_signal_connect (dialog->priv->settings, + "changed::" SPC_AUTOSAVE_KEY, + G_CALLBACK (on_autosave_value_notify), + dialog); g_signal_connect (button, "toggled", @@ -752,17 +748,10 @@ gsm_properties_dialog_init (GsmPropertiesDialog *dialog) { GtkWidget *content_area; GtkWidget *widget; - MateConfClient *client; GError *error; dialog->priv = GSM_PROPERTIES_DIALOG_GET_PRIVATE (dialog); - client = mateconf_client_get_default (); - mateconf_client_add_dir (client, - SPC_MATECONF_CONFIG_PREFIX, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - dialog->priv->xml = gtk_builder_new (); gtk_builder_set_translation_domain (dialog->priv->xml, GETTEXT_PACKAGE); diff --git a/capplet/main.c b/capplet/main.c index 155b560..4857867 100644 --- a/capplet/main.c +++ b/capplet/main.c @@ -27,8 +27,6 @@ #include #include -#include - #include "gsm-properties-dialog.h" static gboolean show_version = FALSE; diff --git a/configure.ac b/configure.ac index 60c5741..c1d626a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mate-session], [1.4.0], [http://www.mate-desktop.org/]) +AC_INIT([mate-session], [1.5.0], [http://www.mate-desktop.org/]) AC_CONFIG_SRCDIR([mate-session]) AC_CONFIG_HEADERS([config.h]) @@ -47,6 +47,7 @@ AC_ARG_WITH([gtk], AC_MSG_RESULT([$with_gtk]) GLIB_REQUIRED=2.16.0 +GIO_REQUIRED=2.25.0 DBUS_GLIB_REQUIRED=0.76 UPOWER_REQUIRED=0.9.0 @@ -66,7 +67,7 @@ PKG_PROG_PKG_CONFIG() PKG_CHECK_MODULES(MATE_SESSION, glib-2.0 >= $GLIB_REQUIRED - gio-2.0 >= $GLIB_REQUIRED + gio-2.0 >= $GIO_REQUIRED gtk+-$GTK_API_VERSION >= $GTK_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED upower-glib >= $UPOWER_REQUIRED @@ -82,7 +83,6 @@ PKG_CHECK_MODULES(ICE, ice) PKG_CHECK_MODULES(XEXT, xext xau) PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= $DBUS_GLIB_REQUIRED) -PKG_CHECK_MODULES(MATECONF, mateconf-2.0) PKG_CHECK_MODULES(EGG_SMCLIENT, gtk+-$GTK_API_VERSION) @@ -100,28 +100,9 @@ AC_SUBST(DEFAULT_WM) AM_CONDITIONAL(USE_MATE_WM, test x$with_default_wm = xmate-wm) dnl ==================================================================== -dnl MateConf Checks +dnl GSettings dnl ==================================================================== -AC_PATH_PROG(MATECONFTOOL, mateconftool-2, no) -if test x"$MATECONFTOOL" = xno; then - AC_MSG_ERROR([mateconftool-2 executable not found in your path - should be installed with MateConf]) -fi - -AM_MATECONF_SOURCE_2 - -MATECONF_SERVERDIR=`$PKG_CONFIG --variable=mateconf_serverdir mateconf-2.0` -old_path=$PATH -if test x"$MATECONF_SERVERDIR" != x; then - PATH=$MATECONF_SERVERDIR:$PATH -fi - -AC_PATH_PROG(MATECONF_SANITY_CHECK, mateconf-sanity-check-2, no) -if test x"$MATECONF_SANITY_CHECK" = xno; then - AC_MSG_ERROR([mateconf-sanity-check-2 executable not found in your path - should be installed with MateConf]) -fi - -AC_SUBST(MATECONF_SANITY_CHECK) -PATH=$old_path +GLIB_GSETTINGS dnl ==================================================================== dnl X development libraries check diff --git a/data/Makefile.am b/data/Makefile.am index c68a309..2cd9a8a 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,41 +21,23 @@ endif @INTLTOOL_DESKTOP_RULE@ -schemas_in_in_files = mate-session.schemas.in.in -schemas_in_files = $(schemas_in_in_files:.schemas.in.in=.schemas.in) -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) - -$(schemas_in_files): $(schemas_in_files).in Makefile +org.mate.session.gschema.xml.in: org.mate.session.gschema.xml.in.in Makefile $(AM_V_GEN)sed \ -e "s|\@DEFAULT_WM\@|$(DEFAULT_WM)|" \ $< > $@ -@INTLTOOL_SCHEMAS_RULE@ - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schemas_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/data/$$p ; \ - done \ - fi -uninstall-local: - for p in $(schema_DATA) ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-uninstall-rule $(top_builddir)/data/$$p ; \ - done -endif +gsettings_SCHEMAS = org.mate.session.gschema.xml +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ EXTRA_DIST = \ mate-wm \ $(xsession_in_files) \ - $(schemas_in_in_files) \ + $(gsettings_SCHEMAS) \ $(ui_DATA) \ $(pixmap_DATA_dist) CLEANFILES = \ - $(schemas_in_files) \ - $(schemas_DATA) \ $(xsession_DATA) \ $(desktop_DATA) \ mate-wm.desktop diff --git a/data/mate-session.schemas.in.in b/data/mate-session.schemas.in.in deleted file mode 100644 index c049cf0..0000000 --- a/data/mate-session.schemas.in.in +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - /schemas/apps/mate-session/options/auto_save_session - /apps/mate-session/options/auto_save_session - mate - bool - false - - Save sessions - If enabled, mate-session will save the session automatically. - - - - /schemas/apps/mate-session/options/logout_prompt - /apps/mate-session/options/logout_prompt - mate - bool - true - - Logout prompt - If enabled, mate-session will prompt the user before ending a session. - - - - /schemas/desktop/mate/session/idle_delay - /desktop/mate/session/idle_delay - mate - int - 5 - - Time before session is considered idle - - The number of minutes of inactivity before the session is - considered idle. - - - - - /schemas/desktop/mate/session/default_session - /desktop/mate/session/default_session - mate - list - string - [mate-settings-daemon] - - - Default session - List of applications that are part of the default session. - - - - /schemas/desktop/mate/session/required_components_list - /desktop/mate/session/required_components_list - mate - list - string - [windowmanager,panel,filemanager] - - Required session components - List of components that are required as part of the session. (Each element names a key under "/desktop/mate/session/required_components"). The Startup Applications preferences tool will not normally allow users to remove a required component from the session, and the session manager will automatically add the required components back to the session at login time if they do get removed. - - - - /schemas/desktop/mate/session/required_components/windowmanager - /desktop/mate/session/required_components/windowmanager - mate - string - @DEFAULT_WM@ - - Window Manager - The window manager is the program that draws the title bar and borders around windows, and allows you to move and resize windows. - - - - /schemas/desktop/mate/session/required_components/panel - /desktop/mate/session/required_components/panel - mate - string - mate-panel - - Panel - The panel provides the bar at the top or bottom of the screen containing menus, the window list, status icons, the clock, etc. - - - - /schemas/desktop/mate/session/required_components/filemanager - /desktop/mate/session/required_components/filemanager - mate - string - caja - - File Manager - The file manager provides the desktop icons and allows you to interact with your saved files. - - - - - diff --git a/data/org.mate.session.gschema.xml.in.in b/data/org.mate.session.gschema.xml.in.in new file mode 100644 index 0000000..2b0f5f1 --- /dev/null +++ b/data/org.mate.session.gschema.xml.in.in @@ -0,0 +1,47 @@ + + + + false + <_summary>Save sessions + <_description>If enabled, mate-session will save the session automatically. + + + true + <_summary>Logout prompt + <_description>If enabled, mate-session will prompt the user before ending a session. + + + 5 + <_summary>Time before session is considered idle + <_description>The number of minutes of inactivity before the session is considered idle. + + + [ 'mate-settings-daemon' ] + <_summary>Default session + <_description>List of applications that are part of the default session. + + + [ 'windowmanager', 'panel', 'filemanager' ] + <_summary>Required session components + <_description>List of components that are required as part of the session. (Each element names a key under "/desktop/mate/session/required_components"). The Startup Applications preferences tool will not normally allow users to remove a required component from the session, and the session manager will automatically add the required components back to the session at login time if they do get removed. + + + + + + '@DEFAULT_WM@' + <_summary>Window Manager + <_description>The window manager is the program that draws the title bar and borders around windows, and allows you to move and resize windows. + + + 'mate-panel' + <_summary>Panel + <_description>The panel provides the bar at the top or bottom of the screen containing menus, the window list, status icons, the clock, etc. + + + 'caja' + <_summary>File Manager + <_description>The file manager provides the desktop icons and allows you to interact with your saved files. + + + diff --git a/mate-session/Makefile.am b/mate-session/Makefile.am index ee98a30..b2ddcbd 100644 --- a/mate-session/Makefile.am +++ b/mate-session/Makefile.am @@ -33,8 +33,6 @@ mate_session_SOURCES = \ gs-idle-monitor.c \ gsm-presence.h \ gsm-presence.c \ - gsm-mateconf.c \ - gsm-mateconf.h \ mdm.h \ mdm.c \ mdm-signal-handler.h \ @@ -58,14 +56,11 @@ mate_session_CPPFLAGS = \ $(SM_CFLAGS) \ $(ICE_CFLAGS) \ $(XEXT_CFLAGS) \ - $(MATECONF_CFLAGS) \ -I$(top_srcdir)/egg \ -DLOCALE_DIR=\""$(datadir)/locale"\" \ -DDATA_DIR=\""$(datadir)/mate-session"\" \ -DLIBEXECDIR=\"$(libexecdir)\" \ -DGTKBUILDER_DIR=\""$(pkgdatadir)"\" \ - -DMATECONF_SANITY_CHECK=\""$(MATECONF_SANITY_CHECK)"\" \ - -DMATECONFTOOL_CMD=\"$(MATECONFTOOL)\" \ -DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE mate_session_LDADD = \ @@ -77,7 +72,6 @@ mate_session_LDADD = \ $(XTEST_LIBS) \ $(XEXT_LIBS) \ $(MATE_SESSION_LIBS) \ - $(MATECONF_LIBS) \ $(EXECINFO_LIBS) libgsmutil_la_SOURCES = \ diff --git a/mate-session/README b/mate-session/README index 05bfe9d..5b4e67b 100644 --- a/mate-session/README +++ b/mate-session/README @@ -12,7 +12,7 @@ represents an app resumed from the previous saved session.) Startup is divided into 6 phases (GsmSessionPhase): * GSM_SESSION_PHASE_STARTUP covers mate-session's internal - startup, which also includes starting mateconfd and dbus-daemon (if + startup, which also includes starting dbus-daemon (if it's not already running). Mate-session starts up those explicitly because it needs them for its own purposes. diff --git a/mate-session/gsm-autostart-app.c b/mate-session/gsm-autostart-app.c index a696a96..b6272ee 100644 --- a/mate-session/gsm-autostart-app.c +++ b/mate-session/gsm-autostart-app.c @@ -29,8 +29,6 @@ #include #include -#include - #include "gsm-autostart-app.h" #include "gsm-util.h" @@ -62,7 +60,7 @@ struct _GsmAutostartAppPrivate { gboolean autorestart; GFileMonitor *condition_monitor; - guint condition_notify_id; + GSettings *condition_settings; int launch_type; GPid pid; @@ -238,10 +236,9 @@ unless_exists_condition_cb (GFileMonitor *monitor, } static void -mateconf_condition_cb (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +gsettings_condition_cb (GSettings *settings, + const char *key, + gpointer user_data) { GsmApp *app; GsmAutostartAppPrivate *priv; @@ -253,10 +250,7 @@ mateconf_condition_cb (MateConfClient *client, priv = GSM_AUTOSTART_APP (app)->priv; - condition = FALSE; - if (entry->value != NULL && entry->value->type == MATECONF_VALUE_BOOL) { - condition = mateconf_value_get_bool (entry->value); - } + condition = g_settings_get_boolean (settings, key); g_debug ("GsmAutostartApp: app:%s condition changed condition:%d", gsm_app_peek_id (app), @@ -269,6 +263,53 @@ mateconf_condition_cb (MateConfClient *client, } } +static gboolean +setup_gsettings_condition_monitor (GsmAutostartApp *app, + const char *key) +{ + GSettings *settings; + const char * const *schemas; + char **elems; + gboolean schema_exists; + guint i; + gboolean retval; + char *signal; + + elems = g_strsplit (key, " ", 2); + if (elems == NULL) + return FALSE; + if (elems[0] == NULL || elems[1] == NULL) { + g_strfreev (elems); + return FALSE; + } + + schemas = g_settings_list_schemas (); + schema_exists = FALSE; + for (i = 0; schemas[i] != NULL; i++) { + if (g_str_equal (schemas[i], elems[0])) { + schema_exists = TRUE; + break; + } + } + + if (schema_exists == FALSE) + return FALSE; + + settings = g_settings_new (elems[0]); + retval = g_settings_get_boolean (settings, elems[1]); + + signal = g_strdup_printf ("changed::%s", elems[1]); + g_signal_connect (G_OBJECT (settings), signal, + G_CALLBACK (gsettings_condition_cb), app); + g_free (signal); + + app->priv->condition_settings = settings; + + g_strfreev (elems); + + return retval; +} + static void setup_condition_monitor (GsmAutostartApp *app) { @@ -281,12 +322,9 @@ setup_condition_monitor (GsmAutostartApp *app) g_file_monitor_cancel (app->priv->condition_monitor); } - if (app->priv->condition_notify_id > 0) { - MateConfClient *client; - client = mateconf_client_get_default (); - mateconf_client_notify_remove (client, - app->priv->condition_notify_id); - app->priv->condition_notify_id = 0; + if (app->priv->condition_settings != NULL) { + g_object_unref (app->priv->condition_settings); + app->priv->condition_settings = NULL; } if (app->priv->condition_string == NULL) { @@ -344,26 +382,7 @@ setup_condition_monitor (GsmAutostartApp *app) g_object_unref (file); g_free (file_path); } else if (kind == GSM_CONDITION_MATE) { - MateConfClient *client; - char *dir; - - client = mateconf_client_get_default (); - g_assert (MATECONF_IS_CLIENT (client)); - - disabled = !mateconf_client_get_bool (client, key, NULL); - - dir = g_path_get_dirname (key); - - mateconf_client_add_dir (client, - dir, - MATECONF_CLIENT_PRELOAD_NONE, NULL); - g_free (dir); - - app->priv->condition_notify_id = mateconf_client_notify_add (client, - key, - mateconf_condition_cb, - app, NULL, NULL); - g_object_unref (client); + disabled = !setup_gsettings_condition_monitor (app, key); } else { disabled = TRUE; } @@ -641,12 +660,11 @@ is_conditionally_disabled (GsmApp *app) file_path = g_build_filename (g_get_user_config_dir (), key, NULL); disabled = g_file_test (file_path, G_FILE_TEST_EXISTS); g_free (file_path); - } else if (kind == GSM_CONDITION_MATE) { - MateConfClient *client; - client = mateconf_client_get_default (); - g_assert (MATECONF_IS_CLIENT (client)); - disabled = !mateconf_client_get_bool (client, key, NULL); - g_object_unref (client); + } else if (kind == GSM_CONDITION_MATE && priv->condition_settings != NULL) { + char **elems; + elems = g_strsplit (key, " ", 2); + disabled = !g_settings_get_boolean (priv->condition_settings, elems[1]); + g_strfreev (elems); } else { disabled = TRUE; } diff --git a/mate-session/gsm-inhibit-dialog.c b/mate-session/gsm-inhibit-dialog.c index 53b0d08..3587d33 100644 --- a/mate-session/gsm-inhibit-dialog.c +++ b/mate-session/gsm-inhibit-dialog.c @@ -31,8 +31,6 @@ #include #include -#include - #include "gsm-inhibit-dialog.h" #include "gsm-store.h" #include "gsm-client.h" diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 8bdc49e..b0ce46b 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -41,7 +41,7 @@ #include #include /* for logout dialog */ -#include +#include /* for gsettings */ #include "gsm-manager.h" #include "gsm-manager-glue.h" @@ -76,17 +76,16 @@ #define GDM_FLEXISERVER_ARGS "--startnew Standard" -#define KEY_LOCKDOWN_DIR "/desktop/mate/lockdown" -#define KEY_LOCK_DISABLE KEY_LOCKDOWN_DIR "/disable_lock_screen" -#define KEY_USER_SWITCH_DISABLE KEY_LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_SCHEMA "org.mate.lockdown" +#define KEY_LOCK_DISABLE "disable-lock-screen" +#define KEY_USER_SWITCH_DISABLE "disable-user-switching" -#define KEY_DESKTOP_DIR "/desktop/mate/session" -#define KEY_IDLE_DELAY KEY_DESKTOP_DIR "/idle_delay" +#define SESSION_SCHEMA "org.mate.session" +#define KEY_IDLE_DELAY "idle-delay" +#define KEY_AUTOSAVE "auto-save-session" -#define KEY_MATE_SESSION_DIR "/apps/mate-session/options" -#define KEY_AUTOSAVE KEY_MATE_SESSION_DIR "/auto_save_session" - -#define KEY_SLEEP_LOCK "/apps/mate-screensaver/lock_enabled" +#define SCREENSAVER_SCHEMA "org.mate.screensaver" +#define KEY_SLEEP_LOCK "lock-enabled" #define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0') @@ -130,9 +129,8 @@ struct GsmManagerPrivate * and shouldn't be automatically restarted */ GSList *condition_clients; - MateConfClient *mateconf_client; - guint desktop_notify_id; - guint lockdown_notify_id; + GSettings *settings_session; + GSettings *settings_lockdown; DBusGProxy *bus_proxy; DBusGConnection *connection; @@ -964,23 +962,8 @@ manager_switch_user (GsmManager *manager) static gboolean sleep_lock_is_enabled (GsmManager *manager) { - GError *error; - gboolean enable_lock; - - error = NULL; - enable_lock = mateconf_client_get_bool (manager->priv->mateconf_client, - KEY_SLEEP_LOCK, &error); - - if (error) { - g_warning ("Error retrieving configuration key '%s': %s", - KEY_SLEEP_LOCK, error->message); - g_error_free (error); - - /* If we fail to query mateconf key, just enable locking */ - enable_lock = TRUE; - } - - return enable_lock; + return g_settings_get_boolean (manager->priv->settings_lockdown, + KEY_SLEEP_LOCK); } static void @@ -1823,25 +1806,8 @@ on_xsmp_client_register_request (GsmXSMPClient *client, static gboolean auto_save_is_enabled (GsmManager *manager) { - GError *error; - gboolean auto_save; - - error = NULL; - auto_save = mateconf_client_get_bool (manager->priv->mateconf_client, - KEY_AUTOSAVE, - &error); - - if (error) { - g_warning ("Error retrieving configuration key '%s': %s", - KEY_AUTOSAVE, - error->message); - g_error_free (error); - - /* If we fail to query mateconf key, disable auto save */ - auto_save = FALSE; - } - - return auto_save; + return g_settings_get_boolean (manager->priv->settings_session, + KEY_AUTOSAVE); } static void @@ -2197,26 +2163,14 @@ gsm_manager_dispose (GObject *object) manager->priv->presence = NULL; } - if (manager->priv->mateconf_client) { - if (manager->priv->desktop_notify_id != 0) { - mateconf_client_remove_dir (manager->priv->mateconf_client, - KEY_DESKTOP_DIR, - NULL); - mateconf_client_notify_remove (manager->priv->mateconf_client, - manager->priv->desktop_notify_id); - manager->priv->desktop_notify_id = 0; - } - if (manager->priv->lockdown_notify_id != 0) { - mateconf_client_remove_dir (manager->priv->mateconf_client, - KEY_LOCKDOWN_DIR, - NULL); - mateconf_client_notify_remove (manager->priv->mateconf_client, - manager->priv->lockdown_notify_id); - manager->priv->lockdown_notify_id = 0; - } + if (manager->priv->settings_session) { + g_object_unref (manager->priv->settings_session); + manager->priv->settings_session = NULL; + } - g_object_unref (manager->priv->mateconf_client); - manager->priv->mateconf_client = NULL; + if (manager->priv->settings_lockdown) { + g_object_unref (manager->priv->settings_lockdown); + manager->priv->settings_lockdown = NULL; } if (manager->priv->up_client != NULL) { @@ -2332,83 +2286,29 @@ gsm_manager_class_init (GsmManagerClass *klass) } static void -invalid_type_warning (const char *type) +load_idle_delay_from_gsettings (GsmManager *manager) { - g_warning ("Error retrieving configuration key '%s': Invalid type", - type); -} - -static void -load_idle_delay_from_mateconf (GsmManager *manager) -{ - GError *error; glong value; - - error = NULL; - value = mateconf_client_get_int (manager->priv->mateconf_client, - KEY_IDLE_DELAY, - &error); - if (error == NULL) { - gsm_presence_set_idle_timeout (manager->priv->presence, value * 60000); - } else { - g_warning ("Error retrieving configuration key '%s': %s", - KEY_IDLE_DELAY, - error->message); - g_error_free (error); - } - + value = g_settings_get_int (manager->priv->settings_session, + KEY_IDLE_DELAY); + gsm_presence_set_idle_timeout (manager->priv->presence, value * 60000); } static void -on_mateconf_key_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - GsmManager *manager) -{ - const char *key; - MateConfValue *value; - - key = mateconf_entry_get_key (entry); - - if (! g_str_has_prefix (key, KEY_DESKTOP_DIR) - && ! g_str_has_prefix (key, KEY_LOCKDOWN_DIR)) { - return; - } - - value = mateconf_entry_get_value (entry); - - if (strcmp (key, KEY_IDLE_DELAY) == 0) { - if (value->type == MATECONF_VALUE_INT) { - int delay; - - delay = mateconf_value_get_int (value); - - gsm_presence_set_idle_timeout (manager->priv->presence, delay * 60000); - } else { - invalid_type_warning (key); - } - } else if (strcmp (key, KEY_LOCK_DISABLE) == 0) { - if (value->type == MATECONF_VALUE_BOOL) { - gboolean disabled; - - disabled = mateconf_value_get_bool (value); - - /* FIXME: handle this */ - } else { - invalid_type_warning (key); - } - } else if (strcmp (key, KEY_USER_SWITCH_DISABLE) == 0) { - - if (value->type == MATECONF_VALUE_BOOL) { - gboolean disabled; - - disabled = mateconf_value_get_bool (value); - - /* FIXME: handle this */ - } else { - invalid_type_warning (key); - } - +on_gsettings_key_changed (GSettings *settings, + gchar *key, + GsmManager *manager) +{ + if (g_strcmp0 (key, KEY_IDLE_DELAY) == 0) { + int delay; + delay = g_settings_get_int (settings, key); + gsm_presence_set_idle_timeout (manager->priv->presence, delay * 60000); + } else if (g_strcmp0 (key, KEY_LOCK_DISABLE) == 0) { + gboolean disabled; + disabled = g_settings_get_boolean (settings, key); + } else if (g_strcmp0 (key, KEY_USER_SWITCH_DISABLE) == 0) { + gboolean disabled; + disabled = g_settings_get_boolean (settings, key); } else { g_debug ("Config key not handled: %s", key); } @@ -2432,7 +2332,8 @@ gsm_manager_init (GsmManager *manager) manager->priv = GSM_MANAGER_GET_PRIVATE (manager); - manager->priv->mateconf_client = mateconf_client_get_default (); + manager->priv->settings_session = g_settings_new (SESSION_SCHEMA); + manager->priv->settings_lockdown = g_settings_new (LOCKDOWN_SCHEMA); manager->priv->inhibitors = gsm_store_new (); g_signal_connect (manager->priv->inhibitors, @@ -2454,26 +2355,16 @@ gsm_manager_init (GsmManager *manager) manager->priv->up_client = up_client_new (); - /* MateConf setup */ - mateconf_client_add_dir (manager->priv->mateconf_client, - KEY_DESKTOP_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); - mateconf_client_add_dir (manager->priv->mateconf_client, - KEY_LOCKDOWN_DIR, - MATECONF_CLIENT_PRELOAD_NONE, NULL); - - manager->priv->desktop_notify_id = mateconf_client_notify_add (manager->priv->mateconf_client, - KEY_DESKTOP_DIR, - (MateConfClientNotifyFunc)on_mateconf_key_changed, - manager, - NULL, NULL); - manager->priv->lockdown_notify_id = mateconf_client_notify_add (manager->priv->mateconf_client, - KEY_LOCKDOWN_DIR, - (MateConfClientNotifyFunc)on_mateconf_key_changed, - manager, - NULL, NULL); + g_signal_connect (manager->priv->settings_session, + "changed", + G_CALLBACK (on_gsettings_key_changed), + manager); + g_signal_connect (manager->priv->settings_lockdown, + "changed", + G_CALLBACK (on_gsettings_key_changed), + manager); - load_idle_delay_from_mateconf (manager); + load_idle_delay_from_gsettings (manager); } static void @@ -2914,9 +2805,8 @@ user_logout (GsmManager *manager, } logout_prompt = - mateconf_client_get_bool (manager->priv->mateconf_client, - "/apps/mate-session/options/logout_prompt", - NULL); + g_settings_get_boolean (manager->priv->settings_session, + "logout-prompt"); /* Global settings overides input parameter in order to disable confirmation * dialog accordingly. If we're shutting down, we always show the confirmation diff --git a/mate-session/gsm-mateconf.c b/mate-session/gsm-mateconf.c deleted file mode 100644 index cd5adc4..0000000 --- a/mate-session/gsm-mateconf.c +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * gsm-mateconf.c - * Copyright (C) 2007 Novell, Inc. - * - * FIXME: (C) on mateconf-sanity-check call, gsm_get_conf_client, - * gsm_shutdown_mateconfd - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include -#include - -#include "gsm-mateconf.h" -#include "gsm-util.h" - -static pid_t gsc_pid; - -static void unset_display_setup (gpointer user_data); - -/** - * gsm_mateconf_init: - * - * Starts mateconfd asynchronously if it is not already running. This - * must be called very soon after startup. It requires no - * initialization beyond g_type_init(). - **/ -void -gsm_mateconf_init (void) -{ - GError *error = NULL; - char *argv[2]; - - /* Run mateconf-sanity-check. As a side effect, this will cause mateconfd - * to be started. (We do this asynchronously so that other GSM - * initialization can happen in parallel.) - */ - - argv[0] = MATECONF_SANITY_CHECK; - argv[1] = NULL; - - g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, - unset_display_setup, NULL, &gsc_pid, &error); - if (error != NULL) { - g_warning ("Failed to run mateconf-sanity-check-2: %s\n", - error->message); - g_error_free (error); - - /* This probably means mateconf-sanity-check wasn't found, which - * really shouldn't happen, but we'll just ignore it for now as - * long as mateconf seems to be working later on... - */ - - gsc_pid = 0; - } -} - -static void -unset_display_setup (gpointer user_data) -{ - /* Unset DISPLAY to make sure mateconf-sanity-check spews errors to - * stderr instead of trying to show a dialog (since it doesn't - * compensate for the fact that a window manager isn't running yet.) - */ - g_unsetenv ("DISPLAY"); -} - -/** - * gsm_mateconf_check: - * - * Verifies that gsm_mateconf_init() succeeded. (Exits with an error - * dialog on failure.) - **/ -void -gsm_mateconf_check (void) -{ - if (gsc_pid) { - int status; - - /* Wait for mateconf-sanity-check to finish */ - while (waitpid (gsc_pid, &status, 0) != gsc_pid) { - ; - } - gsc_pid = 0; - - if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) { - /* FIXME: capture mateconf-sanity-check's stderr */ - gsm_util_init_error (TRUE, - _("There is a problem with the configuration server.\n" - "(%s exited with status %d)"), - MATECONF_SANITY_CHECK, status); - } - } -} - -/** - * gsm_mateconf_shutdown: - * - * Shuts down mateconfd before exiting. - * - * FIXME: does this need to be called even if mateconf-sanity-check fails? - **/ -void -gsm_mateconf_shutdown (void) -{ - GError *error; - char *command; - int status; - - command = g_strjoin (" ", MATECONFTOOL_CMD, "--shutdown", NULL); - - status = 0; - error = NULL; - if (!g_spawn_command_line_sync (command, NULL, NULL, &status, &error)) { - g_warning ("Failed to execute '%s' on logout: %s\n", - command, error->message); - g_error_free (error); - } - - if (status) { - g_warning ("Running '%s' at logout returned an exit status of '%d'", - command, status); - } - - g_free (command); -} diff --git a/mate-session/gsm-mateconf.h b/mate-session/gsm-mateconf.h deleted file mode 100644 index d30d548..0000000 --- a/mate-session/gsm-mateconf.h +++ /dev/null @@ -1,31 +0,0 @@ -/* gsm-mateconf.h - * Copyright (C) 2007 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __GSM_MATECONF_H__ -#define __GSM_MATECONF_H__ - -#include - -void gsm_mateconf_init (void); -void gsm_mateconf_check (void); -void gsm_mateconf_shutdown (void); - -MateConfClient *gsm_mateconf_get_client (void); - -#endif /* __GSM_MATECONF_H__ */ diff --git a/mate-session/main.c b/mate-session/main.c index 2d7dd64..5b1171a 100644 --- a/mate-session/main.c +++ b/mate-session/main.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -41,15 +42,15 @@ #include "mdm-log.h" #include "gsm-consolekit.h" -#include "gsm-mateconf.h" #include "gsm-util.h" #include "gsm-manager.h" #include "gsm-xsmp-server.h" #include "gsm-store.h" -#define GSM_MATECONF_DEFAULT_SESSION_KEY "/desktop/mate/session/default_session" -#define GSM_MATECONF_REQUIRED_COMPONENTS_DIRECTORY "/desktop/mate/session/required_components" -#define GSM_MATECONF_REQUIRED_COMPONENTS_LIST_KEY "/desktop/mate/session/required_components_list" +#define GSM_SCHEMA "org.mate.session" +#define GSM_DEFAULT_SESSION_KEY "default-session" +#define GSM_REQUIRED_COMPONENTS_SCHEMA GSM_SCHEMA ".required-components" +#define GSM_REQUIRED_COMPONENTS_LIST_KEY "required-components-list" #define GSM_DBUS_NAME "org.mate.SessionManager" @@ -156,29 +157,29 @@ static gboolean acquire_name(void) * call append_required_apps() after a call to append_default_apps(). */ static void append_default_apps(GsmManager* manager, const char* default_session_key, char** autostart_dirs) { - GSList* default_apps; - GSList* a; - MateConfClient* client; + gint i; + gchar** default_apps; + GSettings* settings; g_debug("main: *** Adding default apps"); g_assert(default_session_key != NULL); g_assert(autostart_dirs != NULL); - client = mateconf_client_get_default(); - default_apps = mateconf_client_get_list(client, default_session_key, MATECONF_VALUE_STRING, NULL); - g_object_unref(client); + settings = g_settings_new (GSM_SCHEMA); + default_apps = g_settings_get_strv (settings, default_session_key); + g_object_unref(settings); - for (a = default_apps; a; a = a->next) + for (i = 0; default_apps[i]; i++) { char* app_path; - if (IS_STRING_EMPTY((char*) a->data)) + if (IS_STRING_EMPTY((char*) default_apps[i])) { continue; } - app_path = gsm_util_find_desktop_file_for_app_name(a->data, autostart_dirs); + app_path = gsm_util_find_desktop_file_for_app_name(default_apps[i], autostart_dirs); if (app_path != NULL) { @@ -187,44 +188,43 @@ static void append_default_apps(GsmManager* manager, const char* default_session } } - g_slist_foreach(default_apps, (GFunc) g_free, NULL); - g_slist_free(default_apps); + g_strfreev (default_apps); } static void append_required_apps(GsmManager* manager) { - GSList* required_components; - GSList* r; - MateConfClient* client; + gchar** required_components; + gint i; + GSettings* settings; + GSettings* settings_required_components; g_debug("main: *** Adding required apps"); - client = mateconf_client_get_default(); - required_components = mateconf_client_get_list(client, GSM_MATECONF_REQUIRED_COMPONENTS_LIST_KEY, MATECONF_VALUE_STRING, NULL); + settings = g_settings_new (GSM_SCHEMA); + settings_required_components = g_settings_new (GSM_REQUIRED_COMPONENTS_SCHEMA); + + required_components = g_settings_get_strv(settings, GSM_REQUIRED_COMPONENTS_LIST_KEY); if (required_components == NULL) { g_warning("No required applications specified"); } - for (r = required_components; r != NULL; r = r->next) + for (i = 0; required_components[i]; i++) { - char* path; char* default_provider; const char* component; - if (IS_STRING_EMPTY((char*) r->data)) + if (IS_STRING_EMPTY((char*) required_components[i])) { continue; } - component = r->data; - - path = g_strdup_printf("%s/%s", GSM_MATECONF_REQUIRED_COMPONENTS_DIRECTORY, component); + component = required_components[i]; - default_provider = mateconf_client_get_string(client, path, NULL); + default_provider = g_settings_get_string (settings_required_components, component); - g_debug ("main: %s looking for component: '%s'", path, default_provider); + g_debug ("main: %s looking for component: '%s'", component, default_provider); if (default_provider != NULL) { @@ -245,15 +245,14 @@ static void append_required_apps(GsmManager* manager) } g_free(default_provider); - g_free(path); } g_debug("main: *** Done adding required apps"); - g_slist_foreach(required_components, (GFunc) g_free, NULL); - g_slist_free(required_components); + g_strfreev(required_components); - g_object_unref(client); + g_object_unref(settings); + g_object_unref(settings_required_components); } static void maybe_load_saved_session_apps(GsmManager* manager) @@ -417,11 +416,9 @@ int main(int argc, char** argv) GsmXsmpServer* xsmp_server; MdmSignalHandler* signal_handler; static char** override_autostart_dirs = NULL; - static char* default_session_key = NULL; static GOptionEntry entries[] = { {"autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override standard autostart directories"), NULL}, - {"default-session-key", 0, 0, G_OPTION_ARG_STRING, &default_session_key, N_("MateConf key used to look up default session"), NULL}, {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL}, {"failsafe", 'f', 0, G_OPTION_ARG_NONE, &failsafe, N_("Do not load user-specified applications"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL}, @@ -475,16 +472,11 @@ int main(int argc, char** argv) client_store = gsm_store_new(); - - /* Start up mateconfd if not already running. */ - gsm_mateconf_init(); - xsmp_server = gsm_xsmp_server_new(client_store); /* Now make sure they succeeded. (They'll call * gsm_util_init_error() if they failed.) */ - gsm_mateconf_check(); acquire_name(); manager = gsm_manager_new(client_store, failsafe); @@ -504,14 +496,7 @@ int main(int argc, char** argv) } else { - if (!IS_STRING_EMPTY(default_session_key)) - { - load_standard_apps(manager, default_session_key); - } - else - { - load_standard_apps(manager, GSM_MATECONF_DEFAULT_SESSION_KEY); - } + load_standard_apps(manager, GSM_DEFAULT_SESSION_KEY); } gsm_xsmp_server_start(xsmp_server); @@ -535,8 +520,6 @@ int main(int argc, char** argv) g_object_unref(client_store); } - gsm_mateconf_shutdown(); - mdm_log_shutdown(); return 0; diff --git a/po/POTFILES.in b/po/POTFILES.in index 59d24dc..4e43b47 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,7 +12,6 @@ data/mate-session-properties.desktop.in.in [type: gettext/glade]data/session-properties.ui egg/eggdesktopfile.c egg/eggsmclient.c -mate-session/gsm-mateconf.c mate-session/gsm-inhibit-dialog.c mate-session/gsm-logout-dialog.c mate-session/gsm-manager.c -- cgit v1.2.1