[gnome-control-center] bluetooth: Fix main switch acting bizarrely
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] bluetooth: Fix main switch acting bizarrely
- Date: Thu, 8 Nov 2012 17:38:42 +0000 (UTC)
commit 9818f3b25620ffa180726ac2c20abc3abce374f4
Author: Bastien Nocera <hadess hadess net>
Date: Thu Nov 8 18:31:07 2012 +0100
bluetooth: Fix main switch acting bizarrely
The only time we were looking at the powered state of the adapter
is when the killswitch state was changing. Except that we're fast enough
that bluetoothd didn't have time to power up the adapter, so its
state was unpowered, which we would set the switch to.
The switch was off, the adapter was on.
We fix that problem by tracking the powered state of the adapter
separately.
https://bugzilla.redhat.com/show_bug.cgi?id=841881
panels/bluetooth/cc-bluetooth-panel.c | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/panels/bluetooth/cc-bluetooth-panel.c b/panels/bluetooth/cc-bluetooth-panel.c
index bfad56e..455a21f 100644
--- a/panels/bluetooth/cc-bluetooth-panel.c
+++ b/panels/bluetooth/cc-bluetooth-panel.c
@@ -418,7 +418,6 @@ cc_bluetooth_panel_update_power (CcBluetoothPanel *self)
BluetoothKillswitchState state;
char *path;
gboolean powered, sensitive;
- GtkSwitch *button;
g_object_get (G_OBJECT (self->priv->client),
"default-adapter", &path,
@@ -455,12 +454,6 @@ cc_bluetooth_panel_update_power (CcBluetoothPanel *self)
g_free (path);
gtk_widget_set_sensitive (WID ("box_power") , sensitive);
gtk_widget_set_sensitive (WID ("box_vis") , sensitive);
-
- button = GTK_SWITCH (WID ("switch_bluetooth"));
-
- g_signal_handlers_block_by_func (button, power_callback, self);
- gtk_switch_set_active (button, powered);
- g_signal_handlers_unblock_by_func (button, power_callback, self);
}
static void
@@ -739,12 +732,34 @@ cc_bluetooth_panel_update_state (CcBluetoothPanel *self)
}
static void
+cc_bluetooth_panel_update_powered_state (CcBluetoothPanel *self)
+{
+ gboolean powered;
+
+ g_object_get (G_OBJECT (self->priv->client),
+ "default-adapter-powered", &powered,
+ NULL);
+ gtk_switch_set_active (GTK_SWITCH (WID ("switch_bluetooth")), powered);
+}
+
+static void
+default_adapter_power_changed (BluetoothClient *client,
+ GParamSpec *spec,
+ CcBluetoothPanel *self)
+{
+ g_debug ("Default adapter power changed");
+ cc_bluetooth_panel_update_powered_state (self);
+}
+
+static void
default_adapter_changed (BluetoothClient *client,
GParamSpec *spec,
CcBluetoothPanel *self)
{
+ g_debug ("Default adapter changed");
cc_bluetooth_panel_update_state (self);
cc_bluetooth_panel_update_power (self);
+ cc_bluetooth_panel_update_powered_state (self);
}
static void
@@ -752,6 +767,7 @@ killswitch_changed (BluetoothKillswitch *killswitch,
BluetoothKillswitchState state,
CcBluetoothPanel *self)
{
+ g_debug ("Killswitch changed to state '%s' (%d)", bluetooth_killswitch_state_to_string (state) , state);
cc_bluetooth_panel_update_state (self);
cc_bluetooth_panel_update_power (self);
}
@@ -792,6 +808,8 @@ cc_bluetooth_panel_init (CcBluetoothPanel *self)
cc_bluetooth_panel_update_state (self);
g_signal_connect (G_OBJECT (self->priv->client), "notify::default-adapter",
G_CALLBACK (default_adapter_changed), self);
+ g_signal_connect (G_OBJECT (self->priv->client), "notify::default-adapter-powered",
+ G_CALLBACK (default_adapter_power_changed), self);
/* The discoverable button */
cc_bluetooth_panel_update_visibility (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]