[gnome-bluetooth] settings: Defer pairing when the name isn't known yet
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] settings: Defer pairing when the name isn't known yet
- Date: Sat, 7 Dec 2013 10:31:18 +0000 (UTC)
commit 414881b62e5d9ed6c73f07c0e8e7e6a175cec770
Author: Bastien Nocera <hadess hadess net>
Date: Sat Dec 7 10:24:05 2013 +0100
settings: Defer pairing when the name isn't known yet
lib/bluetooth-settings-widget.c | 41 +++++++++++++++++++++++++++++++++-----
1 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 5223f66..2d3858c 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -698,6 +698,29 @@ create_callback (GObject *source_object,
//gtk_assistant_set_current_page (window_assistant, PAGE_FINISHING);
}
+static void start_pairing (BluetoothSettingsWidget *self,
+ GtkListBoxRow *row);
+
+static void
+device_name_appeared (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ char *name;
+
+ g_object_get (G_OBJECT (gobject),
+ "name", &name,
+ NULL);
+ if (!name)
+ return;
+
+ g_debug ("Pairing device name is now '%s'", name);
+ start_pairing (user_data, GTK_LIST_BOX_ROW (gobject));
+ g_free (name);
+
+ g_signal_handlers_disconnect_by_func (gobject, device_name_appeared, user_data);
+}
+
static void
start_pairing (BluetoothSettingsWidget *self,
GtkListBoxRow *row)
@@ -718,6 +741,18 @@ start_pairing (BluetoothSettingsWidget *self,
"legacy-pairing", &legacy_pairing,
NULL);
+ if (name == NULL) {
+ g_debug ("No name yet, will start pairing later");
+ g_signal_connect (G_OBJECT (row), "notify::name",
+ G_CALLBACK (device_name_appeared), self);
+ g_object_unref (proxy);
+ g_free (bdaddr);
+ g_free (name);
+ return;
+ }
+
+ g_debug ("Starting pairing for '%s'", name);
+
if (legacy_pairing) {
const char *pincode;
@@ -1233,12 +1268,6 @@ activate_row (BluetoothSettingsWidget *self,
gtk_window_set_modal (GTK_WINDOW (w), TRUE);
gtk_window_present (GTK_WINDOW (w));
} else {
- char *name;
-
- g_object_get (G_OBJECT (row), "name", &name, NULL);
- g_debug ("Start pairing '%s'", name);
- g_free (name);
-
start_pairing (self, row);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]