[network-manager-applet/new-editor: 5/7] connection-editor: Move VPN subtypes into the main New Connection dialog
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/new-editor: 5/7] connection-editor: Move VPN subtypes into the main New Connection dialog
- Date: Fri, 16 Mar 2012 11:35:45 +0000 (UTC)
commit 9dba43d2651f708a8a52cff7faaa5f832656fe98
Author: Dan Winship <danw gnome org>
Date: Fri Mar 9 12:06:22 2012 -0500
connection-editor: Move VPN subtypes into the main New Connection dialog
src/connection-editor/ce-page.h | 1 +
src/connection-editor/main.c | 18 +++-
src/connection-editor/new-connection.c | 164 +++++++++++++++++++++--
src/connection-editor/new-connection.h | 1 +
src/connection-editor/nm-connection-editor.ui | 30 ++++-
src/connection-editor/nm-connection-list.c | 3 +-
src/connection-editor/nm-connection-list.h | 2 +-
src/connection-editor/page-dsl.c | 1 +
src/connection-editor/page-dsl.h | 1 +
src/connection-editor/page-mobile.c | 1 +
src/connection-editor/page-mobile.h | 1 +
src/connection-editor/page-vpn.c | 39 +++---
src/connection-editor/page-vpn.h | 7 +
src/connection-editor/page-wired.c | 1 +
src/connection-editor/page-wired.h | 1 +
src/connection-editor/page-wireless.c | 1 +
src/connection-editor/page-wireless.h | 1 +
src/connection-editor/vpn-helpers.c | 179 -------------------------
src/connection-editor/vpn-helpers.h | 2 -
19 files changed, 236 insertions(+), 218 deletions(-)
---
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index b5ec497..68dbecc 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -41,6 +41,7 @@ typedef void (*PageNewConnectionResultFunc) (NMConnection *connection,
typedef GSList * (*PageGetConnectionsFunc) (gpointer user_data);
typedef void (*PageNewConnectionFunc) (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 50d5d3f..8b35576 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -146,11 +146,23 @@ handle_arguments (NMConnectionList *list,
{
gboolean show_list = TRUE;
GType ctype;
+ char *type_tmp = NULL;
+ const char *p, *detail = NULL;
+
+ if (type) {
+ p = strchr (type, ':');
+ if (p) {
+ type = type_tmp = g_strndup (type, p - type);
+ detail = p + 1;
+ }
+ } else
+ type = NM_SETTING_WIRED_SETTING_NAME;
/* Grab type to create or show */
- ctype = nm_connection_lookup_setting_type (type ? type : NM_SETTING_WIRED_SETTING_NAME);
+ ctype = nm_connection_lookup_setting_type (type);
if (ctype == 0) {
g_warning ("Unknown connection type '%s'", type);
+ g_free (type_tmp);
return TRUE;
}
@@ -160,9 +172,10 @@ handle_arguments (NMConnectionList *list,
} else if (create) {
if (!type) {
g_warning ("'create' requested but no connection type given.");
+ g_free (type_tmp);
return TRUE;
}
- nm_connection_list_create (list, ctype);
+ nm_connection_list_create (list, ctype, detail);
show_list = FALSE;
} else if (edit_uuid) {
@@ -175,6 +188,7 @@ handle_arguments (NMConnectionList *list,
if (show_list == FALSE && quit_after == TRUE)
g_signal_connect_swapped (list, "editing-done", G_CALLBACK (g_main_loop_quit), loop);
+ g_free (type_tmp);
return show_list;
}
diff --git a/src/connection-editor/new-connection.c b/src/connection-editor/new-connection.c
index 54d1c5c..38d4772 100644
--- a/src/connection-editor/new-connection.c
+++ b/src/connection-editor/new-connection.c
@@ -31,9 +31,12 @@
#include "page-vpn.h"
#include "vpn-helpers.h"
-#define COL_ICON 0
-#define COL_LABEL 1
-#define COL_NEW_FUNC 2
+static GSList *vpn_plugins;
+
+#define COL_ICON 0
+#define COL_LABEL 1
+#define COL_NEW_FUNC 2
+#define COL_VPN_PLUGIN 3
#define ICON_LOAD(x, y) \
{ \
@@ -44,6 +47,25 @@
} \
}
+static gint
+sort_vpn_plugins (gconstpointer a, gconstpointer b)
+{
+ NMVpnPluginUiInterface *aa = NM_VPN_PLUGIN_UI_INTERFACE (a);
+ NMVpnPluginUiInterface *bb = NM_VPN_PLUGIN_UI_INTERFACE (b);
+ char *aa_desc = NULL, *bb_desc = NULL;
+ int ret;
+
+ g_object_get (aa, NM_VPN_PLUGIN_UI_INTERFACE_NAME, &aa_desc, NULL);
+ g_object_get (bb, NM_VPN_PLUGIN_UI_INTERFACE_NAME, &bb_desc, NULL);
+
+ ret = g_strcmp0 (aa_desc, bb_desc);
+
+ g_free (aa_desc);
+ g_free (bb_desc);
+
+ return ret;
+}
+
ConnectionTypeData *
get_connection_type_list (void)
{
@@ -52,7 +74,7 @@ get_connection_type_list (void)
static ConnectionTypeData *list;
static GtkIconTheme *theme;
GError *error = NULL;
- GHashTable *vpn_plugins;
+ GHashTable *vpn_plugins_hash;
gboolean have_vpn_plugins;
if (list)
@@ -86,28 +108,100 @@ get_connection_type_list (void)
g_array_append_val (array, data);
/* Add "VPN" only if there are plugins */
- vpn_plugins = vpn_get_plugins (NULL);
- have_vpn_plugins = vpn_plugins && g_hash_table_size (vpn_plugins);
+ vpn_plugins_hash = vpn_get_plugins (NULL);
+ have_vpn_plugins = vpn_plugins_hash && g_hash_table_size (vpn_plugins_hash);
if (have_vpn_plugins) {
+ GHashTableIter iter;
+ gpointer name, plugin;
+
data.name = _("VPN");
ICON_LOAD (data.icon, "nm-vpn-standalone-lock");
data.new_connection_func = vpn_connection_new;
data.setting_type = NM_TYPE_SETTING_VPN;
g_array_append_val (array, data);
+
+ vpn_plugins = NULL;
+ g_hash_table_iter_init (&iter, vpn_plugins_hash);
+ while (g_hash_table_iter_next (&iter, &name, &plugin))
+ vpn_plugins = g_slist_prepend (vpn_plugins, plugin);
+ vpn_plugins = g_slist_sort (vpn_plugins, sort_vpn_plugins);
}
return (ConnectionTypeData *)g_array_free (array, FALSE);
}
+static gboolean
+combo_row_separator_func (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ char *label;
+
+ gtk_tree_model_get (model, iter,
+ COL_LABEL, &label,
+ -1);
+ if (label) {
+ g_free (label);
+ return FALSE;
+ } else
+ return TRUE;
+}
+
static void
-fill_connection_type_model (GtkComboBox *combo)
+combo_changed_cb (GtkComboBox *combo, gpointer user_data)
+{
+ GtkLabel *label = GTK_LABEL (user_data);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ NMVpnPluginUiInterface *plugin = NULL;
+ char *description, *markup;
+
+ if (!gtk_combo_box_get_active_iter (combo, &iter))
+ goto error;
+
+ model = gtk_combo_box_get_model (combo);
+ if (!model)
+ goto error;
+
+ gtk_tree_model_get (model, &iter, COL_VPN_PLUGIN, &plugin, -1);
+ if (!plugin)
+ goto error;
+
+ g_object_get (G_OBJECT (plugin), NM_VPN_PLUGIN_UI_INTERFACE_DESC, &description, NULL);
+ g_object_unref (plugin);
+ if (!description)
+ goto error;
+
+ markup = g_markup_printf_escaped ("<i>%s</i>", description);
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+ g_free (description);
+ return;
+
+error:
+ gtk_label_set_text (label, "");
+}
+
+static void
+set_up_connection_type_combo (GtkComboBox *combo,
+ GtkLabel *description_label)
{
GtkListStore *model = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
ConnectionTypeData *list = get_connection_type_list ();
GtkTreeIter iter;
- int i;
+ GSList *p;
+ int i, vpn_index = -1;
+ gboolean import_supported = FALSE;
+
+ gtk_combo_box_set_row_separator_func (combo, combo_row_separator_func, NULL, NULL);
+ g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (combo_changed_cb), description_label);
for (i = 0; list[i].name; i++) {
+ if (list[i].setting_type == NM_TYPE_SETTING_VPN) {
+ vpn_index = i;
+ continue;
+ }
+
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
COL_ICON, list[i].icon,
@@ -115,6 +209,43 @@ fill_connection_type_model (GtkComboBox *combo)
COL_NEW_FUNC, list[i].new_connection_func,
-1);
}
+
+ if (!vpn_plugins || vpn_index == -1)
+ return;
+
+ /* Separator */
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+ for (p = vpn_plugins; p; p = p->next) {
+ NMVpnPluginUiInterface *plugin = NM_VPN_PLUGIN_UI_INTERFACE (p->data);
+ char *desc;
+
+ g_object_get (plugin, NM_VPN_PLUGIN_UI_INTERFACE_NAME, &desc, NULL);
+
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter,
+ COL_ICON, list[vpn_index].icon,
+ COL_LABEL, desc,
+ COL_NEW_FUNC, list[vpn_index].new_connection_func,
+ COL_VPN_PLUGIN, plugin,
+ -1);
+ g_free (desc);
+
+ if (nm_vpn_plugin_ui_interface_get_capabilities (plugin) & NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT)
+ import_supported = TRUE;
+ }
+
+ if (import_supported) {
+ /* Separator */
+ gtk_list_store_append (model, &iter);
+
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter,
+ COL_ICON, list[vpn_index].icon,
+ COL_LABEL, _("Import a saved VPN configuration..."),
+ COL_NEW_FUNC, vpn_connection_import,
+ -1);
+ }
}
typedef struct {
@@ -152,6 +283,7 @@ void
new_connection_of_type (GtkWindow *parent_window,
NMRemoteSettings *settings,
PageNewConnectionFunc new_func,
+ const char *detail,
PageNewConnectionResultFunc result_func,
gpointer user_data)
{
@@ -164,6 +296,7 @@ new_connection_of_type (GtkWindow *parent_window,
ncd->user_data = user_data;
new_func (parent_window,
+ detail,
new_connection_result,
new_connection_get_connections,
ncd);
@@ -179,9 +312,12 @@ new_connection_dialog (GtkWindow *parent_window,
GtkBuilder *gui;
GtkDialog *type_dialog;
GtkComboBox *combo;
+ GtkLabel *label;
GtkTreeIter iter;
int response;
PageNewConnectionFunc new_func = NULL;
+ NMVpnPluginUiInterface *plugin = NULL;
+ char *vpn_type = NULL;
GError *error = NULL;
/* load GUI */
@@ -200,7 +336,8 @@ new_connection_dialog (GtkWindow *parent_window,
gtk_window_set_transient_for (GTK_WINDOW (type_dialog), parent_window);
combo = GTK_COMBO_BOX (gtk_builder_get_object (gui, "new-connection-combo"));
- fill_connection_type_model (combo);
+ label = GTK_LABEL (gtk_builder_get_object (gui, "new-connection-description"));
+ set_up_connection_type_combo (combo, label);
gtk_combo_box_set_active (combo, 0);
response = gtk_dialog_run (type_dialog);
@@ -208,12 +345,19 @@ new_connection_dialog (GtkWindow *parent_window,
gtk_combo_box_get_active_iter (combo, &iter);
gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
COL_NEW_FUNC, &new_func,
+ COL_VPN_PLUGIN, &plugin,
-1);
+
+ if (plugin) {
+ g_object_get (G_OBJECT (plugin), NM_VPN_PLUGIN_UI_INTERFACE_SERVICE, &vpn_type, NULL);
+ g_object_unref (plugin);
+ }
}
gtk_widget_destroy (GTK_WIDGET (type_dialog));
g_object_unref (gui);
if (new_func)
- new_connection_of_type (parent_window, settings, new_func, result_func, user_data);
+ new_connection_of_type (parent_window, settings, new_func, vpn_type, result_func, user_data);
+ g_free (vpn_type);
}
diff --git a/src/connection-editor/new-connection.h b/src/connection-editor/new-connection.h
index 429e9bb..ea40130 100644
--- a/src/connection-editor/new-connection.h
+++ b/src/connection-editor/new-connection.h
@@ -40,6 +40,7 @@ void new_connection_dialog (GtkWindow *parent_window,
void new_connection_of_type (GtkWindow *parent_window,
NMRemoteSettings *settings,
PageNewConnectionFunc new_func,
+ const char *detail,
PageNewConnectionResultFunc result_func,
gpointer user_data);
diff --git a/src/connection-editor/nm-connection-editor.ui b/src/connection-editor/nm-connection-editor.ui
index 56d3d4b..23329cd 100644
--- a/src/connection-editor/nm-connection-editor.ui
+++ b/src/connection-editor/nm-connection-editor.ui
@@ -48,6 +48,7 @@
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="spacing">6</property>
<child>
@@ -61,6 +62,9 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="rules_hint">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
+ </child>
</object>
</child>
</object>
@@ -73,6 +77,7 @@
<child>
<object class="GtkVButtonBox" id="connection_button_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">start</property>
<child>
@@ -125,20 +130,25 @@
<column type="gchararray"/>
<!-- column-name new_func -->
<column type="gpointer"/>
+ <!-- column-name vpn_plugin -->
+ <column type="NMVpnPluginUiInterface"/>
</columns>
</object>
<object class="GtkDialog" id="new-connection-dialog">
+ <property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Create New Connection</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox4">
+ <object class="GtkBox" id="dialog-vbox4">
+ <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area4">
+ <property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button1">
@@ -181,11 +191,13 @@
<child>
<object class="GtkVBox" id="box1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
<property name="label" translatable="yes">Select the type of connection to create:</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -200,6 +212,7 @@
<child>
<object class="GtkComboBox" id="new-connection-combo">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="model">new-connection-combo-model</property>
<child>
<object class="GtkCellRendererPixbuf" id="renderer1"/>
@@ -220,6 +233,19 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="new-connection-description">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="max_width_chars">40</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 66163c0..7dc6be6 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -1277,7 +1277,7 @@ nm_connection_list_set_type (NMConnectionList *self, GType ctype)
}
void
-nm_connection_list_create (NMConnectionList *self, GType ctype)
+nm_connection_list_create (NMConnectionList *self, GType ctype, const char *detail)
{
ConnectionTypeData *types;
int i;
@@ -1297,6 +1297,7 @@ nm_connection_list_create (NMConnectionList *self, GType ctype)
new_connection_of_type (GTK_WINDOW (self->dialog),
self->settings,
types[i].new_connection_func,
+ detail,
really_add_connection,
self);
}
diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h
index 1a01bb3..6099c76 100644
--- a/src/connection-editor/nm-connection-list.h
+++ b/src/connection-editor/nm-connection-list.h
@@ -68,7 +68,7 @@ NMConnectionList *nm_connection_list_new (void);
void nm_connection_list_set_type (NMConnectionList *list, GType ctype);
void nm_connection_list_present (NMConnectionList *list);
-void nm_connection_list_create (NMConnectionList *list, GType ctype);
+void nm_connection_list_create (NMConnectionList *list, GType ctype, const char *detail);
void nm_connection_list_edit (NMConnectionList *list, const gchar *uuid);
#endif
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index 5485a55..2b6823d 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -222,6 +222,7 @@ ce_page_dsl_class_init (CEPageDslClass *dsl_class)
void
dsl_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
diff --git a/src/connection-editor/page-dsl.h b/src/connection-editor/page-dsl.h
index 2679939..0267de3 100644
--- a/src/connection-editor/page-dsl.h
+++ b/src/connection-editor/page-dsl.h
@@ -54,6 +54,7 @@ CEPage *ce_page_dsl_new (NMConnection *connection,
GError **error);
void dsl_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc callback,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index 517ebb9..90192f2 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -612,6 +612,7 @@ cancel_dialog (GtkDialog *dialog)
void
mobile_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
diff --git a/src/connection-editor/page-mobile.h b/src/connection-editor/page-mobile.h
index 19d449e..84990c9 100644
--- a/src/connection-editor/page-mobile.h
+++ b/src/connection-editor/page-mobile.h
@@ -54,6 +54,7 @@ CEPage *ce_page_mobile_new (NMConnection *connection,
GError **error);
void mobile_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 8e9f1a9..dc33373 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -253,41 +253,38 @@ import_cb (NMConnection *connection, gpointer user_data)
}
void
+vpn_connection_import (GtkWindow *parent,
+ const char *detail,
+ PageNewConnectionResultFunc result_func,
+ PageGetConnectionsFunc get_connections_func,
+ gpointer user_data)
+{
+ NewVpnInfo *info;
+
+ info = g_slice_new (NewVpnInfo);
+ info->result_func = result_func;
+ info->get_connections_func = get_connections_func;
+ info->user_data = user_data;
+ vpn_import (import_cb, info);
+}
+
+void
vpn_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
{
- char *service = NULL;
NMConnection *connection;
NMSetting *s_vpn;
- service = vpn_ask_connection_type (parent);
- if (!service) {
- (*result_func) (NULL, TRUE, NULL, user_data);
- return;
- }
-
- if (!strcmp (service, "import")) {
- NewVpnInfo *info;
-
- g_free (service);
- info = g_slice_new (NewVpnInfo);
- info->result_func = result_func;
- info->get_connections_func = get_connections_func;
- info->user_data = user_data;
- vpn_import (import_cb, info);
- return;
- }
-
connection = ce_page_new_connection (_("VPN connection %d"),
NM_SETTING_VPN_SETTING_NAME,
FALSE,
get_connections_func,
user_data);
s_vpn = nm_setting_vpn_new ();
- g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service, NULL);
- g_free (service);
+ g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, detail, NULL);
nm_connection_add_setting (connection, s_vpn);
(*result_func) (connection, FALSE, NULL, user_data);
diff --git a/src/connection-editor/page-vpn.h b/src/connection-editor/page-vpn.h
index d9a4106..e9022fe 100644
--- a/src/connection-editor/page-vpn.h
+++ b/src/connection-editor/page-vpn.h
@@ -56,8 +56,15 @@ CEPage *ce_page_vpn_new (NMConnection *connection,
gboolean ce_page_vpn_can_export (CEPageVpn *page);
void vpn_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
+void vpn_connection_import (GtkWindow *parent,
+ const char *detail,
+ PageNewConnectionResultFunc result_func,
+ PageGetConnectionsFunc get_connections_func,
+ gpointer user_data);
+
#endif /* __PAGE_VPN_H__ */
diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c
index 2d1ad0f..d9e06c4 100644
--- a/src/connection-editor/page-wired.c
+++ b/src/connection-editor/page-wired.c
@@ -440,6 +440,7 @@ ce_page_wired_class_init (CEPageWiredClass *wired_class)
void
wired_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
diff --git a/src/connection-editor/page-wired.h b/src/connection-editor/page-wired.h
index 4a38568..a6dc25b 100644
--- a/src/connection-editor/page-wired.h
+++ b/src/connection-editor/page-wired.h
@@ -54,6 +54,7 @@ CEPage *ce_page_wired_new (NMConnection *connection,
GError **error);
void wired_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index 3b1b57e..ca5ec48 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -656,6 +656,7 @@ ce_page_wireless_class_init (CEPageWirelessClass *wireless_class)
void
wifi_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
diff --git a/src/connection-editor/page-wireless.h b/src/connection-editor/page-wireless.h
index 5ddb696..34725c3 100644
--- a/src/connection-editor/page-wireless.h
+++ b/src/connection-editor/page-wireless.h
@@ -58,6 +58,7 @@ GByteArray *ce_page_wireless_get_ssid (CEPageWireless *self);
void wifi_connection_new (GtkWindow *parent,
+ const char *detail,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
diff --git a/src/connection-editor/vpn-helpers.c b/src/connection-editor/vpn-helpers.c
index 7bb4fe1..affa788 100644
--- a/src/connection-editor/vpn-helpers.c
+++ b/src/connection-editor/vpn-helpers.c
@@ -391,182 +391,3 @@ vpn_export (NMConnection *connection)
gtk_widget_show_all (dialog);
gtk_window_present (GTK_WINDOW (dialog));
}
-
-static gint
-sort_plugins (gconstpointer a, gconstpointer b)
-{
- NMVpnPluginUiInterface *aa = NM_VPN_PLUGIN_UI_INTERFACE (a);
- NMVpnPluginUiInterface *bb = NM_VPN_PLUGIN_UI_INTERFACE (b);
- char *aa_desc = NULL, *bb_desc = NULL;
- gint ret;
-
- g_object_get (aa, NM_VPN_PLUGIN_UI_INTERFACE_NAME, &aa_desc, NULL);
- g_object_get (bb, NM_VPN_PLUGIN_UI_INTERFACE_NAME, &bb_desc, NULL);
-
- if (!aa_desc)
- ret = -1;
- else if (!bb_desc)
- ret = 1;
- else
- ret = strcmp (aa_desc, bb_desc);
-
- g_free (aa_desc);
- g_free (bb_desc);
- return ret;
-}
-
-#define COL_PLUGIN_DESC 0
-#define COL_PLUGIN_OBJ 1
-
-static gboolean
-combo_row_separator_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer data)
-{
- char *desc;
-
- gtk_tree_model_get (model, iter,
- COL_PLUGIN_DESC, &desc,
- -1);
- if (desc) {
- g_free (desc);
- return FALSE;
- } else
- return TRUE;
-}
-
-static void
-combo_changed_cb (GtkComboBox *combo, gpointer user_data)
-{
- GtkLabel *label = GTK_LABEL (user_data);
- GtkTreeModel *model;
- GtkTreeIter iter;
- NMVpnPluginUiInterface *plugin = NULL;
- char *desc = NULL;
- char *tmp;
-
- if (!gtk_combo_box_get_active_iter (combo, &iter))
- goto error;
-
- model = gtk_combo_box_get_model (combo);
- if (!model)
- goto error;
-
- gtk_tree_model_get (model, &iter, COL_PLUGIN_OBJ, &plugin, -1);
- if (!plugin)
- goto error;
-
- g_object_get (G_OBJECT (plugin), NM_VPN_PLUGIN_UI_INTERFACE_DESC, &desc, NULL);
- g_object_unref (plugin);
- if (!desc)
- goto error;
-
- tmp = g_strdup_printf ("<i>%s</i>", desc);
- gtk_label_set_markup (label, tmp);
- g_free (tmp);
- g_free (desc);
- return;
-
-error:
- gtk_label_set_text (label, "");
-}
-
-char *
-vpn_ask_connection_type (GtkWindow *parent)
-{
- GtkBuilder *builder;
- GtkWidget *dialog, *combo, *widget;
- GtkTreeModel *model;
- GHashTableIter hash_iter;
- gpointer key, value;
- GSList *plugin_list = NULL, *iter;
- gint response;
- GtkTreeIter tree_iter;
- char *service_type = NULL;
- GError *error = NULL;
- gboolean import_supported = FALSE;
-
- if (!plugins || !g_hash_table_size (plugins)) {
- g_warning ("%s: no VPN plugins could be found!", __func__);
- return NULL;
- }
-
- builder = gtk_builder_new();
-
- if (!gtk_builder_add_from_file (builder, UIDIR "/ce-vpn-wizard.ui", &error)) {
- g_warning ("Couldn't load builder file: %s", error->message);
- g_error_free (error);
- return NULL;
- }
-
- dialog = GTK_WIDGET (gtk_builder_get_object (builder, "vpn_type_dialog"));
- if (!dialog) {
- g_warning ("%s: couldn't load VPN wizard dialog!", __func__);
- g_object_unref (builder);
- return NULL;
- }
-
- model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_OBJECT));
-
- g_hash_table_iter_init (&hash_iter, plugins);
- while (g_hash_table_iter_next (&hash_iter, &key, &value))
- plugin_list = g_slist_prepend (plugin_list, value);
- plugin_list = g_slist_sort (plugin_list, sort_plugins);
-
- for (iter = plugin_list; iter; iter = g_slist_next (iter)) {
- NMVpnPluginUiInterface *plugin = NM_VPN_PLUGIN_UI_INTERFACE (iter->data);
- char *desc;
-
- gtk_list_store_append (GTK_LIST_STORE (model), &tree_iter);
- g_object_get (plugin, NM_VPN_PLUGIN_UI_INTERFACE_NAME, &desc, NULL);
- gtk_list_store_set (GTK_LIST_STORE (model), &tree_iter,
- COL_PLUGIN_DESC, desc,
- COL_PLUGIN_OBJ, plugin, -1);
- g_free (desc);
-
- if (nm_vpn_plugin_ui_interface_get_capabilities (plugin) & NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT)
- import_supported = TRUE;
- }
- g_slist_free (plugin_list);
-
- if (import_supported) {
- gtk_list_store_append (GTK_LIST_STORE (model), &tree_iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &tree_iter,
- COL_PLUGIN_DESC, NULL,
- COL_PLUGIN_OBJ, NULL, -1);
- gtk_list_store_append (GTK_LIST_STORE (model), &tree_iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &tree_iter,
- COL_PLUGIN_DESC, _("Import a saved VPN configuration..."),
- COL_PLUGIN_OBJ, NULL, -1);
- }
-
- combo = GTK_WIDGET (gtk_builder_get_object (builder, "vpn_type_combo"));
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "vpn_desc_label"));
- g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (combo_changed_cb), widget);
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model);
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
- gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo), combo_row_separator_func, NULL, NULL);
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
- gtk_widget_show_all (dialog);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response != GTK_RESPONSE_OK)
- goto out;
-
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &tree_iter)) {
- NMVpnPluginUiInterface *plugin = NULL;
-
- gtk_tree_model_get (model, &tree_iter, COL_PLUGIN_OBJ, &plugin, -1);
- if (plugin) {
- g_object_get (G_OBJECT (plugin), NM_VPN_PLUGIN_UI_INTERFACE_SERVICE, &service_type, NULL);
- g_object_unref (plugin);
- } else
- service_type = g_strdup ("import");
- }
-
-out:
- gtk_widget_destroy (dialog);
- g_object_unref (builder);
- return service_type;
-}
-
diff --git a/src/connection-editor/vpn-helpers.h b/src/connection-editor/vpn-helpers.h
index f7cd1cb..41fe3df 100644
--- a/src/connection-editor/vpn-helpers.h
+++ b/src/connection-editor/vpn-helpers.h
@@ -39,6 +39,4 @@ void vpn_import (VpnImportSuccessCallback callback, gpointer user_data);
void vpn_export (NMConnection *connection);
-char *vpn_ask_connection_type (GtkWindow *parent);
-
#endif /* _VPN_HELPERS_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]