[gnome-bluetooth/wip/hadess/bluetooth-off-turn-off] lib: Fix "Bluetooth Off/Turn Off" wedged state in gnome-shell
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/hadess/bluetooth-off-turn-off] lib: Fix "Bluetooth Off/Turn Off" wedged state in gnome-shell
- Date: Fri, 10 Dec 2021 10:03:46 +0000 (UTC)
commit aeacc445dd37d93925530dbfc98a60011f631571
Author: Bastien Nocera <hadess hadess net>
Date: Fri Dec 10 10:59:53 2021 +0100
lib: Fix "Bluetooth Off/Turn Off" wedged state in gnome-shell
When the adapter was set to be the new default, nothing was telling
gnome-shell, which only listens to the "row-changed" signals for
updates, that there was a new default adapter, so it was stuck in the
off position ("Bluetooth Off" menu header), but rfkill correctly said
that a Bluetooth adapter was available and offering to turn it off
("Turn Off").
lib/bluetooth-client.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 367bdc13..1fe3f4ad 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -519,8 +519,8 @@ default_adapter_changed (GDBusObjectManager *manager,
{
BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
GtkTreeIter iter;
- GtkTreePath *tree_path;
- gboolean powered;
+ g_autoptr(GtkTreePath) tree_path = NULL;
+ gboolean powered, is_default;
g_assert (!priv->default_adapter);
@@ -529,13 +529,16 @@ default_adapter_changed (GDBusObjectManager *manager,
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
priv->default_adapter = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->store), tree_path);
- gtk_tree_path_free (tree_path);
-
- gtk_tree_store_set (priv->store, &iter,
- BLUETOOTH_COLUMN_DEFAULT, TRUE, -1);
gtk_tree_model_get (GTK_TREE_MODEL(priv->store), &iter,
- BLUETOOTH_COLUMN_POWERED, &powered, -1);
+ BLUETOOTH_COLUMN_DEFAULT, &is_default,
+ BLUETOOTH_COLUMN_POWERED, &powered, -1);
+
+ if (!is_default) {
+ gtk_tree_store_set (priv->store, &iter,
+ BLUETOOTH_COLUMN_DEFAULT, TRUE, -1);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (priv->store), tree_path, &iter);
+ }
if (powered) {
g_object_notify (G_OBJECT (client), "default-adapter");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]