diff options
author | Bastien Nocera <hadess@hadess.net> | 2016-11-29 17:45:49 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2016-11-29 18:23:33 +0100 |
commit | 307ec495493bc255b55edf035e08c11b188df23b (patch) | |
tree | 80aff0f24cdc7bc6349cc064c9c8832439bf2093 | |
parent | e9ca301c332697d9f0e2f0854e415e462299d1cd (diff) | |
download | gnome-bluetooth-307ec495493bc255b55edf035e08c11b188df23b.tar.gz |
lib: Make row unsensitive when device cannot be paired
We need the name to not start pairing with another device than the
intended one, as the device type usually shows up before its name.
-rw-r--r-- | lib/bluetooth-settings-row.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/bluetooth-settings-row.c b/lib/bluetooth-settings-row.c index 9704cdac..ff8c523b 100644 --- a/lib/bluetooth-settings-row.c +++ b/lib/bluetooth-settings-row.c @@ -159,6 +159,21 @@ bluetooth_settings_row_get_property (GObject *object, } static void +update_row (BluetoothSettingsRow *self) +{ + BluetoothSettingsRowPrivate *priv = BLUETOOTH_SETTINGS_ROW_GET_PRIVATE (self); + + if (priv->name == NULL) { + gtk_label_set_text (GTK_LABEL (priv->label), + bluetooth_type_to_string (priv->type)); + gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE); + } else { + gtk_label_set_text (GTK_LABEL (priv->label), priv->name); + gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE); + } +} + +static void bluetooth_settings_row_set_property (GObject *object, guint property_id, const GValue *value, @@ -182,10 +197,7 @@ bluetooth_settings_row_set_property (GObject *object, break; case PROP_TYPE: priv->type = g_value_get_flags (value); - if (priv->name == NULL) { - gtk_label_set_text (GTK_LABEL (priv->label), - bluetooth_type_to_string (priv->type)); - } + update_row (self); break; case PROP_CONNECTED: priv->connected = g_value_get_boolean (value); @@ -194,8 +206,7 @@ bluetooth_settings_row_set_property (GObject *object, case PROP_NAME: g_free (priv->name); priv->name = g_value_dup_string (value); - if (priv->name != NULL) - gtk_label_set_text (GTK_LABEL (priv->label), priv->name); + update_row (self); break; case PROP_ADDRESS: g_free (priv->bdaddr); |