From 581155aa300bd236ee00f04cb2fc4467ba714e62 Mon Sep 17 00:00:00 2001 From: Ingo Saitz Date: Sun, 3 Jan 2021 16:00:38 +0100 Subject: [PATCH] GTK: ignore options Specifying any options on the command line besides the ROM dump aborts with "Unknown option <--option-name>". This happened after starting the GTK application, which wants to parse the command line again. Install an empty command-line signal handler into the GTK application, since options are already parsed by CommandLine::parse(). Setting .nds_filename was alredy done by CommandLine::parse(), too, so the signal handler for open can be removed. --- desmume/src/frontend/posix/gtk/main.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/desmume/src/frontend/posix/gtk/main.cpp b/desmume/src/frontend/posix/gtk/main.cpp index 6ca9b273c..06312d99b 100644 --- a/desmume/src/frontend/posix/gtk/main.cpp +++ b/desmume/src/frontend/posix/gtk/main.cpp @@ -3549,16 +3549,13 @@ static void Teardown() { #endif } -static void -handle_open(GApplication *application, - GFile **files, - gint n_files, - const gchar *hint, +static gint +ignore_command_line(GApplication *application, + GApplicationCommandLine *command_line, gpointer user_data) { - configured_features *my_config = static_cast(user_data); - my_config->nds_file = g_file_get_path(files[0]); common_gtk_main(application, user_data); + return 0; } int main (int argc, char *argv[]) @@ -3578,10 +3575,9 @@ int main (int argc, char *argv[]) fprintf(stderr, "Warning: X11 not thread-safe\n"); } - // TODO: pass G_APPLICATION_HANDLES_COMMAND_LINE instead. - GtkApplication *app = gtk_application_new("org.desmume.DeSmuME", G_APPLICATION_HANDLES_OPEN); + GtkApplication *app = gtk_application_new("org.desmume.DeSmuME", G_APPLICATION_HANDLES_COMMAND_LINE); g_signal_connect (app, "activate", G_CALLBACK(common_gtk_main), &my_config); - g_signal_connect (app, "open", G_CALLBACK(handle_open), &my_config); + g_signal_connect (app, "command-line", G_CALLBACK(ignore_command_line), &my_config); g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app);