[gnome-control-center] network: allow selecting a specific VPN or virtual interface



commit 10ffa301b725de070807483047bcccc5bcbe2ee2
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Feb 17 14:50:51 2014 +0100

    network: allow selecting a specific VPN or virtual interface
    
    Overload the show-device operation to accept paths to NMConnections,
    which can be matched to VPN connections or unadopted virtual
    interfaces.
    This will be used by gnome-shell to implement the VPN Settings
    menu item.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724547

 panels/network/cc-network-panel.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 895edca..cc1df5f 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -594,6 +594,28 @@ handle_argv_for_device (CcNetworkPanel *panel,
         return FALSE;
 }
 
+static gboolean
+handle_argv_for_connection (CcNetworkPanel *panel,
+                            NMConnection   *connection,
+                            GtkTreeIter    *iter)
+{
+        CcNetworkPanelPrivate *priv = panel->priv;
+
+        if (priv->arg_operation == OPERATION_NULL)
+                return TRUE;
+        if (priv->arg_operation != OPERATION_SHOW_DEVICE)
+                return FALSE;
+
+        if (g_strcmp0 (nm_connection_get_path (connection), priv->arg_device) == 0) {
+                reset_command_line_args (panel);
+                select_tree_iter (panel, iter);
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+
 static void
 handle_argv (CcNetworkPanel *panel)
 {
@@ -610,15 +632,20 @@ handle_argv (CcNetworkPanel *panel)
         while (ret) {
                 GObject *object_tmp;
                 NMDevice *device;
+                NMConnection *connection;
                 gboolean done = FALSE;
 
                 gtk_tree_model_get (model, &iter,
                                     PANEL_DEVICES_COLUMN_OBJECT, &object_tmp,
                                     -1);
-                if (g_object_class_find_property (G_OBJECT_GET_CLASS (object_tmp), "nm-device") != NULL) {
+                if (NET_IS_DEVICE (object_tmp)) {
                         g_object_get (object_tmp, "nm-device", &device, NULL);
                         done = handle_argv_for_device (panel, device, &iter);
                         g_object_unref (device);
+                } else if (NET_IS_VPN (object_tmp) || NET_IS_VIRTUAL_DEVICE (object_tmp)) {
+                        g_object_get (object_tmp, "connection", &connection, NULL);
+                        done = handle_argv_for_connection (panel, connection, &iter);
+                        g_object_unref (connection);
                 }
 
                 g_object_unref (object_tmp);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]