[GTK3] Implement boot ROM search path preference

This commit is contained in:
Maximilian Mader 2019-09-28 00:15:37 +02:00
parent f3f2e66faf
commit 404e9dd1d5
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
2 changed files with 15 additions and 4 deletions

View File

@ -30,6 +30,7 @@ static GtkBuilder *builder;
static GtkGLArea *gl_area;
static GtkApplicationWindow *main_window;
static GtkWindow *preferences;
static GtkWindow *vram_viewer;
static GtkWindow *memory_viewer;
static GtkWindow *console;
@ -406,10 +407,18 @@ G_MODULE_EXPORT void on_rewind_duration_changed(GtkWidget *w, gpointer user_data
G_MODULE_EXPORT void on_boot_rom_location_changed(GtkWidget *w, gpointer user_data_gptr) {
GtkComboBox *box = GTK_COMBO_BOX(w);
const gchar *id = gtk_combo_box_get_active_id(box);
if (id == NULL) return;
if (g_strcmp0(id, "other") == 0) {
g_print("TODO: Open path picker\n");
update_boot_rom_selector(builder);
GtkFileChooserNative *native = gtk_file_chooser_native_new("Select Folder", preferences, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "_Select", "_Cancel");
gint res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
if (res == GTK_RESPONSE_ACCEPT) {
config.boot_rom_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native));
update_boot_rom_selector(builder);
}
g_object_unref(native);
}
else {
config.boot_rom_path = (gchar *)id;
@ -439,7 +448,7 @@ static void startup(GApplication *app, gpointer user_data_gptr) {
gtk_widget_destroy(gtkget(GTK_WIDGET, "menubar_override_selector"));
#endif
GtkWindow *preferences = GTK_WINDOW(get_object("preferences"));
preferences = GTK_WINDOW(get_object("preferences"));
g_signal_connect(preferences, "realize", G_CALLBACK(on_preferences_realize), (gpointer) builder);
init_settings(user_data->config_path, preferences);

View File

@ -182,11 +182,13 @@ void update_boot_rom_selector(GtkBuilder *builder) {
GtkComboBoxText *combo_box = gtkget(GTK_COMBO_BOX_TEXT, "boot_rom_selector");
gtk_combo_box_text_remove_all(combo_box);
gtk_combo_box_text_append(combo_box, "auto", "Use Built-in Boot ROMs");
gtk_combo_box_set_active_id(GTK_COMBO_BOX(combo_box), "auto");
if (config.boot_rom_path != NULL && !g_str_equal(config.boot_rom_path, "auto") && !g_str_equal(config.boot_rom_path, "other")) {
gtk_combo_box_text_append(combo_box, config.boot_rom_path, config.boot_rom_path);
gtk_combo_box_set_active_id(GTK_COMBO_BOX(combo_box), config.boot_rom_path);
}
else {
gtk_combo_box_set_active_id(GTK_COMBO_BOX(combo_box), "auto");
}
gtk_combo_box_text_append_text(combo_box, "<separator>");
gtk_combo_box_text_append(combo_box, "other", "Other");
}