Google
  Web www.spinics.net

Re: Wizard patch

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


On Sat, 2008-06-28 at 00:23 +0200, Marcel Holtmann wrote:
> looks nice. However you have to break this up into pieces for. Sent
> small patches and I can quickly review and commit them.

And here's the actual wizard UI patch.  It's a bit large, but not
terribly break-down-able.

It adds the passkey code for the UI and modifies the UI a bit, as I
mentioned in previous emails.

It also adds a call to the client code to get an address's user-visible
name from its path.

Bastien suggested that the applet label to launch the wizard should
continue to be "Setup" and not "Connect" because we may want to do more
setup for certain device types in the future.  That may be true, but
some of that would be automatic (like the SyncML example he cited) and
so wouldn't be visible from the user's perspective.

Even if we did add a page for some sort of device configuration, I
maintain that the overriding user metaphor will be connecting not
configuring.

-mt
diff -uprN ../bluez-gnome-services/applet/main.c ./applet/main.c
--- ../bluez-gnome-services/applet/main.c	2008-06-30 09:27:23.000000000 -0400
+++ ./applet/main.c	2008-06-30 09:56:45.000000000 -0400
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
 		g_printerr("Couldn't execute command: %s\n", command);
 }
 
-#if 0
 static void wizard_callback(GObject *widget, gpointer user_data)
 {
 	const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
 	if (!g_spawn_command_line_async(command, NULL))
 		g_printerr("Couldn't execute command: %s\n", command);
 }
-#endif
 
 static void activate_callback(GObject *widget, gpointer user_data)
 {
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
 
 	menuitem_browse = item;
 
-#if 0
 	item = gtk_separator_menu_item_new();
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
-	item = gtk_menu_item_new_with_label(_("Setup New Device"));
+	item = gtk_menu_item_new_with_label(_("Connect New Device..."));
 	g_signal_connect(item, "activate",
 				G_CALLBACK(wizard_callback), NULL);
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
 
 	return menu;
 }
diff -uprN ../bluez-gnome-services/common/client.c ./common/client.c
--- ../bluez-gnome-services/common/client.c	2008-06-30 09:35:52.000000000 -0400
+++ ./common/client.c	2008-06-30 09:58:23.000000000 -0400
@@ -1118,6 +1118,37 @@ BluetoothClient *bluetooth_client_new(vo
 	}
 }
 
+gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return NULL;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		gchar *path;
+		gchar *name;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_NAME, &name, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0)
+			return g_strdup(name);
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return NULL;
+}
+
 int bluetooth_client_available_services(BluetoothClient *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
diff -uprN ../bluez-gnome-services/common/client.h ./common/client.h
--- ../bluez-gnome-services/common/client.h	2008-06-30 09:44:06.000000000 -0400
+++ ./common/client.h	2008-06-30 09:58:19.000000000 -0400
@@ -135,6 +135,8 @@ gboolean bluetooth_client_discover_devic
 
 gboolean bluetooth_client_cancel_discovery(BluetoothClient *self, gchar *adapter);
 
+gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
+
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *self);
 GtkTreeModel *bluetooth_client_get_model_simple(BluetoothClient *self);
 GtkTreeModel *bluetooth_client_get_model_adapter_list(BluetoothClient *self);
