diff options
author | Tobias Brunner <tobias@strongswan.org> | 2010-06-04 14:11:24 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2010-10-14 17:36:17 +0200 |
commit | 980c1b6e0733a75a65fdb71f5a0aa63ffe799066 (patch) | |
tree | 337e97166ec05d607907f7627ebe1f82f0756841 /src/frontends/maemo/src | |
parent | 01f74556401624ab39fe4b694119b6c8666eb4d2 (diff) | |
download | strongswan-980c1b6e0733a75a65fdb71f5a0aa63ffe799066.tar.bz2 strongswan-980c1b6e0733a75a65fdb71f5a0aa63ffe799066.tar.xz |
Helper methods added to StrongSwanConnections to easily show connections in a list widget.
Diffstat (limited to 'src/frontends/maemo/src')
-rw-r--r-- | src/frontends/maemo/src/strongswan-connections.c | 46 | ||||
-rw-r--r-- | src/frontends/maemo/src/strongswan-connections.h | 5 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/frontends/maemo/src/strongswan-connections.c b/src/frontends/maemo/src/strongswan-connections.c index 9378101ca..3f152c2b5 100644 --- a/src/frontends/maemo/src/strongswan-connections.c +++ b/src/frontends/maemo/src/strongswan-connections.c @@ -31,6 +31,7 @@ struct _StrongswanConnectionsPrivate gchar *path; GnomeVFSMonitorHandle *monitor; GHashTable *connections; + GtkTreeModel *model; }; G_DEFINE_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT); @@ -39,6 +40,8 @@ static void strongswan_connections_load_connections (StrongswanConnections *connections) { StrongswanConnectionsPrivate *priv = connections->priv; + GHashTableIter iter; + gpointer key, value; gchar **groups; guint i; @@ -57,6 +60,17 @@ strongswan_connections_load_connections (StrongswanConnections *connections) } } g_strfreev (groups); + + gtk_list_store_clear (GTK_LIST_STORE (priv->model)); + g_hash_table_iter_init (&iter, priv->connections); + while (g_hash_table_iter_next (&iter, &key, &value)) + { + gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->model), + NULL, + -1, + 0, key, + -1); + } } static void @@ -123,6 +137,12 @@ strongswan_connections_init (StrongswanConnections *connections) g_free, g_object_unref); + priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, + G_TYPE_STRING, + G_TYPE_STRING)); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->model), + 0, + GTK_SORT_ASCENDING); } static void @@ -162,6 +182,11 @@ strongswan_connections_dispose (GObject *object) g_return_if_fail (STRONGSWAN_IS_CONNECTIONS (object)); priv = STRONGSWAN_CONNECTIONS (object)->priv; + if (priv->model) + { + priv->model = (g_object_unref (priv->model), NULL); + } + G_OBJECT_CLASS (strongswan_connections_parent_class)->dispose (object); } @@ -193,6 +218,27 @@ strongswan_connections_class_init (StrongswanConnectionsClass *klass) g_type_class_add_private (klass, sizeof (StrongswanConnectionsPrivate)); } +GtkTreeModel * +strongswan_connections_get_model (StrongswanConnections *self) +{ + StrongswanConnectionsPrivate *priv = self->priv; + return g_object_ref (priv->model); +} + +void +strongswan_connections_setup_column_renderers (StrongswanConnections *self, + GtkCellLayout *layout) +{ + GtkCellRenderer *renderer; + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (layout, + renderer, + TRUE); + gtk_cell_layout_add_attribute (layout, + renderer, + "text", 0); +} + StrongswanConnections * strongswan_connections_new (void) { diff --git a/src/frontends/maemo/src/strongswan-connections.h b/src/frontends/maemo/src/strongswan-connections.h index 6a9f557d2..ff753413c 100644 --- a/src/frontends/maemo/src/strongswan-connections.h +++ b/src/frontends/maemo/src/strongswan-connections.h @@ -16,6 +16,8 @@ #ifndef __STRONGSWAN_CONNECTIONS_H__ #define __STRONGSWAN_CONNECTIONS_H__ +#include <gtk/gtk.h> + #include "strongswan-connection.h" G_BEGIN_DECLS @@ -47,6 +49,9 @@ GType strongswan_connections_get_type (void); StrongswanConnections *strongswan_connections_new (void); +GtkTreeModel *strongswan_connections_get_model (StrongswanConnections *connections); +void strongswan_connections_setup_column_renderers (StrongswanConnections *connections, GtkCellLayout *layout); + StrongswanConnection *strongswan_connections_get_connection (StrongswanConnections *self, const gchar *name); void strongswan_connections_save_connection (StrongswanConnections *self, StrongswanConnection *conn); void strongswan_connections_remove_connection (StrongswanConnections *self, const gchar *name); |