From 738cacf13e15b22a44b8c565dc8d19f9afd21759 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 17 Feb 2023 22:48:40 +0200 Subject: [PATCH 21/21] gtk: Hide Production tab from diplomat investigate city dialog It was empty, but still present. See osdn #45318 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/citydlg.c | 24 +++++++++++++++--------- client/gui-gtk-3.22/citydlg.c | 21 +++++++++++++-------- client/gui-gtk-4.0/citydlg.c | 14 ++++++++++---- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/client/gui-gtk-3.0/citydlg.c b/client/gui-gtk-3.0/citydlg.c index 25b34ef6b6..a5345650c7 100644 --- a/client/gui-gtk-3.0/citydlg.c +++ b/client/gui-gtk-3.0/citydlg.c @@ -1512,6 +1512,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) GtkWidget *vbox, *hbox, *cbox, *ebox; int citizen_bar_width; int citizen_bar_height; + struct player *owner; if (!city_dialogs_have_been_initialised) { initialize_city_dialogs(); @@ -1525,10 +1526,13 @@ static struct city_dialog *create_city_dialog(struct city *pcity) pdialog->happiness.map_canvas.ebox = NULL; /* ditto */ pdialog->happiness.map_canvas.darea = NULL; /* ditto */ pdialog->happiness.citizens = NULL; /* ditto */ + pdialog->production.buy_command = NULL; + pdialog->production.production_label = NULL; + pdialog->production.production_bar = NULL; pdialog->cma_editor = NULL; pdialog->map_canvas_store_unscaled = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - canvas_width, canvas_height); + canvas_width, canvas_height); pdialog->shell = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(pdialog->shell), city_name_get(pcity)); @@ -1608,14 +1612,16 @@ static struct city_dialog *create_city_dialog(struct city *pcity) create_and_append_overview_page(pdialog); create_and_append_map_page(pdialog); create_and_append_buildings_page(pdialog); - create_and_append_worklist_page(pdialog); - /* only create these tabs if not a spy */ - if (!client_has_player() || city_owner(pcity) == client_player()) { + owner = city_owner(pcity); + + /* Only create these tabs if not a spy */ + if (owner == client_player() || client_is_global_observer()) { + create_and_append_worklist_page(pdialog); create_and_append_happiness_page(pdialog); } - if (city_owner(pcity) == client_player() + if (owner == client_player() && !client_is_observer()) { create_and_append_cma_page(pdialog); create_and_append_settings_page(pdialog); @@ -1643,17 +1649,17 @@ static struct city_dialog *create_city_dialog(struct city *pcity) _("_Next city")); gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell), pdialog->next_command, 2); - - if (city_owner(pcity) != client.conn.playing) { + + if (owner != client_player()) { gtk_widget_set_sensitive(pdialog->prev_command, FALSE); gtk_widget_set_sensitive(pdialog->next_command, FALSE); } close_command = gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response(GTK_DIALOG(pdialog->shell), - GTK_RESPONSE_CLOSE); + GTK_RESPONSE_CLOSE); g_signal_connect(close_command, "clicked", G_CALLBACK(close_callback), pdialog); diff --git a/client/gui-gtk-3.22/citydlg.c b/client/gui-gtk-3.22/citydlg.c index 6dfbc2b7c8..d10e1c7df8 100644 --- a/client/gui-gtk-3.22/citydlg.c +++ b/client/gui-gtk-3.22/citydlg.c @@ -1543,11 +1543,11 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) static struct city_dialog *create_city_dialog(struct city *pcity) { struct city_dialog *pdialog; - GtkWidget *close_command; GtkWidget *vbox, *hbox, *cbox, *ebox; int citizen_bar_width; int citizen_bar_height; + struct player *owner; if (!city_dialogs_have_been_initialised) { initialize_city_dialogs(); @@ -1561,10 +1561,13 @@ static struct city_dialog *create_city_dialog(struct city *pcity) pdialog->happiness.map_canvas.ebox = NULL; /* ditto */ pdialog->happiness.map_canvas.darea = NULL; /* ditto */ pdialog->happiness.citizens = NULL; /* ditto */ + pdialog->production.buy_command = NULL; + pdialog->production.production_label = NULL; + pdialog->production.production_bar = NULL; pdialog->cma_editor = NULL; pdialog->map_canvas_store_unscaled = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - canvas_width, canvas_height); + canvas_width, canvas_height); pdialog->shell = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(pdialog->shell), city_name_get(pcity)); @@ -1644,14 +1647,16 @@ static struct city_dialog *create_city_dialog(struct city *pcity) create_and_append_overview_page(pdialog); create_and_append_map_page(pdialog); create_and_append_buildings_page(pdialog); - create_and_append_worklist_page(pdialog); - /* only create these tabs if not a spy */ - if (!client_has_player() || city_owner(pcity) == client_player()) { + owner = city_owner(pcity); + + /* Only create these tabs if not a spy */ + if (owner == client_player() || client_is_global_observer()) { + create_and_append_worklist_page(pdialog); create_and_append_happiness_page(pdialog); } - if (city_owner(pcity) == client_player() + if (owner == client_player() && !client_is_observer()) { create_and_append_cma_page(pdialog); create_and_append_settings_page(pdialog); @@ -1678,7 +1683,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell), GTK_WIDGET(pdialog->next_command), 2); - if (city_owner(pcity) != client.conn.playing) { + if (owner != client_player()) { gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE); } @@ -1687,7 +1692,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) _("_Close"), GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response(GTK_DIALOG(pdialog->shell), - GTK_RESPONSE_CLOSE); + GTK_RESPONSE_CLOSE); g_signal_connect(close_command, "clicked", G_CALLBACK(close_callback), pdialog); diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index 93f496095d..dbf13d713f 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -1562,6 +1562,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) int citizen_bar_height; int ccol = 0; GtkEventController *controller; + struct player *owner; if (!city_dialogs_have_been_initialised) { initialize_city_dialogs(); @@ -1574,6 +1575,9 @@ static struct city_dialog *create_city_dialog(struct city *pcity) pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */ pdialog->happiness.map_canvas.darea = NULL; /* Ditto */ pdialog->happiness.citizens = NULL; /* Ditto */ + pdialog->production.buy_command = NULL; + pdialog->production.production_label = NULL; + pdialog->production.production_bar = NULL; pdialog->cma_editor = NULL; pdialog->map_canvas_store_unscaled = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, @@ -1652,14 +1656,16 @@ static struct city_dialog *create_city_dialog(struct city *pcity) create_and_append_overview_page(pdialog); create_and_append_map_page(pdialog); create_and_append_buildings_page(pdialog); - create_and_append_worklist_page(pdialog); + + owner = city_owner(pcity); /* Only create these tabs if not a spy */ - if (!client_has_player() || city_owner(pcity) == client_player()) { + if (owner == client_player() || client_is_global_observer()) { + create_and_append_worklist_page(pdialog); create_and_append_happiness_page(pdialog); } - if (city_owner(pcity) == client_player() + if (owner == client_player() && !client_is_observer()) { create_and_append_cma_page(pdialog); create_and_append_settings_page(pdialog); @@ -1686,7 +1692,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell), GTK_WIDGET(pdialog->next_command), 2); - if (city_owner(pcity) != client.conn.playing) { + if (owner != client_player()) { gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE); } -- 2.39.1