[gnome-bluetooth] Use GBinding instead of the Seahorse copy/paste



commit 10c655d3522986530044fd3bdde9bdb05f11d684
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jun 25 18:34:58 2010 +0100

    Use GBinding instead of the Seahorse copy/paste

 lib/Makefile.am               |    1 -
 lib/bluetooth-filter-widget.c |   38 +--
 lib/seahorse-bind.c           |  550 -----------------------------------------
 lib/seahorse-bind.h           |   43 ----
 4 files changed, 10 insertions(+), 622 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index da6e4af..0ca2921 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -29,7 +29,6 @@ libgnome_bluetooth_la_SOURCES =				\
 	gnome-bluetooth-enum-types.c			\
 	bluetooth-chooser.c bluetooth-chooser.h		\
 	bluetooth-chooser-private.h			\
-	seahorse-bind.c seahorse-bind.h			\
 	bluetooth-filter-widget.c			\
 	bluetooth-filter-widget.h			\
 	bluetooth-chooser-button.c			\
diff --git a/lib/bluetooth-filter-widget.c b/lib/bluetooth-filter-widget.c
index 96f1a04..e61beab 100644
--- a/lib/bluetooth-filter-widget.c
+++ b/lib/bluetooth-filter-widget.c
@@ -32,7 +32,6 @@
 #include "bluetooth-filter-widget.h"
 #include "bluetooth-client.h"
 #include "gnome-bluetooth-enum-types.h"
-#include "seahorse-bind.h"
 
 #define BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
 						BLUETOOTH_TYPE_FILTER_WIDGET, BluetoothFilterWidgetPrivate))
@@ -52,9 +51,6 @@ struct _BluetoothFilterWidgetPrivate {
 	int device_category_filter;
 	char *device_service_filter;
 
-	/* See bluetooth_filter_widget_bind_chooser () */
-	gpointer bindings[8];
-
 	guint show_device_type : 1;
 	guint show_device_category : 1;
 };
@@ -180,19 +176,15 @@ bluetooth_filter_widget_set_title (BluetoothFilterWidget *self, gchar *title)
 static void
 bluetooth_filter_widget_bind_chooser_single (BluetoothFilterWidget *self,
 					     BluetoothChooser *chooser,
-					     const char *property,
-					     guint *i)
+					     const char *property)
 {
-	BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(self);
-
 	/* NOTE: We are binding the chooser as the source so that all of it's
 	 * properties are pushed to the filter.
-	 * Remember the bindings so we can unbind them later on */
-	priv->bindings[*i] = seahorse_bind_property (property, (gpointer) chooser,
-						    property, (gpointer) self);
-	priv->bindings[(*i)++] = seahorse_bind_property (property, (gpointer) self,
-		 				      property, (gpointer) chooser);
-	(*i)++;
+	 * The bindings will be automatically removed when one of the
+	 * objects go away */
+	g_object_bind_property ((gpointer) chooser, property,
+				(gpointer) self, property,
+				G_BINDING_BIDIRECTIONAL);
 }
 
 /**
@@ -209,13 +201,10 @@ bluetooth_filter_widget_bind_chooser_single (BluetoothFilterWidget *self,
 void
 bluetooth_filter_widget_bind_filter (BluetoothFilterWidget *self, BluetoothChooser *chooser)
 {
-	guint i;
-
-	i = 0;
-	bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-type-filter", &i);
-	bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-category-filter", &i);
-	bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-type", &i);
-	bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-category", &i);
+	bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-type-filter");
+	bluetooth_filter_widget_bind_chooser_single (self, chooser, "device-category-filter");
+	bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-type");
+	bluetooth_filter_widget_bind_chooser_single (self, chooser, "show-device-category");
 }
 
 static void
@@ -353,18 +342,11 @@ static void
 bluetooth_filter_widget_dispose (GObject *object)
 {
 	BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(object);
-	guint i;
 
 	if (priv->chooser) {
 		g_object_unref (priv->chooser);
 		priv->chooser = NULL;
 	}
-	for (i = 0; i < 8; i++) {
-		if (priv->bindings[i] != NULL) {
-			seahorse_bind_disconnect (priv->bindings[i]);
-			priv->bindings[i] = NULL;
-		}
-	}
 
 	G_OBJECT_CLASS(bluetooth_filter_widget_parent_class)->dispose(object);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]