diff options
author | Bastien Nocera <hadess@hadess.net> | 2016-01-10 15:51:25 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2016-01-10 16:00:20 +0100 |
commit | 64b1281d245843a772a559239850ac3af50e030d (patch) | |
tree | c85e9eea6825a43b2a35effcc4a9a34ede391023 | |
parent | 16fc8c0d4b24699e3e047dda1bdee0a919f908e4 (diff) | |
download | gnome-control-center-64b1281d245843a772a559239850ac3af50e030d.tar.gz |
bluetooth: Don't change the switch status when transitioning
When transitioning from an enabled platform rfkill to disabled, the
Bluetooth adapter's power will lag behind. Make sure to not change the
switch's status when we get into this temporary state.
https://bugzilla.gnome.org/show_bug.cgi?id=760168
-rw-r--r-- | panels/bluetooth/cc-bluetooth-panel.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/panels/bluetooth/cc-bluetooth-panel.c b/panels/bluetooth/cc-bluetooth-panel.c index 61e96f1f9..e5d4cbc3a 100644 --- a/panels/bluetooth/cc-bluetooth-panel.c +++ b/panels/bluetooth/cc-bluetooth-panel.c @@ -134,12 +134,14 @@ static void cc_bluetooth_panel_update_power (CcBluetoothPanel *self) { GObject *toggle; - gboolean sensitive, powered; + gboolean sensitive, powered, change_powered; const char *page; g_debug ("Updating airplane mode: has_airplane_mode %d, hardware_airplane_mode %d, BT airplane_mode %d, airplane_mode %d", self->priv->has_airplane_mode, self->priv->hardware_airplane_mode, self->priv->bt_airplane_mode, self->priv->airplane_mode); + change_powered = TRUE; + if (self->priv->has_airplane_mode == FALSE) { g_debug ("No Bluetooth available"); sensitive = FALSE; @@ -159,7 +161,7 @@ cc_bluetooth_panel_update_power (CcBluetoothPanel *self) !bluetooth_settings_widget_get_default_adapter_powered (BLUETOOTH_SETTINGS_WIDGET (self->priv->widget))) { g_debug ("Default adapter is unpowered, but should be available"); sensitive = TRUE; - powered = FALSE; + change_powered = FALSE; page = BLUETOOTH_DISABLED_PAGE; } else { g_debug ("Bluetooth is available and powered"); @@ -171,9 +173,11 @@ cc_bluetooth_panel_update_power (CcBluetoothPanel *self) gtk_widget_set_sensitive (WID ("box_power") , sensitive); toggle = G_OBJECT (WID ("switch_bluetooth")); - g_signal_handlers_block_by_func (toggle, power_callback, self); - gtk_switch_set_active (GTK_SWITCH (toggle), powered); - g_signal_handlers_unblock_by_func (toggle, power_callback, self); + if (change_powered) { + g_signal_handlers_block_by_func (toggle, power_callback, self); + gtk_switch_set_active (GTK_SWITCH (toggle), powered); + g_signal_handlers_unblock_by_func (toggle, power_callback, self); + } gtk_stack_set_visible_child_name (GTK_STACK (self->priv->stack), page); } @@ -341,6 +345,8 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self) airplane_mode_changed (NULL, NULL, NULL, self); g_signal_connect (self->priv->rfkill, "g-properties-changed", G_CALLBACK (airplane_mode_changed), self); + g_signal_connect_swapped (G_OBJECT (self->priv->widget), "adapter-status-changed", + G_CALLBACK (cc_bluetooth_panel_update_power), self); g_signal_connect (G_OBJECT (WID ("switch_bluetooth")), "notify::active", G_CALLBACK (power_callback), self); |