[gnome-bluetooth/wip/hadess/remove-gtk-tree: 11/19] lib: Use GListModel in _set_trusted()




commit 1b141694188a38e1cd32a6a512558050ef48056b
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Dec 1 16:00:25 2021 +0100

    lib: Use GListModel in _set_trusted()

 lib/bluetooth-client.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 37db9de9..20af2d23 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1481,25 +1481,23 @@ bluetooth_client_set_trusted (BluetoothClient *client,
                              const char      *device_path,
                              gboolean         trusted)
 {
-       GObject *device;
-       GtkTreeIter iter;
+       g_autoptr(BluetoothDevice) device = NULL;
+       g_autoptr(GDBusProxy) proxy = NULL;
 
        g_return_val_if_fail (BLUETOOTH_IS_CLIENT (client), FALSE);
        g_return_val_if_fail (device_path != NULL, FALSE);
 
-       if (get_iter_from_path (client->store, &iter, device_path) == FALSE) {
+       device = get_device_for_path (client, device_path);
+       if (device == NULL) {
                g_debug ("Couldn't find device '%s' in tree to mark it as trusted", device_path);
                return FALSE;
        }
 
-       gtk_tree_model_get (GTK_TREE_MODEL (client->store), &iter,
-                           BLUETOOTH_COLUMN_PROXY, &device, -1);
-
-       if (device == NULL)
-               return FALSE;
+       g_object_get (G_OBJECT (device),
+                     "proxy", &proxy,
+                     NULL);
 
-       g_object_set (device, "trusted", trusted, NULL);
-       g_object_unref (device);
+       g_object_set (proxy, "trusted", trusted, NULL);
 
        return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]