[GTK3] Implement boot ROM search path preference

This commit is contained in:
Maximilian Mader 2019-09-28 00:15:37 +02:00
parent 023d43e893
commit a243325b8c
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 GtkGLArea *gl_area;
static GtkApplicationWindow *main_window; static GtkApplicationWindow *main_window;
static GtkWindow *preferences;
static GtkWindow *vram_viewer; static GtkWindow *vram_viewer;
static GtkWindow *memory_viewer; static GtkWindow *memory_viewer;
static GtkWindow *console; 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) { G_MODULE_EXPORT void on_boot_rom_location_changed(GtkWidget *w, gpointer user_data_gptr) {
GtkComboBox *box = GTK_COMBO_BOX(w); GtkComboBox *box = GTK_COMBO_BOX(w);
const gchar *id = gtk_combo_box_get_active_id(box); const gchar *id = gtk_combo_box_get_active_id(box);
if (id == NULL) return;
if (g_strcmp0(id, "other") == 0) { if (g_strcmp0(id, "other") == 0) {
g_print("TODO: Open path picker\n"); GtkFileChooserNative *native = gtk_file_chooser_native_new("Select Folder", preferences, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "_Select", "_Cancel");
update_boot_rom_selector(builder); 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 { else {
config.boot_rom_path = (gchar *)id; 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")); gtk_widget_destroy(gtkget(GTK_WIDGET, "menubar_override_selector"));
#endif #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); g_signal_connect(preferences, "realize", G_CALLBACK(on_preferences_realize), (gpointer) builder);
init_settings(user_data->config_path, preferences); 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"); GtkComboBoxText *combo_box = gtkget(GTK_COMBO_BOX_TEXT, "boot_rom_selector");
gtk_combo_box_text_remove_all(combo_box); gtk_combo_box_text_remove_all(combo_box);
gtk_combo_box_text_append(combo_box, "auto", "Use Built-in Boot ROMs"); 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")) { 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_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); 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_text(combo_box, "<separator>");
gtk_combo_box_text_append(combo_box, "other", "Other"); gtk_combo_box_text_append(combo_box, "other", "Other");
} }