Skip to content

Commit 18f5562

Browse files
committed
Added files as additional command line arguments
1 parent fea06cc commit 18f5562

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

remmina/src/remmina.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,20 @@ static int gcrypt_thread_initialized = 0;
7575

7676
static GOptionEntry remmina_options[] =
7777
{
78-
{ "about", 'a', 0, G_OPTION_ARG_NONE, NULL, N_("Show about dialog"), NULL },
79-
{ "connect", 'c', 0, G_OPTION_ARG_FILENAME, NULL, N_("Connect to a .remmina file"), "FILE" },
80-
{ "edit", 'e', 0, G_OPTION_ARG_FILENAME, NULL, N_("Edit a .remmina file"), "FILE" },
81-
{ "help", '?', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, NULL, NULL, NULL },
82-
{ "new", 'n', 0, G_OPTION_ARG_NONE, NULL, N_("Create a new connection profile"), NULL },
83-
{ "pref", 'p', 0, G_OPTION_ARG_STRING, NULL, N_("Show preferences dialog page"), "PAGENR" },
84-
{ "plugin", 'x', 0, G_OPTION_ARG_STRING, NULL, N_("Execute the plugin"), "PLUGIN" },
85-
{ "quit", 'q', 0, G_OPTION_ARG_NONE, NULL, N_("Quit the application"), NULL },
86-
{ "server", 's', 0, G_OPTION_ARG_STRING, NULL, N_("Use default server name (for --new)"), "SERVER" },
87-
{ "protocol", 't', 0, G_OPTION_ARG_STRING, NULL, N_("Use default protocol (for --new)"), "PROTOCOL" },
88-
{ "icon", 'i', 0, G_OPTION_ARG_NONE, NULL, N_("Start as tray icon"), NULL },
89-
{ "version", 'v', 0, G_OPTION_ARG_NONE, NULL, N_("Show the application's version"), NULL },
90-
{ "full-version", 'V', 0, G_OPTION_ARG_NONE, NULL, N_("Show the application's version, including the pulgin versions"), NULL },
78+
{ "about", 'a', 0, G_OPTION_ARG_NONE, NULL, N_("Show about dialog"), NULL },
79+
{ "connect", 'c', 0, G_OPTION_ARG_FILENAME, NULL, N_("Connect to a .remmina file"), "FILE" },
80+
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, NULL, N_("Connect to a .remmina file"), "FILE" },
81+
{ "edit", 'e', 0, G_OPTION_ARG_FILENAME, NULL, N_("Edit a .remmina file"), "FILE" },
82+
{ "help", '?', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, NULL, NULL, NULL },
83+
{ "new", 'n', 0, G_OPTION_ARG_NONE, NULL, N_("Create a new connection profile"), NULL },
84+
{ "pref", 'p', 0, G_OPTION_ARG_STRING, NULL, N_("Show preferences dialog page"), "PAGENR" },
85+
{ "plugin", 'x', 0, G_OPTION_ARG_STRING, NULL, N_("Execute the plugin"), "PLUGIN" },
86+
{ "quit", 'q', 0, G_OPTION_ARG_NONE, NULL, N_("Quit the application"), NULL },
87+
{ "server", 's', 0, G_OPTION_ARG_STRING, NULL, N_("Use default server name (for --new)"), "SERVER" },
88+
{ "protocol", 't', 0, G_OPTION_ARG_STRING, NULL, N_("Use default protocol (for --new)"), "PROTOCOL" },
89+
{ "icon", 'i', 0, G_OPTION_ARG_NONE, NULL, N_("Start as tray icon"), NULL },
90+
{ "version", 'v', 0, G_OPTION_ARG_NONE, NULL, N_("Show the application's version"), NULL },
91+
{ "full-version", 'V', 0, G_OPTION_ARG_NONE, NULL, N_("Show the application's version, including the pulgin versions"), NULL },
9192
{ NULL }
9293
};
9394

@@ -111,6 +112,7 @@ static gint remmina_on_command_line(GApplication *app, GApplicationCommandLine *
111112
gboolean executed = FALSE;
112113
GVariantDict *opts;
113114
gchar *str;
115+
const gchar **remaining_args;
114116
gchar *protocol;
115117
gchar *server;
116118

@@ -132,11 +134,17 @@ static gint remmina_on_command_line(GApplication *app, GApplicationCommandLine *
132134
* https://github.com/FreeRDP/Remmina/issues/915
133135
*/
134136
if (g_variant_dict_lookup(opts, "connect", "^ay", &str)) {
135-
remmina_exec_command(REMMINA_COMMAND_CONNECT, str);
137+
remmina_exec_command(REMMINA_COMMAND_CONNECT, g_strdup(str));
136138
g_free(str);
137139
executed = TRUE;
138140
}
139141

142+
if (g_variant_dict_lookup(opts, G_OPTION_REMAINING, "^a&ay", &remaining_args)) {
143+
remmina_exec_command(REMMINA_COMMAND_CONNECT, remaining_args[0]);
144+
g_free(remaining_args);
145+
executed = TRUE;
146+
}
147+
140148
if (g_variant_dict_lookup(opts, "edit", "^ay", &str)) {
141149
remmina_exec_command(REMMINA_COMMAND_EDIT, str);
142150
g_free(str);

0 commit comments

Comments
 (0)