[network-manager-applet/lr/import] fixup! editor: add --import command line argument



commit 6bf3421a81df2b7e41259ada582339439f947a48
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Sun Oct 30 16:06:30 2016 +0100

    fixup! editor: add --import command line argument

 src/connection-editor/main.c |   43 ++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 752472a..23cf4c2 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -49,17 +49,25 @@ static GDBusNodeInfo *introspection_data = NULL;
 
 /*************************************************/
 
+typedef struct {
+       NMConnectionList *list;
+       GType ctype;
+       char *detail;
+       NMConnection *connection;
+} CreateConnectionInfo;
+
 static gboolean
 idle_create_connection (gpointer user_data)
 {
-       NMConnectionList *list = user_data;
-       GType ctype = (GType) GPOINTER_TO_SIZE (g_object_get_data (G_OBJECT (list), 
"nm-connection-editor-ctype"));
-       char *detail = g_object_get_data (G_OBJECT (list), "nm-connection-editor-detail");
-       NMConnection *connection = g_object_get_data (G_OBJECT (list), "nm-connection-editor-connection");
+       CreateConnectionInfo *info = user_data;
 
-       nm_connection_list_create (list, ctype, detail, connection);
+       nm_connection_list_create (info->list, info->ctype,
+                                  info->detail, info->connection);
 
-       nm_g_object_unref (connection);
+       g_object_unref (info->list);
+       g_free (info->detail);
+       nm_g_object_unref (info->connection);
+       g_slice_free (CreateConnectionInfo, info);
        return FALSE;
 }
 
@@ -76,7 +84,7 @@ handle_arguments (NMConnectionList *list,
        GType ctype = 0;
        gs_free char *type_tmp = NULL;
        const char *p, *detail = NULL;
-       NMConnection *connection = NULL;
+       CreateConnectionInfo *info;
 
        if (type) {
                p = strchr (type, ':');
@@ -101,20 +109,19 @@ handle_arguments (NMConnectionList *list,
                        /* If type is "vpn" and the user cancels the "vpn type" dialog, we need
                         * to quit. But we haven't even started yet. So postpone this to an idle.
                         */
-                       g_idle_add (idle_create_connection, list);
-                       g_object_set_data (G_OBJECT (list), "nm-connection-editor-ctype",
-                                          GSIZE_TO_POINTER (ctype));
-                       g_object_set_data_full (G_OBJECT (list), "nm-connection-editor-detail",
-                                               g_strdup (detail), g_free);
+                       info = g_slice_new0 (CreateConnectionInfo);
+                       info->list = g_object_ref (list);
+                       info->ctype = ctype;
+                       info->detail = g_strdup (detail);
+                       g_idle_add (idle_create_connection, info);
                }
                show_list = FALSE;
        } else if (import) {
-               connection = vpn_connection_from_file (import);
-               g_idle_add (idle_create_connection, list);
-               g_object_set_data (G_OBJECT (list), "nm-connection-editor-ctype",
-                                  GSIZE_TO_POINTER (NM_TYPE_SETTING_VPN));
-               g_object_set_data_full (G_OBJECT (list), "nm-connection-editor-connection",
-                                       nm_g_object_ref (connection), nm_g_object_unref);
+               info = g_slice_new0 (CreateConnectionInfo);
+               info->list = g_object_ref (list);
+               info->ctype = NM_TYPE_SETTING_VPN;
+               info->connection = nm_g_object_ref (vpn_connection_from_file (import));
+               g_idle_add (idle_create_connection, info);
                show_list = FALSE;
        } else if (edit_uuid) {
                /* Show the edit dialog for the given UUID */


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