diff options
-rw-r--r-- | docs/reference/tmpl/xfconf-gtk.sgml | 4 | ||||
-rw-r--r-- | docs/reference/tmpl/xfconf-unused.sgml | 10 | ||||
-rw-r--r-- | docs/reference/xfconf-sections.txt | 2 | ||||
-rw-r--r-- | xfconf-gtk/xfconf-gtk.c | 56 | ||||
-rw-r--r-- | xfconf-gtk/xfconf-gtk.h | 8 |
5 files changed, 44 insertions, 36 deletions
diff --git a/docs/reference/tmpl/xfconf-gtk.sgml b/docs/reference/tmpl/xfconf-gtk.sgml index 45e88e4..298d3e6 100644 --- a/docs/reference/tmpl/xfconf-gtk.sgml +++ b/docs/reference/tmpl/xfconf-gtk.sgml @@ -26,12 +26,12 @@ in the Xfconf store. <!-- ##### SECTION Stability_Level ##### --> -<!-- ##### FUNCTION xfconf_gtk_widget_bind_property ##### --> +<!-- ##### FUNCTION xfconf_gtk_editable_bind_property ##### --> <para> </para> -@widget: +@editable: @channel: @property: @property_type: diff --git a/docs/reference/tmpl/xfconf-unused.sgml b/docs/reference/tmpl/xfconf-unused.sgml index a941f34..2621d57 100644 --- a/docs/reference/tmpl/xfconf-unused.sgml +++ b/docs/reference/tmpl/xfconf-unused.sgml @@ -103,3 +103,13 @@ stamp-xfconf-marshal @value: @Returns: +<!-- ##### FUNCTION xfconf_gtk_widget_bind_property ##### --> +<para> + +</para> + +@widget: +@channel: +@property: +@property_type: + diff --git a/docs/reference/xfconf-sections.txt b/docs/reference/xfconf-sections.txt index 01b8d10..7344342 100644 --- a/docs/reference/xfconf-sections.txt +++ b/docs/reference/xfconf-sections.txt @@ -86,6 +86,6 @@ xfconf_g_value_set_uint16 <SECTION> <FILE>xfconf-gtk</FILE> -xfconf_gtk_widget_bind_property +xfconf_gtk_editable_bind_property xfconf_gtk_widget_unbind </SECTION> diff --git a/xfconf-gtk/xfconf-gtk.c b/xfconf-gtk/xfconf-gtk.c index c4db92e..a68fdae 100644 --- a/xfconf-gtk/xfconf-gtk.c +++ b/xfconf-gtk/xfconf-gtk.c @@ -155,6 +155,9 @@ xfconf_gtk_editable_binding(XfconfChannel *channel, gchar *cur_val, *new_val; gint strpos = 0; + if(strcmp(property, binding->property)) + return; + if(!xfconf_channel_get_property(channel, property, &val)) return; @@ -199,53 +202,48 @@ xfconf_gtk_editable_changed(GtkEditable *editable, /** - * xfconf_gtk_widget_bind_property: - * @widget: A #GtkWidget. + * xfconf_gtk_editable_bind_property: + * @editable: A widget implementing #GtkEditable. * @channel: An #XfconfChannel. * @property: A string property name. * @property_type: The #GType of @property. * - * Binds @widget to @property on @channel such that @widget will + * Binds @editable to @property on @channel such that @editable will * always display the value of @property, even if that value changes * via any other means. If @widget is editable, the binding will also * cause @property to be updated in the Xfconf configuration store. * - * Note that not all types of #GtkWidget are supported. Specifically, - * the following widgets are supported: - * FIXME: list widgets + * Note: #GtkEntry and #GtkSpinButton (and perhaps others) both + * implement the #GtkEditable interface and can be used with + * this function. **/ void -xfconf_gtk_widget_bind_property(GtkWidget *widget, - XfconfChannel *channel, - const gchar *property, - GType property_type) +xfconf_gtk_editable_bind_property(GtkEditable *editable, + XfconfChannel *channel, + const gchar *property, + GType property_type) { XfconfGtkBinding *binding; + GtkWidget *widget; - g_return_if_fail(GTK_IS_WIDGET(widget) && XFCONF_IS_CHANNEL(channel) + g_return_if_fail(GTK_IS_EDITABLE(editable) && XFCONF_IS_CHANNEL(channel) && property && *property); - if(GTK_IS_EDITABLE(widget)) { - binding = g_new0(XfconfGtkBinding, 1); + widget = GTK_WIDGET(editable); - binding->widget = widget; - binding->channel = channel; - binding->property = g_strdup(property); - binding->property_type = property_type; - binding->xfconf_callback = G_CALLBACK(xfconf_gtk_editable_binding); - binding->gtk_callback = G_CALLBACK(xfconf_gtk_editable_changed); + binding = g_new0(XfconfGtkBinding, 1); + binding->widget = widget; + binding->channel = channel; + binding->property = g_strdup(property); + binding->property_type = property_type; + binding->xfconf_callback = G_CALLBACK(xfconf_gtk_editable_binding); + binding->gtk_callback = G_CALLBACK(xfconf_gtk_editable_changed); - /* set initial entry value */ - xfconf_gtk_editable_binding(channel, property, binding); - - g_signal_connect(G_OBJECT(widget), "changed", - binding->gtk_callback, binding); - } else { - g_warning("GtkWidget type %s cannot be bound to an xfconf property", - G_OBJECT_TYPE_NAME(widget)); - return; - } + /* set initial entry value */ + xfconf_gtk_editable_binding(channel, property, binding); + g_signal_connect(G_OBJECT(widget), "changed", + binding->gtk_callback, binding); g_signal_connect(G_OBJECT(channel), "property-changed", binding->xfconf_callback, binding); diff --git a/xfconf-gtk/xfconf-gtk.h b/xfconf-gtk/xfconf-gtk.h index 79e97f6..6a8a94c 100644 --- a/xfconf-gtk/xfconf-gtk.h +++ b/xfconf-gtk/xfconf-gtk.h @@ -25,10 +25,10 @@ G_BEGIN_DECLS -void xfconf_gtk_widget_bind_property(GtkWidget *widget, - XfconfChannel *channel, - const gchar *property, - GType property_type); +void xfconf_gtk_editable_bind_property(GtkEditable *editable, + XfconfChannel *channel, + const gchar *property, + GType property_type); void xfconf_gtk_widget_unbind(GtkWidget *widget); |