From 301ca7500e08865291dc8d4b503efb7f145415c9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 11 Jun 2022 16:24:31 +0300 Subject: [PATCH 38/38] gtk4: Add menu entry for founding a city See osdn #44798 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/menu.c | 30 +++++++++++++++++++++++++----- client/gui-gtk-4.0/wldlg.c | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index fa5d5bc657..8ced19647f 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -255,7 +255,11 @@ static void unit_homecity_callback(GtkMenuItem *item, gpointer data); static void unit_upgrade_callback(GtkMenuItem *item, gpointer data); static void unit_convert_callback(GtkMenuItem *item, gpointer data); static void unit_disband_callback(GtkMenuItem *item, gpointer data); -static void build_city_callback(GtkMenuItem *item, gpointer data); +#endif /* MENUS_GTK3 */ +static void build_city_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data); +#ifdef MENUS_GTK3 static void auto_settle_callback(GtkMenuItem *item, gpointer data); static void build_road_callback(GtkMenuItem *item, gpointer data); static void build_irrigation_callback(GtkMenuItem *item, gpointer data); @@ -277,6 +281,7 @@ static void diplomat_action_callback(GtkMenuItem *item, gpointer data); static struct menu_entry_info menu_entries[] = { + /* Game menu */ { "CLEAR_CHAT_LOGS", N_("_Clear Chat Log"), "app.clear_chat", NULL, MGROUP_SAFE }, { "SAVE_CHAT_LOGS", N_("Save Chat _Log"), @@ -291,6 +296,11 @@ static struct menu_entry_info menu_entries[] = { "QUIT", N_("_Quit"), "app.quit", "q", MGROUP_SAFE }, + + /* Work menu */ + { "BUILD_CITY", N_("_Build City"), + "app.build_city", "b", MGROUP_UNIT }, + #ifdef MENUS_GTK3 { "MENU_GAME", N_("_Game"), 0, 0, NULL, MGROUP_SAFE }, { "MENU_OPTIONS", N_("_Options"), 0, 0, NULL, MGROUP_SAFE }, @@ -531,8 +541,7 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(unit_convert_callback), MGROUP_UNIT }, { "UNIT_DISBAND", N_("_Disband"), GDK_KEY_d, GDK_SHIFT_MASK, G_CALLBACK(unit_disband_callback), MGROUP_UNIT }, - { "BUILD_CITY", N_("_Build City"), GDK_KEY_b, 0, - G_CALLBACK(build_city_callback), MGROUP_UNIT }, + { "AUTO_SETTLER", N_("_Auto Settler"), GDK_KEY_a, 0, G_CALLBACK(auto_settle_callback), MGROUP_UNIT }, { "BUILD_ROAD", N_("Build _Road"), GDK_KEY_r, 0, @@ -588,7 +597,9 @@ const GActionEntry acts[] = { { "message_options", message_options_callback }, { "leave", leave_callback }, - { "quit", quit_callback } + { "quit", quit_callback }, + + { "build_city", build_city_callback } }; static struct menu_entry_info *menu_entry_info_find(const char *key); @@ -1629,11 +1640,14 @@ static void unit_disband_callback(GtkMenuItem *item, gpointer data) { popup_disband_dialog(get_units_in_focus()); } +#endif /* MENUS_GTK3 */ /************************************************************************//** Item "BUILD_CITY" callback. ****************************************************************************/ -static void build_city_callback(GtkMenuItem *item, gpointer data) +static void build_city_callback(GSimpleAction *action, + GVariant *parameter, + gpointer data) { unit_list_iterate(get_units_in_focus(), punit) { /* FIXME: this can provide different items for different units... @@ -1649,6 +1663,7 @@ static void build_city_callback(GtkMenuItem *item, gpointer data) } unit_list_iterate_end; } +#ifdef MENUS_GTK3 /************************************************************************//** Action "AUTO_SETTLE" callback. ****************************************************************************/ @@ -1996,6 +2011,11 @@ GMenu *setup_menus(GtkApplication *app) g_menu_append_submenu(menubar, _("_Game"), G_MENU_MODEL(topmenu)); + topmenu = g_menu_new(); + menu_entry_init(topmenu, "BUILD_CITY"); + + g_menu_append_submenu(menubar, _("_Work"), G_MENU_MODEL(topmenu)); + #ifndef FREECIV_DEBUG menu_entry_set_visible("RELOAD_TILESET", FALSE, FALSE); #endif /* FREECIV_DEBUG */ diff --git a/client/gui-gtk-4.0/wldlg.c b/client/gui-gtk-4.0/wldlg.c index d87043f3db..11149ba1de 100644 --- a/client/gui-gtk-4.0/wldlg.c +++ b/client/gui-gtk-4.0/wldlg.c @@ -1237,8 +1237,8 @@ GtkWidget *create_worklist(void) g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), ptr); ptr->add_cmd = item; -#endif /* MENUS_GTK3 */ gtk_widget_set_sensitive(ptr->add_cmd, FALSE); +#endif /* MENUS_GTK3 */ button = icon_label_button_new("help-browser", _("Help")); gtk_box_append(GTK_BOX(bbox), button); -- 2.35.1