diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-12-07 10:24:05 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2013-12-07 11:11:38 +0100 |
commit | 414881b62e5d9ed6c73f07c0e8e7e6a175cec770 (patch) | |
tree | 94d4b83ed51ea1f0791dc203f00aad86a2649b1b | |
parent | 48825fff99e11ef097838db11b5cfff05af404db (diff) | |
download | gnome-bluetooth-414881b62e5d9ed6c73f07c0e8e7e6a175cec770.tar.gz |
settings: Defer pairing when the name isn't known yet
-rw-r--r-- | 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 5223f665..2d3858c7 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); } } |