summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>1999-12-02 23:36:37 +0000
committerHavoc Pennington <hp@src.gnome.org>1999-12-02 23:36:37 +0000
commite18eae09ab11dcd172329020804f71f99b769823 (patch)
tree9bb8ad01b18a2326320bbd57378c0ae7d601ac7b /examples
parent0bb56c7ccb332781cd6fe2bfff3b11d53a8bbbb9 (diff)
downloadgconf-e18eae09ab11dcd172329020804f71f99b769823.tar.gz
use gconf_client_get_string() instead of gconf_client_get()
1999-12-02 Havoc Pennington <hp@pobox.com> * examples/basic-gconf-app.c (create_configurable_widget): use gconf_client_get_string() instead of gconf_client_get() (update_entry): Check for the default value if we have an unset value in the change set. * wrappers/gtk/gconf-client.c (gconf_client_create_change_set_from_currentv): use without_default (revert_foreach): use without_default * gconf/gconf-changeset.c (gconf_create_change_set_from_currentv): use gconf_get_without_default() (revert_foreach): use gconf_get_without_default() * wrappers/gtk/testgconfclient.c (entry_notify_func): fix to compile * examples/basic-gconf-app.c (configurable_widget_config_notify): fix to compile * wrappers/gtk/gconf-client.c (gconf_client_get_default_from_schema): New function * gconf/gconf.c (gconf_get_without_default): renamed from gconf_get_no_default(), so that gconf_get_default_from_schema() won't be as confusing maybe. (gconf_get_default_from_schema): new function to read the default setting in the schema * backends/xml-backend.c (xentry_extract_value): remove ignore_subsequent (xentry_set_value): ditto * gconf/gconf-sources.c (gconf_sources_query_value): Remove ignore subsequent * gconf/gconf-value.c (gconf_value_new_from_string): remove ignore_subsequent (gconf_value_to_string): remove ignore_subsequent (gconf_value_copy): Remove ignore_subsequent * gconf/gconfd.c (context_unset): add is_default to notification (context_set): add is_default to notification * gconf/gconf-internals.c (gconf_value_type_to_string): Remove ignore_subsequent. * gconf/gconf.c (gconf_cnxn_notify): add is_default (notify) add is_default * gconf/gconf-value.h: Remove GCONF_VALUE_IGNORE_SUBSEQUENT * gconf/gconf-sources.c (gconf_sources_unset_value): don't do that weird IGNORE_SUBSEQUENT goo * wrappers/gtk/Makefile.am (INCLUDES): add top_builddir to include search to get the built sources * gconf/gconf-engine.h: fix includes * gconf/gconf-changeset.h: fix includes * gconf/Makefile.am (gconfd_SOURCES): add gconf-sources.h here instead of installing it. * wrappers/gtk/Makefile.am (INCLUDES): remove -I$(top_builddir)/gconf * wrappers/gtk/gconf-client.c (gconf_client_get_full): Add this, etc. * gconf/gconf-sources.c (gconf_sources_query_value): Set a flag indicating whether the retrieved value was the default or not. * gconf/GConf.idl: add value_is_default out flag to lookup_with_locale()
Diffstat (limited to 'examples')
-rw-r--r--examples/basic-gconf-app.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/examples/basic-gconf-app.c b/examples/basic-gconf-app.c
index 778cd278..60bc8b34 100644
--- a/examples/basic-gconf-app.c
+++ b/examples/basic-gconf-app.c
@@ -122,6 +122,7 @@ configurable_widget_config_notify(GConfClient* client,
guint cnxn_id,
const gchar* key,
GConfValue* value,
+ gboolean is_default,
gpointer user_data)
{
GtkWidget* label = user_data;
@@ -152,8 +153,8 @@ create_configurable_widget(GConfClient* client, const gchar* config_key)
{
GtkWidget* frame;
GtkWidget* label;
- GConfValue* initial;
guint notify_id;
+ gchar* str;
frame = gtk_frame_new(config_key);
@@ -161,12 +162,12 @@ create_configurable_widget(GConfClient* client, const gchar* config_key)
gtk_container_add(GTK_CONTAINER(frame), label);
- initial = gconf_client_get(client, config_key, NULL);
+ str = gconf_client_get_string(client, config_key, NULL);
- if (initial != NULL && initial->type == GCONF_VALUE_STRING)
+ if (str != NULL)
{
- const gchar* str = gconf_value_string(initial);
gtk_label_set_text(GTK_LABEL(label), str);
+ g_free(str);
}
notify_id = gconf_client_notify_add(client,
@@ -360,6 +361,9 @@ static void
update_entry(GtkWidget* dialog, GConfChangeSet* cs, const gchar* config_key)
{
GConfValue* value = NULL;
+ GConfClient* client;
+
+ client = gtk_object_get_data(GTK_OBJECT(dialog), "client");
if (gconf_change_set_check_value(cs, config_key,
&value))
@@ -372,7 +376,27 @@ update_entry(GtkWidget* dialog, GConfChangeSet* cs, const gchar* config_key)
if (value == NULL)
{
- gtk_entry_set_text(GTK_ENTRY(entry), "");
+ /* We need to check for a default value,
+ since the revert set will unset the user setting */
+ GConfValue* def;
+
+ def = gconf_client_get_default_from_schema(client,
+ config_key,
+ NULL);
+
+ if (def)
+ {
+ if (def->type == GCONF_VALUE_STRING)
+ {
+ gtk_entry_set_text(GTK_ENTRY(entry), gconf_value_string(def));
+ }
+ else
+ g_warning("Wrong type for default value of %s", config_key);
+
+ gconf_value_destroy(def);
+ }
+ else
+ gtk_entry_set_text(GTK_ENTRY(entry), "");
}
else if (value->type == GCONF_VALUE_STRING)
{