From 250f23b97b497346e6a60b667b9d8a09ca524c3b Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Mon, 17 Dec 2001 19:32:15 +0000 Subject: [PATCH] Work correctly with multiple callback signatures 2001-12-17 Bradford Hovinen * gconf-property-editor.c (peditor_string_widget_changed): Work correctly with multiple callback signatures (gconf_peditor_new_string): Use changed signal --- capplets/common/ChangeLog | 4 ++++ capplets/common/gconf-property-editor.c | 28 +++++++++++++------------ capplets/common/gconf-property-editor.h | 3 +-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index bedac4105..09d410e0a 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -13,6 +13,10 @@ signal handler (peditor_select_menu_value_changed): Use gtk_option_menu_set_history + (guard_value_changed, gconf_peditor_widget_set_guard): Implement + (peditor_string_widget_changed): Work correctly with multiple + callback signatures + (gconf_peditor_new_string): Use changed signal 2001-12-08 Bradford Hovinen diff --git a/capplets/common/gconf-property-editor.c b/capplets/common/gconf-property-editor.c index 3ab359fc3..fc806eb68 100644 --- a/capplets/common/gconf-property-editor.c +++ b/capplets/common/gconf-property-editor.c @@ -311,9 +311,13 @@ peditor_string_value_changed (GConfEngine *engine, guint cnxn_id, GConfEntry *en } static void -peditor_string_widget_changed (GConfPropertyEditor *peditor, GtkEntry *entry) +peditor_string_widget_changed (GConfPropertyEditor *peditor) { GConfValue *value; + GtkEntry *entry; + + /* I do this so that we don't have to deal with multiple callback signatures */ + entry = g_object_get_data (peditor, "entry"); gconf_change_set_set_string (peditor->p->changeset, peditor->p->key, gtk_entry_get_text (entry)); gconf_change_set_check_value (peditor->p->changeset, peditor->p->key, &value); @@ -334,11 +338,7 @@ gconf_peditor_new_string (GConfChangeSet *changeset, gchar *key, GtkWidget *entr "object", entry, NULL); - g_signal_connect_swapped (G_OBJECT (entry), "insert_at_cursor", - (GCallback) peditor_string_widget_changed, peditor); - g_signal_connect_swapped (G_OBJECT (entry), "delete_from_cursor", - (GCallback) peditor_string_widget_changed, peditor); - g_signal_connect_swapped (G_OBJECT (entry), "paste_clipboard", + g_signal_connect_swapped (G_OBJECT (entry), "changed", (GCallback) peditor_string_widget_changed, peditor); g_object_set_data (peditor, "entry", entry); @@ -534,17 +534,19 @@ gconf_peditor_new_select_radio (GConfChangeSet *changeset, gchar *key, GSList *r } static void -guard_value_changed (GConfEngine *engine, guint cnxn_id, GConfEntry *entry, GtkWidget *widget) -{ -} - -static void -guard_widget_changed (GConfPropertyEditor *peditor, gchar *key, GConfValue *value, GtkWidget *widget) +guard_value_changed (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *widget) { + gtk_widget_set_sensitive (widget, gconf_value_get_bool (value)); } void -peditor_widget_set_guard (GConfPropertyEditor *peditor, GtkWidget *widget, gchar *key) +gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor, GtkWidget *widget) { + GConfEngine *engine; + + engine = gconf_engine_get_default (); + gtk_widget_set_sensitive (widget, gconf_engine_get_bool (engine, peditor->p->key, NULL)); + + g_signal_connect (G_OBJECT (peditor), "value-changed", (GCallback) guard_value_changed, widget); } diff --git a/capplets/common/gconf-property-editor.h b/capplets/common/gconf-property-editor.h index 22b334e2e..367321ce9 100644 --- a/capplets/common/gconf-property-editor.h +++ b/capplets/common/gconf-property-editor.h @@ -76,8 +76,7 @@ GObject *gconf_peditor_new_select_radio (GConfChangeSet *changeset, GSList *radio_group); void gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor, - GtkWidget *widget, - gchar *key); + GtkWidget *widget); G_END_DECLS