[gnome-bluetooth] properties: Show "extra configuration" widgets



commit a9616ebbe695f6c571563e9a187177ed16d3139f
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 31 15:55:57 2011 +0100

    properties: Show "extra configuration" widgets
    
    For devices that support it. Means that we don't need
    to pair devices again to enable Bluetooth DUN or PAN/NAP.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646348

 properties/bluetooth.ui         |   19 +++++++++++++-
 properties/cc-bluetooth-panel.c |   50 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 5 deletions(-)
---
diff --git a/properties/bluetooth.ui b/properties/bluetooth.ui
index f91ea3e..ce62807 100644
--- a/properties/bluetooth.ui
+++ b/properties/bluetooth.ui
@@ -391,9 +391,13 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkLabel" id="label7">
-                                <property name="visible">True</property>
+                              <object class="GtkVBox" id="additional_setup_box">
                                 <property name="can_focus">False</property>
+                                <property name="no_show_all">True</property>
+                                <property name="spacing">8</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
                               </object>
                               <packing>
                                 <property name="expand">True</property>
@@ -502,6 +506,17 @@
                                 <property name="position">2</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkLabel" id="label7">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
                           </object>
                         </child>
                       </object>
diff --git a/properties/cc-bluetooth-panel.c b/properties/cc-bluetooth-panel.c
index b084472..c0d4b17 100644
--- a/properties/cc-bluetooth-panel.c
+++ b/properties/cc-bluetooth-panel.c
@@ -209,6 +209,47 @@ set_notebook_page (CcBluetoothPanel *self,
 }
 
 static void
+add_extra_setup_widgets (CcBluetoothPanel *self,
+			 const char       *bdaddr)
+{
+	GValue value = { 0 };
+	char **uuids;
+	GList *list, *l;
+	GtkWidget *container;
+
+	if (bluetooth_chooser_get_selected_device_info (BLUETOOTH_CHOOSER (self->priv->chooser),
+							"uuids", &value) == FALSE)
+		return;
+
+	uuids = (char **) g_value_get_boxed (&value);
+	list = bluetooth_plugin_manager_get_widgets (bdaddr, (const char **) uuids);
+	if (list == NULL) {
+		g_value_unset (&value);
+		return;
+	}
+
+	container = WID ("additional_setup_box");
+	for (l = list; l != NULL; l = l->next) {
+		GtkWidget *widget = l->data;
+		gtk_box_pack_start (GTK_BOX (container), widget,
+				    FALSE, FALSE, 0);
+		gtk_widget_show (widget);
+	}
+	gtk_widget_show (container);
+	g_value_unset (&value);
+}
+
+static void
+remove_extra_setup_widgets (CcBluetoothPanel *self)
+{
+	GtkWidget *box;
+
+	box = WID ("additional_setup_box");
+	gtk_container_forall (GTK_CONTAINER (box), (GtkCallback) gtk_widget_destroy, NULL);
+	gtk_widget_hide (WID ("additional_setup_box"));
+}
+
+static void
 cc_bluetooth_panel_update_properties (CcBluetoothPanel *self)
 {
 	char *bdaddr;
@@ -222,13 +263,13 @@ cc_bluetooth_panel_update_properties (CcBluetoothPanel *self)
 	gtk_widget_hide (WID ("sound_button"));
 	gtk_widget_hide (WID ("mouse_button"));
 
+	/* Remove the extra setup widgets */
+	remove_extra_setup_widgets (self);
+
 	bdaddr = bluetooth_chooser_get_selected_device (BLUETOOTH_CHOOSER (self->priv->chooser));
 	if (bdaddr == NULL) {
 		gtk_widget_set_sensitive (WID ("properties_vbox"), FALSE);
 		gtk_switch_set_active (button, FALSE);
-		gtk_label_set_text (GTK_LABEL (WID ("paired_label")), "");
-		gtk_label_set_text (GTK_LABEL (WID ("type_label")), "");
-		gtk_label_set_text (GTK_LABEL (WID ("address_label")), "");
 		gtk_widget_set_sensitive (WID ("button_delete"), FALSE);
 		set_notebook_page (self, NOTEBOOK_PAGE_EMPTY);
 	} else {
@@ -279,6 +320,9 @@ cc_bluetooth_panel_update_properties (CcBluetoothPanel *self)
 			;
 		}
 
+		/* Extra widgets */
+		add_extra_setup_widgets (self, bdaddr);
+
 		gtk_label_set_text (GTK_LABEL (WID ("address_label")), bdaddr);
 		g_free (bdaddr);
 



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