2 * Copyright (C) 2010 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
18 #include <hildon/hildon.h>
22 #include "strongswan-connections.h"
33 StrongswanConnections
*conns
;
34 } ListDialog
= { 0, };
37 * Creates a dialog showing a list of all connections
40 create_list_dialog (gpointer
*parent
)
42 GtkWidget
*dialog
= gtk_dialog_new_with_buttons (
43 "strongSwan Connections",
45 GTK_DIALOG_MODAL
| GTK_DIALOG_NO_SEPARATOR
,
55 ListDialog
.dialog
= dialog
;
56 GtkWidget
*vbox
= GTK_DIALOG (dialog
)->vbox
;
58 ListDialog
.conns
= strongswan_connections_new ();
60 GtkTreeModel
*model
= strongswan_connections_get_model (ListDialog
.conns
);
61 ListDialog
.list
= gtk_tree_view_new_with_model (model
);
62 g_object_unref (model
);
64 GtkTreeSelection
*selection
;
65 selection
= gtk_tree_view_get_selection (GTK_TREE_VIEW (ListDialog
.list
));
66 gtk_tree_selection_set_mode (selection
, GTK_SELECTION_BROWSE
);
68 GtkTreeViewColumn
*column
= gtk_tree_view_column_new ();
69 strongswan_connections_setup_column_renderers (ListDialog
.conns
,
70 GTK_CELL_LAYOUT (column
));
71 gtk_tree_view_append_column (GTK_TREE_VIEW (ListDialog
.list
), column
);
73 gtk_box_pack_start (GTK_BOX (vbox
),
77 HILDON_MARGIN_DEFAULT
);
78 gtk_widget_show_all (dialog
);
79 gtk_widget_hide (dialog
);
84 * main callback for control panel plugins
86 osso_return_t
execute(osso_context_t
*osso
, gpointer data
,
87 gboolean user_activated
)
91 create_list_dialog (data
);
101 response
= gtk_dialog_run (GTK_DIALOG (ListDialog
.dialog
));
112 case RESPONSE_DELETE
:
120 while (response
> 0);
122 gtk_widget_destroy (ListDialog
.dialog
);
123 g_object_unref (ListDialog
.conns
);
128 * callback called in case state has to be saved
130 osso_return_t
save_state(osso_context_t
*osso
, gpointer data
)