From d854909b040b021ef027d53cbfd6555b175c1bb8 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 3 Oct 2020 01:41:52 +0200 Subject: [PATCH] GTK: Fix opening a ROM from the command line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only the first of the positional arguments is interpreted as the ROM’s filename, because we don’t emulate multiple ROMs at once. Fixes #382. --- desmume/src/frontend/posix/gtk/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/desmume/src/frontend/posix/gtk/main.cpp b/desmume/src/frontend/posix/gtk/main.cpp index b1e090ff8..6da213ce4 100644 --- a/desmume/src/frontend/posix/gtk/main.cpp +++ b/desmume/src/frontend/posix/gtk/main.cpp @@ -4446,6 +4446,18 @@ static void Teardown() { #endif } +static void +handle_open(GApplication *application, + GFile **files, + gint n_files, + const gchar *hint, + 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); +} + int main (int argc, char *argv[]) { configured_features my_config; @@ -4464,8 +4476,9 @@ int main (int argc, char *argv[]) } // TODO: pass G_APPLICATION_HANDLES_COMMAND_LINE instead. - GtkApplication *app = gtk_application_new("org.desmume.DeSmuME", G_APPLICATION_FLAGS_NONE); + GtkApplication *app = gtk_application_new("org.desmume.DeSmuME", G_APPLICATION_HANDLES_OPEN); g_signal_connect (app, "activate", G_CALLBACK(common_gtk_main), &my_config); + g_signal_connect (app, "open", G_CALLBACK(handle_open), &my_config); g_action_map_add_action_entries(G_ACTION_MAP(app), app_entries, G_N_ELEMENTS(app_entries), app);