From 9007c35d378cb936c4c5c5a29fcb4eda500795f6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 13 Apr 2023 04:00:47 +0300 Subject: [PATCH 47/47] gtk4: Add "Reload Tileset" menu entry See osdn #47849 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/menu.c | 63 +++++++++++++++------------------------ 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index ba2dab1a24..0ba2601bc2 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -75,12 +75,6 @@ static bool menus_built = FALSE; static GMenu *setup_menus(GtkApplication *app); -#ifndef FREECIV_DEBUG -static void menu_entry_set_visible(const char *key, - gboolean is_visible, - gboolean is_sensitive); -#endif /* FREECIV_DEBUG */ - #ifdef MENUS_GTK3 static void menu_entry_set_active(const char *key, gboolean is_active); @@ -141,9 +135,11 @@ static void save_game_as_callback(GSimpleAction *action, GVariant *parameter, gpointer data); -#ifdef MENUS_GTK3 -static void reload_tileset_callback(GtkMenuItem *item, gpointer data); -#endif /* MENUS_GTK3 */ +#ifdef FREECIV_DEBUG +static void reload_tileset_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data); +#endif /* FREECIV_DEBUG */ static void save_mapimg_callback(GSimpleAction *action, GVariant *parameter, @@ -567,6 +563,12 @@ static struct menu_entry_info menu_entries[] = "save_options_on_exit", NULL, MGROUP_SAFE, save_options_on_exit_callback, FALSE }, +#ifdef FREECIV_DEBUG + { "RELOAD_TILESET", N_("_Reload Tileset"), + "reload_tileset", "r", MGROUP_SAFE, + NULL, FALSE }, +#endif /* FREECIV_DEBUG */ + { "GAME_SAVE", N_("_Save Game"), "game_save", "s", MGROUP_SAFE, NULL, FALSE }, @@ -1008,10 +1010,6 @@ static struct menu_entry_info menu_entries[] = NULL, FALSE }, #ifdef MENUS_GTK3 - { "RELOAD_TILESET", N_("_Reload Tileset"), - GDK_KEY_r, GDK_ALT_MASK | GDK_CONTROL_MASK, - G_CALLBACK(reload_tileset_callback), MGROUP_SAFE }, - { "RECALC_BORDERS", N_("Recalculate _Borders"), 0, 0, G_CALLBACK(recalc_borders_callback), MGROUP_EDIT }, #endif /* MENUS_GTK3 */ @@ -1058,6 +1056,10 @@ const GActionEntry acts[] = { { "server_options", server_options_callback }, { "save_options", save_options_callback }, +#ifdef FREECIV_DEBUG + { "reload_tileset", reload_tileset_callback }, +#endif /* FREECIV_DEBUG */ + { "game_save", save_game_callback }, { "game_save_as", save_game_as_callback }, { "save_mapimg", save_mapimg_callback }, @@ -1246,15 +1248,17 @@ static void save_options_on_exit_callback(GSimpleAction *action, create_toggle_menu_item(info)); } -#ifdef MENUS_GTK3 +#ifdef FREECIV_DEBUG /************************************************************************//** Item "RELOAD_TILESET" callback. ****************************************************************************/ -static void reload_tileset_callback(GtkMenuItem *item, gpointer data) +static void reload_tileset_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data) { tilespec_reread(NULL, TRUE, 1.0); } -#endif /* MENUS_GTK3 */ +#endif /* FREECIV_DEBUG */ /************************************************************************//** Item "SAVE_GAME" callback. @@ -3059,6 +3063,10 @@ static GMenu *setup_menus(GtkApplication *app) submenu_append_unref(topmenu, _("_Options"), G_MENU_MODEL(options_menu)); +#ifdef FREECIV_DEBUG + menu_entry_init(topmenu, "RELOAD_TILESET"); +#endif /* FREECIV_DEBUG */ + menu_entry_init(topmenu, "GAME_SAVE"); menu_entry_init(topmenu, "GAME_SAVE_AS"); menu_entry_init(topmenu, "MAPIMG_SAVE"); @@ -3275,10 +3283,6 @@ static GMenu *setup_menus(GtkApplication *app) submenu_append_unref(menubar, _("_Help"), G_MENU_MODEL(topmenu)); -#ifndef FREECIV_DEBUG - menu_entry_set_visible("RELOAD_TILESET", FALSE, FALSE); -#endif /* FREECIV_DEBUG */ - menus_built = TRUE; real_menus_update(); @@ -3361,25 +3365,6 @@ static void menu_entry_group_set_sensitive(GActionMap *map, } } -/************************************************************************//** - Sets an action visible. -****************************************************************************/ -#ifndef FREECIV_DEBUG -static void menu_entry_set_visible(const char *key, - gboolean is_visible, - gboolean is_sensitive) -{ -#ifdef MENUS_GTK3 - GtkWidget *item = GTK_WIDGET(gtk_builder_get_object(ui_builder, key)); - - if (item != NULL) { - gtk_widget_set_visible(item, is_visible); - gtk_widget_set_sensitive(item, is_sensitive); - } -#endif /* MENUS_GTK3 */ -} -#endif /* FREECIV_DEBUG */ - #ifdef MENUS_GTK3 /************************************************************************//** Renames an action. -- 2.39.2