diff -uprN ../bluez-gnome-services/wizard/agent.c ./wizard/agent.c
--- ../bluez-gnome-services/wizard/agent.c	1969-12-31 19:00:00.000000000 -0500
+++ ./wizard/agent.c	2008-06-30 10:01:52.000000000 -0400
@@ -0,0 +1,340 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2005-2008  Marcel Holtmann <marcel@xxxxxxxxxxxx>
+ *  Copyright (C) 2006-2007  Bastien Nocera <hadess@xxxxxxxxxx>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <dbus/dbus-glib.h>
+
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+
+#include "agent.h"
+
+static GtkWidget *main_dialog;
+
+typedef enum {
+	AGENT_ERROR_REJECT
+} AgentError;
+
+#define AGENT_ERROR (agent_error_quark())
+
+#define AGENT_ERROR_TYPE (agent_error_get_type()) 
+
+static GQuark agent_error_quark(void)
+{
+	static GQuark quark = 0;
+	if (!quark)
+		quark = g_quark_from_static_string("agent");
+
+	return quark;
+}
+
+static GList *input_list = NULL;
+
+struct input_data {
+	char *path;
+	char *address;
+	char *service;
+	char *uuid;
+	DBusGMethodInvocation *context;
+	GtkWidget *dialog;
+	GtkWidget *button;
+	GtkWidget *entry;
+};
+
+static gint input_compare(gconstpointer a, gconstpointer b)
+{
+	struct input_data *a_data = (struct input_data *) a;
+	struct input_data *b_data = (struct input_data *) b;
+
+	return g_ascii_strcasecmp(a_data->address, b_data->address);
+}
+
+static void input_free(struct input_data *input)
+{
+	gtk_widget_destroy(input->dialog);
+
+	g_free(input->uuid);
+	g_free(input->service);
+	g_free(input->address);
+	g_free(input->path);
+	g_free(input);
+}
+
+static void passkey_callback(GtkWidget *dialog,
+				gint response, gpointer user_data)
+{
+	struct input_data *input = user_data;
+
+	if (response == GTK_RESPONSE_ACCEPT) {
+		const char *passkey;
+		passkey = gtk_entry_get_text(GTK_ENTRY(input->entry));
+		dbus_g_method_return(input->context, passkey);
+	} else {
+		GError *error;
+		error = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+						_("Pairing request rejected"));
+		dbus_g_method_return_error(input->context, error);
+	}
+
+	input_free(input);
+}
+
+static void changed_callback(GtkWidget *editable, gpointer user_data)
+{
+	struct input_data *input = user_data;
+	const gchar *text;
+
+	text = gtk_entry_get_text(GTK_ENTRY(input->entry));
+
+	gtk_widget_set_sensitive(input->button, *text != '\0' ? TRUE : FALSE);
+}
+
+static void toggled_callback(GtkWidget *button, gpointer user_data)
+{
+	struct input_data *input = user_data;
+	gboolean mode;
+
+	mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+
+	gtk_entry_set_visibility(GTK_ENTRY(input->entry), mode);
+}
+
+static void passkey_dialog(const char *path, const char *address,
+			const gchar *device, DBusGMethodInvocation *context)
+{
+	GtkWidget *dialog;
+	GtkWidget *button;
+	GtkWidget *image;
+	GtkWidget *label;
+	GtkWidget *entry;
+	GtkWidget *table;
+	GtkWidget *vbox;
+	struct input_data *input;
+	gchar *markup;
+
+	input = g_try_malloc0(sizeof(*input));
+	if (!input)
+		return;
+
+	input->path = g_strdup(path);
+	input->address = g_strdup(address);
+
+	input->context = context;
+
+	dialog = gtk_dialog_new();
+
+	gtk_window_set_title(GTK_WINDOW(dialog), _("Authentication request"));
+
+	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+
+	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+
+	gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+
+	gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
+
+	gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+
+	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_dialog));
+
+	input->dialog = dialog;
+
+	button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+				GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+
+	button = gtk_dialog_add_button(GTK_DIALOG(dialog),
+					GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+
+	gtk_widget_grab_default(button);
+
+	gtk_widget_set_sensitive(button, FALSE);
+
+	input->button = button;
+
+	table = gtk_table_new(5, 2, FALSE);
+
+	gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+	gtk_table_set_col_spacings(GTK_TABLE(table), 20);
+
+	gtk_container_set_border_width(GTK_CONTAINER(table), 12);
+
+	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+
+	image = gtk_image_new_from_icon_name(GTK_STOCK_DIALOG_AUTHENTICATION,
+							GTK_ICON_SIZE_DIALOG);
+
+	gtk_misc_set_alignment(GTK_MISC(image), 0.0, 0.0);
+
+	gtk_table_attach(GTK_TABLE(table), image, 0, 1, 0, 5,
+						GTK_SHRINK, GTK_FILL, 0, 0);
+
+	vbox = gtk_vbox_new(FALSE, 6);
+
+	label = gtk_label_new(_("Pairing request for device:"));
+
+	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+	gtk_container_add(GTK_CONTAINER(vbox), label);
+
+	gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 0, 1,
+				GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+	label = gtk_label_new(NULL);
+
+	markup = g_strdup_printf("<b>%s</b>", device);
+	gtk_label_set_markup(GTK_LABEL(label), markup);
+	g_free(markup);
+
+	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+
+	gtk_label_set_selectable(GTK_LABEL(label), TRUE);
+
+	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+	gtk_widget_set_size_request(GTK_WIDGET(label), 280, -1);
+
+	gtk_container_add(GTK_CONTAINER(vbox), label);
+
+	vbox = gtk_vbox_new(FALSE, 6);
+
+	label = gtk_label_new(_("Enter passkey for authentication:"));
+
+	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+
+	gtk_container_add(GTK_CONTAINER(vbox), label);
+
+	gtk_table_attach(GTK_TABLE(table), vbox, 1, 2, 2, 3,
+				GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+
+	entry = gtk_entry_new();
+
+	gtk_entry_set_max_length(GTK_ENTRY(entry), 16);
+
+	gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+
+	gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
+
+	input->entry = entry;
+
+	g_signal_connect(G_OBJECT(entry), "changed",
+				G_CALLBACK(changed_callback), input);
+
+	gtk_container_add(GTK_CONTAINER(vbox), entry);
+
+	button = gtk_check_button_new_with_label(_("Show input"));
+
+	g_signal_connect(G_OBJECT(button), "toggled",
+				G_CALLBACK(toggled_callback), input);
+
+	gtk_container_add(GTK_CONTAINER(vbox), button);
+
+	input_list = g_list_append(input_list, input);
+	gtk_widget_show_all(dialog);
+	gtk_window_present(GTK_WINDOW(dialog));
+
+	g_signal_connect(G_OBJECT(dialog), "response",
+				G_CALLBACK(passkey_callback), input);
+}
+
+static gboolean passkey_agent_request(GObject *agent,
+				const char *path, const char *address,
+					DBusGMethodInvocation *context)
+{
+	BluetoothClient *client = BLUETOOTH_CLIENT(agent);
+	const char *name = NULL;
+	gchar *device;
+
+	name = bluetooth_client_get_name(client, path);
+
+	if (name) {
+		if (g_strrstr(name, address))
+			device = g_strdup(name);
+		else
+			device = g_strdup_printf("%s (%s)", name, address);
+	} else
+		device = g_strdup(address);
+
+	passkey_dialog(path, address, device, context);
+
+	g_free(device);
+	return TRUE;
+}
+
+static gboolean passkey_agent_cancel(GObject *agent,
+			const char *path, const char *address, GError **error)
+{
+	GList *list;
+	GError *result;
+	struct input_data *input;
+
+	input = g_try_malloc0(sizeof(*input));
+	if (!input)
+		return FALSE;
+
+	input->path = g_strdup(path);
+	input->address = g_strdup(address);
+
+	list = g_list_find_custom(input_list, input, input_compare);
+
+	g_free(input->address);
+	g_free(input->path);
+	g_free(input);
+
+	if (!list || !list->data)
+		return FALSE;
+
+	input = list->data;
+
+	result = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
+						_("Agent callback canceled"));
+
+	dbus_g_method_return_error(input->context, result);
+
+	input_free(input);
+
+	return TRUE;
+}
+
+static gboolean passkey_agent_release(GObject *agent, GError **error)
+{
+	return TRUE;
+}
+
+#include "passkey-agent-glue.h"
+
+void set_agent_parent_window(GtkWidget *window)
+{
+	main_dialog = window;
+}
+
+gboolean register_agent(BluetoothClient *client,
+						const char *path, const char *address)
+{
+	return bluetooth_client_register_passkey_agent(client, path, address, &dbus_glib_passkey_agent_object_info);
+}
+
diff -uprN ../bluez-gnome-services/wizard/agent.h ./wizard/agent.h
--- ../bluez-gnome-services/wizard/agent.h	1969-12-31 19:00:00.000000000 -0500
+++ ./wizard/agent.h	2008-06-30 09:56:45.000000000 -0400
@@ -0,0 +1,30 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2005-2008  Marcel Holtmann <marcel@xxxxxxxxxxxx>
+ *  Copyright (C) 2006-2007  Bastien Nocera <hadess@xxxxxxxxxx>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
diff -uprN ../bluez-gnome-services/wizard/main.c ./wizard/main.c
--- ../bluez-gnome-services/wizard/main.c	2008-06-30 09:27:23.000000000 -0400
+++ ./wizard/main.c	2008-06-30 10:04:29.000000000 -0400
@@ -32,6 +32,7 @@
 #include <gtk/gtk.h>
 
 #include "client.h"
