aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-12-18 08:21:40 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-12-18 08:21:40 +0100
commitb0d5b0a8d4a54271aaa97cb6945f61b2c0987624 (patch)
treeba4b3f40fa6aaec48ddfbe9f65b3eaa036b03e07
parent9989dcb60922cadd575f9341063ce39545678f71 (diff)
downloadconnman-gnome-b0d5b0a8d4a54271aaa97cb6945f61b2c0987624.tar.gz
Add function to get a combined device and network model
-rw-r--r--common/connman-client.c37
-rw-r--r--common/connman-client.h1
2 files changed, 38 insertions, 0 deletions
diff --git a/common/connman-client.c b/common/connman-client.c
index f7c3b36..c4bbe21 100644
--- a/common/connman-client.c
+++ b/common/connman-client.c
@@ -198,6 +198,43 @@ GtkTreeModel *connman_client_get_device_model(ConnmanClient *client)
return model;
}
+static gboolean device_network_filter(GtkTreeModel *model,
+ GtkTreeIter *iter, gpointer user_data)
+{
+ DBusGProxy *proxy;
+ gboolean active;
+
+ gtk_tree_model_get(model, iter, CONNMAN_COLUMN_PROXY, &proxy, -1);
+
+ if (proxy == NULL)
+ return FALSE;
+
+ active = g_str_equal(CONNMAN_DEVICE_INTERFACE,
+ dbus_g_proxy_get_interface(proxy));
+ if (active == FALSE)
+ active = g_str_equal(CONNMAN_NETWORK_INTERFACE,
+ dbus_g_proxy_get_interface(proxy));
+
+ g_object_unref(proxy);
+
+ return active;
+}
+
+GtkTreeModel *connman_client_get_device_network_model(ConnmanClient *client)
+{
+ ConnmanClientPrivate *priv = CONNMAN_CLIENT_GET_PRIVATE(client);
+ GtkTreeModel *model;
+
+ DBG("client %p", client);
+
+ model = gtk_tree_model_filter_new(GTK_TREE_MODEL(priv->store), NULL);
+
+ gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(model),
+ device_network_filter, NULL, NULL);
+
+ return model;
+}
+
static gboolean network_filter(GtkTreeModel *model,
GtkTreeIter *iter, gpointer user_data)
{
diff --git a/common/connman-client.h b/common/connman-client.h
index 52b0dfd..7ba47a8 100644
--- a/common/connman-client.h
+++ b/common/connman-client.h
@@ -55,6 +55,7 @@ ConnmanClient *connman_client_new(void);
GtkTreeModel *connman_client_get_model(ConnmanClient *client);
GtkTreeModel *connman_client_get_device_model(ConnmanClient *client);
+GtkTreeModel *connman_client_get_device_network_model(ConnmanClient *client);
GtkTreeModel *connman_client_get_network_model(ConnmanClient *client,
const gchar *device);