[gnome-bluetooth/wip/hadess/remove-gtk-tree: 8/19] lib: Remove GtkTreeModel usage when selecting new default adapter
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/hadess/remove-gtk-tree: 8/19] lib: Remove GtkTreeModel usage when selecting new default adapter
- Date: Wed, 1 Dec 2021 16:43:24 +0000 (UTC)
commit 9feb344f375e91e222b28a420b7d86cef04caa71
Author: Bastien Nocera <hadess hadess net>
Date: Wed Dec 1 15:43:39 2021 +0100
lib: Remove GtkTreeModel usage when selecting new default adapter
lib/bluetooth-client.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 4a58fe64..d05d8452 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -791,6 +791,8 @@ adapter_removed (GDBusObjectManager *manager,
BluetoothClient *client)
{
GtkTreeIter iter, childiter;
+ g_autoptr(GDBusProxy) new_default_adapter = NULL;
+ GList *object_list, *l;
gboolean was_default = FALSE;
gboolean have_child;
@@ -824,16 +826,22 @@ adapter_removed (GDBusObjectManager *manager,
g_clear_object (&client->default_adapter);
gtk_tree_store_remove (client->store, &iter);
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(client->store),
- &iter)) {
- GDBusProxy *adapter;
-
- gtk_tree_model_get (GTK_TREE_MODEL(client->store), &iter,
- BLUETOOTH_COLUMN_PROXY, &adapter, -1);
+ new_default_adapter = NULL;
+ object_list = g_dbus_object_manager_get_objects (client->manager);
+ for (l = object_list; l != NULL; l = l->next) {
+ GDBusObject *object = l->data;
+ GDBusInterface *iface;
- default_adapter_changed (manager, adapter, client);
+ iface = g_dbus_object_get_interface (object, BLUEZ_ADAPTER_INTERFACE);
+ if (iface) {
+ new_default_adapter = G_DBUS_PROXY (g_object_ref (iface));
+ break;
+ }
+ }
+ g_list_free_full (object_list, g_object_unref);
- g_object_unref(adapter);
+ if (new_default_adapter) {
+ default_adapter_changed (manager, new_default_adapter, client);
} else {
g_object_notify (G_OBJECT (client), "default-adapter");
g_object_notify (G_OBJECT (client), "default-adapter-powered");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]