From 6360389d08b8b3f1e8efad55fc83c4780e0e2806 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 11 Apr 2020 18:55:21 +0200 Subject: [PATCH] [GTK3] Implement ROM loading from open file dialog --- gtk3/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gtk3/main.c b/gtk3/main.c index 7eeb7de..45b3dbc 100644 --- a/gtk3/main.c +++ b/gtk3/main.c @@ -1096,8 +1096,10 @@ static void activate_open(GSimpleAction *action, GVariant *parameter, gpointer a gint res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)); if (res == GTK_RESPONSE_ACCEPT) { - // TODO: Emit an event for our emulation loop - g_message("%s", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native))); + const char* path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native)); + gui_data.file = g_file_new_for_path(path); + + activate_reset(action, parameter, app); } g_object_unref(native); @@ -2090,6 +2092,8 @@ static void run(GuiData *gui_data) { static gpointer run_thread(gpointer gui_data_gptr) { GuiData *gui_data = gui_data_gptr; + if (!gui_data->file) return NULL; + if (gui_data->stopped) { start(gui_data); } @@ -2101,7 +2105,6 @@ static gpointer run_thread(gpointer gui_data_gptr) { return NULL; } - static void init(GuiData *gui_data) { if (GB_is_inited(&gb)) return;