[gnome-bluetooth] properties: Disable toolbar with no Bluetooth



commit 9ea82246cc8a955c8171589879f5278d9011b0a9
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Feb 22 02:10:53 2011 +0000

    properties: Disable toolbar with no Bluetooth

 properties/bluetooth.ui         |    2 +-
 properties/cc-bluetooth-panel.c |   30 +++++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/properties/bluetooth.ui b/properties/bluetooth.ui
index 2eaf9b9..28d2925 100644
--- a/properties/bluetooth.ui
+++ b/properties/bluetooth.ui
@@ -394,7 +394,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkToolbar" id="toolbar1">
+              <object class="GtkToolbar" id="toolbar">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="icon_size">1</property>
diff --git a/properties/cc-bluetooth-panel.c b/properties/cc-bluetooth-panel.c
index ee3dc45..34a2700 100644
--- a/properties/cc-bluetooth-panel.c
+++ b/properties/cc-bluetooth-panel.c
@@ -130,7 +130,7 @@ cc_bluetooth_panel_update_properties (CcBluetoothPanel *self)
 			gtk_widget_show (WID ("keyboard_button"));
 			break;
 		case BLUETOOTH_TYPE_MOUSE:
-			/* FIXME what about touchpads */
+			/* FIXME what about Bluetooth touchpads */
 			gtk_widget_show (WID ("mouse_button"));
 			break;
 		case BLUETOOTH_TYPE_HEADSET:
@@ -225,7 +225,7 @@ delete_clicked (GtkToolButton    *button,
 
 static void
 setup_clicked (GtkToolButton    *button,
-		CcBluetoothPanel *self)
+	       CcBluetoothPanel *self)
 {
 	const char *command = "bluetooth-wizard";
 	GError *error = NULL;
@@ -236,6 +236,25 @@ setup_clicked (GtkToolButton    *button,
 	}
 }
 
+/* Overall device state */
+static void
+cc_bluetooth_panel_update_state (CcBluetoothPanel *self)
+{
+	char *bdaddr;
+
+	g_object_get (G_OBJECT (self->priv->client), "default-adapter", &bdaddr, NULL);
+	gtk_widget_set_sensitive (WID ("toolbar"), (bdaddr != NULL));
+	g_free (bdaddr);
+}
+
+static void
+default_adapter_changed (BluetoothClient  *client,
+			 GParamSpec       *spec,
+			 CcBluetoothPanel *self)
+{
+	cc_bluetooth_panel_update_state (self);
+}
+
 static void
 cc_bluetooth_panel_init (CcBluetoothPanel *self)
 {
@@ -263,6 +282,11 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
 	widget = WID ("vbox");
 	gtk_widget_reparent (widget, GTK_WIDGET (self));
 
+	/* Overall device state */
+	cc_bluetooth_panel_update_state (self);
+	g_signal_connect (G_OBJECT (self->priv->client), "notify::default-adapter",
+			  G_CALLBACK (default_adapter_changed), self);
+
 	/* The discoverable button */
 	cc_bluetooth_panel_update_visibility (self);
 	g_signal_connect (G_OBJECT (self->priv->client), "notify::default-adapter-discoverable",
@@ -296,7 +320,7 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
 	gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (widget), 250);
 	context = gtk_widget_get_style_context (widget);
 	gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
-	widget = WID ("toolbar1");
+	widget = WID ("toolbar");
 	context = gtk_widget_get_style_context (widget);
 	gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
 



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