+#include "agent.h"
 
 #include "dbus-glue.h"
 
@@ -41,93 +42,140 @@
 static gboolean singleton = FALSE;
 
 static BluetoothClient *client;
+static DBusGProxyCall *call = NULL;
 
 static gchar *address = NULL;
-static gchar *passkey = "123456";
 
+static GtkWidget *page_prev = NULL;
 static GtkWidget *page_search = NULL;
-static GtkWidget *page_info = NULL;
 static GtkWidget *page_pairing = NULL;
+static GtkWidget *page_info = NULL;
 static GtkWidget *page_summary = NULL;
+static int page_summary_num = 0;
 
-static GtkWidget *label_pairing = NULL;
-static GtkWidget *label_passkey = NULL;
+static GtkWidget *pairing_progress = NULL;
+static guint pairing_progress_timeout = 0;
+static GtkWidget *pairing_message = NULL;
 
+static GSList *type_group = NULL;
 static GtkWidget *selector = NULL;
 
-static gboolean passkey_agent_request(GObject *agent,
-				const char *path, const char *address,
-					DBusGMethodInvocation *context)
-{
-	const char *value = passkey;
-
-	/* Apple Wireless and Mighty Mouse */
-	if (g_str_has_prefix(address, "00:0A:95:") == TRUE ||
-				g_str_has_prefix(address, "00:14:51:") == TRUE)
-		value = "0000";
-
-	dbus_g_method_return(context, value);
+static void close_callback(GtkWidget *assistant, gpointer data)
+{
+	gtk_widget_destroy(assistant);
 
-	return TRUE;
+	gtk_main_quit();
 }
 
-static gboolean passkey_agent_cancel(GObject *agent,
-			const char *path, const char *address, GError **error)
+static void cancel_callback(GtkWidget *assistant, gpointer data)
 {
-	return TRUE;
+	gtk_widget_destroy(assistant);
+
+	gtk_main_quit();
 }
 
-static gboolean passkey_agent_release(GObject *agent, GError **error)
+static gint selected_type(void)
 {
-	return TRUE;
+	GSList *iter;
+	for (iter = type_group; iter; iter = iter->next) {
+		GtkToggleButton *button = GTK_TOGGLE_BUTTON(iter->data);
+		if (gtk_toggle_button_get_active(button)) {
+			gpointer data = g_object_get_data(G_OBJECT(button), "bluez-type");
+			return GPOINTER_TO_INT(data);
+		}
+	}
+	return BLUETOOTH_TYPE_ANY;
 }
+ 
+static void show_pairing_error(GError *error)
+{
+	gchar *msg;
+	const gchar *errmsg;
 
-#include "passkey-agent-glue.h"
+	gtk_widget_hide(pairing_progress);
+	if (pairing_progress_timeout > 0) {
+		g_source_remove(pairing_progress_timeout);
+		pairing_progress_timeout = 0;
+	}
 
-#if 0
-static gint page_forward(gint current_page, gpointer data)
-{
-	return current_page + 1;
+	if (!error)
+		errmsg = _("Could not contact bluetooth service");
+	else
+		errmsg = error->message;
+
+	msg = g_strdup_printf("<b>%s</b>\n\n%s", _("Cannot connect to device:"), errmsg);
+	gtk_label_set_markup(GTK_LABEL(pairing_message), msg);
+	gtk_widget_show(pairing_message);
+	g_free(msg);
 }
-#endif
 
-static void close_callback(GtkWidget *assistant, gpointer data)
+static void trusted_callback(GError *error, gpointer data)
 {
-	gtk_widget_destroy(assistant);
+	GtkAssistant *assistant = GTK_ASSISTANT(data);
 
-	gtk_main_quit();
+	gtk_widget_hide(pairing_progress);
+	if (pairing_progress_timeout > 0) {
+		g_source_remove(pairing_progress_timeout);
+		pairing_progress_timeout = 0;
+	}
+
+	if (error) {
+		show_pairing_error(error);
+	}
+	else {
+		gtk_assistant_set_page_complete(assistant, page_pairing, TRUE);
+		gtk_assistant_set_current_page(assistant, page_summary_num); /* jump to summary */
+	}
 }
 
-static void cancel_callback(GtkWidget *assistant, gpointer data)
+static void connect_callback(GError *error, gpointer data)
 {
-	gtk_widget_destroy(assistant);
+	if (error || !bluetooth_client_set_trusted(client, NULL, address, trusted_callback, data))
+		show_pairing_error(error);
+}
 
-	gtk_main_quit();
+static gboolean pulse_progress(gpointer data)
+{
+	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pairing_progress));
+	return TRUE;
 }
 
 static void prepare_callback(GtkWidget *assistant,
 				GtkWidget *page, gpointer data)
 {
+	gboolean complete = TRUE;
+
 	if (page == page_search) {
+		gint type = selected_type();
+		g_object_set(G_OBJECT(selector), "device-type-filter", type, NULL);
 		bluetooth_device_selection_start_discovery(BLUETOOTH_DEVICE_SELECTION(selector));
-		return;
+		if (address)
+			bluetooth_client_cancel_call(client, NULL, address);
+		complete = address != NULL;
 	}
-
-	if (page == page_pairing) {
+	else if (page == page_pairing) {
 		bluetooth_client_cancel_discovery(client, NULL);
 
-		bluetooth_client_register_passkey_agent(client,
-					"/org/bluez/applet", address,
-					&dbus_glib_passkey_agent_object_info);
-
-		bluetooth_client_create_bonding(client, NULL, address);
-
-		gtk_label_set_markup(GTK_LABEL(label_pairing), address);
-		gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);
-		return;
+		register_agent(client, "/org/bluez/applet", address);
+
+		if (page_prev == page_search) {
+			pairing_progress_timeout = g_timeout_add(100, pulse_progress, pairing_progress);
+			gtk_widget_show(pairing_progress);
+			gtk_widget_hide(pairing_message);
+			complete = FALSE;
+			if (!bluetooth_client_connect(client, selected_type(), NULL, address,
+			                              connect_callback, assistant))
+				show_pairing_error(NULL);
+		}
+	}
+
+	if (page != page_pairing && pairing_progress_timeout > 0) {
+		g_source_remove(pairing_progress_timeout);
+		pairing_progress_timeout = 0;
 	}
 
-	gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, TRUE);
+	gtk_assistant_set_page_complete(GTK_ASSISTANT(assistant), page, complete);
+	page_prev = page;
 }
 
 static GtkWidget *create_vbox(GtkWidget *assistant, GtkAssistantPageType type,
@@ -180,56 +228,6 @@ static GtkWidget *create_vbox(GtkWidget 
 	return vbox;
 }
 
-static void create_intro(GtkWidget *assistant)
-{
-	GtkWidget *vbox;
-	GtkWidget *label;
-	GtkWidget *combo;
-	GtkTreeModel *model;
-	GtkCellRenderer *renderer;
-
-	vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_INTRO,
-			_("Introduction"),
-			_("Welcome to the Bluetooth device setup wizard"));
-
-	label = gtk_label_new(NULL);
-
-	gtk_label_set_markup(GTK_LABEL(label), _("The device wizard will "
-				"walk you through the process of configuring "
-				"Bluetooth enabled devices for use with this "
-				"computer.\n\n"));
-
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-
-	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
-
-	gtk_widget_set_size_request(GTK_WIDGET(label), 380, -1);
-
-	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
-	combo = gtk_combo_box_new();
-
-	model = bluetooth_client_get_model_adapter_list(client);
-
-	gtk_combo_box_set_model(GTK_COMBO_BOX(combo), model);
-
-	g_object_unref(model);
-
-	gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
-
-	gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo));
-
-	renderer = gtk_cell_renderer_text_new();
-
-	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
-
-	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer,
-						"text", COLUMN_NAME, NULL);
-
-	if (gtk_tree_model_iter_n_children(model, NULL) > 1)
-		gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
-}
-
 static void create_type(GtkWidget *assistant)
 {
 	GtkWidget *vbox;
@@ -238,55 +236,24 @@ static void create_type(GtkWidget *assis
 
 	vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
 			_("Device type"),
-			_("Select the type of device you want to setup"));
-
-	button = gtk_radio_button_new_with_label(group, _("Mouse"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
-	//gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+			_("Select the type of device you want to connect"));
 
+	button = gtk_radio_button_new_with_label(NULL, _("Mouse"));
+	g_object_set_data(G_OBJECT(button),
+	                  "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_MOUSE));
 	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
-	button = gtk_radio_button_new_with_label(group, _("Keyboard"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
-	//gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+	button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Keyboard"));
+	g_object_set_data(G_OBJECT(button),
+	                  "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_KEYBOARD));
 	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
-	button = gtk_radio_button_new_with_label(group, _("Mobile phone"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
-	gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
-	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
-	button = gtk_radio_button_new_with_label(group, _("Printer"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
-	gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
-	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
-
-	button = gtk_radio_button_new_with_label(group, _("Headset"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
-	gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
-
+	button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), _("Headset"));
+	g_object_set_data(G_OBJECT(button),
+	                  "bluez-type", GINT_TO_POINTER(BLUETOOTH_TYPE_HEADSET));
 	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
-	button = gtk_radio_button_new_with_label(group, _("Any device"));
-
-	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
-
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
-	gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+	type_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
 }
 
 static void select_callback(BluetoothDeviceSelection *sel,
@@ -310,7 +277,7 @@ static void create_search(GtkWidget *ass
 
 	vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
 				_("Device search"),
-				_("Select the device you want to setup"));
+				_("Select the device you want to connect"));
 
 	selector = bluetooth_device_selection_new(NULL);
 
@@ -327,48 +294,31 @@ static void create_search(GtkWidget *ass
 	page_search = vbox;
 }
 
-static void create_info(GtkWidget *assistant)
-{
-	GtkWidget *vbox;
-	GtkWidget *label;
-
-	vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
-				_("Device information"),
-				_("Gathering information about device"));
-
-	label = gtk_label_new(NULL);
-
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-
-	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
-	page_info = vbox;
-}
-
 static void create_pairing(GtkWidget *assistant)
 {
 	GtkWidget *vbox;
 	GtkWidget *label;
+	GtkWidget *progress;
 
 	vbox = create_vbox(assistant, GTK_ASSISTANT_PAGE_CONTENT,
-				_("Device pairing"),
-				_("Pairing with new device"));
+				_("Device connection"),
+				_("Connecting with new device"));
 
-	label = gtk_label_new(NULL);
+	progress = gtk_progress_bar_new();
 
-	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), progress, FALSE, TRUE, 0);
 
-	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
-	label_pairing = label;
+	pairing_progress = progress;
 
 	label = gtk_label_new(NULL);
+	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+	gtk_label_set_selectable(GTK_LABEL(label), TRUE);
 
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 
 	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
 
-	label_passkey = label;
+	pairing_message = label;
 
 	page_pairing = vbox;
 }
@@ -381,6 +331,8 @@ static void create_summary(GtkWidget *as
 				_("Summary"),
 				_("Succesfully configured new device"));
 
+	page_summary_num = gtk_assistant_get_n_pages(GTK_ASSISTANT(assistant)) - 1;
+
 	page_summary = vbox;
 }
 
@@ -401,14 +353,10 @@ static GtkWidget *create_wizard(void)
 						page_forward, NULL, NULL);
 #endif
 
-	create_intro(assistant);
-
 	create_type(assistant);
 
 	create_search(assistant);
 
-	create_info(assistant);
-
 	create_pairing(assistant);
 
 	create_summary(assistant);
@@ -465,6 +413,7 @@ int main(int argc, char *argv[])
 	client = bluetooth_client_new();
 
 	window = create_wizard();
+	set_agent_parent_window(window);
 
 	bluetooth_instance_set_window(instance, GTK_WINDOW(window));
 
diff -uprN ../bluez-gnome-services/wizard/Makefile.am ./wizard/Makefile.am
--- ../bluez-gnome-services/wizard/Makefile.am	2008-06-30 09:27:23.000000000 -0400
+++ ./wizard/Makefile.am	2008-06-30 10:02:35.000000000 -0400
@@ -1,7 +1,7 @@
 
-noinst_PROGRAMS = bluetooth-wizard
+bin_PROGRAMS = bluetooth-wizard
 
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
 
 bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
 		$(top_builddir)/common/libcommon.a
@@ -13,8 +13,8 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GTK_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_builddir)/common
 
-noinst_MANS = bluetooth-wizard.1
+man_MANS = bluetooth-wizard.1
 
-EXTRA_DIST = $(noinst_MANS)
+EXTRA_DIST = $(man_MANS)
 
 MAINTAINERCLEANFILES = Makefile.in
diff -upr ../bluez-gnome-services/po/POTFILES.in ./po/POTFILES.in
--- ../bluez-gnome-services/po/POTFILES.in	2008-06-30 09:27:23.000000000 -0400
+++ ./po/POTFILES.in	2008-06-30 11:34:33.000000000 -0400
@@ -22,3 +22,5 @@ analyzer/dialog.c
 analyzer/tracer.c
 analyzer/bluetooth-analyzer.desktop.in
 analyzer/bluetooth-manager.xml.in
+wizard/agent.c
+wizard/main.c

Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
Bluez-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bluez-devel

[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux