From a8e6fb30cbc55326629d471ee441d50371724e76 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 20 Oct 2023 08:32:45 +0300 Subject: [PATCH 32/32] gtk4x: Migrate options from gtk4-client See osdn #48865 Signed-off-by: Marko Lindqvist --- client/gui-gtk-5.0/gui_main.c | 82 +++++++++++++++++++++++++++++------ client/options.c | 6 +++ client/options.h | 1 + 3 files changed, 75 insertions(+), 14 deletions(-) diff --git a/client/gui-gtk-5.0/gui_main.c b/client/gui-gtk-5.0/gui_main.c index 7713c809b4..8885838208 100644 --- a/client/gui-gtk-5.0/gui_main.c +++ b/client/gui-gtk-5.0/gui_main.c @@ -1856,7 +1856,7 @@ static void migrate_options_from_gtk3_22(void) #define MIGRATE_OPTION(opt) gui_options.gui_gtk4_##opt = gui_options.gui_gtk3_22_##opt; #define MIGRATE_STR_OPTION(opt) \ - strncpy(GUI_GTK_OPTION(opt), gui_options.gui_gtk3_22_##opt, \ + strncpy(gui_options.gui_gtk4_##opt, gui_options.gui_gtk3_22_##opt, \ sizeof(gui_options.gui_gtk4_##opt)); /* Default theme name is never migrated */ @@ -1898,6 +1898,57 @@ static void migrate_options_from_gtk3_22(void) gui_options.gui_gtk4_migrated_from_gtk3_22 = TRUE; } +/**********************************************************************//** + Migrate gtk4x client specific options from gtk4 client options. +**************************************************************************/ +static void migrate_options_from_gtk4(void) +{ + log_normal(_("Migrating options from gtk4 to gtk4x client")); + +#define MIGRATE_OPTION(opt) gui_options.gui_gtk5_##opt = gui_options.gui_gtk4_##opt; +#define MIGRATE_STR_OPTION(opt) \ + strncpy(gui_options.gui_gtk5_##opt, gui_options.gui_gtk4_##opt, \ + sizeof(gui_options.gui_gtk5_##opt)); + + /* Default theme name is never migrated */ + MIGRATE_OPTION(fullscreen); + MIGRATE_OPTION(map_scrollbars); + MIGRATE_OPTION(dialogs_on_top); + MIGRATE_OPTION(show_task_icons); + MIGRATE_OPTION(enable_tabs); + MIGRATE_OPTION(show_chat_message_time); + MIGRATE_OPTION(new_messages_go_to_top); + MIGRATE_OPTION(show_message_window_buttons); + MIGRATE_OPTION(metaserver_tab_first); + MIGRATE_OPTION(allied_chat_only); + MIGRATE_OPTION(message_chat_location); + MIGRATE_OPTION(small_display_layout); + MIGRATE_OPTION(mouse_over_map_focus); + MIGRATE_OPTION(chatline_autocompletion); + MIGRATE_OPTION(citydlg_xsize); + MIGRATE_OPTION(citydlg_ysize); + MIGRATE_OPTION(popup_tech_help); + + MIGRATE_STR_OPTION(font_city_label); + MIGRATE_STR_OPTION(font_notify_label); + MIGRATE_STR_OPTION(font_spaceship_label); + MIGRATE_STR_OPTION(font_help_label); + MIGRATE_STR_OPTION(font_help_link); + MIGRATE_STR_OPTION(font_help_text); + MIGRATE_STR_OPTION(font_chatline); + MIGRATE_STR_OPTION(font_beta_label); + MIGRATE_STR_OPTION(font_small); + MIGRATE_STR_OPTION(font_comment_label); + MIGRATE_STR_OPTION(font_city_names); + MIGRATE_STR_OPTION(font_city_productions); + MIGRATE_STR_OPTION(font_reqtree_text); + +#undef MIGRATE_OPTION +#undef MIGRATE_STR_OPTION + + gui_options.gui_gtk5_migrated_from_gtk4 = TRUE; +} + /**********************************************************************//** Called from client_main(), is what it's named. **************************************************************************/ @@ -1983,24 +2034,27 @@ static void activate_gui(GtkApplication *app, gpointer data) adjust_default_options(); /* We're using fresh defaults for this version of this client, * so prevent any future migrations from other clients / versions */ - gui_options.gui_gtk4_migrated_from_gtk3_22 = TRUE; + gui_options.gui_gtk5_migrated_from_gtk4 = TRUE; /* Avoid also marking previous Gtk clients as migrated, so that * they can have their own run of their adjust_default_options() if - * they are ever run (as a side effect of Gtk2->Gtk3 migration). */ + * they are ever run (as a side effect of Gtk3.22->Gtk4 migration). */ } else { - if (!gui_options.gui_gtk4_migrated_from_gtk3_22) { - if (!gui_options.gui_gtk3_22_migrated_from_gtk3) { - if (!gui_options.gui_gtk3_migrated_from_gtk2) { - migrate_options_from_gtk2(); - /* We want a fresh look at screen-size-related options after Gtk2 */ - adjust_default_options(); - /* We don't ever want to consider pre-2.6 fullscreen option again - * (even for gui-gtk3) */ - gui_options.gui_gtk3_migrated_from_2_5 = TRUE; + if (!gui_options.gui_gtk5_migrated_from_gtk4) { + if (!gui_options.gui_gtk4_migrated_from_gtk3_22) { + if (!gui_options.gui_gtk3_22_migrated_from_gtk3) { + if (!gui_options.gui_gtk3_migrated_from_gtk2) { + migrate_options_from_gtk2(); + /* We want a fresh look at screen-size-related options after Gtk2 */ + adjust_default_options(); + /* We don't ever want to consider pre-2.6 fullscreen option again + * (even for gui-gtk3) */ + gui_options.gui_gtk3_migrated_from_2_5 = TRUE; + } + migrate_options_from_gtk3(); } - migrate_options_from_gtk3(); + migrate_options_from_gtk3_22(); } - migrate_options_from_gtk3_22(); + migrate_options_from_gtk4(); } } diff --git a/client/options.c b/client/options.c index 6c9620a59a..925ed361cb 100644 --- a/client/options.c +++ b/client/options.c @@ -99,6 +99,7 @@ struct client_options gui_options = { .default_tileset_iso_name = "\0", .gui_gtk3_migrated_from_gtk2 = FALSE, .gui_gtk3_22_migrated_from_gtk3 = FALSE, + .gui_gtk5_migrated_from_gtk4 = FALSE, .gui_gtk4_migrated_from_gtk3_22 = FALSE, .gui_sdl2_migrated_from_sdl = FALSE, .gui_sdl3_migrated_from_sdl2 = FALSE, @@ -6222,6 +6223,9 @@ void options_load(void) gui_options.gui_gtk4_migrated_from_gtk3_22 = secfile_lookup_bool_default(sf, gui_options.gui_gtk4_migrated_from_gtk3_22, "%s.migration_gtk4_from_gtk3_22", prefix); + gui_options.gui_gtk5_migrated_from_gtk4 = + secfile_lookup_bool_default(sf, gui_options.gui_gtk5_migrated_from_gtk4, + "%s.migration_gtk5_from_gtk4", prefix); gui_options.gui_sdl2_migrated_from_sdl = secfile_lookup_bool_default(sf, gui_options.gui_sdl2_migrated_from_sdl, "%s.migration_sdl2_from_sdl", prefix); @@ -6373,6 +6377,8 @@ void options_save(option_save_log_callback log_cb) "client.migration_gtk3_22_from_gtk3"); secfile_insert_bool(sf, gui_options.gui_gtk4_migrated_from_gtk3_22, "client.migration_gtk4_from_gtk3"); + secfile_insert_bool(sf, gui_options.gui_gtk5_migrated_from_gtk4, + "client.migration_gtk5_from_gtk4"); secfile_insert_bool(sf, gui_options.gui_sdl2_migrated_from_sdl, "client.migration_sdl2_from_sdl"); secfile_insert_bool(sf, gui_options.gui_sdl3_migrated_from_sdl2, diff --git a/client/options.h b/client/options.h index 5d752a0ab4..5b71d4758e 100644 --- a/client/options.h +++ b/client/options.h @@ -132,6 +132,7 @@ struct client_options char default_tileset_iso_name[512]; /* ...overhead and iso topologies. */ bool gui_gtk3_migrated_from_gtk2; bool gui_gtk3_22_migrated_from_gtk3; + bool gui_gtk5_migrated_from_gtk4; bool gui_gtk4_migrated_from_gtk3_22; bool gui_sdl2_migrated_from_sdl; bool gui_sdl3_migrated_from_sdl2; -- 2.42.0