[gnome-bluetooth] Use the new plugin infrastructure



commit fab803bbf16655a33d67ac1d7588f73be0b80950
Author: Bastien Nocera <hadess hadess net>
Date:   Thu May 28 17:20:21 2009 +0100

    Use the new plugin infrastructure
    
    So we can provide extra setup widgets in the summary page of the wizard.
---
 wizard/main.c    |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 wizard/wizard.ui |   32 ++++++++++++++++++++++++++++++--
 2 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/wizard/main.c b/wizard/main.c
index badfc24..ace0805 100644
--- a/wizard/main.c
+++ b/wizard/main.c
@@ -36,6 +36,7 @@
 #include <bluetooth-client.h>
 #include <bluetooth-chooser.h>
 #include <bluetooth-agent.h>
+#include <bluetooth-plugin-manager.h>
 
 #include "pin.h"
 
@@ -66,6 +67,8 @@ static GtkWidget *page_summary = NULL;
 static GtkWidget *label_setup = NULL;
 static GtkWidget *label_passkey = NULL;
 static GtkWidget *label_passkey_help = NULL;
+static GtkWidget *extra_config_label = NULL;
+static GtkWidget *extra_config_help_label = NULL;
 
 static BluetoothChooser *selector = NULL;
 
@@ -253,7 +256,7 @@ void prepare_callback(GtkWidget *assistant,
 	}
 
 	if (page == page_setup) {
-		gchar *text, *address, *name, *pin_ret;
+		char *text, *address, *name, *pin_ret;
 		BluetoothType type;
 
 		/* Get the info about the device now,
@@ -297,6 +300,12 @@ void prepare_callback(GtkWidget *assistant,
 		g_free (pincode);
 		pincode = NULL;
 
+		/* Set the filter on the selector, so we can use it to get more
+		 * info later, in page_summary */
+		g_object_set (selector,
+			      "device-category-filter", BLUETOOTH_CATEGORY_ALL,
+			      NULL);
+
 		if (user_pincode != NULL && *user_pincode != '\0') {
 			pincode = g_strdup (user_pincode);
 		} else {
@@ -337,6 +346,38 @@ void prepare_callback(GtkWidget *assistant,
 		}
 	}
 
+	if (page == page_summary) {
+		GList *widgets = NULL;
+		GValue value = { 0, };
+		char **uuids;
+
+		bluetooth_chooser_get_selected_device_info (selector, "name", &value);
+		g_value_unset (&value);
+
+		if (bluetooth_chooser_get_selected_device_info (selector, "uuids", &value) != FALSE) {
+			uuids = g_value_get_boxed (&value);
+			widgets = bluetooth_plugin_manager_get_widgets (target_address,
+									(const char **) uuids);
+			g_value_unset (&value);
+		}
+		if (widgets != NULL) {
+			GList *l;
+
+			gtk_widget_show (extra_config_label);
+			gtk_widget_show (extra_config_help_label);
+			for (l = widgets; l != NULL; l = l->next) {
+				GtkWidget *widget = l->data;
+				gtk_box_pack_start (GTK_BOX (page_summary),
+						    widget,
+						    FALSE,
+						    TRUE,
+						    6);
+				gtk_widget_show (widget);
+			}
+			g_list_free (widgets);
+		}
+	}
+
 	gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant),
 							page, complete);
 }
@@ -553,6 +594,8 @@ static GtkWidget *create_wizard(void)
 
 	/* Summary page */
 	page_summary = GTK_WIDGET(gtk_builder_get_object(builder, "page_summary"));
+	extra_config_label = GTK_WIDGET(gtk_builder_get_object(builder, "extra_config_label"));
+	extra_config_help_label = GTK_WIDGET(gtk_builder_get_object(builder, "extra_config_help_label"));
 
 	/* Set page icons (named icons not supported by Glade) */
 	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
@@ -646,6 +689,8 @@ int main(int argc, char *argv[])
 
 	bluetooth_agent_setup(agent, AGENT_PATH);
 
+	bluetooth_plugin_manager_init ();
+
 	window = create_wizard();
 	if (window == NULL)
 		return 1;
@@ -656,6 +701,8 @@ int main(int argc, char *argv[])
 
 	gtk_main();
 
+	bluetooth_plugin_manager_cleanup ();
+
 	g_object_unref(agent);
 
 	g_object_unref(client);
diff --git a/wizard/wizard.ui b/wizard/wizard.ui
index 2d89e52..9a025ea 100644
--- a/wizard/wizard.ui
+++ b/wizard/wizard.ui
@@ -171,8 +171,8 @@
             <property name="visible">True</property>
             <property name="xalign">0</property>
             <property name="yalign">0</property>
-            <property name="label" translatable="yes">&lt;b&gt;Successfully configured new device&lt;/b&gt;</property>
-            <property name="use_markup">True</property>
+            <property name="label" translatable="yes">Successfully configured new device</property>
+            <property name="use_markup">False</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -181,6 +181,34 @@
           </packing>
         </child>
         <child>
+          <object class="GtkLabel" id="extra_config_label">
+            <property name="visible">False</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="label" translatable="yes">&lt;b&gt;Additional setup&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="extra_config_help_label">
+            <property name="visible">False</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="label" translatable="yes">Select the additional services you want to use with your device: </property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
           <placeholder/>
         </child>
       </object>



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