From cd46ffae3220d486a1e1801d9f969189990cf2d5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 1 Jun 2023 02:30:42 +0300 Subject: [PATCH 28/28] gtk4: Avoid deprecated gtk_widget_show() / gtk_widget_hide() Those functions are deprecated in gtk-4.10 The replacement, gtk_widget_set_visible(), exist in all versions of gtk4. See osdn #47902 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/action_dialog.c | 6 +- client/gui-gtk-4.0/chatline.c | 25 ++--- client/gui-gtk-4.0/choice_dialog.c | 32 +++--- client/gui-gtk-4.0/citizensinfo.c | 6 +- client/gui-gtk-4.0/citydlg.c | 150 ++++++++++++--------------- client/gui-gtk-4.0/cityrep.c | 2 +- client/gui-gtk-4.0/cma_fe.c | 8 +- client/gui-gtk-4.0/dialogs.c | 63 +++++------ client/gui-gtk-4.0/diplodlg.c | 2 +- client/gui-gtk-4.0/editgui.c | 91 +++++++--------- client/gui-gtk-4.0/editprop.c | 21 ++-- client/gui-gtk-4.0/gamedlgs.c | 4 +- client/gui-gtk-4.0/gotodlg.c | 34 +++--- client/gui-gtk-4.0/gui_main.c | 37 +++---- client/gui-gtk-4.0/gui_stuff.c | 60 ++++++----- client/gui-gtk-4.0/gui_stuff.h | 2 + client/gui-gtk-4.0/happiness.c | 4 +- client/gui-gtk-4.0/helpdlg.c | 137 ++++++++++++------------ client/gui-gtk-4.0/infradlg.c | 6 +- client/gui-gtk-4.0/inputdlg.c | 5 +- client/gui-gtk-4.0/inteldlg.c | 6 +- client/gui-gtk-4.0/menu.c | 4 +- client/gui-gtk-4.0/messagedlg.c | 13 +-- client/gui-gtk-4.0/optiondlg.c | 17 +-- client/gui-gtk-4.0/pages.c | 36 +++---- client/gui-gtk-4.0/repodlgs.c | 3 +- client/gui-gtk-4.0/soundset_dlg.c | 10 +- client/gui-gtk-4.0/theme_dlg.c | 5 +- client/gui-gtk-4.0/tileset_dlg.c | 5 +- client/gui-gtk-4.0/unitselect.c | 7 +- client/gui-gtk-4.0/unitselextradlg.c | 12 ++- client/gui-gtk-4.0/unitselunitdlg.c | 12 ++- client/gui-gtk-4.0/voteinfo_bar.c | 6 +- client/gui-gtk-4.0/wldlg.c | 28 +++-- 34 files changed, 421 insertions(+), 438 deletions(-) diff --git a/client/gui-gtk-4.0/action_dialog.c b/client/gui-gtk-4.0/action_dialog.c index 421f8ee130..2632783e4f 100644 --- a/client/gui-gtk-4.0/action_dialog.c +++ b/client/gui-gtk-4.0/action_dialog.c @@ -677,7 +677,8 @@ static void create_advances_list(struct player *pplayer, gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_tech_shell), GTK_RESPONSE_ACCEPT, FALSE); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell)), + TRUE); g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), "changed", G_CALLBACK(spy_advances_callback), args); @@ -853,7 +854,8 @@ static void create_improvements_list(struct player *pplayer, gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_sabotage_shell), GTK_RESPONSE_ACCEPT, FALSE); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell))); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell)), + TRUE); g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), "changed", G_CALLBACK(spy_improvements_callback), args); diff --git a/client/gui-gtk-4.0/chatline.c b/client/gui-gtk-4.0/chatline.c index d7c752feef..55fcff4baf 100644 --- a/client/gui-gtk-4.0/chatline.c +++ b/client/gui-gtk-4.0/chatline.c @@ -1091,6 +1091,7 @@ static void color_set(GObject *object, const gchar *color_target, cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, 16, 16); cairo_t *cr = cairo_create(surface); + gdk_cairo_set_source_rgba(cr, current_color); cairo_paint(cr); cairo_destroy(cr); @@ -1099,7 +1100,7 @@ static void color_set(GObject *object, const gchar *color_target, } image = gtk_image_new_from_pixbuf(pixbuf); gtk_button_set_child(button, image); - gtk_widget_show(image); + gtk_widget_set_visible(image, TRUE); g_object_unref(G_OBJECT(pixbuf)); } } @@ -1162,7 +1163,7 @@ static void select_color_callback(GtkButton *button, gpointer data) gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(chooser), current_color); } - gtk_widget_show(dialog); + gtk_widget_set_visible(dialog, TRUE); g_free(buf); } @@ -1185,7 +1186,7 @@ static gboolean move_toolkit(GtkWidget *toolkit_view, gpointer data) /* N.B.: We need to hide/show the toolbar to reset the sensitivity * of the tool buttons. */ if (ptoolkit->toolbar_displayed) { - gtk_widget_hide(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, FALSE); } g_object_ref(ptoolkit->main_widget); /* Make sure reference count stays above 0 * during the transition to new parent. */ @@ -1193,16 +1194,16 @@ static gboolean move_toolkit(GtkWidget *toolkit_view, gpointer data) gtk_box_append(GTK_BOX(toolkit_view), ptoolkit->main_widget); g_object_unref(ptoolkit->main_widget); if (ptoolkit->toolbar_displayed) { - gtk_widget_show(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, TRUE); } if (!gtk_widget_get_parent(button_box)) { /* Attach to the toolkit button_box. */ gtk_box_append(GTK_BOX(ptoolkit->button_box), button_box); } - gtk_widget_show(button_box); + gtk_widget_set_visible(button_box, TRUE); if (!ptoolkit->toolbar_displayed) { - gtk_widget_hide(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, FALSE); } /* Hide all other buttons boxes. */ @@ -1210,7 +1211,7 @@ static gboolean move_toolkit(GtkWidget *toolkit_view, gpointer data) iter != NULL; iter = gtk_widget_get_next_sibling(iter)) { if (iter != button_box) { - gtk_widget_hide(iter); + gtk_widget_set_visible(iter, FALSE); } } @@ -1218,7 +1219,7 @@ static gboolean move_toolkit(GtkWidget *toolkit_view, gpointer data) /* First time attached to a parent. */ gtk_box_append(GTK_BOX(toolkit_view), ptoolkit->main_widget); gtk_box_append(GTK_BOX(ptoolkit->button_box), button_box); - gtk_widget_show(ptoolkit->main_widget); + gtk_widget_set_visible(ptoolkit->main_widget, TRUE); } return FALSE; @@ -1238,7 +1239,7 @@ static gboolean set_toolbar_visibility(GtkWidget *w, gpointer data) gtk_toggle_button_set_active(button, TRUE); } else { /* Ensure the widget is visible. */ - gtk_widget_show(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, TRUE); } } else { if (gtk_toggle_button_get_active(button)) { @@ -1246,7 +1247,7 @@ static gboolean set_toolbar_visibility(GtkWidget *w, gpointer data) gtk_toggle_button_set_active(button, FALSE); } else { /* Ensure the widget is not visible. */ - gtk_widget_hide(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, FALSE); } } @@ -1261,14 +1262,14 @@ static void button_toggled(GtkToggleButton *button, gpointer data) struct inputline_toolkit *ptoolkit = (struct inputline_toolkit *) data; if (gtk_toggle_button_get_active(button)) { - gtk_widget_show(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, TRUE); ptoolkit->toolbar_displayed = TRUE; if (chatline_is_scrolled_to_bottom()) { /* Make sure to be still at the end. */ chatline_scroll_to_bottom(TRUE); } } else { - gtk_widget_hide(ptoolkit->toolbar); + gtk_widget_set_visible(ptoolkit->toolbar, FALSE); ptoolkit->toolbar_displayed = FALSE; } } diff --git a/client/gui-gtk-4.0/choice_dialog.c b/client/gui-gtk-4.0/choice_dialog.c index bb079f07c7..acb64eb929 100644 --- a/client/gui-gtk-4.0/choice_dialog.c +++ b/client/gui-gtk-4.0/choice_dialog.c @@ -103,8 +103,7 @@ void choice_dialog_button_move_to_the_end(GtkWidget *cd, GtkWidget *choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text) { - GtkWidget *dshell, *dlabel, *vgrid, *bbox; - int grid_row = 0; + GtkWidget *dshell, *dlabel, *vbox, *bbox; dshell = gtk_window_new(); setup_dialog(dshell, toplevel); @@ -114,29 +113,26 @@ GtkWidget *choice_dialog_start(GtkWindow *parent, const gchar *name, gtk_window_set_transient_for(GTK_WINDOW(dshell), parent); gtk_window_set_destroy_with_parent(GTK_WINDOW(dshell), TRUE); - vgrid = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vgrid), 5); - gtk_window_set_child(GTK_WINDOW(dshell), vgrid); + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); + gtk_window_set_child(GTK_WINDOW(dshell), vbox); - gtk_widget_set_margin_start(vgrid, 5); - gtk_widget_set_margin_end(vgrid, 5); - gtk_widget_set_margin_top(vgrid, 5); - gtk_widget_set_margin_bottom(vgrid, 5); + gtk_widget_set_margin_start(vbox, 5); + gtk_widget_set_margin_end(vbox, 5); + gtk_widget_set_margin_top(vbox, 5); + gtk_widget_set_margin_bottom(vbox, 5); dlabel = gtk_label_new(text); - gtk_grid_attach(GTK_GRID(vgrid), dlabel, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), dlabel); bbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); - gtk_grid_attach(GTK_GRID(vgrid), bbox, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), bbox); g_object_set_data(G_OBJECT(dshell), "bbox", bbox); g_object_set_data(G_OBJECT(dshell), "nbuttons", GINT_TO_POINTER(0)); g_object_set_data(G_OBJECT(dshell), "hide", GINT_TO_POINTER(FALSE)); - gtk_widget_show(vgrid); - gtk_widget_show(dlabel); + gtk_widget_set_visible(vbox, TRUE); + gtk_widget_set_visible(dlabel, TRUE); return dshell; } @@ -148,7 +144,7 @@ GtkWidget *choice_dialog_start(GtkWindow *parent, const gchar *name, static void choice_dialog_clicked(GtkWidget *w, gpointer data) { if (g_object_get_data(G_OBJECT(data), "hide")) { - gtk_widget_hide(GTK_WIDGET(data)); + gtk_widget_set_visible(GTK_WIDGET(data), FALSE); } else { gtk_window_destroy(GTK_WINDOW(data)); } @@ -199,8 +195,8 @@ void choice_dialog_end(GtkWidget *dshell) bbox = g_object_get_data(G_OBJECT(dshell), "bbox"); - gtk_widget_show(bbox); - gtk_widget_show(dshell); + gtk_widget_set_visible(bbox, TRUE); + gtk_widget_set_visible(dshell, TRUE); } /*******************************************************************//** diff --git a/client/gui-gtk-4.0/citizensinfo.c b/client/gui-gtk-4.0/citizensinfo.c index f639fd7a00..b2cc26c142 100644 --- a/client/gui-gtk-4.0/citizensinfo.c +++ b/client/gui-gtk-4.0/citizensinfo.c @@ -367,7 +367,7 @@ void citizens_dialog_close(const struct city *pcity) return; } - gtk_widget_hide(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, FALSE); dialog_list_remove(dialog_list, pdialog); @@ -383,11 +383,11 @@ GtkWidget *citizens_dialog_display(const struct city *pcity) { struct citizens_dialog *pdialog = citizens_dialog_get(pcity); - if (!pdialog) { + if (pdialog == NULL) { pdialog = citizens_dialog_create(pcity); } - gtk_widget_show(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, TRUE); citizens_dialog_refresh(pcity); return pdialog->shell; diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index 4f43a6797b..c874b20adb 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -857,7 +857,7 @@ static GtkWidget *create_city_info_table(struct city_dialog *pdialog, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } - gtk_widget_show(table); + gtk_widget_set_visible(table, TRUE); return table; } @@ -953,10 +953,8 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) const char *tab_title = _("_Overview"); int unit_height = tileset_unit_with_upkeep_height(tileset); int page_row = 0; - int bottom_col = 0; - int right_row = 0; - /* main page */ + /* Main page */ page = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(page), GTK_ORIENTATION_VERTICAL); @@ -969,35 +967,30 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) if (!low_citydlg) { GtkWidget *middle; - GtkWidget *vgrid; - GtkWidget *hgrid; + GtkWidget *vbox; + GtkWidget *hbox; int middle_col = 0; - int grid_row = 0; - int grid_col = 0; - /* middle: city map, improvements */ + /* Middle: city map, improvements */ middle = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(middle), 6); gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1); - /* city map */ + /* City map */ create_citydlg_main_map(pdialog, middle, middle_col++, 0); - /* improvements */ - vgrid = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), - GTK_ORIENTATION_VERTICAL); - gtk_grid_attach(GTK_GRID(middle), vgrid, middle_col++, 0, 1, 1); + /* Improvements */ + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_grid_attach(GTK_GRID(middle), vbox, middle_col++, 0, 1, 1); view = create_citydlg_improvement_list(pdialog); label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), label); - hgrid = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10); - gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); + gtk_box_append(GTK_BOX(vbox), hbox); production_store = gtk_list_store_new(4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN); @@ -1006,7 +999,7 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) bar = gtk_progress_bar_new(); gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(bar), TRUE); pdialog->overview.production_bar = bar; - gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), bar); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns")); @@ -1014,7 +1007,7 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) = gtk_combo_box_new_with_model(GTK_TREE_MODEL(production_store)); gtk_widget_set_hexpand(production_combo, TRUE); pdialog->overview.production_combo = production_combo; - gtk_grid_attach(GTK_GRID(hgrid), production_combo, grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), production_combo); g_object_unref(production_store); g_signal_connect(production_combo, "changed", G_CALLBACK(change_production_callback), pdialog); @@ -1033,8 +1026,7 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) pdialog->overview.buy_command = icon_label_button_new("system-run", _("_Buy")); - gtk_grid_attach(GTK_GRID(hgrid), GTK_WIDGET(pdialog->overview.buy_command), - grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), GTK_WIDGET(pdialog->overview.buy_command)); g_signal_connect(pdialog->overview.buy_command, "clicked", G_CALLBACK(buy_callback), pdialog); @@ -1042,13 +1034,13 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) "mnemonic-widget", view, "label", _("I_mprovements:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), label); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), sw); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); } else { @@ -1058,14 +1050,13 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) pdialog->overview.change_production_store = NULL; } - /* bottom: info, units */ - bottom = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(bottom), 6); + /* Bottom: info, units */ + bottom = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); gtk_grid_attach(GTK_GRID(page), bottom, 0, page_row++, 1, 1); - /* info */ + /* Info */ frame = gtk_frame_new(_("Info")); - gtk_grid_attach(GTK_GRID(bottom), frame, bottom_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(bottom), frame); table = create_city_info_table(pdialog, pdialog->overview.info_label); @@ -1073,20 +1064,16 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) gtk_widget_set_valign(table, GTK_ALIGN_CENTER); gtk_frame_set_child(GTK_FRAME(frame), table); - /* right: present and supported units (overview page) */ - right = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(right), - GTK_ORIENTATION_VERTICAL); - gtk_grid_attach(GTK_GRID(bottom), right, bottom_col++, 0, 1, 1); + /* Right: present and supported units (overview page) */ + right = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_box_append(GTK_BOX(bottom), right); pdialog->overview.supported_units_frame = gtk_frame_new(""); - gtk_grid_attach(GTK_GRID(right), pdialog->overview.supported_units_frame, - 0, right_row++, 1, 1); + gtk_box_append(GTK_BOX(right), pdialog->overview.supported_units_frame); pdialog->overview.present_units_frame = gtk_frame_new(""); - gtk_grid_attach(GTK_GRID(right), pdialog->overview.present_units_frame, - 0, right_row++, 1, 1); + gtk_box_append(GTK_BOX(right), pdialog->overview.present_units_frame); - /* supported units */ + /* Supported units */ sw = gtk_scrolled_window_new(); gtk_widget_set_hexpand(sw, TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), @@ -1103,7 +1090,7 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) pdialog->overview.supported_unit_table = table; unit_node_vector_init(&pdialog->overview.supported_units); - /* present units */ + /* Present units */ sw = gtk_scrolled_window_new(); gtk_widget_set_hexpand(sw, TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), @@ -1118,8 +1105,8 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) pdialog->overview.present_unit_table = table; unit_node_vector_init(&pdialog->overview.present_units); - /* show page */ - gtk_widget_show(page); + /* Show page */ + gtk_widget_set_visible(page, TRUE); } /***********************************************************************//** @@ -1145,7 +1132,7 @@ static void create_and_append_map_page(struct city_dialog *pdialog) create_citydlg_main_map(pdialog, page, 0, page_row++); - gtk_widget_show(page); + gtk_widget_set_visible(page, TRUE); } } @@ -1220,11 +1207,10 @@ static void create_and_append_buildings_page(struct city_dialog *pdialog) if (low_citydlg) { GtkWidget *page; GtkWidget *label; - GtkWidget *vgrid; + GtkWidget *vbox; GtkWidget *view; const char *tab_title = _("Buildings"); int page_row = 0; - int grid_row = 0; page = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(page), @@ -1238,16 +1224,14 @@ static void create_and_append_buildings_page(struct city_dialog *pdialog) page_row = create_production_header(pdialog, page, page_row); gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); - vgrid = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), - GTK_ORIENTATION_VERTICAL); - gtk_grid_attach(GTK_GRID(page), vgrid, 0, page_row++, 1, 1); + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1); view = create_citydlg_improvement_list(pdialog); - gtk_grid_attach(GTK_GRID(vgrid), view, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), view); - gtk_widget_show(page); + gtk_widget_set_visible(page, TRUE); } } @@ -1270,7 +1254,7 @@ static void create_and_append_worklist_page(struct city_dialog *pdialog) gtk_widget_set_margin_bottom(page, 8); gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); - /* stuff that's being currently built */ + /* Stuff that's being currently built */ if (!low_citydlg) { label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"), @@ -1292,7 +1276,7 @@ static void create_and_append_worklist_page(struct city_dialog *pdialog) gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1); pdialog->production.worklist = editor; - gtk_widget_show(page); + gtk_widget_set_visible(page, TRUE); } /***********************************************************************//** @@ -1311,9 +1295,8 @@ static void create_and_append_happiness_page(struct city_dialog *pdialog) const char *tab_title = _("Happ_iness"); int page_col = 0; int left_row = 0; - int right_row = 0; - /* main page */ + /* Main page */ page = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(page), 6); gtk_widget_set_margin_start(page, 8); @@ -1323,14 +1306,14 @@ static void create_and_append_happiness_page(struct city_dialog *pdialog) label = gtk_label_new_with_mnemonic(tab_title); gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); - /* left: info, citizens */ + /* Left: info, citizens */ left = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(left), GTK_ORIENTATION_VERTICAL); gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1); if (!low_citydlg) { - /* upper left: info */ + /* Upper left: info */ frame = gtk_frame_new(_("Info")); gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1); @@ -1340,7 +1323,7 @@ static void create_and_append_happiness_page(struct city_dialog *pdialog) gtk_frame_set_child(GTK_FRAME(frame), table); } - /* lower left: citizens */ + /* Lower left: citizens */ if (game.info.citizen_nationality) { pdialog->happiness.citizens = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_grid_attach(GTK_GRID(left), pdialog->happiness.citizens, @@ -1349,31 +1332,30 @@ static void create_and_append_happiness_page(struct city_dialog *pdialog) citizens_dialog_display(pdialog->pcity)); } - /* right: city map, happiness */ - right = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(right), - GTK_ORIENTATION_VERTICAL); + /* Right: city map, happiness */ + right = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1); if (!low_citydlg) { - /* upper right: city map */ + /* Upper right: city map */ frame = gtk_frame_new(_("City map")); gtk_widget_set_size_request(frame, CITY_MAP_MIN_SIZE_X, CITY_MAP_MIN_SIZE_Y); - gtk_grid_attach(GTK_GRID(right), frame, 0, right_row++, 1, 1); + gtk_box_append(GTK_BOX(right), frame); city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas); gtk_frame_set_child(GTK_FRAME(frame), pdialog->happiness.map_canvas.sw); } - /* lower right: happiness */ + /* Lower right: happiness */ pdialog->happiness.widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); - gtk_grid_attach(GTK_GRID(right), pdialog->happiness.widget, 0, right_row++, 1, 1); + gtk_box_append(GTK_BOX(right), pdialog->happiness.widget); gtk_box_append(GTK_BOX(pdialog->happiness.widget), - get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell)); + get_top_happiness_display(pdialog->pcity, low_citydlg, + pdialog->shell)); - /* show page */ - gtk_widget_show(page); + /* Show page */ + gtk_widget_set_visible(page, TRUE); } /***********************************************************************//** @@ -1393,7 +1375,7 @@ static void create_and_append_cma_page(struct city_dialog *pdialog) pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg); gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell); - gtk_widget_show(page); + gtk_widget_set_visible(page, TRUE); } /***********************************************************************//** @@ -1429,7 +1411,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) static bool new_citizens_label_done; static bool misc_whichtab_label_done; - /* initialize signal_blocker */ + /* Initialize signal_blocker */ pdialog->misc.block_signal = 0; @@ -1471,7 +1453,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) group = button; } - /* next is the next-time-open radio group in the right column */ + /* Next is the next-time-open radio group in the right column */ frame = gtk_frame_new(_("Next time open")); gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1); gtk_size_group_add_widget(size, frame); @@ -1497,7 +1479,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) group = button; } - /* now we go back and fill the hbox rename */ + /* Now we go back and fill the hbox rename */ frame = gtk_frame_new(_("City")); gtk_widget_set_margin_top(frame, 12); gtk_widget_set_margin_bottom(frame, 12); @@ -1517,7 +1499,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) gtk_widget_set_sensitive(button, can_client_issue_orders()); - /* the disband-city-on-unit-production button */ + /* The disband-city-on-unit-production button */ button = gtk_check_button_new_with_mnemonic(_(disband_label)); pdialog->misc.disband_on_settler = button; gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); @@ -1532,14 +1514,14 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) set_cityopt_values(pdialog); - gtk_widget_show(page); + gtk_widget_set_visible(page, TRUE); if (new_dialog_def_page == (NUM_PAGES - 1)) { gtk_notebook_set_current_page(GTK_NOTEBOOK(pdialog->notebook), - last_page); + last_page); } else { gtk_notebook_set_current_page(GTK_NOTEBOOK(pdialog->notebook), - new_dialog_def_page); + new_dialog_def_page); } } @@ -1724,7 +1706,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) /* Need to do this every time a new dialog is opened. */ city_dialog_update_prev_next(); - gtk_widget_show(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, TRUE); gtk_window_set_focus(GTK_WINDOW(pdialog->shell), close_command); @@ -2272,8 +2254,8 @@ static void city_dialog_update_supported_units(struct city_dialog *pdialog) gtk_widget_set_sensitive(cmd, TRUE); } - gtk_widget_show(pix); - gtk_widget_show(cmd); + gtk_widget_set_visible(pix, TRUE); + gtk_widget_set_visible(cmd, TRUE); } i++; } unit_list_iterate_end; @@ -2394,8 +2376,8 @@ static void city_dialog_update_present_units(struct city_dialog *pdialog) gtk_widget_set_sensitive(cmd, TRUE); } - gtk_widget_show(pix); - gtk_widget_show(cmd); + gtk_widget_set_visible(pix, TRUE); + gtk_widget_set_visible(cmd, TRUE); } i++; } unit_list_iterate_end; @@ -3500,7 +3482,7 @@ static void city_destroy_callback(GtkWidget *w, gpointer data) pdialog = (struct city_dialog *) data; - gtk_widget_hide(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, FALSE); if (game.info.citizen_nationality) { citizens_dialog_close(pdialog->pcity); diff --git a/client/gui-gtk-4.0/cityrep.c b/client/gui-gtk-4.0/cityrep.c index 4a3df57e8c..71fa7e77f6 100644 --- a/client/gui-gtk-4.0/cityrep.c +++ b/client/gui-gtk-4.0/cityrep.c @@ -1236,7 +1236,7 @@ static void create_city_report_dialog(bool make_modal) "text", i, NULL); header = gtk_label_new(titles[i]); gtk_widget_set_tooltip_text(header, spec->explanation); - gtk_widget_show(header); + gtk_widget_set_visible(header, TRUE); gtk_tree_view_column_set_widget(col, header); gtk_tree_view_column_set_visible(col, spec->show); gtk_tree_view_column_set_sort_column_id(col, i); diff --git a/client/gui-gtk-4.0/cma_fe.c b/client/gui-gtk-4.0/cma_fe.c index a71af63368..12b49d4b36 100644 --- a/client/gui-gtk-4.0/cma_fe.c +++ b/client/gui-gtk-4.0/cma_fe.c @@ -422,8 +422,8 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) g_signal_connect(pdialog->happy_button, "toggled", G_CALLBACK(hscale_changed), pdialog); - pdialog->factor[O_LAST] = hscale = - gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL); + pdialog->factor[O_LAST] = hscale + = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, NULL); gtk_range_set_range(GTK_RANGE(hscale), 0, 50); gtk_range_set_increments(GTK_RANGE(hscale), 1, 1); layout = gtk_scale_get_layout(GTK_SCALE(hscale)); @@ -469,7 +469,7 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) gtk_widget_set_name(pdialog->active_command, "comment_label"); gtk_box_append(GTK_BOX(hbox), pdialog->active_command); - gtk_widget_show(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, TRUE); dialog_list_prepend(dialog_list, pdialog); @@ -477,7 +477,7 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) gtk_tree_view_focus(GTK_TREE_VIEW(view)); - /* refresh is done in refresh_city_dialog */ + /* Refresh is done in refresh_city_dialog() */ return pdialog; } diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index 2dcdd23b74..beec79e6b1 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -223,13 +223,14 @@ void popup_notify_goto_dialog(const char *headline, const char *lines, gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CLOSE); label = gtk_label_new(lines); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), label); - gtk_widget_show(label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), + label); + gtk_widget_set_visible(label, TRUE); g_object_set_data(G_OBJECT(shell), "tile", ptile); g_signal_connect(shell, "response", G_CALLBACK(notify_goto_response), NULL); - gtk_widget_show(shell); + gtk_widget_set_visible(shell, TRUE); } /**********************************************************************//** @@ -247,14 +248,15 @@ void popup_connect_msg(const char *headline, const char *message) label = gtk_label_new(message); gtk_label_set_selectable(GTK_LABEL(label), 1); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), label); - gtk_widget_show(label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), + label); + gtk_widget_set_visible(label, TRUE); gtk_dialog_add_button(GTK_DIALOG(shell), _("_Close"),GTK_RESPONSE_CLOSE); g_signal_connect(shell, "response", G_CALLBACK(notify_connect_msg_response), NULL); - gtk_widget_show(shell); + gtk_widget_set_visible(shell, TRUE); } /**********************************************************************//** @@ -700,7 +702,7 @@ static void create_nation_selection_lists(void) int i; for (i = 0; i < nation_group_count(); i++) { - struct nation_group* group = (nation_group_by_number(i)); + struct nation_group *group = (nation_group_by_number(i)); if (is_nation_group_hidden(group)) { races_nation_list[i] = NULL; @@ -778,7 +780,7 @@ void races_update_pickable(bool nationset_change) create_nation_selection_lists(); /* Can't set current tab before child widget is visible */ - gtk_widget_show(GTK_WIDGET(races_notebook)); + gtk_widget_set_visible(GTK_WIDGET(races_notebook), TRUE); /* Restore selected tab */ if (groupidx != -1 && races_nation_list[groupidx] != NULL) { @@ -844,7 +846,7 @@ static void create_races_dialog(struct player *pplayer) GtkWidget *shell; GtkWidget *cmd; GtkWidget *group; - GtkWidget *hgrid, *table; + GtkWidget *hbox, *table; GtkWidget *frame, *label, *combo; GtkWidget *text; GtkWidget *notebook; @@ -855,7 +857,6 @@ static void create_races_dialog(struct player *pplayer) GtkTreeViewColumn *column; int i; char *title; - int grid_col = 0; /* Init. */ selected_nation = -1; @@ -874,7 +875,7 @@ static void create_races_dialog(struct player *pplayer) _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Random Nation"), - GTK_RESPONSE_NO, /* arbitrary */ + GTK_RESPONSE_NO, /* Arbitrary */ _("_OK"), GTK_RESPONSE_ACCEPT, NULL); @@ -887,18 +888,17 @@ static void create_races_dialog(struct player *pplayer) frame = gtk_frame_new(_("Select a nation")); gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), frame); - hgrid = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hgrid), 18); - gtk_widget_set_margin_start(hgrid, 3); - gtk_widget_set_margin_end(hgrid, 3); - gtk_widget_set_margin_top(hgrid, 3); - gtk_widget_set_margin_bottom(hgrid, 3); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 18); + gtk_widget_set_margin_start(hbox, 3); + gtk_widget_set_margin_end(hbox, 3); + gtk_widget_set_margin_top(hbox, 3); + gtk_widget_set_margin_bottom(hbox, 3); - gtk_frame_set_child(GTK_FRAME(frame), hgrid); + gtk_frame_set_child(GTK_FRAME(frame), hbox); /* Left side: nation list */ { - GtkWidget* nation_selection_list = gtk_grid_new(); + GtkWidget *nation_selection_list = gtk_grid_new(); nationsets_chooser = NULL; @@ -1049,13 +1049,13 @@ static void create_races_dialog(struct player *pplayer) /* Populate treeview */ create_nation_selection_lists(); - gtk_grid_attach(GTK_GRID(hgrid), nation_selection_list, grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), nation_selection_list); } /* Right side. */ notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM); - gtk_grid_attach(GTK_GRID(hgrid), notebook, grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), notebook); /* Properties pane. */ label = gtk_label_new_with_mnemonic(_("_Properties")); @@ -1108,7 +1108,7 @@ static void create_races_dialog(struct player *pplayer) /* City style. */ store = gtk_list_store_new(3, G_TYPE_INT, - GDK_TYPE_PIXBUF, G_TYPE_STRING); + GDK_TYPE_PIXBUF, G_TYPE_STRING); list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); gtk_widget_set_hexpand(list, TRUE); @@ -1117,13 +1117,13 @@ static void create_races_dialog(struct player *pplayer) g_object_unref(store); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(list)), "changed", - G_CALLBACK(races_style_callback), NULL); + G_CALLBACK(races_style_callback), NULL); sw = gtk_scrolled_window_new(); gtk_widget_set_margin_top(sw, 6); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), list); gtk_grid_attach(GTK_GRID(table), sw, 1, 2, 2, 2); @@ -1140,11 +1140,11 @@ static void create_races_dialog(struct player *pplayer) render = gtk_cell_renderer_pixbuf_new(); column = gtk_tree_view_column_new_with_attributes(NULL, render, - "pixbuf", 1, NULL); + "pixbuf", 1, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); render = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(NULL, render, - "text", 2, NULL); + "text", 2, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); /* Populate style store. */ @@ -1190,15 +1190,15 @@ static void create_races_dialog(struct player *pplayer) g_signal_connect(shell, "destroy", G_CALLBACK(widget_destroyed), &races_shell); g_signal_connect(shell, "response", - G_CALLBACK(races_response), NULL); + G_CALLBACK(races_response), NULL); g_signal_connect(GTK_COMBO_BOX(races_leader), "changed", - G_CALLBACK(races_leader_callback), NULL); + G_CALLBACK(races_leader_callback), NULL); g_signal_connect(races_sex[0], "toggled", - G_CALLBACK(races_sex_callback), GINT_TO_POINTER(SEX_FEMALE)); + G_CALLBACK(races_sex_callback), GINT_TO_POINTER(SEX_FEMALE)); g_signal_connect(races_sex[1], "toggled", - G_CALLBACK(races_sex_callback), GINT_TO_POINTER(SEX_MALE)); + G_CALLBACK(races_sex_callback), GINT_TO_POINTER(SEX_MALE)); /* Finish up. */ gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CANCEL); @@ -1209,7 +1209,8 @@ static void create_races_dialog(struct player *pplayer) FALSE); } - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(shell))); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(shell)), + TRUE); /* Select player's current nation in UI, if any */ if (races_player->nation) { diff --git a/client/gui-gtk-4.0/diplodlg.c b/client/gui-gtk-4.0/diplodlg.c index fb460ac170..deb877b572 100644 --- a/client/gui-gtk-4.0/diplodlg.c +++ b/client/gui-gtk-4.0/diplodlg.c @@ -1018,7 +1018,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct Treaty *ptreaty, gtk_box_append(GTK_BOX(vbox), label); gtk_box_append(GTK_BOX(vbox), sw); - gtk_widget_show(mainbox); + gtk_widget_set_visible(mainbox, TRUE); g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog); diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index b5f64fe458..04cb8fde18 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -332,7 +332,7 @@ static int tool_value_selector_run(struct tool_value_selector *tvs) dialog = tvs->dialog; res = blocking_dialog(dialog); - gtk_widget_hide(dialog); + gtk_widget_set_visible(dialog, FALSE); if (res != GTK_RESPONSE_ACCEPT) { return -1; @@ -679,7 +679,7 @@ static void editbar_refresh(struct editbar *eb) } if (!editor_is_active()) { - gtk_widget_hide(eb->widget); + gtk_widget_set_visible(eb->widget, FALSE); return; } @@ -687,7 +687,7 @@ static void editbar_refresh(struct editbar *eb) refresh_all_tool_value_selectors(eb); refresh_player_pov_indicator(eb); - gtk_widget_show(eb->widget); + gtk_widget_set_visible(eb->widget, TRUE); } /************************************************************************//** @@ -997,7 +997,8 @@ create_tool_value_selector(struct editbar *eb, tvs->editbar_parent = eb; tvs->dialog = gtk_dialog_new_with_buttons(_("Select Tool Value"), - GTK_WINDOW(toplevel), GTK_DIALOG_MODAL, + GTK_WINDOW(toplevel), + GTK_DIALOG_MODAL, _("_OK"), GTK_RESPONSE_ACCEPT, _("_Cancel"), GTK_RESPONSE_REJECT, NULL); @@ -1061,7 +1062,7 @@ create_tool_value_selector(struct editbar *eb, tvs->view = view; /* Show everything but the window itself. */ - gtk_widget_show(vbox); + gtk_widget_set_visible(vbox, TRUE); return tvs; } @@ -1159,16 +1160,14 @@ static void editinfobox_tool_applied_player_changed(GtkComboBox *combo, ****************************************************************************/ static struct editinfobox *editinfobox_create(void) { - GtkWidget *label, *vgrid, *frame, *hgrid, *vgrid2, *pic; + GtkWidget *label, *vbox, *frame, *hgrid, *vbox2, *pic; GtkWidget *spin, *combo; GtkListStore *store; GtkCellRenderer *cell; GtkEventController *controller; struct editinfobox *ei; char buf[128]; - int grid_row = 0; int grid_col = 0; - int grid2_row = 0; ei = fc_calloc(1, sizeof(*ei)); @@ -1181,20 +1180,17 @@ static struct editinfobox *editinfobox_create(void) gtk_widget_set_margin_bottom(frame, 4); ei->widget = frame; - vgrid = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vgrid), 8); - gtk_widget_set_margin_start(vgrid, 4); - gtk_widget_set_margin_end(vgrid, 4); - gtk_widget_set_margin_top(vgrid, 4); - gtk_widget_set_margin_bottom(vgrid, 4); - gtk_frame_set_child(GTK_FRAME(frame), vgrid); - - /* tool section */ + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8); + gtk_widget_set_margin_start(vbox, 4); + gtk_widget_set_margin_end(vbox, 4); + gtk_widget_set_margin_top(vbox, 4); + gtk_widget_set_margin_bottom(vbox, 4); + gtk_frame_set_child(GTK_FRAME(frame), vbox); + + /* Tool section */ hgrid = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8); - gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), hgrid); pic = gtk_picture_new(); gtk_widget_set_tooltip_text(pic, _("Click to change value if applicable.")); @@ -1208,29 +1204,26 @@ static struct editinfobox *editinfobox_create(void) gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1); ei->tool_pic = pic; - vgrid2 = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4); - gtk_grid_attach(GTK_GRID(hgrid), vgrid2, grid_col++, 0, 1, 1); + vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_grid_attach(GTK_GRID(hgrid), vbox2, grid_col++, 0, 1, 1); label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox2), label); ei->tool_label = label; label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox2), label); ei->tool_value_label = label; - /* mode section */ + /* Mode section */ hgrid = gtk_grid_new(); grid_col = 0; gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8); - gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), hgrid); pic = gtk_picture_new(); gtk_widget_set_tooltip_text(pic, _("Click to change tool mode.")); @@ -1244,12 +1237,8 @@ static struct editinfobox *editinfobox_create(void) gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1); ei->mode_pic = pic; - vgrid2 = gtk_grid_new(); - grid2_row = 0; - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4); - gtk_grid_attach(GTK_GRID(hgrid), vgrid2, grid_col++, 0, 1, 1); + vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_grid_attach(GTK_GRID(hgrid), vbox2, grid_col++, 0, 1, 1); label = gtk_label_new(NULL); fc_snprintf(buf, sizeof(buf), "%s", @@ -1257,19 +1246,19 @@ static struct editinfobox *editinfobox_create(void) gtk_label_set_markup(GTK_LABEL(label), buf); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox2), label); label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox2), label); ei->mode_label = label; - /* spinner section */ + /* Spinner section */ hgrid = gtk_grid_new(); grid_col = 0; gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8); - gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), hgrid); ei->size_hbox = hgrid; spin = gtk_spin_button_new_with_range(1, 255, 1); gtk_widget_set_tooltip_text(spin, @@ -1288,7 +1277,7 @@ static struct editinfobox *editinfobox_create(void) hgrid = gtk_grid_new(); grid_col = 0; gtk_grid_set_column_spacing(GTK_GRID(hgrid), 8); - gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), hgrid); ei->count_hbox = hgrid; spin = gtk_spin_button_new_with_range(1, 255, 1); gtk_widget_set_tooltip_text(spin, @@ -1329,7 +1318,7 @@ static struct editinfobox *editinfobox_create(void) _("Use this to change the \"applied player\" tool parameter. " "This controls for example under which player units and cities " "are created.")); - gtk_grid_attach(GTK_GRID(vgrid), combo, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), combo); ei->tool_applied_player_combobox = combo; /* We add a ref to the editinfobox widget so that it is @@ -1339,7 +1328,7 @@ static struct editinfobox *editinfobox_create(void) /* The edit info box starts with no parent, so we have to * show its internal widgets manually. */ - gtk_widget_show(ei->widget); + gtk_widget_set_visible(ei->widget, TRUE); return ei; } @@ -1370,7 +1359,7 @@ static void refresh_tool_applied_player_combo(struct editinfobox *ei) } if (!editor_tool_has_applied_player(ett)) { - gtk_widget_hide(combo); + gtk_widget_set_visible(combo, FALSE); return; } @@ -1407,7 +1396,7 @@ static void refresh_tool_applied_player_combo(struct editinfobox *ei) editor_tool_set_applied_player(ett, index); } gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index); - gtk_widget_show(combo); + gtk_widget_set_visible(combo, TRUE); } /************************************************************************//** @@ -1516,11 +1505,11 @@ static void replace_widget(GtkWidget *old, GtkWidget *new) GtkWidget *parent; parent = gtk_widget_get_parent(old); - if (!parent) { + if (parent == NULL) { return; } - gtk_widget_hide(old); + gtk_widget_set_visible(old, FALSE); if (GTK_IS_FRAME(parent)) { gtk_frame_set_child(GTK_FRAME(parent), new); @@ -1531,7 +1520,7 @@ static void replace_widget(GtkWidget *old, GtkWidget *new) gtk_box_append(GTK_BOX(parent), new); } - gtk_widget_show(new); + gtk_widget_set_visible(new, TRUE); } /************************************************************************//** @@ -1605,17 +1594,17 @@ static void editinfobox_refresh(struct editinfobox *ei) if (editor_tool_has_size(ett)) { gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->size_spin_button), editor_tool_get_size(ett)); - gtk_widget_show(ei->size_hbox); + gtk_widget_set_visible(ei->size_hbox, TRUE); } else { - gtk_widget_hide(ei->size_hbox); + gtk_widget_set_visible(ei->size_hbox, FALSE); } if (editor_tool_has_count(ett)) { gtk_spin_button_set_value(GTK_SPIN_BUTTON(ei->count_spin_button), editor_tool_get_count(ett)); - gtk_widget_show(ei->count_hbox); + gtk_widget_set_visible(ei->count_hbox, TRUE); } else { - gtk_widget_hide(ei->count_hbox); + gtk_widget_set_visible(ei->count_hbox, FALSE); } refresh_tool_applied_player_combo(ei); diff --git a/client/gui-gtk-4.0/editprop.c b/client/gui-gtk-4.0/editprop.c index eff783f17e..5ac5f22ee3 100644 --- a/client/gui-gtk-4.0/editprop.c +++ b/client/gui-gtk-4.0/editprop.c @@ -3760,8 +3760,8 @@ static struct extviewer *extviewer_new(struct objprop *op) break; } - gtk_widget_show(ev->panel_widget); - gtk_widget_show(ev->view_widget); + gtk_widget_set_visible(ev->panel_widget, TRUE); + gtk_widget_set_visible(ev->view_widget, TRUE); return ev; } @@ -4716,11 +4716,7 @@ static void property_page_quick_find_entry_changed(GtkWidget *entry, matched = property_filter_match(pf, op); w = objprop_get_widget(op); if (objprop_has_widget(op) && w != NULL) { - if (matched) { - gtk_widget_show(w); - } else { - gtk_widget_hide(w); - } + gtk_widget_set_visible(w, matched); } col = objprop_get_treeview_column(op); if (objprop_show_in_listview(op) && col != NULL) { @@ -4958,7 +4954,7 @@ property_page_new(enum editor_object_type objtype, button = gtk_button_new_with_mnemonic(_("_Close")); gtk_size_group_add_widget(sizegroup, button); g_signal_connect_swapped(button, "clicked", - G_CALLBACK(gtk_widget_hide), pe->widget); + G_CALLBACK(fc_gtk_widget_hide), pe->widget); gtk_grid_attach(GTK_GRID(hgrid2), button, grid2_col++, 0, 1, 1); /* Now create the properties panel. */ @@ -6276,11 +6272,11 @@ void property_editor_load_tiles(struct property_editor *pe, void property_editor_popup(struct property_editor *pe, enum editor_object_type objtype) { - if (!pe || !pe->widget) { + if (pe == NULL || pe->widget == NULL) { return; } - gtk_widget_show(pe->widget); + gtk_widget_set_visible(pe->widget, TRUE); gtk_window_present(GTK_WINDOW(pe->widget)); if (objtype < NUM_OBJTYPES) { @@ -6293,10 +6289,11 @@ void property_editor_popup(struct property_editor *pe, ****************************************************************************/ void property_editor_popdown(struct property_editor *pe) { - if (!pe || !pe->widget) { + if (pe == NULL || pe->widget == NULL) { return; } - gtk_widget_hide(pe->widget); + + gtk_widget_set_visible(pe->widget, FALSE); } /************************************************************************//** diff --git a/client/gui-gtk-4.0/gamedlgs.c b/client/gui-gtk-4.0/gamedlgs.c index 89b8af195a..4a694fc691 100644 --- a/client/gui-gtk-4.0/gamedlgs.c +++ b/client/gui-gtk-4.0/gamedlgs.c @@ -373,7 +373,7 @@ static GtkWidget *create_multiplier_dialog(void) g_signal_connect(shell, "response", G_CALLBACK(multipliers_command_callback), NULL); - gtk_widget_show(content); + gtk_widget_set_visible(content, TRUE); return shell; } @@ -499,7 +499,7 @@ static GtkWidget *create_rates_dialog(void) g_signal_connect(shell, "destroy", G_CALLBACK(widget_destroyed), &rates_dialog_shell); - gtk_widget_show(shell); + gtk_widget_set_visible(shell, TRUE); rates_tax_value = -1; rates_lux_value = -1; diff --git a/client/gui-gtk-4.0/gotodlg.c b/client/gui-gtk-4.0/gotodlg.c index 37cb7a9b3e..f9a790e825 100644 --- a/client/gui-gtk-4.0/gotodlg.c +++ b/client/gui-gtk-4.0/gotodlg.c @@ -113,7 +113,7 @@ static void goto_cmd_callback(GtkWidget *dlg, gint arg) struct city *pdestcity = get_selected_city(); if (pdestcity) { - unit_list_iterate(get_units_in_focus(), punit) { + unit_list_iterate(get_units_in_focus(), punit) { send_goto_tile(punit, pdestcity->tile); } unit_list_iterate_end; } @@ -133,10 +133,9 @@ static void goto_cmd_callback(GtkWidget *dlg, gint arg) **************************************************************************/ static void create_goto_dialog(void) { - GtkWidget *sw, *label, *frame, *vgrid; + GtkWidget *sw, *label, *frame, *vbox; GtkCellRenderer *rend; GtkTreeViewColumn *col; - int grid_row = 0; dshell = gtk_dialog_new_with_buttons(_("Goto/Airlift Unit"), NULL, @@ -155,7 +154,7 @@ static void create_goto_dialog(void) g_signal_connect(dshell, "response", G_CALLBACK(goto_cmd_callback), NULL); - source = gtk_label_new("" /* filled in later */); + source = gtk_label_new("" /* Filled in later */); gtk_label_set_wrap(GTK_LABEL(source), TRUE); gtk_label_set_justify(GTK_LABEL(source), GTK_JUSTIFY_CENTER); gtk_box_insert_child_after(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dshell))), @@ -172,14 +171,12 @@ static void create_goto_dialog(void) gtk_box_insert_child_after(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dshell))), frame, NULL); - vgrid = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vgrid), 6); - gtk_frame_set_child(GTK_FRAME(frame), vgrid); + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); + gtk_frame_set_child(GTK_FRAME(frame), vbox); goto_list_store = gtk_list_store_new(GD_COL_NUM, G_TYPE_INT, G_TYPE_STRING, - GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); + GDK_TYPE_PIXBUF, G_TYPE_STRING, + G_TYPE_STRING); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(goto_list_store), GD_COL_CITY_NAME, GTK_SORT_ASCENDING); @@ -216,33 +213,36 @@ static void create_goto_dialog(void) rend = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new_with_attributes(_("Nation"), rend, - "text", GD_COL_NATION, NULL); + "text", GD_COL_NATION, + NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); gtk_tree_view_column_set_sort_column_id(col, GD_COL_NATION); rend = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new_with_attributes(_("Airlift"), rend, - "text", GD_COL_AIRLIFT, NULL); + "text", GD_COL_AIRLIFT, + NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); gtk_tree_view_column_set_sort_column_id(col, GD_COL_AIRLIFT); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200); - gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), sw); all_toggle = gtk_check_button_new_with_mnemonic(_("Show _All Cities")); - gtk_grid_attach(GTK_GRID(vgrid), all_toggle, 0, grid_row++, 1, 1); + gtk_box_append(GTK_BOX(vbox), all_toggle); - g_signal_connect(all_toggle, "toggled", G_CALLBACK(update_goto_dialog), NULL); + g_signal_connect(all_toggle, "toggled", + G_CALLBACK(update_goto_dialog), NULL); g_signal_connect(goto_list_selection, "changed", G_CALLBACK(goto_selection_callback), NULL); - gtk_widget_show(dshell); + gtk_widget_set_visible(dshell, TRUE); original_tile = get_center_tile_mapcanvas(); diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index 97e6967126..daee7d2d39 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -775,7 +775,7 @@ static void tearoff_destroy(GtkWidget *w, gpointer data) b = g_object_get_data(G_OBJECT(w), "toggle"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b), FALSE); - gtk_widget_hide(w); + gtk_widget_set_visible(w, FALSE); move_from_container_to_container(box, old_parent, p); } @@ -804,15 +804,15 @@ static void tearoff_callback(GtkWidget *b, gpointer data) temp_hide = g_object_get_data(G_OBJECT(box), "hide-over-reparent"); if (temp_hide != NULL) { - gtk_widget_hide(temp_hide); + gtk_widget_set_visible(temp_hide, FALSE); } move_from_container_to_container(box, old_parent, w); - gtk_widget_show(w); + gtk_widget_set_visible(w, TRUE); if (temp_hide != NULL) { - gtk_widget_show(temp_hide); + gtk_widget_set_visible(temp_hide, TRUE); } } else { if (GTK_IS_BOX(old_parent)) { @@ -970,7 +970,7 @@ static void populate_unit_pic_table(void) 1, 0, 1, 1); } - gtk_widget_show(table); + gtk_widget_set_visible(table, TRUE); } /**********************************************************************//** @@ -1010,13 +1010,13 @@ void reset_unit_table(void) populate_unit_pic_table(); - /* We have to force a redraw of the units. And we explicitly have + /* We have to force a redraw of the units. And we explicitly have * to force a redraw of the focus unit, which is normally only * redrawn when the focus changes. We also have to force the 'more' * arrow to go away, both by expicitly hiding it and telling it to * do so (this will be reset immediately afterwards if necessary, * but we have to make the *internal* state consistent). */ - gtk_widget_hide(more_arrow); + gtk_widget_set_visible(more_arrow, FALSE); set_unit_icons_more_arrow(FALSE); if (get_num_units_in_focus() == 1) { set_unit_icon(-1, head_of_units_in_focus()); @@ -1632,7 +1632,8 @@ static void setup_widgets(void) /* Other things to take care of */ - gtk_widget_show(gtk_window_get_child(GTK_WINDOW(toplevel))); + gtk_widget_set_visible(gtk_window_get_child(GTK_WINDOW(toplevel)), + TRUE); if (GUI_GTK_OPTION(enable_tabs)) { meswin_dialog_popup(FALSE); @@ -1642,8 +1643,8 @@ static void setup_widgets(void) gtk_notebook_set_current_page(GTK_NOTEBOOK(bottom_notebook), 0); if (!GUI_GTK_OPTION(map_scrollbars)) { - gtk_widget_hide(map_horizontal_scrollbar); - gtk_widget_hide(map_vertical_scrollbar); + gtk_widget_set_visible(map_horizontal_scrollbar, FALSE); + gtk_widget_set_visible(map_vertical_scrollbar, FALSE); } } @@ -2071,12 +2072,12 @@ static void activate_gui(GtkApplication *app, gpointer data) tileset_use_preferred_theme(tileset); - gtk_widget_show(toplevel); + gtk_widget_set_visible(toplevel, TRUE); - /* assumes toplevel showing */ + /* Assumes toplevel showing */ set_client_state(C_S_DISCONNECTED); - /* assumes client_state is set */ + /* Assumes client_state is set */ timer_id = g_timeout_add(TIMER_INTERVAL, timer_callback, NULL); } @@ -2162,15 +2163,15 @@ void set_unit_icons_more_arrow(bool onoff) { static bool showing = FALSE; - if (!more_arrow) { + if (more_arrow == NULL) { return; } if (onoff && !showing) { - gtk_widget_show(more_arrow); + gtk_widget_set_visible(more_arrow, TRUE); showing = TRUE; } else if (!onoff && showing) { - gtk_widget_hide(more_arrow); + gtk_widget_set_visible(more_arrow, FALSE); showing = FALSE; } } @@ -2522,9 +2523,9 @@ void refresh_chat_buttons(void) /* Hide the "Allies Only" button for local games. */ if (is_server_running()) { - gtk_widget_hide(button); + gtk_widget_set_visible(button, FALSE); } else { - gtk_widget_show(button); + gtk_widget_set_visible(button, TRUE); gtk_check_button_set_active(GTK_CHECK_BUTTON(button), GUI_GTK_OPTION(allied_chat_only)); } diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index 9025fb2986..fc3008f49b 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -330,7 +330,7 @@ static void gui_dialog_destroy_handler(GtkWidget *w, struct gui_dialog *dlg) if (adialog->id == dlg->return_dialog_id) { gui_dialog_raise(adialog); - break; + break; } } } @@ -463,7 +463,7 @@ static void gui_dialog_detach(struct gui_dialog *dlg) gtk_window_set_default_size(GTK_WINDOW(dlg->v.window), dlg->default_width, dlg->default_height); - gtk_widget_show(window); + gtk_widget_set_visible(window, TRUE); } /**********************************************************************//** @@ -536,9 +536,9 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, dlg->vertical_content = TRUE; } - gtk_widget_show(dlg->grid); + gtk_widget_set_visible(dlg->grid, TRUE); gui_dialog_add_content_widget(dlg, action_area); - gtk_widget_show(action_area); + gtk_widget_set_visible(action_area, TRUE); gtk_widget_set_margin_start(dlg->grid, 2); gtk_widget_set_margin_end(dlg->grid, 2); @@ -595,12 +595,12 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gtk_box_append(GTK_BOX(hbox), button); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dlg->grid, hbox); - dlg->v.tab.handler_id = - g_signal_connect(notebook, "switch-page", - G_CALLBACK(gui_dialog_switch_page_handler), dlg); + dlg->v.tab.handler_id + = g_signal_connect(notebook, "switch-page", + G_CALLBACK(gui_dialog_switch_page_handler), dlg); dlg->v.tab.child = dlg->grid; gtk_style_context_add_provider(gtk_widget_get_style_context(label), @@ -714,10 +714,10 @@ void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, iter = gtk_widget_get_next_sibling(iter)) { if (GTK_IS_BUTTON(iter)) { gpointer data = g_object_get_data(G_OBJECT(iter), - "gui-dialog-response-data"); + "gui-dialog-response-data"); if (response == GPOINTER_TO_INT(data)) { - gtk_widget_set_sensitive(iter, setting); + gtk_widget_set_sensitive(iter, setting); } } } @@ -736,7 +736,7 @@ GtkWidget *gui_dialog_get_toplevel(struct gui_dialog *dlg) **************************************************************************/ void gui_dialog_show_all(struct gui_dialog *dlg) { - gtk_widget_show(dlg->grid); + gtk_widget_set_visible(dlg->grid, TRUE); if (dlg->type == GUI_DIALOG_TAB) { GtkWidget *iter; @@ -746,23 +746,23 @@ void gui_dialog_show_all(struct gui_dialog *dlg) iter != NULL; iter = gtk_widget_get_next_sibling(iter)) { if (!GTK_IS_BUTTON(iter)) { - num_visible++; + num_visible++; } else { - gpointer data = g_object_get_data(G_OBJECT(iter), - "gui-dialog-response-data"); - int response = GPOINTER_TO_INT(data); - - if (response != GTK_RESPONSE_CLOSE - && response != GTK_RESPONSE_CANCEL) { - num_visible++; - } else { - gtk_widget_hide(iter); - } + gpointer data = g_object_get_data(G_OBJECT(iter), + "gui-dialog-response-data"); + int response = GPOINTER_TO_INT(data); + + if (response != GTK_RESPONSE_CLOSE + && response != GTK_RESPONSE_CANCEL) { + num_visible++; + } else { + gtk_widget_set_visible(iter, FALSE); + } } } if (num_visible == 0) { - gtk_widget_hide(dlg->actions); + gtk_widget_set_visible(dlg->actions, FALSE); } } } @@ -776,7 +776,7 @@ void gui_dialog_present(struct gui_dialog *dlg) switch (dlg->type) { case GUI_DIALOG_WINDOW: - gtk_widget_show(dlg->v.window); + gtk_widget_set_visible(dlg->v.window, TRUE); break; case GUI_DIALOG_TAB: { @@ -787,7 +787,7 @@ void gui_dialog_present(struct gui_dialog *dlg) n = gtk_notebook_page_num(notebook, dlg->grid); if (current != n) { - GtkWidget *label = dlg->v.tab.label; + GtkWidget *label = dlg->v.tab.label; gtk_style_context_add_class(gtk_widget_get_style_context(label), "notice"); @@ -1138,7 +1138,7 @@ gint blocking_dialog(GtkWidget *dlg) struct blocking_dialog_data data; GMainLoop *dlg_loop; - gtk_widget_show(dlg); + gtk_widget_set_visible(dlg, TRUE); dlg_loop = g_main_loop_new(NULL, FALSE); data.loop = dlg_loop; g_signal_connect(dlg, "response", G_CALLBACK(blocking_dialog_response), @@ -1165,3 +1165,11 @@ GtkWidget *widget_get_child(GtkWidget *wdg) { return gtk_widget_get_first_child(wdg); } + +/**********************************************************************//** + Callback to hide a widget. +**************************************************************************/ +void fc_gtk_widget_hide(GtkWidget *hide, void *data) +{ + gtk_widget_set_visible(GTK_WIDGET(data), FALSE); +} diff --git a/client/gui-gtk-4.0/gui_stuff.h b/client/gui-gtk-4.0/gui_stuff.h index c4f6a589f1..d64d4f4540 100644 --- a/client/gui-gtk-4.0/gui_stuff.h +++ b/client/gui-gtk-4.0/gui_stuff.h @@ -23,6 +23,8 @@ GtkWidget *icon_label_button_new(const gchar *icon_name, void gtk_stockbutton_set_label(GtkWidget *button, const gchar *label_text); void gtk_expose_now(GtkWidget *w); +void fc_gtk_widget_hide(GtkWidget *hide, void *data); + void intl_slist(int n, const char **s, bool *done); /* the standard GTK+ 2.0 API is braindamaged. this is slightly better! */ diff --git a/client/gui-gtk-4.0/happiness.c b/client/gui-gtk-4.0/happiness.c index da3dea0029..6e7491f8f5 100644 --- a/client/gui-gtk-4.0/happiness.c +++ b/client/gui-gtk-4.0/happiness.c @@ -252,7 +252,7 @@ static struct happiness_dialog *create_happiness_dialog(struct city *pcity, gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_grid_attach(GTK_GRID(table), label, 0, NUM_HAPPINESS_MODIFIERS, 2, 1); - gtk_widget_show(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, TRUE); dialog_list_prepend(dialog_list, pdialog); refresh_happiness_dialog(pcity); @@ -316,7 +316,7 @@ void close_happiness_dialog(struct city *pcity) return; } - gtk_widget_hide(pdialog->shell); + gtk_widget_set_visible(pdialog->shell, FALSE); dialog_list_remove(dialog_list, pdialog); diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index ab3a428f42..d3b5a50bd6 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -385,7 +385,7 @@ static GtkWidget *help_hyperlink_new(GtkWidget *label, gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_widget_set_name(label, "help_link"); gtk_button_set_child(GTK_BUTTON(button), label); - gtk_widget_show(button); + gtk_widget_set_visible(button, TRUE); g_signal_connect_swapped(button, "clicked", G_CALLBACK(help_hyperlink_callback), label); g_object_set_data(G_OBJECT(label), "page_type", select); @@ -432,23 +432,21 @@ static GtkWidget *help_slink_new_page(const gchar *txt, **************************************************************************/ static void help_box_hide(void) { - gtk_widget_hide(help_box); + gtk_widget_set_visible(help_box, FALSE); - gtk_widget_hide(help_tile); + gtk_widget_set_visible(help_tile, FALSE); - gtk_widget_hide(help_itable); - gtk_widget_hide(help_wtable); - gtk_widget_hide(help_utable); - gtk_widget_hide(help_ttable); - gtk_widget_hide(help_etable); + gtk_widget_set_visible(help_itable, FALSE); + gtk_widget_set_visible(help_wtable, FALSE); + gtk_widget_set_visible(help_utable, FALSE); + gtk_widget_set_visible(help_ttable, FALSE); + gtk_widget_set_visible(help_etable, FALSE); - gtk_widget_hide(help_tile); /* FIXME: twice? */ + gtk_widget_set_visible(help_vbox, FALSE); + gtk_widget_set_visible(help_text_sw, FALSE); - gtk_widget_hide(help_vbox); - gtk_widget_hide(help_text_sw); - - gtk_widget_hide(help_tree_sw); - gtk_widget_hide(help_tree_buttons_hbox); + gtk_widget_set_visible(help_tree_sw, FALSE); + gtk_widget_set_visible(help_tree_buttons_hbox, FALSE); } /**********************************************************************//** @@ -563,7 +561,7 @@ static void create_help_dialog(void) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(help_dialog_shell))), hbox); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); /* Build tree store. */ store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); @@ -614,14 +612,14 @@ static void create_help_dialog(void) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request(help_view_sw, 190, -1); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_view_sw), help_view); - gtk_widget_show(help_view); + gtk_widget_set_visible(help_view, TRUE); gtk_box_append(GTK_BOX(hbox), help_view_sw); - gtk_widget_show(help_view_sw); + gtk_widget_set_visible(help_view_sw, TRUE); help_frame = gtk_frame_new(""); gtk_box_append(GTK_BOX(hbox), help_frame); gtk_widget_set_hexpand(help_frame, TRUE); - gtk_widget_show(help_frame); + gtk_widget_set_visible(help_frame, TRUE); help_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); gtk_frame_set_child(GTK_FRAME(help_frame), help_box); @@ -653,7 +651,7 @@ static void create_help_dialog(void) gtk_widget_set_name(help_ilabel[i], "help_label"); } - gtk_widget_show(help_ilabel[i]); + gtk_widget_set_visible(help_ilabel[i], TRUE); } help_wtable = gtk_grid_new(); @@ -672,7 +670,7 @@ static void create_help_dialog(void) gtk_widget_set_name(help_wlabel[i], "help_label"); } - gtk_widget_show(help_wlabel[i]); + gtk_widget_set_visible(help_wlabel[i], TRUE); } help_utable = gtk_grid_new(); @@ -697,7 +695,8 @@ static void create_help_dialog(void) i, j, 1, 1); gtk_widget_set_name(help_ulabel[j][i], "help_label"); } - gtk_widget_show(help_ulabel[j][i]); + + gtk_widget_set_visible(help_ulabel[j][i], TRUE); } } @@ -716,12 +715,12 @@ static void create_help_dialog(void) /* Extra wide cell for terrain specials */ gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i], i, j, 4, 1); - gtk_widget_show(help_tlabel[j][i]); - break; /* skip rest of row */ + gtk_widget_set_visible(help_tlabel[j][i], TRUE); + break; /* Skip rest of row */ } else { gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i], i, j, 1, 1); - gtk_widget_show(help_tlabel[j][i]); + gtk_widget_set_visible(help_tlabel[j][i], TRUE); } } } @@ -730,12 +729,12 @@ static void create_help_dialog(void) gtk_box_append(GTK_BOX(help_box), help_etable); for (i = 0; i < 6; i++) { - help_elabel[i] = - gtk_label_new(help_elabel_name[i] ? _(help_elabel_name[i]) : ""); + help_elabel[i] + = gtk_label_new(help_elabel_name[i] ? _(help_elabel_name[i]) : ""); gtk_widget_set_hexpand(help_elabel[i], TRUE); gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1); gtk_widget_set_name(help_elabel[i], "help_label"); - gtk_widget_show(help_elabel[i]); + gtk_widget_set_visible(help_elabel[i], TRUE); } help_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1); @@ -757,7 +756,7 @@ static void create_help_dialog(void) gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); gtk_widget_set_name(text, "help_text"); help_text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); - gtk_widget_show(text); + gtk_widget_set_visible(text, TRUE); help_text_sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_text_sw), @@ -805,7 +804,7 @@ static void create_help_dialog(void) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_tree_sw), help_tree); gtk_widget_set_size_request(help_tree_sw, -1, 200); - gtk_widget_show(help_tree); + gtk_widget_set_visible(help_tree, TRUE); gtk_box_append(GTK_BOX(help_box), help_tree_sw); help_tree_expand = gtk_button_new_with_label(_("Expand All")); @@ -820,7 +819,7 @@ static void create_help_dialog(void) gtk_box_append(GTK_BOX(help_tree_buttons_hbox), help_tree_expand); gtk_box_append(GTK_BOX(help_tree_buttons_hbox), help_tree_collapse); gtk_box_append(GTK_BOX(help_box), help_tree_buttons_hbox); - gtk_widget_show(help_tree_buttons_hbox); + gtk_widget_set_visible(help_tree_buttons_hbox, TRUE); } /**********************************************************************//** @@ -833,7 +832,7 @@ static void set_help_tile_from_sprite(struct sprite *spr) } picture_set_from_surface(GTK_PICTURE(help_tile), spr->surface); - gtk_widget_show(help_tile); + gtk_widget_set_visible(help_tile, TRUE); } /**********************************************************************//** @@ -863,7 +862,7 @@ static void set_help_tile_from_terrain(struct terrain *pterr) } picture_set_from_surface(GTK_PICTURE(help_tile), canvas.surface); - gtk_widget_show(help_tile); + gtk_widget_set_visible(help_tile, TRUE); cairo_surface_destroy(canvas.surface); } @@ -891,7 +890,7 @@ static void set_help_tile_from_extra(const struct extra_type *pextra) put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE); picture_set_from_surface(GTK_PICTURE(help_tile), canvas.surface); - gtk_widget_show(help_tile); + gtk_widget_set_visible(help_tile, TRUE); cairo_surface_destroy(canvas.surface); } @@ -938,11 +937,11 @@ static void help_update_improvement(const struct help_item *pitem, set_help_tile_from_sprite(get_building_sprite(tileset, imp)); - gtk_widget_show(help_itable); + gtk_widget_set_visible(help_itable, TRUE); - helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp); + helptext_building(buf, sizeof(buf), client_player(), pitem->text, imp); gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1002,11 +1001,11 @@ static void help_update_wonder(const struct help_item *pitem, set_help_tile_from_sprite(get_building_sprite(tileset, imp)); - gtk_widget_show(help_wtable); + gtk_widget_set_visible(help_wtable, TRUE); - helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp); + helptext_building(buf, sizeof(buf), client_player(), pitem->text, imp); gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1051,10 +1050,10 @@ static void help_update_unit_type(const struct help_item *pitem, utype_name_translation(utype->obsoleted_by)); } - helptext_unit(buf, sizeof(buf), client.conn.playing, pitem->text, utype); + helptext_unit(buf, sizeof(buf), client_player(), pitem->text, utype); gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); set_help_tile_from_sprite(get_unittype_sprite(tileset, utype, ACTIVITY_LAST, @@ -1075,9 +1074,10 @@ static void help_update_unit_type(const struct help_item *pitem, skip_intl_qualifier_prefix(REQ_LABEL_NONE)); gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } - gtk_widget_show(help_utable); + + gtk_widget_set_visible(help_utable, TRUE); } /**********************************************************************//** @@ -1121,10 +1121,11 @@ static void help_update_tech(const struct help_item *pitem, char *title) for (j = 0; j < ARRAY_SIZE(help_advances); j++) { help_advances[j] = FALSE; } + gtk_tree_store_clear(tstore); create_tech_tree(i, TECH_TREE_DEPTH, NULL); - gtk_widget_show(help_tree_sw); - gtk_widget_show(help_tree_buttons_hbox); + gtk_widget_set_visible(help_tree_sw, TRUE); + gtk_widget_set_visible(help_tree_buttons_hbox, TRUE); helptext_advance(buf, sizeof(buf), client.conn.playing, pitem->text, i); len = strlen(buf); @@ -1144,10 +1145,10 @@ static void help_update_tech(const struct help_item *pitem, char *title) gtk_widget_set_margin_bottom(w, 5); gtk_text_view_set_editable(GTK_TEXT_VIEW(w), FALSE); help_box_add(w); - gtk_widget_show(w); + gtk_widget_set_visible(w, TRUE); txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w)); - if (txt) { + if (txt != NULL) { gtk_text_buffer_set_text(txt, buf, -1); } @@ -1159,7 +1160,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) gtk_widget_set_hexpand(w, TRUE); gtk_widget_set_vexpand(w, TRUE); help_box_add(w); - gtk_widget_show(w); + gtk_widget_set_visible(w, TRUE); governments_iterate(pgov) { /* FIXME: need a more general mechanism for this, since this @@ -1174,7 +1175,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) w = help_slink_new_page(government_name_translation(pgov), HELP_GOVERNMENT); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } } requirement_vector_iterate_end; } governments_iterate_end; @@ -1193,7 +1194,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) ? HELP_WONDER : HELP_IMPROVEMENT); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } } requirement_vector_iterate_end; requirement_vector_iterate(&pimprove->obsolete_by, pobs) { @@ -1209,7 +1210,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) ? HELP_WONDER : HELP_IMPROVEMENT); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } } requirement_vector_iterate_end; } @@ -1226,7 +1227,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) gtk_box_append(GTK_BOX(hbox), w); w = help_slink_new_page(utype_name_translation(punittype), HELP_UNIT); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } unit_type_iterate_end; advance_iterate_all(ptest) { @@ -1238,7 +1239,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) gtk_box_append(GTK_BOX(hbox), w); w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } else { hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); help_box_add(hbox); @@ -1254,7 +1255,7 @@ static void help_update_tech(const struct help_item *pitem, char *title) gtk_box_append(GTK_BOX(hbox), w); w = gtk_label_new(Q_("?techhelp:")); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } } if (padvance == advance_requires(ptest, AR_TWO)) { @@ -1272,11 +1273,11 @@ static void help_update_tech(const struct help_item *pitem, char *title) gtk_box_append(GTK_BOX(hbox), w); w = gtk_label_new(Q_("?techhelp:")); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } } advance_iterate_all_end; - gtk_widget_show(help_vbox); + gtk_widget_set_visible(help_vbox, TRUE); } } @@ -1300,7 +1301,7 @@ static void add_act_help_for_terrain(const char *act_label, w = gtk_label_new(descr_label); gtk_box_append(GTK_BOX(hbox), w); - gtk_widget_show(hbox); + gtk_widget_set_visible(hbox, TRUE); } /**********************************************************************//** @@ -1426,16 +1427,16 @@ static void help_update_terrain(const struct help_item *pitem, help_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, _("Build as base")); } - gtk_widget_show(help_vbox); + gtk_widget_set_visible(help_vbox, TRUE); } helptext_terrain(buf, sizeof(buf), client.conn.playing, pitem->text, pterrain); gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); - gtk_widget_show(help_ttable); + gtk_widget_set_visible(help_ttable, TRUE); } /**********************************************************************//** @@ -1512,10 +1513,10 @@ static void help_update_extra(const struct help_item *pitem, char *title) helptext_extra(buf, sizeof(buf), client.conn.playing, pitem->text, pextra); } - gtk_widget_show(help_etable); + gtk_widget_set_visible(help_etable, TRUE); gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1535,7 +1536,7 @@ static void help_update_goods(const struct help_item *pitem, } gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1555,7 +1556,7 @@ static void help_update_specialist(const struct help_item *pitem, } gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1575,7 +1576,7 @@ static void help_update_government(const struct help_item *pitem, } gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1595,7 +1596,7 @@ static void help_update_nation(const struct help_item *pitem, char *title, } gtk_text_buffer_set_text(help_text, buf, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); } /**********************************************************************//** @@ -1649,12 +1650,12 @@ static void help_update_dialog(const struct help_item *pitem) default: /* It was a pure text item */ gtk_text_buffer_set_text(help_text, pitem->text, -1); - gtk_widget_show(help_text_sw); + gtk_widget_set_visible(help_text_sw, TRUE); break; } set_title_topic(pitem->topic); - gtk_widget_show(help_box); + gtk_widget_set_visible(help_box, TRUE); } /**********************************************************************//** diff --git a/client/gui-gtk-4.0/infradlg.c b/client/gui-gtk-4.0/infradlg.c index 25590b6c72..bffcb756e7 100644 --- a/client/gui-gtk-4.0/infradlg.c +++ b/client/gui-gtk-4.0/infradlg.c @@ -127,8 +127,8 @@ void infra_dialog_popup(void) g_signal_connect(dlg, "destroy", G_CALLBACK(infra_response_callback), NULL); g_signal_connect(dlg, "response", G_CALLBACK(infra_response_callback), NULL); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(dlg))); - gtk_widget_show(dlg); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(dlg)), TRUE); + gtk_widget_set_visible(dlg, TRUE); update_infra_dialog(); } @@ -202,5 +202,5 @@ void infra_placement_set_tile(struct tile *ptile) _("Select infra for the tile, or another tile.")); } - gtk_widget_show(infra_list_box); + gtk_widget_set_visible(infra_list_box, TRUE); } diff --git a/client/gui-gtk-4.0/inputdlg.c b/client/gui-gtk-4.0/inputdlg.c index 289fb1d85c..d8f7f2df32 100644 --- a/client/gui-gtk-4.0/inputdlg.c +++ b/client/gui-gtk-4.0/inputdlg.c @@ -92,11 +92,12 @@ GtkWidget *input_dialog_create(GtkWindow *parent, const char *dialogname, input = gtk_entry_new(); gtk_frame_set_child(GTK_FRAME(label), input); - gtk_entry_buffer_set_text(gtk_entry_get_buffer(GTK_ENTRY(input)), postinputtest, -1); + gtk_entry_buffer_set_text(gtk_entry_get_buffer(GTK_ENTRY(input)), + postinputtest, -1); gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); g_object_set_data(G_OBJECT(shell), "iinput", input); - gtk_widget_show(GTK_WIDGET(shell)); + gtk_widget_set_visible(GTK_WIDGET(shell), TRUE); gtk_window_present(GTK_WINDOW(shell)); return shell; diff --git a/client/gui-gtk-4.0/inteldlg.c b/client/gui-gtk-4.0/inteldlg.c index 710cf9bbbf..55b118cdea 100644 --- a/client/gui-gtk-4.0/inteldlg.c +++ b/client/gui-gtk-4.0/inteldlg.c @@ -377,7 +377,8 @@ static struct intel_dialog *create_intel_dialog(struct player *p) label = gtk_label_new_with_mnemonic(_("_Techs")); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(shell))); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(shell)), + TRUE); dialog_list_prepend(dialog_list, pdialog); @@ -465,7 +466,8 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), sw); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(shell))); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(shell)), + TRUE); wonder_dialog_list_prepend(wonder_dialogs, pdialog); diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index 3f640c0e44..fff9e5ac56 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -4273,7 +4273,7 @@ void real_menus_init(void) /* Add new government entries. */ item = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); + gtk_widget_set_visible(item, TRUE); governments_iterate(g) { if (g != game.government_during_revolution) { @@ -4285,7 +4285,7 @@ void real_menus_init(void) g_signal_connect(item, "activate", G_CALLBACK(government_callback), g); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); + gtk_widget_set_visible(item, TRUE); } } governments_iterate_end; } diff --git a/client/gui-gtk-4.0/messagedlg.c b/client/gui-gtk-4.0/messagedlg.c index b909f0fd2f..ecc2a1a3e9 100644 --- a/client/gui-gtk-4.0/messagedlg.c +++ b/client/gui-gtk-4.0/messagedlg.c @@ -86,7 +86,7 @@ static void create_messageopt_dialog(void) "Popup individual window")); gtk_widget_set_name(explanation, "comment_label"); gui_dialog_add_content_widget(shell, explanation); - gtk_widget_show(explanation); + gtk_widget_set_visible(explanation, TRUE); form = gtk_grid_new(); gui_dialog_add_content_widget(shell, form); @@ -128,7 +128,7 @@ static void create_messageopt_dialog(void) renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Event"), - renderer, "text", 3, NULL); + renderer, "text", 3, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); gtk_tree_view_column_set_expand(column, TRUE); @@ -161,7 +161,7 @@ static void create_messageopt_dialog(void) gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_grid_attach(GTK_GRID(form), sw, form_col++, 0, 1, 1); gtk_tree_view_focus(GTK_TREE_VIEW(view)); @@ -194,9 +194,10 @@ static void messageopt_response(struct gui_dialog *dlg, int response, for (j = 0; j < NUM_MW; j++) { itree_get(&it, j, &toggle, 4, &i, -1); - if (toggle) - messages_where[i] |= (1<shell); + gtk_widget_set_visible(pdialog->shell, TRUE); return pdialog; } @@ -537,9 +539,10 @@ static void option_dialog_option_add(struct option_dialog *pdialog, gtk_widget_set_margin_start(pdialog->vboxes[category], 8); gtk_widget_set_margin_top(pdialog->vboxes[category], 8); gtk_widget_set_hexpand(pdialog->vboxes[category], TRUE); - gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), pdialog->vboxes[category]); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), + pdialog->vboxes[category]); - gtk_widget_show(sw); + gtk_widget_set_visible(sw, TRUE); } pdialog->box_children[category]++; @@ -688,7 +691,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, gtk_grid_attach(GTK_GRID(main_hbox), w, main_col++, 0, 1, 1); } - gtk_widget_show(main_hbox); + gtk_widget_set_visible(main_hbox, TRUE); /* Set as current value. */ option_dialog_option_refresh(poption); diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index 5955c8729c..07e92d58ee 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -584,7 +584,6 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, GtkCellRenderer *rend; GtkTreeSelection *selection; struct save_dialog *pdialog; - int grids_row = 0; fc_assert_ret_val(NULL != action, NULL); fc_assert_ret_val(NULL != files, NULL); @@ -622,10 +621,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, G_CALLBACK(save_dialog_row_callback), pdialog); pdialog->tree_view = GTK_TREE_VIEW(view); - sbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(sbox), 2); + sbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_box_append(vbox, sbox); label = g_object_new(GTK_TYPE_LABEL, @@ -635,7 +631,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, "xalign", 0.0, "yalign", 0.5, NULL); - gtk_grid_attach(GTK_GRID(sbox), label, 0, grids_row++, 1, 1); + gtk_box_append(GTK_BOX(sbox), label); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sw), 300); @@ -644,7 +640,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); - gtk_grid_attach(GTK_GRID(sbox), sw, 0, grids_row++, 1, 1); + gtk_box_append(GTK_BOX(sbox), sw); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); @@ -663,15 +659,11 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, G_CALLBACK(save_dialog_entry_callback), pdialog); pdialog->entry = GTK_ENTRY(entry); - sbox = gtk_grid_new(); - grids_row = 0; + sbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_widget_set_margin_bottom(sbox, 12); gtk_widget_set_margin_end(sbox, 12); gtk_widget_set_margin_start(sbox, 12); gtk_widget_set_margin_top(sbox, 12); - gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(sbox), 2); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -680,14 +672,14 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, "xalign", 0.0, "yalign", 0.5, NULL); - gtk_grid_attach(GTK_GRID(sbox), label, 0, grids_row++, 1, 1); + gtk_box_append(GTK_BOX(sbox), label); - gtk_grid_attach(GTK_GRID(sbox), entry, 0, grids_row++, 1, 1); + gtk_box_append(GTK_BOX(sbox), entry); gtk_box_append(vbox, sbox); save_dialog_update(pdialog); gtk_window_set_focus(GTK_WINDOW(shell), entry); - gtk_widget_show(GTK_WIDGET(vbox)); + gtk_widget_set_visible(GTK_WIDGET(vbox), TRUE); return shell; } @@ -3527,14 +3519,10 @@ void real_set_client_page(enum client_pages new_page) case PAGE_MAIN: case PAGE_START: if (is_server_running()) { - if (game.info.is_new_game) { - gtk_widget_show(start_options_table); - } else { - gtk_widget_hide(start_options_table); - } + gtk_widget_set_visible(start_options_table, game.info.is_new_game); update_start_page(); } else { - gtk_widget_hide(start_options_table); + gtk_widget_set_visible(start_options_table, FALSE); } voteinfo_gui_update(); overview_size_changed(); @@ -3564,12 +3552,12 @@ void real_set_client_page(enum client_pages new_page) break; } - /* hide/show statusbar. */ + /* Hide/show statusbar. */ if (new_page == PAGE_START || new_page == PAGE_GAME) { clear_network_statusbar(); - gtk_widget_hide(statusbar_frame); + gtk_widget_set_visible(statusbar_frame, FALSE); } else { - gtk_widget_show(statusbar_frame); + gtk_widget_set_visible(statusbar_frame, TRUE); } gtk_notebook_set_current_page(GTK_NOTEBOOK(toplevel_tabs), new_page); diff --git a/client/gui-gtk-4.0/repodlgs.c b/client/gui-gtk-4.0/repodlgs.c index 07b9c3efcb..ff0a482c5e 100644 --- a/client/gui-gtk-4.0/repodlgs.c +++ b/client/gui-gtk-4.0/repodlgs.c @@ -1717,11 +1717,12 @@ static void units_report_init(struct units_report *preport) if (strlen(unit_report_columns[i].title) > 0) { GtkWidget *header = gtk_label_new(Q_(unit_report_columns[i].title)); + if (unit_report_columns[i].tooltip) { gtk_widget_set_tooltip_text(header, Q_(unit_report_columns[i].tooltip)); } - gtk_widget_show(header); + gtk_widget_set_visible(header, TRUE); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_widget(col, header); if (unit_report_columns[i].rightalign) { diff --git a/client/gui-gtk-4.0/soundset_dlg.c b/client/gui-gtk-4.0/soundset_dlg.c index f7c5653281..7bc8c0ec44 100644 --- a/client/gui-gtk-4.0/soundset_dlg.c +++ b/client/gui-gtk-4.0/soundset_dlg.c @@ -73,9 +73,10 @@ void popup_soundset_suggestion_dialog(void) game.control.preferred_soundset, sound_set_name); label = gtk_label_new(buf); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), + label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); - gtk_widget_show(label); + gtk_widget_set_visible(label, TRUE); /* In case incoming rulesets are incompatible with current soundset * we need to block their receive before user has accepted loading @@ -123,9 +124,10 @@ void popup_musicset_suggestion_dialog(void) game.control.preferred_musicset, music_set_name); label = gtk_label_new(buf); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), + label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); - gtk_widget_show(label); + gtk_widget_set_visible(label, TRUE); /* In case incoming rulesets are incompatible with current musicset * we need to block their receive before user has accepted loading diff --git a/client/gui-gtk-4.0/theme_dlg.c b/client/gui-gtk-4.0/theme_dlg.c index 913d7f39c0..9dd41ba57a 100644 --- a/client/gui-gtk-4.0/theme_dlg.c +++ b/client/gui-gtk-4.0/theme_dlg.c @@ -72,9 +72,10 @@ bool popup_theme_suggestion_dialog(const char *theme_name) theme_name, current_name); label = gtk_label_new(buf); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), + label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); - gtk_widget_show(label); + gtk_widget_set_visible(label, TRUE); theme_suggestion_response(blocking_dialog(dialog)); diff --git a/client/gui-gtk-4.0/tileset_dlg.c b/client/gui-gtk-4.0/tileset_dlg.c index 3fd3093f8a..d2c17c014e 100644 --- a/client/gui-gtk-4.0/tileset_dlg.c +++ b/client/gui-gtk-4.0/tileset_dlg.c @@ -78,9 +78,10 @@ void popup_tileset_suggestion_dialog(void) game.control.preferred_tileset, tileset_basename(tileset)); label = gtk_label_new(buf); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), + label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); - gtk_widget_show(label); + gtk_widget_set_visible(label, TRUE); /* In case incoming rulesets are incompatible with current tileset * we need to block their receive before user has accepted loading diff --git a/client/gui-gtk-4.0/unitselect.c b/client/gui-gtk-4.0/unitselect.c index 7c8722bd3a..8853e5b810 100644 --- a/client/gui-gtk-4.0/unitselect.c +++ b/client/gui-gtk-4.0/unitselect.c @@ -200,7 +200,7 @@ void unit_select_dialog_popup_main(struct tile *ptile, bool create) /* Present the unit selection dialog if it exists. */ if (pdialog) { /* Show all. */ - gtk_widget_show(GTK_WIDGET(pdialog->shell)); + gtk_widget_set_visible(GTK_WIDGET(pdialog->shell), TRUE); /* Update tile. */ usdlg_tile(pdialog, ptile); /* Refresh data and hide unused tabs. */ @@ -352,9 +352,9 @@ static void usdlg_refresh(struct unit_select_dialog *pdialog) bool show = usdlg_tab_update(pdialog, ushash, loc); if (!show) { - gtk_widget_hide(pdialog->tabs[loc].page); + gtk_widget_set_visible(pdialog->tabs[loc].page, FALSE); } else { - gtk_widget_show(pdialog->tabs[loc].page); + gtk_widget_set_visible(pdialog->tabs[loc].page, TRUE); if (pdialog->tabs[loc].path) { gtk_tree_view_expand_row(GTK_TREE_VIEW(pdialog->tabs[loc].view), @@ -366,6 +366,7 @@ static void usdlg_refresh(struct unit_select_dialog *pdialog) } } } + /* Destroy the hash. */ usdlg_data_destroy(ushash); } diff --git a/client/gui-gtk-4.0/unitselextradlg.c b/client/gui-gtk-4.0/unitselextradlg.c index 07a340417d..1f7cd94e25 100644 --- a/client/gui-gtk-4.0/unitselextradlg.c +++ b/client/gui-gtk-4.0/unitselextradlg.c @@ -226,17 +226,19 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); - /* This function should never be called so that there would be no extra to select, - * and where there is extra to select, one of them gets selected as the default. */ + /* This function should never be called so that there would be no extra + * to select, and where there is extra to select, one of them gets + * selected as the default. */ fc_assert(default_extra != NULL); if (default_extra != NULL) { /* Compiler still wants this */ - g_object_set_data(G_OBJECT(dlg), "target", GINT_TO_POINTER(default_extra->id)); + g_object_set_data(G_OBJECT(dlg), "target", + GINT_TO_POINTER(default_extra->id)); } g_signal_connect(dlg, "response", do_callback, actor); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(dlg))); - gtk_widget_show(dlg); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(dlg)), TRUE); + gtk_widget_set_visible(dlg, TRUE); return TRUE; } diff --git a/client/gui-gtk-4.0/unitselunitdlg.c b/client/gui-gtk-4.0/unitselunitdlg.c index d7463bc7d0..e5682a9f4a 100644 --- a/client/gui-gtk-4.0/unitselunitdlg.c +++ b/client/gui-gtk-4.0/unitselunitdlg.c @@ -183,17 +183,19 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); - /* This function should never be called so that there would be no unit to select, - * and where there is unit to select, one of them gets selected as the default. */ + /* This function should never be called so that there would be no unit + * to select, and where there is unit to select, one of them gets + * selected as the default. */ fc_assert(default_unit != NULL); if (default_unit != NULL) { /* Compiler still wants this */ - g_object_set_data(G_OBJECT(dlg), "target", GINT_TO_POINTER(default_unit->id)); + g_object_set_data(G_OBJECT(dlg), "target", + GINT_TO_POINTER(default_unit->id)); } g_signal_connect(dlg, "response", do_callback, actor); - gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(dlg))); - gtk_widget_show(dlg); + gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(dlg)), TRUE); + gtk_widget_set_visible(dlg, TRUE); return TRUE; } diff --git a/client/gui-gtk-4.0/voteinfo_bar.c b/client/gui-gtk-4.0/voteinfo_bar.c index ce65c99bcb..6f52f7233d 100644 --- a/client/gui-gtk-4.0/voteinfo_bar.c +++ b/client/gui-gtk-4.0/voteinfo_bar.c @@ -229,7 +229,7 @@ void voteinfo_gui_update(void) } if (!voteinfo_bar_can_be_shown()) { - gtk_widget_hide(vib->box); + gtk_widget_set_visible(vib->box, FALSE); return; } @@ -306,10 +306,10 @@ void voteinfo_gui_update(void) need_scroll = !gtk_widget_get_visible(vib->box) && chatline_is_scrolled_to_bottom(); - gtk_widget_show(vib->box); + gtk_widget_set_visible(vib->box, TRUE); if (vote_count <= 1) { - gtk_widget_hide(vib->next_button); + gtk_widget_set_visible(vib->next_button, FALSE); } if (need_scroll) { diff --git a/client/gui-gtk-4.0/wldlg.c b/client/gui-gtk-4.0/wldlg.c index 086da8c067..b4e7d199b2 100644 --- a/client/gui-gtk-4.0/wldlg.c +++ b/client/gui-gtk-4.0/wldlg.c @@ -217,9 +217,8 @@ static void cell_edited(GtkCellRendererText *cell, static GtkWidget *create_worklists_report(void) { GtkWidget *shell, *list; - GtkWidget *vgrid, *label, *sw; + GtkWidget *vbox, *label, *sw; GtkCellRenderer *rend; - int grid_row = 0; shell = gtk_dialog_new_with_buttons(_("Edit worklists"), NULL, @@ -240,11 +239,9 @@ static GtkWidget *create_worklists_report(void) g_signal_connect(shell, "destroy", G_CALLBACK(worklists_destroy_callback), NULL); - vgrid = gtk_grid_new(); - gtk_grid_set_row_spacing(GTK_GRID(vgrid), 2); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), - GTK_ORIENTATION_VERTICAL); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), vgrid); + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), + vbox); worklists_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); @@ -277,9 +274,9 @@ static GtkWidget *create_worklists_report(void) "label", _("_Worklists:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); - gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); - gtk_widget_show(vgrid); + gtk_box_append(GTK_BOX(vbox), label); + gtk_box_append(GTK_BOX(vbox), sw); + gtk_widget_set_visible(vbox, TRUE); return shell; } @@ -403,8 +400,9 @@ static void popup_worklist(struct global_worklist *pgwl) reset_global_worklist(editor, pgwl); insert_worklist(global_worklist_id(pgwl), editor); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), editor); - gtk_widget_show(editor); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), + editor); + gtk_widget_set_visible(editor, TRUE); refresh_worklist(editor); } @@ -1359,8 +1357,8 @@ GtkWidget *create_worklist(void) G_CALLBACK(dst_selection_callback), ptr); - gtk_widget_show(table); - gtk_widget_show(bbox); + gtk_widget_set_visible(table, TRUE); + gtk_widget_set_visible(bbox, TRUE); return editor; } @@ -1473,7 +1471,7 @@ static void reset_global_worklist(GtkWidget *editor, gtk_list_store_clear(ptr->src); gtk_list_store_clear(ptr->dst); - gtk_widget_hide(ptr->change_cmd); + gtk_widget_set_visible(ptr->change_cmd, FALSE); g_object_set(ptr->src_col, "visible", FALSE, NULL); g_object_set(ptr->dst_col, "visible", FALSE, NULL); -- 2.39.2