Helper methods added to StrongSwanConnections to easily show connections in a list widget.
This commit is contained in:
@@ -31,6 +31,7 @@ struct _StrongswanConnectionsPrivate
|
|||||||
gchar *path;
|
gchar *path;
|
||||||
GnomeVFSMonitorHandle *monitor;
|
GnomeVFSMonitorHandle *monitor;
|
||||||
GHashTable *connections;
|
GHashTable *connections;
|
||||||
|
GtkTreeModel *model;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (StrongswanConnections, strongswan_connections, G_TYPE_OBJECT);
|
||||||
@@ -39,6 +40,8 @@ static void
|
|||||||
strongswan_connections_load_connections (StrongswanConnections *connections)
|
strongswan_connections_load_connections (StrongswanConnections *connections)
|
||||||
{
|
{
|
||||||
StrongswanConnectionsPrivate *priv = connections->priv;
|
StrongswanConnectionsPrivate *priv = connections->priv;
|
||||||
|
GHashTableIter iter;
|
||||||
|
gpointer key, value;
|
||||||
gchar **groups;
|
gchar **groups;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
@@ -57,6 +60,17 @@ strongswan_connections_load_connections (StrongswanConnections *connections)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_strfreev (groups);
|
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
|
static void
|
||||||
@@ -123,6 +137,12 @@ strongswan_connections_init (StrongswanConnections *connections)
|
|||||||
g_free,
|
g_free,
|
||||||
g_object_unref);
|
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
|
static void
|
||||||
@@ -162,6 +182,11 @@ strongswan_connections_dispose (GObject *object)
|
|||||||
g_return_if_fail (STRONGSWAN_IS_CONNECTIONS (object));
|
g_return_if_fail (STRONGSWAN_IS_CONNECTIONS (object));
|
||||||
priv = STRONGSWAN_CONNECTIONS (object)->priv;
|
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);
|
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));
|
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 *
|
StrongswanConnections *
|
||||||
strongswan_connections_new (void)
|
strongswan_connections_new (void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#ifndef __STRONGSWAN_CONNECTIONS_H__
|
#ifndef __STRONGSWAN_CONNECTIONS_H__
|
||||||
#define __STRONGSWAN_CONNECTIONS_H__
|
#define __STRONGSWAN_CONNECTIONS_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "strongswan-connection.h"
|
#include "strongswan-connection.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@@ -47,6 +49,9 @@ GType strongswan_connections_get_type (void);
|
|||||||
|
|
||||||
StrongswanConnections *strongswan_connections_new (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);
|
StrongswanConnection *strongswan_connections_get_connection (StrongswanConnections *self, const gchar *name);
|
||||||
void strongswan_connections_save_connection (StrongswanConnections *self, StrongswanConnection *conn);
|
void strongswan_connections_save_connection (StrongswanConnections *self, StrongswanConnection *conn);
|
||||||
void strongswan_connections_remove_connection (StrongswanConnections *self, const gchar *name);
|
void strongswan_connections_remove_connection (StrongswanConnections *self, const gchar *name);
|
||||||
|
|||||||
Reference in New Issue
Block a user