[network-manager-applet] editor: handle --keep-above passed through to editor_command_line



commit 88e4dcab27e614e948a78e2235495a78fc0f1993
Author: Adam Williamson <awilliam redhat com>
Date:   Fri Jun 1 16:20:34 2018 -0700

    editor: handle --keep-above passed through to editor_command_line
    
    Handling of nm-connection-editor command line arguments was changed in
    f3782da2. Since that commit, most args are handled by `editor_command_line`,
    but one (`--keep-above`) is handled by `main`. Unfortunately, if
    `--keep-above` appears with other arguments, `main` does not strip it from
    argv and parsing in `editor_command_line` fails with "Failed to parse
    options".
    
    To handle this, let's just have `editor_command_line` recognize but ignore
    `--keep-above` if it encounters it.
    
    https://gitlab.gnome.org/GNOME/network-manager-applet/issues/1
    
    Signed-off-by: Adam Williamson <awilliam redhat com>

 src/connection-editor/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 29facda9..92fdbda7 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -224,7 +224,7 @@ editor_command_line (GApplication *application,
        GOptionContext *opt_ctx = NULL;
        GError *error = NULL;
        gs_free char *type = NULL, *uuid = NULL, *import = NULL;
-       gboolean create = FALSE, show = FALSE;
+       gboolean create = FALSE, show = FALSE, keepabove = FALSE;
        int ret = 1;
        GOptionEntry entries[] = {
                { "type",   't', 0, G_OPTION_ARG_STRING, &type,   "Type of connection to show or create", 
NM_SETTING_WIRED_SETTING_NAME },
@@ -232,6 +232,10 @@ editor_command_line (GApplication *application,
                { "show",   's', 0, G_OPTION_ARG_NONE,   &show,   "Show a given connection type page", NULL },
                { "edit",   'e', 0, G_OPTION_ARG_STRING, &uuid,   "Edit an existing connection with a given 
UUID", "UUID" },
                { "import", 'i', 0, G_OPTION_ARG_STRING, &import, "Import a VPN connection from given file", 
NULL },
+               /* handled in main but may be passed through here, so we need
+                * to parse and ignore it
+                */
+               { "keep-above", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &keepabove, NULL, NULL },
                { NULL }
        };
 


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