static gboolean gconf_settings_backend_write_tree (GSettingsBackend *backend, GTree *tree, gpointer origin_tag) { GConfSettingsBackend *gconf = GCONF_SETTINGS_BACKEND (backend); GConfChangeSet *changeset; GConfChangeSet *reversed; gboolean success; changeset = gconf_change_set_new (); g_tree_foreach (tree, (GTraverseFunc) gconf_settings_backend_write_one_to_changeset, changeset); if (gconf_change_set_size (changeset) != g_tree_nnodes (tree)) { gconf_change_set_unref (changeset); return FALSE; } reversed = gconf_client_reverse_change_set (gconf->priv->client, changeset, NULL); success = gconf_client_commit_change_set (gconf->priv->client, changeset, TRUE, NULL); g_tree_foreach (tree, (GTraverseFunc) gconf_settings_backend_add_ignore_notifications, gconf); if (!success) { /* This is a tricky situation: when committing, some keys will have been * changed, so there will be notifications that we'll want to ignore. But * we can't ignore notifications for what was not committed. Note that * when we'll commit the reversed changeset, it should fail for the same * key, so there'll be no other notifications created. And in the worst * case, it's no big deal... */ gconf_change_set_foreach (changeset, (GConfChangeSetForeachFunc) gconf_settings_backend_remove_ignore_notifications, gconf); gconf_client_commit_change_set (gconf->priv->client, reversed, FALSE, NULL); } else g_settings_backend_changed_tree (backend, tree, origin_tag); gconf_change_set_unref (changeset); gconf_change_set_unref (reversed); return success; }
static void prefs_dialog_update_sensitivity(GtkWidget* dialog) { GtkWidget* apply; GtkWidget* revert; GtkWidget* ok; GtkWidget* cancel; GConfChangeSet* cs; GConfChangeSet* revert_cs; apply = g_object_get_data(dialog, "apply"); revert = g_object_get_data(dialog, "revert"); ok = g_object_get_data(dialog, "ok"); cancel = g_object_get_data(dialog, "cancel"); g_assert(apply != NULL); g_assert(revert != NULL); cs = prefs_dialog_get_change_set(dialog); revert_cs = g_object_get_data(dialog, "revert_changeset"); if (gconf_change_set_size(cs) > 0) { gtk_widget_set_sensitive(apply, TRUE); } else { gtk_widget_set_sensitive(apply, FALSE); } if (revert_cs != NULL) gtk_widget_set_sensitive(revert, TRUE); else gtk_widget_set_sensitive(revert, FALSE); }