From 0f7c418ab121fd00312ef2f696afdb32c5ec4d00 Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Tue, 18 Dec 2001 19:37:49 +0000 Subject: [PATCH] Implement 2001-12-18 Bradford Hovinen * gconf-property-editor.c (peditor_int_range_value_changed) (peditor_int_range_widget_changed, gconf_peditor_new_int_range): Implement --- capplets/common/ChangeLog | 9 +++- capplets/common/gconf-property-editor.c | 60 +++++++++++++++++++++++-- capplets/common/gconf-property-editor.h | 3 ++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index 6ab80389a..a6158db70 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,8 +1,13 @@ 2001-12-18 Bradford Hovinen * gconf-property-editor.c (peditor_string_widget_changed): Use - actual signature for the changed signal - Use gconf_client rather than gconf_engine + actual signature for the changed signal Use gconf_client rather + than gconf_engine + (gconf_property_editor_set_prop): Use weak_ref rather than destroy + signal + (peditor_int_range_value_changed) + (peditor_int_range_widget_changed, gconf_peditor_new_int_range): + Implement 2001-12-17 Bradford Hovinen diff --git a/capplets/common/gconf-property-editor.c b/capplets/common/gconf-property-editor.c index c4440668b..c9fc7a3f4 100644 --- a/capplets/common/gconf-property-editor.c +++ b/capplets/common/gconf-property-editor.c @@ -189,9 +189,7 @@ gconf_property_editor_set_prop (GObject *object, guint prop_id, const GValue *va case PROP_OBJECT: det_obj = g_value_get_object (value); - g_signal_connect_swapped (det_obj, "destroy", - (GCallback) g_object_unref, - object); + g_object_weak_ref (det_obj, (GWeakNotify) g_object_unref, object); break; default: @@ -530,6 +528,62 @@ gconf_peditor_new_select_radio (GConfChangeSet *changeset, gchar *key, GSList *r return peditor; } +static void +peditor_int_range_value_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, GConfPropertyEditor *peditor) +{ + GConfValue *value; + GtkAdjustment *adjustment; + + gconf_change_set_remove (peditor->p->changeset, peditor->p->key); + value = gconf_entry_get_value (entry); + + if (value != NULL) { + adjustment = g_object_get_data (G_OBJECT (peditor), "adjustment"); + gtk_adjustment_set_value (adjustment, gconf_value_get_int (value)); + } +} + +static void +peditor_int_range_widget_changed (GConfPropertyEditor *peditor, GtkAdjustment *adjustment) +{ + GConfValue *value; + + gconf_change_set_set_int (peditor->p->changeset, peditor->p->key, + gtk_adjustment_get_value (adjustment)); + + gconf_change_set_check_value (peditor->p->changeset, peditor->p->key, &value); + g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value); +} + +GObject * +gconf_peditor_new_int_range (GConfChangeSet *changeset, gchar *key, GtkWidget *range) +{ + GObject *peditor; + GConfClient *client; + GConfEntry *gconf_entry; + GSList *item; + GtkAdjustment *adjustment; + + peditor = g_object_new (gconf_property_editor_get_type (), + "key", key, + "callback", peditor_int_range_value_changed, + "changeset", changeset, + "object", range, + NULL); + + adjustment = gtk_range_get_adjustment (GTK_RANGE (range)); + g_object_set_data (peditor, "adjustment", adjustment); + + g_signal_connect_swapped (G_OBJECT (adjustment), "changed", + (GCallback) peditor_int_range_widget_changed, peditor); + + client = gconf_client_get_default (); + gconf_entry = gconf_client_get_entry (client, key, NULL, TRUE, NULL); + peditor_int_range_value_changed (client, 0, gconf_entry, GCONF_PROPERTY_EDITOR (peditor)); + + return peditor; +} + static void guard_value_changed (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *widget) { diff --git a/capplets/common/gconf-property-editor.h b/capplets/common/gconf-property-editor.h index 23ea0c40b..4a74bcf06 100644 --- a/capplets/common/gconf-property-editor.h +++ b/capplets/common/gconf-property-editor.h @@ -74,6 +74,9 @@ GObject *gconf_peditor_new_select_menu (GConfChangeSet *changeset, GObject *gconf_peditor_new_select_radio (GConfChangeSet *changeset, gchar *key, GSList *radio_group); +GObject *gconf_peditor_new_int_range (GConfChangeSet *changeset, + gchar *key, + GtkWidget *range); void gconf_peditor_widget_set_guard (GConfPropertyEditor *peditor, GtkWidget *widget);