summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-04-25 12:57:57 +0200
committerLubomir Rintel <lkundrak@v3.sk>2016-04-26 18:34:42 +0200
commit4e2d8351b641f1ce534a8bab3f060fa17a00962f (patch)
tree464851dbcd65d9558974d030175e6219e4e241fb
parenta918f106e5fbba1798679084adb7234380e6e8dd (diff)
applet: open the editor in create mode when there are no vpn connections
Running --show --type vpn doesn't look too good. (cherry picked from commit 8ad7a0cf388f49c8c4e2de9af11918e0130be5de)
-rw-r--r--src/applet.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/applet.c b/src/applet.c
index 53fbfdb7..72ac5c96 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -1070,6 +1070,20 @@ nma_menu_configure_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
}
/*
+ * nma_menu_add_vpn_item_activate
+ *
+ * Signal function called when user clicks "Add a VPN connection..."
+ *
+ */
+static void
+nma_menu_add_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
+{
+ const char *argv[] = { BINDIR "/nm-connection-editor", "--create", "--type", NM_SETTING_VPN_SETTING_NAME, NULL};
+
+ g_spawn_async (NULL, (gchar **) argv, NULL, 0, NULL, NULL, NULL, NULL);
+}
+
+/*
* applet_get_active_vpn_connection:
*
* Gets a VPN connection along with its state. If there are more, ones that
@@ -1478,11 +1492,14 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
}
/* Draw a separator, but only if we have VPN connections above it */
- if (list->len)
+ if (list->len) {
nma_menu_add_separator_item (GTK_WIDGET (vpn_menu));
-
- item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Configure VPN...")));
- g_signal_connect (item, "activate", G_CALLBACK (nma_menu_configure_vpn_item_activate), applet);
+ item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Configure VPN...")));
+ g_signal_connect (item, "activate", G_CALLBACK (nma_menu_configure_vpn_item_activate), applet);
+ } else {
+ item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Add a VPN connection...")));
+ g_signal_connect (item, "activate", G_CALLBACK (nma_menu_add_vpn_item_activate), applet);
+ }
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
gtk_widget_show (GTK_WIDGET (item));