From: Tobias Brunner Date: Fri, 4 Jun 2010 12:15:37 +0000 (+0200) Subject: Adding a dialog to the settings plugin that lists all connections. X-Git-Tag: 4.5.0~72 X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=commitdiff_plain;h=2bf0caec6631468a8f5fd51ad893946d235d4d76 Adding a dialog to the settings plugin that lists all connections. --- diff --git a/src/frontends/maemo/src/strongswan-settings.c b/src/frontends/maemo/src/strongswan-settings.c index f8c3719..56c1875 100644 --- a/src/frontends/maemo/src/strongswan-settings.c +++ b/src/frontends/maemo/src/strongswan-settings.c @@ -14,6 +14,71 @@ */ #include +#include +#include + +#include + +#include "strongswan-connections.h" + +enum { + RESPONSE_NEW = 1, + RESPONSE_EDIT, + RESPONSE_DELETE +}; + +struct { + GtkWidget *dialog; + GtkWidget *list; + StrongswanConnections *conns; +} ListDialog = { 0, }; + +/** + * Creates a dialog showing a list of all connections + */ +static void +create_list_dialog (gpointer *parent) +{ + GtkWidget *dialog = gtk_dialog_new_with_buttons ( + "strongSwan Connections", + GTK_WINDOW (parent), + GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, + GTK_STOCK_NEW, + RESPONSE_NEW, + GTK_STOCK_EDIT, + RESPONSE_EDIT, + GTK_STOCK_DELETE, + RESPONSE_DELETE, + GTK_STOCK_CLOSE, + GTK_RESPONSE_OK, + NULL); + ListDialog.dialog = dialog; + GtkWidget *vbox = GTK_DIALOG (dialog)->vbox; + + ListDialog.conns = strongswan_connections_new (); + + GtkTreeModel *model = strongswan_connections_get_model (ListDialog.conns); + ListDialog.list = gtk_tree_view_new_with_model (model); + g_object_unref (model); + + GtkTreeSelection *selection; + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ListDialog.list)); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); + + GtkTreeViewColumn *column = gtk_tree_view_column_new (); + strongswan_connections_setup_column_renderers (ListDialog.conns, + GTK_CELL_LAYOUT (column)); + gtk_tree_view_append_column (GTK_TREE_VIEW (ListDialog.list), column); + + gtk_box_pack_start (GTK_BOX (vbox), + ListDialog.list, + TRUE, + TRUE, + HILDON_MARGIN_DEFAULT); + gtk_widget_show_all (dialog); + gtk_widget_hide (dialog); +} + /** * main callback for control panel plugins @@ -21,11 +86,41 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated) { + gint response; + + create_list_dialog (data); + if (!user_activated) { /* load state */ } + do + { + gchar *selected; + response = gtk_dialog_run (GTK_DIALOG (ListDialog.dialog)); + switch (response) + { + case RESPONSE_NEW: + { + break; + } + case RESPONSE_EDIT: + { + break; + } + case RESPONSE_DELETE: + { + break; + } + default: + break; + } + } + while (response > 0); + + gtk_widget_destroy (ListDialog.dialog); + g_object_unref (ListDialog.conns); return OSSO_OK; }