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
This commit is contained in:
parent
80c2739d27
commit
9818f3b256
1 changed files with 25 additions and 7 deletions
|
@ -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
|
||||
|
@ -738,13 +731,35 @@ cc_bluetooth_panel_update_state (CcBluetoothPanel *self)
|
|||
g_free (bdaddr);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue