~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to libpanel-applet/panel-applet.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-06-22 22:26:26 UTC
  • mfrom: (1.3.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 147.
  • Revision ID: james.westby@ubuntu.com-20090622222626-lfdc32sakbz19yuu
ImportĀ upstreamĀ versionĀ 2.26.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
 
126
126
        list = gconf_client_all_entries (client, schema_dir, error);
127
127
 
128
 
        g_return_if_fail (*error == NULL);
 
128
        if (*error != NULL)
 
129
                return;
129
130
 
130
131
        for (l = list; l; l = l->next) {
131
 
                GConfEntry *entry = l->data;
132
 
                gchar      *key;
133
 
                gchar      *tmp;
 
132
                GConfEntry  *entry = l->data;
 
133
                const gchar *schema_key;
 
134
                GConfEntry  *applet_entry;
 
135
                const gchar *applet_schema_key;
 
136
                gchar       *key;
 
137
                gchar       *tmp;
134
138
 
135
 
                tmp = g_path_get_basename (gconf_entry_get_key (entry));
 
139
                schema_key = gconf_entry_get_key (entry);
 
140
                tmp = g_path_get_basename (schema_key);
136
141
 
137
142
                if (strchr (tmp, '-'))
138
143
                        g_warning ("Applet key '%s' contains a hyphen. Please "
139
144
                                   "use underscores in gconf keys\n", tmp);
140
145
 
141
146
                key = g_strdup_printf ("%s/%s", prefs_key, tmp);
142
 
 
143
147
                g_free (tmp);
144
148
 
145
 
                gconf_engine_associate_schema (
146
 
                        client->engine, key, gconf_entry_get_key (entry), error);
 
149
                /* Associating a schema is potentially expensive, so let's try
 
150
                 * to avoid this by doing it only when needed. So we check if
 
151
                 * the key is already correctly associated. */
 
152
 
 
153
                applet_entry = gconf_client_get_entry (client, key,
 
154
                                                       NULL, TRUE, NULL);
 
155
                if (applet_entry)
 
156
                        applet_schema_key = gconf_entry_get_schema_name (applet_entry);
 
157
                else
 
158
                        applet_schema_key = NULL;
 
159
 
 
160
                if (g_strcmp0 (schema_key, applet_schema_key) != 0) {
 
161
                        gconf_engine_associate_schema (client->engine,
 
162
                                                       key, schema_key, error);
 
163
 
 
164
                        if (gconf_entry_get_value (applet_entry) == NULL ||
 
165
                            gconf_entry_get_is_default (applet_entry)) {
 
166
                                /* unset the key: gconf_client_get_entry()
 
167
                                 * brought an invalid entry in the client
 
168
                                 * cache, and we want to fix this */
 
169
                                gconf_client_unset (client, key, NULL);
 
170
                        }
 
171
                }
147
172
 
148
173
                g_free (key);
149
174
 
 
175
                if (applet_entry)
 
176
                        gconf_entry_unref (applet_entry);
150
177
                gconf_entry_unref (entry);
151
178
 
152
179
                if (*error) {
170
197
                prefs_subdir  = g_strdup_printf ("%s/%s", prefs_key, tmp);
171
198
                schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp);
172
199
 
173
 
                panel_applet_associate_schemas_in_dir (
174
 
                        client, prefs_subdir, schema_subdir, error);
 
200
                panel_applet_associate_schemas_in_dir (client,
 
201
                                                       prefs_subdir,
 
202
                                                       schema_subdir,
 
203
                                                       error);
175
204
 
176
205
                g_free (prefs_subdir);
177
206
                g_free (schema_subdir);
206
235
        else
207
236
                error = &our_error;
208
237
 
209
 
        panel_applet_associate_schemas_in_dir (
210
 
                applet->priv->client, applet->priv->prefs_key, schema_dir, error);
 
238
        panel_applet_associate_schemas_in_dir (applet->priv->client,
 
239
                                               applet->priv->prefs_key,
 
240
                                               schema_dir,
 
241
                                               error);
211
242
 
212
243
        if (!opt_error && our_error) {
213
244
                g_warning (G_STRLOC ": failed to add preferences from '%s' : '%s'",