From 93b36dd194816e95798b5295fffdb844de14aa47 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 27 Jan 2023 18:00:17 +0200 Subject: [PATCH 15/15] gtk: Add Show Stack Size toggle to View menu See osdn #43377 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/menu.c | 20 ++++++++++++++++++++ client/gui-gtk-3.22/menu.c | 20 ++++++++++++++++++++ client/gui-gtk-4.0/menu.c | 34 ++++++++++++++++++++++++++++++++++ data/gtk3.22_menus.xml | 3 +++ data/gtk3_menus.xml | 3 +++ 5 files changed, 80 insertions(+) diff --git a/client/gui-gtk-3.0/menu.c b/client/gui-gtk-3.0/menu.c index 365d275504..f07cb3adfd 100644 --- a/client/gui-gtk-3.0/menu.c +++ b/client/gui-gtk-3.0/menu.c @@ -200,6 +200,8 @@ static void show_unit_solid_bg_callback(GtkCheckMenuItem *item, gpointer data); static void show_unit_shields_callback(GtkCheckMenuItem *item, gpointer data); +static void show_stack_size_callback(GtkCheckMenuItem *item, + gpointer data); static void show_focus_unit_callback(GtkCheckMenuItem *item, gpointer data); static void show_fog_of_war_callback(GtkCheckMenuItem *item, gpointer data); static void full_screen_callback(GtkCheckMenuItem *item, gpointer data); @@ -464,6 +466,9 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(show_unit_solid_bg_callback), MGROUP_SAFE }, { "SHOW_UNIT_SHIELDS", N_("Unit shields"), 0, 0, G_CALLBACK(show_unit_shields_callback), MGROUP_SAFE }, + { "SHOW_STACK_SIZE", N_("Unit Stack Size"), + GDK_KEY_plus, GDK_CONTROL_MASK, + G_CALLBACK(show_stack_size_callback), MGROUP_SAFE }, { "SHOW_FOCUS_UNIT", N_("Focu_s Unit"), 0, 0, G_CALLBACK(show_focus_unit_callback), MGROUP_SAFE }, { "SHOW_FOG_OF_WAR", N_("Fog of _War"), 0, 0, @@ -1398,6 +1403,17 @@ static void show_unit_shields_callback(GtkCheckMenuItem *item, } } +/************************************************************************//** + Item "SHOW_STACK_SIZE" callback. +****************************************************************************/ +static void show_stack_size_callback(GtkCheckMenuItem *item, + gpointer data) +{ + if (gui_options.draw_unit_stack_size ^ gtk_check_menu_item_get_active(item)) { + key_unit_stack_size_toggle(); + } +} + /************************************************************************//** Item "SHOW_FOCUS_UNIT" callback. ****************************************************************************/ @@ -2275,6 +2291,8 @@ static void view_menu_update_sensitivity(void) gui_options.draw_units || gui_options.draw_focus_unit); menu_entry_set_sensitive("SHOW_UNIT_SHIELDS", gui_options.draw_units || gui_options.draw_focus_unit); + menu_entry_set_sensitive("SHOW_STACK_SIZE", + gui_options.draw_units || gui_options.draw_focus_unit); menu_entry_set_sensitive("SHOW_FOCUS_UNIT", !gui_options.draw_units); } @@ -3104,6 +3122,8 @@ void real_menus_init(void) gui_options.solid_color_behind_units); menu_entry_set_active("SHOW_UNIT_SHIELDS", gui_options.draw_unit_shields); + menu_entry_set_active("SHOW_STACK_SIZE", + gui_options.draw_unit_stack_size); menu_entry_set_active("SHOW_FOCUS_UNIT", gui_options.draw_focus_unit); menu_entry_set_active("SHOW_FOG_OF_WAR", diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index e27cadb1b7..26d010549a 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -201,6 +201,8 @@ static void show_unit_solid_bg_callback(GtkCheckMenuItem *item, gpointer data); static void show_unit_shields_callback(GtkCheckMenuItem *item, gpointer data); +static void show_stack_size_callback(GtkCheckMenuItem *item, + gpointer data); static void show_focus_unit_callback(GtkCheckMenuItem *item, gpointer data); static void show_fog_of_war_callback(GtkCheckMenuItem *item, gpointer data); static void full_screen_callback(GtkCheckMenuItem *item, gpointer data); @@ -471,6 +473,9 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(show_unit_solid_bg_callback), MGROUP_SAFE }, { "SHOW_UNIT_SHIELDS", N_("Unit shields"), 0, 0, G_CALLBACK(show_unit_shields_callback), MGROUP_SAFE }, + { "SHOW_STACK_SIZE", N_("Unit Stack Size"), + GDK_KEY_plus, GDK_CONTROL_MASK, + G_CALLBACK(show_stack_size_callback), MGROUP_SAFE }, { "SHOW_FOCUS_UNIT", N_("Focu_s Unit"), 0, 0, G_CALLBACK(show_focus_unit_callback), MGROUP_SAFE }, { "SHOW_FOG_OF_WAR", N_("Fog of _War"), 0, 0, @@ -1405,6 +1410,17 @@ static void show_unit_shields_callback(GtkCheckMenuItem *item, } } +/************************************************************************//** + Item "SHOW_STACK_SIZE" callback. +****************************************************************************/ +static void show_stack_size_callback(GtkCheckMenuItem *item, + gpointer data) +{ + if (gui_options.draw_unit_stack_size ^ gtk_check_menu_item_get_active(item)) { + key_unit_stack_size_toggle(); + } +} + /************************************************************************//** Item "SHOW_FOCUS_UNIT" callback. ****************************************************************************/ @@ -2298,6 +2314,8 @@ static void view_menu_update_sensitivity(void) gui_options.draw_units || gui_options.draw_focus_unit); menu_entry_set_sensitive("SHOW_UNIT_SHIELDS", gui_options.draw_units || gui_options.draw_focus_unit); + menu_entry_set_sensitive("SHOW_STACK_SIZE", + gui_options.draw_units || gui_options.draw_focus_unit); menu_entry_set_sensitive("SHOW_FOCUS_UNIT", !gui_options.draw_units); } @@ -3116,6 +3134,8 @@ void real_menus_init(void) gui_options.solid_color_behind_units); menu_entry_set_active("SHOW_UNIT_SHIELDS", gui_options.draw_unit_shields); + menu_entry_set_active("SHOW_STACK_SIZE", + gui_options.draw_unit_stack_size); menu_entry_set_active("SHOW_FOCUS_UNIT", gui_options.draw_focus_unit); menu_entry_set_active("SHOW_FOG_OF_WAR", diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index 756864ac46..ddaac17cbd 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -301,6 +301,13 @@ static void show_unit_solid_bg_callback(GSimpleAction *action, static void show_unit_shields_callback(GSimpleAction *action, GVariant *parameter, gpointer data); +#endif /* MENUS_GTK3 */ + +static void show_stack_size_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data); + +#ifdef MENUS_GTK3 static void show_focus_unit_callback(GSimpleAction *action, GVariant *parameter, gpointer data); @@ -554,6 +561,10 @@ static struct menu_entry_info menu_entries[] = "show_city_full_bar", NULL, MGROUP_SAFE, show_city_full_bar_callback, FALSE }, + { "SHOW_STACK_SIZE", N_("Unit Stack Size"), + "show_stack_size", "plus", MGROUP_SAFE, + show_stack_size_callback, FALSE }, + { "FULL_SCREEN", N_("_Fullscreen"), "full_screen", "F11", MGROUP_SAFE, full_screen_callback, FALSE }, @@ -916,6 +927,7 @@ enum { VMENU_NAT_BORDERS, VMENU_NATIVE_TILES, VMENU_CITY_FULL_BAR, + VMENU_STACK_SIZE, VMENU_FULL_SCREEN }; @@ -1816,7 +1828,27 @@ static void show_unit_shields_callback(GSimpleAction *action, key_unit_shields_toggle(); } } +#endif /* MENUS_GTK3 */ +/************************************************************************//** + Item "SHOW_STACK_SIZE" callback. +****************************************************************************/ +static void show_stack_size_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data) +{ + struct menu_entry_info *info = (struct menu_entry_info *)data; + + info->state ^= 1; + + key_unit_stack_size_toggle(); + + g_menu_remove(view_menu, VMENU_STACK_SIZE); + menu_item_insert_unref(view_menu, VMENU_STACK_SIZE, + create_toggle_menu_item_for_key("SHOW_STACK_SIZE")); +} + +#ifdef MENUS_GTK3 /************************************************************************//** Item "SHOW_FOCUS_UNIT" callback. ****************************************************************************/ @@ -2696,6 +2728,7 @@ const struct menu_entry_option_map meoms[] = { { "SHOW_NAT_BORDERS", &gui_options.draw_borders }, { "SHOW_NATIVE_TILES", &gui_options.draw_native }, { "SHOW_CITY_FULL_BAR", &gui_options.draw_full_citybar }, + { "SHOW_STACK_SIZE", &gui_options.draw_unit_stack_size }, { NULL, NULL } }; @@ -2837,6 +2870,7 @@ static GMenu *setup_menus(GtkApplication *app) menu_entry_init(view_menu, "SHOW_NAT_BORDERS"); menu_entry_init(view_menu, "SHOW_NATIVE_TILES"); menu_entry_init(view_menu, "SHOW_CITY_FULL_BAR"); + menu_entry_init(view_menu, "SHOW_STACK_SIZE"); menu_entry_init(view_menu, "FULL_SCREEN"); menu_entry_init(view_menu, "CENTER_VIEW"); diff --git a/data/gtk3.22_menus.xml b/data/gtk3.22_menus.xml index d8886cfc81..2157b233e2 100644 --- a/data/gtk3.22_menus.xml +++ b/data/gtk3.22_menus.xml @@ -198,6 +198,9 @@ + + + diff --git a/data/gtk3_menus.xml b/data/gtk3_menus.xml index 5b01670295..69b9220ee7 100644 --- a/data/gtk3_menus.xml +++ b/data/gtk3_menus.xml @@ -192,6 +192,9 @@ + + + -- 2.39.0