diff options
author | Havoc Pennington <hp@pobox.com> | 2000-09-17 01:57:43 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-09-17 01:57:43 +0000 |
commit | ef7cc963ba244ef688cc54ebdaa95bb9b9d4684b (patch) | |
tree | fc2c9012cbd13a1a05f94b64108bae3306de4d73 /examples | |
parent | b780e8386cc3632992b70d6232bc8e63d64154f8 (diff) | |
download | gconf-ef7cc963ba244ef688cc54ebdaa95bb9b9d4684b.tar.gz |
And actually implement it here. Doh.
2000-09-16 Havoc Pennington <hp@pobox.com>
* gconf/gconf.c (gconf_engine_key_is_writable): And actually
implement it here. Doh.
* wrappers/gtk/gconf-client.c (gconf_client_key_is_writable): Gee,
forgot to actually implement this function after implementing all
the backend work for it...
* gconf/gconf.c (corba_errno_to_gconf_errno): add
NO_WRITABLE_DATABASE handling here also
* gconf/gconfd.c (gconf_set_exception): handle
NO_WRITABLE_DATABASE error
* gconf/GConf.idl: Add NoWritableDatabase to error type enum
* wrappers/gtk/testgconfclient.c (entry_attached_to): Update
to properly handle writability
* examples/simple-controller.c (main): set entry sensitivity
properly
* examples/basic-gconf-app.c (main): Remove ref/sink and destroy,
just use plain refcounting
(create_config_entry): Set entry sensitivity according to key
writability
* wrappers/gtk/gconf-client.c (gconf_client_finalize): Move all
cleanup to finalize, remove destroy handler
Diffstat (limited to 'examples')
-rw-r--r-- | examples/basic-gconf-app.c | 34 | ||||
-rw-r--r-- | examples/simple-controller.c | 5 |
2 files changed, 20 insertions, 19 deletions
diff --git a/examples/basic-gconf-app.c b/examples/basic-gconf-app.c index 07690303..3b9e2118 100644 --- a/examples/basic-gconf-app.c +++ b/examples/basic-gconf-app.c @@ -27,9 +27,10 @@ model; and the prefs dialog is a "controller." */ -/* Throughout, this program is letting GConfClient use its default error handlers - rather than checking for errors or attaching custom handlers to the - "unreturned_error" signal. Thus the last arg to GConfClient functions is NULL. +/* Throughout, this program is letting GConfClient use its default + error handlers rather than checking for errors or attaching custom + handlers to the "unreturned_error" signal. Thus the last arg to + GConfClient functions is NULL. */ /* A word about Apply/Revert/OK/Cancel. These should work as follows: @@ -75,25 +76,15 @@ main(int argc, char** argv) gconf_client_add_dir(client, "/apps/basic-gconf-app", GCONF_CLIENT_PRELOAD_NONE, NULL); - /* The main() function takes over the floating object; the code that - "owns" the object should do this, as with any Gtk object. - Read about refcounting and destruction at developer.gnome.org/doc/GGAD/ */ - gtk_object_ref(GTK_OBJECT(client)); - gtk_object_sink(GTK_OBJECT(client)); - main_window = create_main_window(client); gtk_widget_show_all(main_window); gtk_main(); - /* Shut down the client cleanly. Note the destroy rather than unref, - so the shutdown occurs even if there are outstanding references. - If your program isn't exiting you probably want to just plain unref() - Read about refcounting and destruction at developer.gnome.org/doc/GGAD/ */ - gtk_object_destroy(GTK_OBJECT(client)); - /* Now avoid leaking memory (not that this matters since the program - is exiting... */ + /* This ensures we cleanly detach from the GConf server (assuming + * we hold the last reference) + */ gtk_object_unref(GTK_OBJECT(client)); return 0; @@ -383,8 +374,8 @@ update_entry(GtkWidget* dialog, GConfChangeSet* cs, const gchar* config_key) GConfValue* def; def = gconf_client_get_default_from_schema(client, - config_key, - NULL); + config_key, + NULL); if (def) { @@ -493,7 +484,7 @@ create_config_entry(GtkWidget* prefs_dialog, GConfClient* client, const gchar* c frame = gtk_frame_new(config_key); entry = gtk_entry_new(); - + gtk_container_add(GTK_CONTAINER(frame), entry); initial = gconf_client_get(client, config_key, NULL); @@ -523,6 +514,11 @@ create_config_entry(GtkWidget* prefs_dialog, GConfClient* client, const gchar* c revert code */ gtk_object_set_data(GTK_OBJECT(prefs_dialog), config_key, entry); + + /* Set the entry insensitive if the key it edits isn't writable */ + gtk_widget_set_sensitive (entry, + gconf_client_key_is_writable (client, + config_key, NULL)); return frame; } diff --git a/examples/simple-controller.c b/examples/simple-controller.c index 3ecec907..178376b1 100644 --- a/examples/simple-controller.c +++ b/examples/simple-controller.c @@ -67,6 +67,11 @@ main(int argc, char** argv) gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(entry_activated_callback), client); + + /* If key isn't writable, then set insensitive */ + gtk_widget_set_sensitive (entry, + gconf_client_key_is_writable (client, + "/extra/test/directory/key", NULL)); gtk_widget_show_all(window); |