[gnome-session] gsettings: stop using g_settings_list_schemas()



commit 880379a8dd7181351ba49c579a5278d19eadc6b3
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Dec 11 01:29:23 2013 -0500

    gsettings: stop using g_settings_list_schemas()
    
    Stop using the old deprecated trick of listing and iterating over all
    the schemas.  Use g_settings_schema_source_lookup() instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720232

 gnome-session/gsm-autostart-app.c |   38 +++++++++++++++++-------------------
 1 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/gnome-session/gsm-autostart-app.c b/gnome-session/gsm-autostart-app.c
index a1109f7..683f334 100644
--- a/gnome-session/gsm-autostart-app.c
+++ b/gnome-session/gsm-autostart-app.c
@@ -341,36 +341,33 @@ static gboolean
 setup_gsettings_condition_monitor (GsmAutostartApp *app,
                                    const char      *key)
 {
+        GSettingsSchemaSource *source;
+        GSettingsSchema *schema;
         GSettings *settings;
-        const char * const *schemas;
         char **elems;
-        gboolean schema_exists;
-        guint i;
-        gboolean retval;
+        gboolean retval = FALSE;
         char *signal;
 
+        retval = FALSE;
+
         elems = g_strsplit (key, " ", 2);
+
         if (elems == NULL)
-                return FALSE;
-        if (elems[0] == NULL || elems[1] == NULL) {
-                g_strfreev (elems);
-                return FALSE;
-        }
+                goto out;
 
-        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 (elems[0] == NULL || elems[1] == NULL)
+                goto out;
 
-        if (schema_exists == FALSE)
-                return FALSE;
+        source = g_settings_schema_source_get_default ();
+
+        schema = g_settings_schema_source_lookup (source, elems[0], TRUE);
+
+        if (schema == NULL)
+                goto out;
 
-        settings = g_settings_new (elems[0]);
+        settings = g_settings_new_full (schema, NULL, NULL);
         retval = g_settings_get_boolean (settings, elems[1]);
+        g_settings_schema_unref (schema);
 
         signal = g_strdup_printf ("changed::%s", elems[1]);
         g_signal_connect (G_OBJECT (settings), signal,
@@ -379,6 +376,7 @@ setup_gsettings_condition_monitor (GsmAutostartApp *app,
 
         app->priv->condition_settings = settings;
 
+out:
         g_strfreev (elems);
 
         return retval;


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