[gnome-bluetooth/wip/hadess/lib-changes: 2/18] lib: Add API to access a device-specific list model
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/hadess/lib-changes: 2/18] lib: Add API to access a device-specific list model
- Date: Mon, 29 Nov 2021 15:36:14 +0000 (UTC)
commit b4a66e6006dc3c5bc0fe7e78d20f5fe7aad8a3d6
Author: Bastien Nocera <hadess hadess net>
Date: Fri Nov 19 15:13:27 2021 +0100
lib: Add API to access a device-specific list model
The model is not populated yet.
lib/bluetooth-client.c | 21 +++++++++++++++++++++
lib/bluetooth-client.h | 1 +
lib/gnome-bluetooth.map | 1 +
3 files changed, 23 insertions(+)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 398ec16c..90f010ab 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -42,6 +42,7 @@
#include "bluetooth-client.h"
#include "bluetooth-client-private.h"
#include "bluetooth-client-glue.h"
+#include "bluetooth-device.h"
#include "bluetooth-utils.h"
#include "gnome-bluetooth-enum-types.h"
#include "pin.h"
@@ -54,6 +55,7 @@
struct _BluetoothClient {
GObject parent;
+ GListStore *list_store;
GDBusObjectManager *manager;
GCancellable *cancellable;
GtkTreeStore *store;
@@ -906,6 +908,7 @@ static void bluetooth_client_init(BluetoothClient *client)
G_TYPE_BOOLEAN, /* BLUETOOTH_COLUMN_POWERED */
G_TYPE_HASH_TABLE, /* BLUETOOTH_COLUMN_SERVICES */
G_TYPE_STRV); /* BLUETOOTH_COLUMN_UUIDS */
+ client->list_store = g_list_store_new (BLUETOOTH_TYPE_DEVICE);
g_dbus_object_manager_client_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
@@ -1097,6 +1100,7 @@ static void bluetooth_client_finalize(GObject *object)
}
g_clear_object (&client->manager);
g_object_unref (client->store);
+ g_object_unref (client->list_store);
g_clear_pointer (&client->default_adapter, gtk_tree_row_reference_free);
@@ -1206,6 +1210,23 @@ BluetoothClient *bluetooth_client_new(void)
return bluetooth_client;
}
+/**
+ * bluetooth_client_get_devices:
+ * @client: a #BluetoothClient object
+ *
+ * Returns an unfiltered #GListStore representing the devices attached to the default
+ * Bluetooth adapter.
+ *
+ * Return value: (transfer full): a #GListStore
+ **/
+GListStore *
+bluetooth_client_get_devices (BluetoothClient *client)
+{
+ g_return_val_if_fail (BLUETOOTH_IS_CLIENT (client), NULL);
+
+ return G_LIST_STORE (g_object_ref (client->list_store));
+}
+
/**
* bluetooth_client_get_model:
* @client: a #BluetoothClient object
diff --git a/lib/bluetooth-client.h b/lib/bluetooth-client.h
index 85706c68..82b95f3a 100644
--- a/lib/bluetooth-client.h
+++ b/lib/bluetooth-client.h
@@ -33,6 +33,7 @@ G_DECLARE_FINAL_TYPE (BluetoothClient, bluetooth_client, BLUETOOTH, CLIENT, GObj
BluetoothClient *bluetooth_client_new(void);
GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client);
+GListStore *bluetooth_client_get_devices (BluetoothClient *client);
void bluetooth_client_connect_service (BluetoothClient *client,
const char *path,
diff --git a/lib/gnome-bluetooth.map b/lib/gnome-bluetooth.map
index e9fcb898..d5cfc7fe 100644
--- a/lib/gnome-bluetooth.map
+++ b/lib/gnome-bluetooth.map
@@ -7,6 +7,7 @@ global:
bluetooth_client_dump_device;
bluetooth_client_get_type;
bluetooth_client_new;
+ bluetooth_client_get_devices;
bluetooth_client_get_model;
bluetooth_client_connect_service;
bluetooth_client_connect_service_finish;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]