From 57f360f9d528997cb53146d34eabc2040154736d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 21 Nov 2021 07:49:57 +0200 Subject: [PATCH 37/37] gtk3x: Replace gtk_container_add() calls with modern constructs gtk_container_add() is going away in gtk-3.98.4 See osdn #43256 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/action_dialog.c | 40 ++--- client/gui-gtk-4.0/choice_dialog.c | 27 +-- client/gui-gtk-4.0/citizensinfo.c | 4 +- client/gui-gtk-4.0/citydlg.c | 234 +++++++++++++----------- client/gui-gtk-4.0/cityrep.c | 26 +-- client/gui-gtk-4.0/cma_fe.c | 46 ++--- client/gui-gtk-4.0/dialogs.c | 42 ++--- client/gui-gtk-4.0/diplodlg.c | 87 ++++----- client/gui-gtk-4.0/editgui.c | 123 +++++++------ client/gui-gtk-4.0/editgui.h | 2 +- client/gui-gtk-4.0/editprop.c | 259 ++++++++++++++------------- client/gui-gtk-4.0/finddlg.c | 2 +- client/gui-gtk-4.0/gamedlgs.c | 28 +-- client/gui-gtk-4.0/gotodlg.c | 17 +- client/gui-gtk-4.0/gtkcompat.h | 8 +- client/gui-gtk-4.0/gui_main.c | 91 +++++----- client/gui-gtk-4.0/gui_stuff.c | 19 +- client/gui-gtk-4.0/happiness.c | 8 +- client/gui-gtk-4.0/helpdlg.c | 118 +++++++----- client/gui-gtk-4.0/infradlg.c | 11 +- client/gui-gtk-4.0/inputdlg.c | 2 +- client/gui-gtk-4.0/inteldlg.c | 6 +- client/gui-gtk-4.0/luaconsole.c | 15 +- client/gui-gtk-4.0/mapctrl.c | 2 +- client/gui-gtk-4.0/messagedlg.c | 5 +- client/gui-gtk-4.0/messagewin.c | 2 +- client/gui-gtk-4.0/optiondlg.c | 22 +-- client/gui-gtk-4.0/pages.c | 185 ++++++++++--------- client/gui-gtk-4.0/plrdlg.c | 15 +- client/gui-gtk-4.0/rallypointdlg.c | 5 +- client/gui-gtk-4.0/repodlgs.c | 12 +- client/gui-gtk-4.0/spaceshipdlg.c | 15 +- client/gui-gtk-4.0/unitselect.c | 49 ++--- client/gui-gtk-4.0/unitselextradlg.c | 9 +- client/gui-gtk-4.0/unitselunitdlg.c | 9 +- client/gui-gtk-4.0/voteinfo_bar.c | 61 ++++--- client/gui-gtk-4.0/wldlg.c | 46 ++--- 37 files changed, 899 insertions(+), 753 deletions(-) diff --git a/client/gui-gtk-4.0/action_dialog.c b/client/gui-gtk-4.0/action_dialog.c index 33397bf90c..188590d3ea 100644 --- a/client/gui-gtk-4.0/action_dialog.c +++ b/client/gui-gtk-4.0/action_dialog.c @@ -574,7 +574,7 @@ static void create_advances_list(struct player *pplayer, struct player *pvictim, struct action_data *args) { - GtkWidget *sw, *label, *vbox, *view; + GtkWidget *sw, *frame, *label, *vgrid, *view; GtkListStore *store; GtkCellRenderer *rend; GtkTreeViewColumn *col; @@ -591,14 +591,14 @@ static void create_advances_list(struct player *pplayer, gtk_dialog_set_default_response(GTK_DIALOG(spy_tech_shell), GTK_RESPONSE_ACCEPT); - label = gtk_frame_new(_("Select Advance to Steal")); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))), label); + frame = gtk_frame_new(_("Select Advance to Steal")); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))), frame); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 6); - gtk_container_add(GTK_CONTAINER(label), vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 6); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); @@ -620,17 +620,17 @@ static void create_advances_list(struct player *pplayer, "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, 0, 1, 1); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_container_add(GTK_CONTAINER(sw), view); + 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_widget_set_size_request(sw, -1, 200); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, 1, 1, 1); /* Now populate the list */ if (pvictim) { /* you don't want to know what lag can do -- Syela */ @@ -759,7 +759,7 @@ static void create_improvements_list(struct player *pplayer, struct city *pcity, struct action_data *args) { - GtkWidget *sw, *label, *vbox, *view; + GtkWidget *sw, *frame, *label, *vgrid, *view; GtkListStore *store; GtkCellRenderer *rend; GtkTreeViewColumn *col; @@ -777,14 +777,14 @@ static void create_improvements_list(struct player *pplayer, gtk_dialog_set_default_response(GTK_DIALOG(spy_sabotage_shell), GTK_RESPONSE_ACCEPT); - label = gtk_frame_new(_("Select Improvement to Sabotage")); - gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell))), label); + frame = gtk_frame_new(_("Select Improvement to Sabotage")); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell))), frame); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 6); - gtk_container_add(GTK_CONTAINER(label), vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 6); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); @@ -806,17 +806,17 @@ static void create_improvements_list(struct player *pplayer, "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, 0, 1, 1); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_container_add(GTK_CONTAINER(sw), view); + 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_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, 1, 1, 1); /* Now populate the list */ if (action_prob_possible(actor_unit->client.act_prob_cache[ diff --git a/client/gui-gtk-4.0/choice_dialog.c b/client/gui-gtk-4.0/choice_dialog.c index be9365fb97..0bbab4b0b6 100644 --- a/client/gui-gtk-4.0/choice_dialog.c +++ b/client/gui-gtk-4.0/choice_dialog.c @@ -103,7 +103,8 @@ 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, *vbox, *bbox; + GtkWidget *dshell, *dlabel, *vgrid, *bbox; + int grid_row = 0; dshell = gtk_window_new(); setup_dialog(dshell, toplevel); @@ -113,28 +114,28 @@ 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); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 5); - gtk_container_add(GTK_CONTAINER(dshell),vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 5); + gtk_window_set_child(GTK_WINDOW(dshell), vgrid); - 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); + 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); dlabel = gtk_label_new(text); - gtk_container_add(GTK_CONTAINER(vbox), dlabel); + gtk_grid_attach(GTK_GRID(vgrid), dlabel, 0, grid_row++, 1, 1); bbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); - gtk_container_add(GTK_CONTAINER(vbox), bbox); + gtk_grid_attach(GTK_GRID(vgrid), bbox, 0, grid_row++, 1, 1); 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(vbox); + gtk_widget_show(vgrid); gtk_widget_show(dlabel); return dshell; @@ -171,7 +172,7 @@ void choice_dialog_add(GtkWidget *dshell, const gchar *label, fc_snprintf(name, sizeof(name), "button%d", nbuttons); button = gtk_button_new_with_mnemonic(label); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_object_set_data(G_OBJECT(dshell), name, button); if (handler) { diff --git a/client/gui-gtk-4.0/citizensinfo.c b/client/gui-gtk-4.0/citizensinfo.c index f33d7da5c9..252c5ae7cf 100644 --- a/client/gui-gtk-4.0/citizensinfo.c +++ b/client/gui-gtk-4.0/citizensinfo.c @@ -246,10 +246,10 @@ static struct citizens_dialog *citizens_dialog_create(const struct city *pcity) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), FALSE); - gtk_container_add(GTK_CONTAINER(sw), pdialog->list); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), pdialog->list); frame = gtk_frame_new(_("Citizens")); - gtk_container_add(GTK_CONTAINER(frame), sw); + gtk_frame_set_child(GTK_FRAME(frame), sw); pdialog->shell = frame; diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index a00c68b5ce..a9bb297adc 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -430,7 +430,7 @@ static void city_dialog_map_create(struct city_dialog *pdialog, G_CALLBACK(button_down_citymap), pdialog); g_signal_connect(darea, "draw", G_CALLBACK(canvas_exposed_cb), pdialog); - gtk_container_add(GTK_CONTAINER(sw), darea); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), darea); /* save all widgets for the city map */ cmap_canvas->sw = sw; @@ -687,7 +687,7 @@ static gboolean show_info_popup(GtkWidget *w, GdkEvent *ev, gtk_window_set_transient_for(GTK_WINDOW(p), GTK_WINDOW(pdialog->shell)); frame = gtk_frame_new(NULL); - gtk_container_add(GTK_CONTAINER(p), frame); + gtk_window_set_child(GTK_WINDOW(p), frame); label = gtk_label_new(buf); gtk_widget_set_name(label, "city_label"); @@ -695,7 +695,7 @@ static gboolean show_info_popup(GtkWidget *w, GdkEvent *ev, gtk_widget_set_margin_end(label, 4); gtk_widget_set_margin_top(label, 4); gtk_widget_set_margin_bottom(label, 4); - gtk_container_add(GTK_CONTAINER(frame), label); + gtk_frame_set_child(GTK_FRAME(frame), label); gtk_widget_show(p); } @@ -834,26 +834,27 @@ static GtkWidget *create_city_info_table(struct city_dialog *pdialog, /***********************************************************************//** Create main citydlg map + + Map frame will be placed to top left (col, row) position of the grid. ***************************************************************************/ static void create_citydlg_main_map(struct city_dialog *pdialog, - GtkWidget *container) + GtkWidget *grid, int col, int row) { GtkWidget *frame; frame = gtk_frame_new(_("City map")); gtk_widget_set_size_request(frame, CITY_MAP_MIN_SIZE_X, CITY_MAP_MIN_SIZE_Y); - gtk_container_add(GTK_CONTAINER(container), frame); + gtk_grid_attach(GTK_GRID(grid), frame, col, row, 1, 1); city_dialog_map_create(pdialog, &pdialog->overview.map_canvas); - gtk_container_add(GTK_CONTAINER(frame), pdialog->overview.map_canvas.sw); + gtk_frame_set_child(GTK_FRAME(frame), pdialog->overview.map_canvas.sw); } /***********************************************************************//** Create improvements list ***************************************************************************/ -static GtkWidget *create_citydlg_improvement_list(struct city_dialog *pdialog, - GtkWidget *vbox) +static GtkWidget *create_citydlg_improvement_list(struct city_dialog *pdialog) { GtkWidget *view; GtkListStore *store; @@ -914,13 +915,16 @@ static GtkWidget *create_citydlg_improvement_list(struct city_dialog *pdialog, static void create_and_append_overview_page(struct city_dialog *pdialog) { GtkWidget *page, *bottom; - GtkWidget *hbox, *right, *vbox, *frame, *table; + GtkWidget *right, *frame, *table; GtkWidget *label, *sw, *view, *bar, *production_combo; GtkCellRenderer *rend; GtkListStore *production_store; /* TRANS: Overview tab in city dialog */ 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 */ page = gtk_grid_new(); @@ -935,30 +939,35 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) if (!low_citydlg) { GtkWidget *middle; + GtkWidget *vgrid; + GtkWidget *hgrid; + int middle_col = 0; + int grid_row = 0; + int grid_col = 0; /* middle: city map, improvements */ middle = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(middle), 6); - gtk_container_add(GTK_CONTAINER(page), middle); + gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1); /* city map */ - create_citydlg_main_map(pdialog, middle); + create_citydlg_main_map(pdialog, middle, middle_col++, 0); /* improvements */ - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(middle), vbox); + gtk_grid_attach(GTK_GRID(middle), vgrid, middle_col++, 0, 1, 1); - view = create_citydlg_improvement_list(pdialog, middle); + view = create_citydlg_improvement_list(pdialog); label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 10); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + 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); production_store = gtk_list_store_new(4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN); @@ -968,7 +977,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_container_add(GTK_CONTAINER(hbox), production_combo); + gtk_grid_attach(GTK_GRID(hgrid), production_combo, grid_col++, 0, 1, 1); g_object_unref(production_store); g_signal_connect(production_combo, "changed", G_CALLBACK(change_production_callback), pdialog); @@ -988,13 +997,14 @@ 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_container_add(GTK_CONTAINER(production_combo), bar); + gtk_combo_box_set_child(GTK_COMBO_BOX(production_combo), bar); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns")); pdialog->overview.buy_command = icon_label_button_new("system-run", _("_Buy")); - gtk_container_add(GTK_CONTAINER(hbox), GTK_WIDGET(pdialog->overview.buy_command)); + gtk_grid_attach(GTK_GRID(hgrid), GTK_WIDGET(pdialog->overview.buy_command), + grid_col++, 0, 1, 1); g_signal_connect(pdialog->overview.buy_command, "clicked", G_CALLBACK(buy_callback), pdialog); @@ -1002,15 +1012,15 @@ 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_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); 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_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); } else { pdialog->overview.buy_command = NULL; pdialog->overview.production_bar = NULL; @@ -1021,30 +1031,30 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) /* bottom: info, units */ bottom = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(bottom), 6); - gtk_container_add(GTK_CONTAINER(page), bottom); + gtk_grid_attach(GTK_GRID(page), bottom, 0, page_row++, 1, 1); /* info */ frame = gtk_frame_new(_("Info")); - gtk_container_add(GTK_CONTAINER(bottom), frame); + gtk_grid_attach(GTK_GRID(bottom), frame, bottom_col++, 0, 1, 1); table = create_city_info_table(pdialog, pdialog->overview.info_label); gtk_widget_set_halign(table, GTK_ALIGN_CENTER); gtk_widget_set_valign(table, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(frame), table); + 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_container_add(GTK_CONTAINER(bottom), right); + gtk_grid_attach(GTK_GRID(bottom), right, bottom_col++, 0, 1, 1); pdialog->overview.supported_units_frame = gtk_frame_new(""); - gtk_container_add(GTK_CONTAINER(right), - pdialog->overview.supported_units_frame); + gtk_grid_attach(GTK_GRID(right), pdialog->overview.supported_units_frame, + 0, right_row++, 1, 1); pdialog->overview.present_units_frame = gtk_frame_new(""); - gtk_container_add(GTK_CONTAINER(right), - pdialog->overview.present_units_frame); + gtk_grid_attach(GTK_GRID(right), pdialog->overview.present_units_frame, + 0, right_row++, 1, 1); /* supported units */ sw = gtk_scrolled_window_new(); @@ -1052,13 +1062,13 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), FALSE); - gtk_container_add(GTK_CONTAINER(pdialog->overview.supported_units_frame), - sw); + gtk_frame_set_child(GTK_FRAME(pdialog->overview.supported_units_frame), + sw); table = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_set_size_request(table, -1, unit_height); - gtk_container_add(GTK_CONTAINER(sw), table); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), table); pdialog->overview.supported_unit_table = table; unit_node_vector_init(&pdialog->overview.supported_units); @@ -1069,11 +1079,11 @@ static void create_and_append_overview_page(struct city_dialog *pdialog) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), FALSE); - gtk_container_add(GTK_CONTAINER(pdialog->overview.present_units_frame), sw); + gtk_frame_set_child(GTK_FRAME(pdialog->overview.present_units_frame), sw); table = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_set_size_request(table, -1, unit_height); - gtk_container_add(GTK_CONTAINER(sw), table); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), table); pdialog->overview.present_unit_table = table; unit_node_vector_init(&pdialog->overview.present_units); @@ -1091,6 +1101,7 @@ static void create_and_append_map_page(struct city_dialog *pdialog) GtkWidget *page; GtkWidget *label; const char *tab_title = _("Citymap"); + int page_row = 0; page = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(page), @@ -1102,7 +1113,7 @@ static void create_and_append_map_page(struct city_dialog *pdialog) label = gtk_label_new_with_mnemonic(tab_title); gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); - create_citydlg_main_map(pdialog, page); + create_citydlg_main_map(pdialog, page, 0, page_row++); gtk_widget_show(page); } @@ -1151,22 +1162,23 @@ static void target_drag_data_received(GtkWidget *w, Create production page header - what tab this actually is, depends on screen size and layout. ***************************************************************************/ -static void create_production_header(struct city_dialog *pdialog, - GtkContainer *contain) +static int create_production_header(struct city_dialog *pdialog, + GtkWidget *grid, int row) { - GtkWidget *hbox, *bar; + GtkWidget *hgrid, *bar; + int grid_col = 0; - hbox = gtk_grid_new(); - g_object_set(hbox, "margin", 2, NULL); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 10); - gtk_container_add(contain, hbox); + hgrid = gtk_grid_new(); + g_object_set(hgrid, "margin", 2, NULL); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10); + gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1); /* The label is set in city_dialog_update_building() */ bar = gtk_progress_bar_new(); gtk_widget_set_hexpand(bar, TRUE); gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(bar), TRUE); pdialog->production.production_bar = bar; - gtk_container_add(GTK_CONTAINER(hbox), bar); + gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns")); add_worklist_dnd_target(bar); @@ -1178,10 +1190,13 @@ static void create_production_header(struct city_dialog *pdialog, pdialog->production.buy_command = icon_label_button_new("system-run", _("_Buy")); - gtk_container_add(GTK_CONTAINER(hbox), GTK_WIDGET(pdialog->production.buy_command)); + gtk_grid_attach(GTK_GRID(hgrid), GTK_WIDGET(pdialog->production.buy_command), + grid_col++, 0, 1, 1); g_signal_connect(pdialog->production.buy_command, "clicked", G_CALLBACK(buy_callback), pdialog); + + return row; } /***********************************************************************//** @@ -1192,9 +1207,11 @@ static void create_and_append_buildings_page(struct city_dialog *pdialog) if (low_citydlg) { GtkWidget *page; GtkWidget *label; - GtkWidget *vbox; + GtkWidget *vgrid; 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), @@ -1205,17 +1222,17 @@ static void create_and_append_buildings_page(struct city_dialog *pdialog) gtk_widget_set_margin_bottom(page, 8); label = gtk_label_new_with_mnemonic(tab_title); - create_production_header(pdialog, GTK_CONTAINER(page)); + page_row = create_production_header(pdialog, page, page_row); gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(page), vbox); + gtk_grid_attach(GTK_GRID(page), vgrid, 0, page_row++, 1, 1); - view = create_citydlg_improvement_list(pdialog, vbox); + view = create_citydlg_improvement_list(pdialog); - gtk_container_add(GTK_CONTAINER(vbox), view); + gtk_grid_attach(GTK_GRID(vgrid), view, 0, grid_row++, 1, 1); gtk_widget_show(page); } @@ -1229,6 +1246,7 @@ static void create_and_append_worklist_page(struct city_dialog *pdialog) const char *tab_title = _("P_roduction"); GtkWidget *label = gtk_label_new_with_mnemonic(tab_title); GtkWidget *page, *editor; + int page_row = 0; page = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(page), @@ -1245,9 +1263,9 @@ static void create_and_append_worklist_page(struct city_dialog *pdialog) "label", _("Production:"), "xalign", 0.0, "yalign", 0.5, NULL); pdialog->production.production_label = label; - gtk_container_add(GTK_CONTAINER(page), label); + gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1); - create_production_header(pdialog, GTK_CONTAINER(page)); + page_row = create_production_header(pdialog, page, page_row); } else { pdialog->production.production_label = NULL; } @@ -1255,7 +1273,7 @@ static void create_and_append_worklist_page(struct city_dialog *pdialog) editor = create_worklist(); g_object_set(editor, "margin", 6, NULL); reset_city_worklist(editor, pdialog->pcity); - gtk_container_add(GTK_CONTAINER(page), editor); + gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1); pdialog->production.worklist = editor; gtk_widget_show(page); @@ -1275,6 +1293,9 @@ static void create_and_append_happiness_page(struct city_dialog *pdialog) { GtkWidget *page, *label, *table, *right, *left, *frame; const char *tab_title = _("Happ_iness"); + int page_col = 0; + int left_row = 0; + int right_row = 0; /* main page */ page = gtk_grid_new(); @@ -1290,54 +1311,50 @@ static void create_and_append_happiness_page(struct city_dialog *pdialog) left = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(left), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(page), left); + gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1); if (!low_citydlg) { /* upper left: info */ frame = gtk_frame_new(_("Info")); - gtk_container_add(GTK_CONTAINER(left), frame); + gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1); table = create_city_info_table(pdialog, pdialog->happiness.info_label); gtk_widget_set_halign(table, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(frame), table); + gtk_frame_set_child(GTK_FRAME(frame), table); } /* lower left: citizens */ if (game.info.citizen_nationality) { - pdialog->happiness.citizens = gtk_grid_new(); - gtk_orientable_set_orientation( - GTK_ORIENTABLE(pdialog->happiness.citizens), - GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(left), pdialog->happiness.citizens); - gtk_container_add(GTK_CONTAINER(pdialog->happiness.citizens), - citizens_dialog_display(pdialog->pcity)); + pdialog->happiness.citizens = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_grid_attach(GTK_GRID(left), pdialog->happiness.citizens, + 0, left_row++, 1, 1); + gtk_box_append(GTK_BOX(pdialog->happiness.citizens), + citizens_dialog_display(pdialog->pcity)); } /* right: city map, happiness */ right = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(right), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(page), right); + gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1); if (!low_citydlg) { /* 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_container_add(GTK_CONTAINER(right), frame); + gtk_grid_attach(GTK_GRID(right), frame, 0, right_row++, 1, 1); city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas); - gtk_container_add(GTK_CONTAINER(frame), pdialog->happiness.map_canvas.sw); + gtk_frame_set_child(GTK_FRAME(frame), pdialog->happiness.map_canvas.sw); } /* lower right: happiness */ - pdialog->happiness.widget = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(pdialog->happiness.widget), - GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(right), pdialog->happiness.widget); - gtk_container_add(GTK_CONTAINER(pdialog->happiness.widget), - get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell)); + 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(pdialog->happiness.widget), + get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell)); /* show page */ gtk_widget_show(page); @@ -1350,6 +1367,7 @@ static void create_and_append_cma_page(struct city_dialog *pdialog) { GtkWidget *page, *label; const char *tab_title = _("_Governor"); + int page_col = 0; page = gtk_grid_new(); @@ -1358,7 +1376,8 @@ static void create_and_append_cma_page(struct city_dialog *pdialog) gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg); - gtk_container_add(GTK_CONTAINER(page), pdialog->cma_editor->shell); + gtk_grid_attach(GTK_GRID(page), pdialog->cma_editor->shell, + page_col++, 0, 1, 1); gtk_widget_show(page); } @@ -1369,10 +1388,11 @@ static void create_and_append_cma_page(struct city_dialog *pdialog) static void create_and_append_settings_page(struct city_dialog *pdialog) { int i; - GtkWidget *vbox2, *page, *frame, *label, *button; + GtkWidget *vgrid, *page, *frame, *label, *button; GtkSizeGroup *size; GSList *group; const char *tab_title = _("_Settings"); + int grid_row = 0; static const char *new_citizens_output_label[] = { N_("Luxury"), @@ -1417,10 +1437,10 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1); gtk_size_group_add_widget(size, frame); - vbox2 = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(frame), vbox2); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); intl_slist(ARRAY_SIZE(new_citizens_output_label), new_citizens_output_label, &new_citizens_label_done); @@ -1429,7 +1449,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) { button = gtk_radio_button_new_with_mnemonic(group, new_citizens_output_label[i]); pdialog->misc.new_citizens_radio[i] = button; - gtk_container_add(GTK_CONTAINER(vbox2), button); + gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); g_signal_connect(button, "toggled", G_CALLBACK(cityopt_callback), pdialog); group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); @@ -1440,10 +1460,11 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1); gtk_size_group_add_widget(size, frame); - vbox2 = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid = gtk_grid_new(); + grid_row = 0; + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(frame), vbox2); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); intl_slist(ARRAY_SIZE(misc_whichtab_label), misc_whichtab_label, &misc_whichtab_label_done); @@ -1452,7 +1473,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) { button = gtk_radio_button_new_with_mnemonic(group, misc_whichtab_label[i]); pdialog->misc.whichtab_radio[i] = button; - gtk_container_add(GTK_CONTAINER(vbox2), button); + gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); g_signal_connect(button, "toggled", G_CALLBACK(misc_whichtab_callback), GINT_TO_POINTER(i)); group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); @@ -1464,14 +1485,15 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) gtk_widget_set_margin_bottom(frame, 12); gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1); - vbox2 = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid = gtk_grid_new(); + grid_row = 0; + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(frame), vbox2); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); button = gtk_button_new_with_mnemonic(_("R_ename...")); pdialog->misc.rename_command = button; - gtk_container_add(GTK_CONTAINER(vbox2), button); + gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); g_signal_connect(button, "clicked", G_CALLBACK(rename_callback), pdialog); @@ -1480,7 +1502,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) /* the disband-city-on-unit-production button */ button = gtk_check_button_new_with_mnemonic(_(disband_label)); pdialog->misc.disband_on_settler = button; - gtk_container_add(GTK_CONTAINER(vbox2), button); + gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); g_signal_connect(button, "toggled", G_CALLBACK(cityopt_callback), pdialog); @@ -1516,9 +1538,11 @@ static struct city_dialog *create_city_dialog(struct city *pcity) struct city_dialog *pdialog; GtkWidget *close_command; - GtkWidget *vbox, *hbox, *cbox; + GtkWidget *vbox, *hgrid, *cbox; int citizen_bar_width; int citizen_bar_height; + int grid_col = 0; + int ccol = 0; if (!city_dialogs_have_been_initialised) { initialize_city_dialogs(); @@ -1561,13 +1585,13 @@ static struct city_dialog *create_city_dialog(struct city *pcity) pdialog->popup_menu = gtk_menu_button_new(); vbox = gtk_dialog_get_content_area(GTK_DIALOG(pdialog->shell)); - hbox = gtk_grid_new(); - gtk_grid_set_column_homogeneous(GTK_GRID(hbox), TRUE); - gtk_box_append(GTK_BOX(vbox), hbox); + hgrid = gtk_grid_new(); + gtk_grid_set_column_homogeneous(GTK_GRID(hgrid), TRUE); + gtk_box_append(GTK_BOX(vbox), hgrid); /**** Citizens bar here ****/ cbox = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(hbox), cbox); + gtk_grid_attach(GTK_GRID(hgrid), cbox, grid_col++, 0, 1, 1); citizen_bar_width = tileset_small_sprite_width(tileset) * NUM_CITIZENS_SHOWN; citizen_bar_height = tileset_small_sprite_height(tileset); @@ -1582,7 +1606,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) gtk_widget_set_margin_bottom(pdialog->citizen_images, 2); gtk_widget_set_halign(pdialog->citizen_images, GTK_ALIGN_START); gtk_widget_set_valign(pdialog->citizen_images, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(cbox), pdialog->citizen_images); + gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_images, ccol++, 0, 1, 1); g_signal_connect(G_OBJECT(pdialog->citizen_images), "button-press-event", G_CALLBACK(citizens_callback), pdialog); @@ -1591,7 +1615,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) gtk_widget_set_hexpand(pdialog->name_label, TRUE); gtk_widget_set_halign(pdialog->name_label, GTK_ALIGN_START); gtk_widget_set_valign(pdialog->name_label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), pdialog->name_label); + gtk_grid_attach(GTK_GRID(hgrid), pdialog->name_label, grid_col++, 0, 1, 1); /**** -Start of Notebook- ****/ @@ -2139,7 +2163,7 @@ static void city_dialog_update_supported_units(struct city_dialog *pdialog) node.pix = pix; node.height = tileset_unit_with_upkeep_height(tileset); - gtk_container_add(GTK_CONTAINER(cmd), pix); + gtk_button_set_child(GTK_BUTTON(cmd), pix); gtk_box_append(GTK_BOX(pdialog->overview.supported_unit_table), cmd); @@ -2243,7 +2267,7 @@ static void city_dialog_update_present_units(struct city_dialog *pdialog) node.pix = pix; node.height = tileset_full_tile_height(tileset); - gtk_container_add(GTK_CONTAINER(cmd), pix); + gtk_button_set_child(GTK_BUTTON(cmd), pix); gtk_box_append(GTK_BOX(pdialog->overview.present_unit_table), cmd); @@ -3468,11 +3492,11 @@ static void switch_city_callback(GtkWidget *w, gpointer data) /* reinitialize happiness, and cma dialogs */ if (game.info.citizen_nationality) { - gtk_container_add(GTK_CONTAINER(pdialog->happiness.citizens), - citizens_dialog_display(pdialog->pcity)); + gtk_box_append(GTK_BOX(pdialog->happiness.citizens), + citizens_dialog_display(pdialog->pcity)); } - gtk_container_add(GTK_CONTAINER(pdialog->happiness.widget), - get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell)); + gtk_box_append(GTK_BOX(pdialog->happiness.widget), + get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell)); if (!client_is_observer()) { fc_assert(pdialog->cma_editor != NULL); pdialog->cma_editor->pcity = new_pcity; diff --git a/client/gui-gtk-4.0/cityrep.c b/client/gui-gtk-4.0/cityrep.c index 629f7d03ac..b8f665bbbc 100644 --- a/client/gui-gtk-4.0/cityrep.c +++ b/client/gui-gtk-4.0/cityrep.c @@ -405,15 +405,16 @@ static void append_impr_or_unit_to_menu_item(GtkMenuItem *parent_item, for (item = 0; item < targets_used; item++) { struct universal target = items[item].item; - GtkWidget *menu_item, *hbox, *label; + GtkWidget *menu_item, *hgrid, *label; char txt[256]; + int grid_col = 0; get_city_dialog_production_row(row, sizeof(buf[0]), &target, NULL); menu_item = gtk_menu_item_new(); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 18); - gtk_container_add(GTK_CONTAINER(menu_item), hbox); + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 18); + gtk_container_add(GTK_CONTAINER(menu_item), hgrid); for (i = 0; i < 3; i++) { if (row[i][0] == '\0') { @@ -443,7 +444,7 @@ static void append_impr_or_unit_to_menu_item(GtkMenuItem *parent_item, break; } - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); gtk_size_group_add_widget(group[i], label); } @@ -1050,17 +1051,18 @@ static void update_view_menu(GtkWidget *show_item) ****************************************************************************/ static GtkWidget *create_city_report_menubar(void) { - GtkWidget *vbox, *sep; + GtkWidget *vgrid, *sep; GtkWidget *menubar; + int grid_row = 0; - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(vbox), sep); + gtk_grid_attach(GTK_GRID(vgrid), sep, 0, grid_row++, 1, 1); menubar = gtk_aux_menu_bar_new(); - gtk_container_add(GTK_CONTAINER(vbox), menubar); + gtk_grid_attach(GTK_GRID(vgrid), menubar, 0, grid_row++, 1, 1); #ifdef MENUS_GTK3 GtkWidget *menu, *item; @@ -1131,7 +1133,7 @@ static GtkWidget *create_city_report_menubar(void) update_view_menu(item); #endif /* MENUS_GTK3 */ - return vbox; + return vgrid; } /************************************************************************//** @@ -1241,7 +1243,7 @@ static void create_city_report_dialog(bool make_modal) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(sw), city_view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), city_view); gui_dialog_add_content_widget(city_dialog_shell, sw); diff --git a/client/gui-gtk-4.0/cma_fe.c b/client/gui-gtk-4.0/cma_fe.c index b0226a25b4..c6904774e2 100644 --- a/client/gui-gtk-4.0/cma_fe.c +++ b/client/gui-gtk-4.0/cma_fe.c @@ -219,13 +219,16 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) struct cma_dialog *pdialog; struct cm_parameter param; GtkWidget *frame, *page, *hbox, *label, *table; - GtkWidget *vbox, *sw, *hscale, *button; + GtkWidget *vgrid, *sw, *hscale, *button; GtkListStore *store; GtkCellRenderer *rend; GtkWidget *view; GtkTreeViewColumn *column; gint layout_width; GtkEventController *controller; + int shell_row = 0; + int grid_row = 0; + int page_row = 0; cmafec_get_fe_parameter(pcity, ¶m); pdialog = fc_malloc(sizeof(struct cma_dialog)); @@ -243,13 +246,13 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) page = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(page), 12); - gtk_container_add(GTK_CONTAINER(pdialog->shell), page); + gtk_grid_attach(GTK_GRID(pdialog->shell), page, 0, shell_row++, 1, 1); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(pdialog->shell), 2); - gtk_container_add(GTK_CONTAINER(page), vbox); + gtk_grid_attach(GTK_GRID(page), vgrid, 0, page_row++, 1, 1); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); @@ -291,10 +294,10 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) "mnemonic-widget", view, "label", _("Prese_ts:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); - gtk_container_add(GTK_CONTAINER(sw), view); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); g_signal_connect(view, "row_activated", G_CALLBACK(cma_activate_preset_callback), pdialog); @@ -302,39 +305,40 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) G_CALLBACK(cma_preset_key_pressed_callback), pdialog); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_grid_attach(GTK_GRID(vgrid), hbox, 0, grid_row++, 1, 1); button = icon_label_button_new("document-new", _("Ne_w")); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_box_append(GTK_BOX(hbox), button); g_signal_connect(button, "clicked", G_CALLBACK(cma_add_preset_callback), pdialog); pdialog->add_preset_command = button; pdialog->del_preset_command = icon_label_button_new("edit-delete", _("_Delete")); - gtk_container_add(GTK_CONTAINER(hbox), pdialog->del_preset_command); + gtk_box_append(GTK_BOX(hbox), pdialog->del_preset_command); g_signal_connect(pdialog->del_preset_command, "clicked", G_CALLBACK(cma_del_preset_callback), pdialog); /* the right-hand side */ - vbox = gtk_grid_new(); - g_object_set(vbox, "margin", 2, NULL); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + grid_row = 0; + g_object_set(vgrid, "margin", 2, NULL); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(page), vbox); + gtk_grid_attach(GTK_GRID(page), vgrid, 0, page_row++, 1, 1); /* Result */ if (!tiny) { frame = gtk_frame_new(_("Results")); gtk_widget_set_vexpand(frame, TRUE); gtk_widget_set_valign(frame, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(vbox), frame); + gtk_grid_attach(GTK_GRID(vgrid), frame, 0, grid_row++, 1, 1); pdialog->result_label = gtk_label_new("food\n prod\n trade\n\n people\n grow\n prod\n name"); gtk_widget_set_name(pdialog->result_label, "city_label"); - gtk_container_add(GTK_CONTAINER(frame), pdialog->result_label); + gtk_frame_set_child(GTK_FRAME(frame), pdialog->result_label); gtk_label_set_justify(GTK_LABEL(pdialog->result_label), GTK_JUSTIFY_LEFT); } else { pdialog->result_label = NULL; @@ -344,7 +348,7 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) table = gtk_grid_new(); g_object_set(table, "margin", 2, NULL); - gtk_container_add(GTK_CONTAINER(vbox), table); + gtk_grid_attach(GTK_GRID(vgrid), table, 0, grid_row++, 1, 1); label = gtk_label_new(_("Minimal Surplus")); gtk_widget_set_halign(label, GTK_ALIGN_START); @@ -430,17 +434,17 @@ struct cma_dialog *create_cma_dialog(struct city *pcity, bool tiny) /* buttons */ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_grid_attach(GTK_GRID(vgrid), hbox, 0, grid_row++, 1, 1); button = icon_label_button_new("help-browser", _("Help")); g_signal_connect(button, "clicked", G_CALLBACK(help_callback), NULL); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_box_append(GTK_BOX(hbox), button); pdialog->active_command = gtk_toggle_button_new(); gtk_button_set_use_underline(GTK_BUTTON(pdialog->active_command), TRUE); gtk_widget_set_name(pdialog->active_command, "comment_label"); - gtk_container_add(GTK_CONTAINER(hbox), pdialog->active_command); + gtk_box_append(GTK_BOX(hbox), pdialog->active_command); gtk_widget_show(pdialog->shell); diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index db8a2c619e..78e5ee8149 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -103,7 +103,8 @@ void popup_notify_dialog(const char *caption, const char *headline, const char *lines) { static struct gui_dialog *shell; - GtkWidget *vbox, *label, *headline_label, *sw; + GtkWidget *vgrid, *label, *headline_label, *sw; + int grid_row = 0; gui_dialog_new(&shell, GTK_NOTEBOOK(bottom_notebook), NULL, TRUE); gui_dialog_set_title(shell, caption); @@ -111,14 +112,14 @@ void popup_notify_dialog(const char *caption, const char *headline, gui_dialog_add_button(shell, "window-close", _("_Close"), GTK_RESPONSE_CLOSE); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 2); - gui_dialog_add_content_widget(shell, vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 2); + gui_dialog_add_content_widget(shell, vgrid); headline_label = gtk_label_new(headline); - gtk_container_add(GTK_CONTAINER(vbox), headline_label); + gtk_grid_attach(GTK_GRID(vgrid), headline_label, 0, grid_row++, 1, 1); gtk_widget_set_name(headline_label, "notify_label"); gtk_label_set_justify(GTK_LABEL(headline_label), GTK_JUSTIFY_LEFT); @@ -132,14 +133,14 @@ void popup_notify_dialog(const char *caption, const char *headline, label = gtk_label_new(lines); gtk_widget_set_hexpand(label, TRUE); gtk_widget_set_vexpand(label, TRUE); - gtk_container_add(GTK_CONTAINER(sw), label); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), label); gtk_widget_set_name(label, "notify_label"); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_START); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); gui_dialog_show_all(shell); @@ -655,7 +656,7 @@ static GtkWidget* create_list_of_nations_in_group(struct nation_group* group, 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_ALWAYS); - gtk_container_add(GTK_CONTAINER(sw), list); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), list); render = gtk_cell_renderer_pixbuf_new(); column = gtk_tree_view_column_new_with_attributes("Flag", render, @@ -840,7 +841,7 @@ static void create_races_dialog(struct player *pplayer) { GtkWidget *shell; GtkWidget *cmd; - GtkWidget *hbox, *table; + GtkWidget *hgrid, *table; GtkWidget *frame, *label, *combo; GtkWidget *text; GtkWidget *notebook; @@ -851,6 +852,7 @@ static void create_races_dialog(struct player *pplayer) GtkTreeViewColumn *column; int i; char *title; + int grid_col = 0; /* Init. */ selected_nation = -1; @@ -882,14 +884,14 @@ 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); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 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); + 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); - gtk_container_add(GTK_CONTAINER(frame), hbox); + gtk_frame_set_child(GTK_FRAME(frame), hgrid); /* Left side: nation list */ { @@ -1044,13 +1046,13 @@ static void create_races_dialog(struct player *pplayer) /* Populate treeview */ create_nation_selection_lists(); - gtk_container_add(GTK_CONTAINER(hbox), nation_selection_list); + gtk_grid_attach(GTK_GRID(hgrid), nation_selection_list, grid_col++, 0, 1, 1); } /* Right side. */ notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM); - gtk_container_add(GTK_CONTAINER(hbox), notebook); + gtk_grid_attach(GTK_GRID(hgrid), notebook, grid_col++, 0, 1, 1); /* Properties pane. */ label = gtk_label_new_with_mnemonic(_("_Properties")); @@ -1112,7 +1114,7 @@ static void create_races_dialog(struct player *pplayer) 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_container_add(GTK_CONTAINER(sw), list); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), list); gtk_grid_attach(GTK_GRID(table), sw, 1, 2, 2, 2); label = g_object_new(GTK_TYPE_LABEL, diff --git a/client/gui-gtk-4.0/diplodlg.c b/client/gui-gtk-4.0/diplodlg.c index a0f5216da7..e236a13c39 100644 --- a/client/gui-gtk-4.0/diplodlg.c +++ b/client/gui-gtk-4.0/diplodlg.c @@ -499,7 +499,8 @@ static struct Diplomacy_notebook *diplomacy_main_create(void) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dipl_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(dipl_sw), dipl_main->notebook); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(dipl_sw), + dipl_main->notebook); /* Buttons */ gui_dialog_add_button(dipl_main->dialog, NULL, @@ -626,7 +627,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, struct player *plr1) { struct Diplomacy_notebook *dipl_dialog; - GtkWidget *vbox, *hbox, *table, *mainbox; + GtkWidget *vgrid, *hgrid, *table, *mainbox; GtkWidget *label, *sw, *view, *image, *spin; GtkWidget *menu; #ifdef MENUS_GTK3 @@ -640,6 +641,9 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, struct Diplomacy_dialog *pdialog; char plr_buf[4 * MAX_LEN_NAME]; gchar *buf; + int grid_row = 0; + int grid_col = 0; + int main_row = 0; pdialog = fc_malloc(sizeof(*pdialog)); @@ -688,15 +692,15 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, g_free(buf); /* us. */ - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 5); - gtk_widget_set_margin_start(vbox, 2); - gtk_widget_set_margin_end(vbox, 2); - gtk_widget_set_margin_top(vbox, 2); - gtk_widget_set_margin_bottom(vbox, 2); - gui_dialog_add_content_widget(pdialog->dialog, vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 5); + gtk_widget_set_margin_start(vgrid, 2); + gtk_widget_set_margin_end(vgrid, 2); + gtk_widget_set_margin_top(vgrid, 2); + gtk_widget_set_margin_bottom(vgrid, 2); + gui_dialog_add_content_widget(pdialog->dialog, vgrid); /* Our nation. */ label = gtk_label_new(NULL); @@ -706,17 +710,17 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, nation_plural_for_player(plr0)); gtk_label_set_markup(GTK_LABEL(label), buf); g_free(buf); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 5); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 5); + gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); /* Our flag */ flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr0)); image = image_new_from_surface(flag_spr->surface); - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); /* Our name. */ label = gtk_label_new(NULL); @@ -727,11 +731,11 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf))); gtk_label_set_markup(GTK_LABEL(label), buf); g_free(buf); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); image = gtk_image_new(); pdialog->image0 = image; - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); /* Menu for clauses: we. */ menubar = gtk_aux_menu_bar_new(); @@ -752,7 +756,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, gtk_widget_set_halign(table, GTK_ALIGN_CENTER); gtk_widget_set_valign(table, GTK_ALIGN_CENTER); gtk_grid_set_column_spacing(GTK_GRID(table), 16); - gtk_container_add(GTK_CONTAINER(vbox), table); + gtk_grid_attach(GTK_GRID(vgrid), table, 0, grid_row++, 1, 1); if (game.info.trading_gold) { spin = gtk_spin_button_new_with_range(0.0, plr0->economic.gold + 0.1, @@ -775,15 +779,16 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, } /* them. */ - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + grid_row = 0; + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 5); - gtk_widget_set_margin_start(vbox, 2); - gtk_widget_set_margin_end(vbox, 2); - gtk_widget_set_margin_top(vbox, 2); - gtk_widget_set_margin_bottom(vbox, 2); - gui_dialog_add_content_widget(pdialog->dialog, vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 5); + gtk_widget_set_margin_start(vgrid, 2); + gtk_widget_set_margin_end(vgrid, 2); + gtk_widget_set_margin_top(vgrid, 2); + gtk_widget_set_margin_bottom(vgrid, 2); + gui_dialog_add_content_widget(pdialog->dialog, vgrid); /* Their nation. */ label = gtk_label_new(NULL); @@ -793,17 +798,18 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, nation_plural_for_player(plr1)); gtk_label_set_markup(GTK_LABEL(label), buf); g_free(buf); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 5); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + hgrid = gtk_grid_new(); + grid_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 5); + gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); /* Their flag */ flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr1)); image = image_new_from_surface(flag_spr->surface); - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); /* Their name. */ label = gtk_label_new(NULL); @@ -814,11 +820,11 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, ruler_title_for_player(plr1, plr_buf, sizeof(plr_buf))); gtk_label_set_markup(GTK_LABEL(label), buf); g_free(buf); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); image = gtk_image_new(); pdialog->image1 = image; - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); /* Menu for clauses: they. */ menubar = gtk_aux_menu_bar_new(); @@ -839,7 +845,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, gtk_widget_set_halign(table, GTK_ALIGN_CENTER); gtk_widget_set_valign(table, GTK_ALIGN_CENTER); gtk_grid_set_column_spacing(GTK_GRID(table), 16); - gtk_container_add(GTK_CONTAINER(vbox), table); + gtk_grid_attach(GTK_GRID(vgrid), table, 0, grid_row++, 1, 1); if (game.info.trading_gold) { spin = gtk_spin_button_new_with_range(0.0, plr1->economic.gold + 0.1, @@ -886,7 +892,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, 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_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -896,12 +902,13 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, "yalign", 0.5, NULL); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + grid_row = 0; + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(mainbox), vbox); - gtk_container_add(GTK_CONTAINER(vbox), label); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(mainbox), vgrid, 0, main_row++, 1, 1); + 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(mainbox); diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index 8ca9ce7f2c..7d0b4f10aa 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -438,7 +438,7 @@ static void editbar_add_tool_button(struct editbar *eb, image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(G_OBJECT(pixbuf)); - gtk_container_add(GTK_CONTAINER(button), image); + gtk_button_set_child(GTK_BUTTON(button), image); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); gtk_widget_set_tooltip_text(button, editor_tool_get_tooltip(ett)); gtk_size_group_add_widget(eb->size_group, button); @@ -451,7 +451,7 @@ static void editbar_add_tool_button(struct editbar *eb, G_CALLBACK(editbar_tool_button_mouse_click), GINT_TO_POINTER(ett)); hbox = eb->widget; - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_box_append(GTK_BOX(hbox), button); eb->tool_buttons[ett] = button; if (editor_tool_has_value(ett)) { @@ -497,7 +497,7 @@ static void editbar_add_mode_button(struct editbar *eb, image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(G_OBJECT(pixbuf)); - gtk_container_add(GTK_CONTAINER(button), image); + gtk_button_set_child(GTK_BUTTON(button), image); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); tooltip = editor_get_mode_tooltip(etm); if (tooltip != NULL) { @@ -511,7 +511,7 @@ static void editbar_add_mode_button(struct editbar *eb, G_CALLBACK(editbar_mode_button_toggled), GINT_TO_POINTER(etm)); hbox = eb->widget; - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_box_append(GTK_BOX(hbox), button); eb->mode_buttons[etm] = button; } @@ -521,16 +521,16 @@ static void editbar_add_mode_button(struct editbar *eb, static struct editbar *editbar_create(void) { struct editbar *eb; - GtkWidget *hbox, *button, *combo, *image, *separator, *vbox; + GtkWidget *hbox, *button, *combo, *image, *separator, *vgrid; GtkListStore *store; GtkCellRenderer *cell; GdkPixbuf *pixbuf; const struct editor_sprites *sprites; + int grid_row = 0; eb = fc_calloc(1, sizeof(struct editbar)); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); eb->widget = hbox; eb->size_group = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); @@ -539,7 +539,7 @@ static struct editbar *editbar_create(void) editbar_add_mode_button(eb, ETM_ERASE); separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(hbox), separator); + gtk_box_append(GTK_BOX(hbox), separator); editbar_add_tool_button(eb, ETT_TERRAIN); editbar_add_tool_button(eb, ETT_TERRAIN_RESOURCE); @@ -553,13 +553,13 @@ static struct editbar *editbar_create(void) editbar_add_tool_button(eb, ETT_COPYPASTE); separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(hbox), separator); + gtk_box_append(GTK_BOX(hbox), separator); /* Player POV indicator. */ - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(hbox), vbox); + gtk_box_append(GTK_BOX(hbox), vgrid); store = gtk_list_store_new(PPV_NUM_COLS, GDK_TYPE_PIXBUF, @@ -587,7 +587,7 @@ static struct editbar *editbar_create(void) _("Switch player point-of-view. Use this to edit " "from the perspective of different players, or " "even as a global observer.")); - gtk_container_add(GTK_CONTAINER(vbox), combo); + gtk_grid_attach(GTK_GRID(vgrid), combo, 0, grid_row++, 1, 1); eb->player_pov_combobox = combo; /* Property editor button. */ @@ -595,14 +595,14 @@ static struct editbar *editbar_create(void) pixbuf = sprite_get_pixbuf(sprites->properties); image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(G_OBJECT(pixbuf)); - gtk_container_add(GTK_CONTAINER(button), image); + gtk_button_set_child(GTK_BUTTON(button), image); gtk_widget_set_tooltip_text(button, _("Show the property editor.")); gtk_size_group_add_widget(eb->size_group, button); gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_focus_on_click(button, FALSE); g_signal_connect(button, "clicked", G_CALLBACK(editbar_player_properties_button_clicked), eb); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_box_append(GTK_BOX(hbox), button); eb->player_properties_button = button; return eb; @@ -1088,7 +1088,7 @@ create_tool_value_selector(struct editbar *eb, gtk_tree_view_column_set_sort_column_id(col, TVS_COL_NAME); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); - gtk_container_add(GTK_CONTAINER(scrollwin), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollwin), view); tvs->view = view; /* Show everything but the window itself. */ @@ -1190,13 +1190,16 @@ static void editinfobox_tool_applied_player_changed(GtkComboBox *combo, ****************************************************************************/ static struct editinfobox *editinfobox_create(void) { - GtkWidget *label, *vbox, *frame, *hbox, *vbox2, *image; + GtkWidget *label, *vgrid, *frame, *hgrid, *vgrid2, *image; 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)); @@ -1209,20 +1212,20 @@ static struct editinfobox *editinfobox_create(void) gtk_widget_set_margin_bottom(frame, 4); ei->widget = frame; - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 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_container_add(GTK_CONTAINER(frame), vbox); + 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 */ - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 8); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + 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); image = gtk_image_new(); gtk_widget_set_tooltip_text(image, _("Click to change value if applicable.")); @@ -1233,31 +1236,32 @@ static struct editinfobox *editinfobox_create(void) NULL); gtk_widget_add_controller(image, controller); - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); ei->tool_image = image; - vbox2 = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid2 = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox2), 4); - gtk_container_add(GTK_CONTAINER(hbox), vbox2); + gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4); + gtk_grid_attach(GTK_GRID(hgrid), vgrid2, 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_container_add(GTK_CONTAINER(vbox2), label); + gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); 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_container_add(GTK_CONTAINER(vbox2), label); + gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); ei->tool_value_label = label; /* mode section */ - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 8); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + 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); image = gtk_image_new(); gtk_widget_set_tooltip_text(image, _("Click to change tool mode.")); @@ -1268,14 +1272,15 @@ static struct editinfobox *editinfobox_create(void) NULL); gtk_widget_add_controller(image, controller); - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); ei->mode_image = image; - vbox2 = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid2 = gtk_grid_new(); + grid2_row = 0; + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox2), 4); - gtk_container_add(GTK_CONTAINER(hbox), vbox2); + gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4); + gtk_grid_attach(GTK_GRID(hgrid), vgrid2, grid_col++, 0, 1, 1); label = gtk_label_new(NULL); fc_snprintf(buf, sizeof(buf), "%s", @@ -1283,19 +1288,20 @@ 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_container_add(GTK_CONTAINER(vbox2), label); + gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(vbox2), label); + gtk_grid_attach(GTK_GRID(vgrid2), label, 0, grid2_row++, 1, 1); ei->mode_label = label; /* spinner section */ - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 8); - gtk_container_add(GTK_CONTAINER(vbox), hbox); - ei->size_hbox = hbox; + 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); + ei->size_hbox = hgrid; spin = gtk_spin_button_new_with_range(1, 255, 1); gtk_widget_set_tooltip_text(spin, _("Use this to change the \"size\" parameter for the tool. " @@ -1305,15 +1311,16 @@ static struct editinfobox *editinfobox_create(void) g_signal_connect(spin, "value-changed", G_CALLBACK(editinfobox_spin_button_value_changed), GINT_TO_POINTER(SPIN_BUTTON_SIZE)); - gtk_container_add(GTK_CONTAINER(hbox), spin); + gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1); ei->size_spin_button = spin; label = gtk_label_new(_("Size")); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 8); - gtk_container_add(GTK_CONTAINER(vbox), hbox); - ei->count_hbox = hbox; + 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); + ei->count_hbox = hgrid; spin = gtk_spin_button_new_with_range(1, 255, 1); gtk_widget_set_tooltip_text(spin, _("Use this to change the tool's \"count\" parameter. " @@ -1322,10 +1329,10 @@ static struct editinfobox *editinfobox_create(void) g_signal_connect(spin, "value-changed", G_CALLBACK(editinfobox_spin_button_value_changed), GINT_TO_POINTER(SPIN_BUTTON_COUNT)); - gtk_container_add(GTK_CONTAINER(hbox), spin); + gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1); ei->count_spin_button = spin; label = gtk_label_new(_("Count")); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); /* combo section */ store = gtk_list_store_new(TAP_NUM_COLS, @@ -1353,7 +1360,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_container_add(GTK_CONTAINER(vbox), combo); + gtk_grid_attach(GTK_GRID(vgrid), combo, 0, grid_row++, 1, 1); ei->tool_applied_player_combobox = combo; /* We add a ref to the editinfobox widget so that it is diff --git a/client/gui-gtk-4.0/editgui.h b/client/gui-gtk-4.0/editgui.h index 2e41aa1d04..8c58b0be67 100644 --- a/client/gui-gtk-4.0/editgui.h +++ b/client/gui-gtk-4.0/editgui.h @@ -28,7 +28,7 @@ struct editbar { GtkSizeGroup *size_group; GtkWidget *mode_buttons[NUM_EDITOR_TOOL_MODES]; - GtkWidget *tool_buttons[NUM_EDITOR_TOOL_TYPES]; + GtkWidget *tool_buttons[NUM_EDITOR_TOOL_TYPES]; /* TODO: Make these GtkToggleButtons */ GtkWidget *player_properties_button; struct tool_value_selector *tool_selectors[NUM_EDITOR_TOOL_TYPES]; diff --git a/client/gui-gtk-4.0/editprop.c b/client/gui-gtk-4.0/editprop.c index a1986e6aef..fa693d12d2 100644 --- a/client/gui-gtk-4.0/editprop.c +++ b/client/gui-gtk-4.0/editprop.c @@ -2913,9 +2913,11 @@ static void objprop_widget_toggle_button_changed(GtkToggleButton *button, ****************************************************************************/ static void objprop_setup_widget(struct objprop *op) { - GtkWidget *hbox, *hbox2, *label, *image, *text, *spin, *button; + GtkWidget *hgrid, *hgrid2, *label, *image, *text, *spin, *button; struct extviewer *ev = NULL; enum object_property_ids propid; + int grid_col = 0; + int grid2_col = 0; if (!op) { return; @@ -2925,15 +2927,15 @@ static void objprop_setup_widget(struct objprop *op) return; } - hbox = gtk_grid_new(); - op->widget = hbox; + hgrid = gtk_grid_new(); + op->widget = hgrid; - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); label = gtk_label_new(objprop_get_name(op)); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); objprop_set_child_widget(op, "name-label", label); propid = objprop_get_id(op); @@ -2965,7 +2967,7 @@ static void objprop_setup_widget(struct objprop *op) gtk_widget_set_hexpand(label, TRUE); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); objprop_set_child_widget(op, "value-label", label); return; @@ -2977,7 +2979,7 @@ static void objprop_setup_widget(struct objprop *op) gtk_widget_set_hexpand(image, TRUE); gtk_widget_set_halign(image, GTK_ALIGN_START); gtk_widget_set_valign(image, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); objprop_set_child_widget(op, "image", image); return; @@ -2991,7 +2993,7 @@ static void objprop_setup_widget(struct objprop *op) gtk_editable_set_width_chars(GTK_EDITABLE(text), 8); g_signal_connect(text, "changed", G_CALLBACK(objprop_widget_text_changed), op); - gtk_container_add(GTK_CONTAINER(hbox), text); + gtk_grid_attach(GTK_GRID(hgrid), text, grid_col++, 0, 1, 1); objprop_set_child_widget(op, "text", text); return; @@ -3006,7 +3008,7 @@ static void objprop_setup_widget(struct objprop *op) gtk_widget_set_halign(spin, GTK_ALIGN_END); g_signal_connect(spin, "value-changed", G_CALLBACK(objprop_widget_spin_button_changed), op); - gtk_container_add(GTK_CONTAINER(hbox), spin); + gtk_grid_attach(GTK_GRID(hgrid), spin, grid_col++, 0, 1, 1); objprop_set_child_widget(op, "spin", spin); return; @@ -3014,20 +3016,20 @@ static void objprop_setup_widget(struct objprop *op) case OPID_UNIT_HP: case OPID_UNIT_VETERAN: case OPID_CITY_FOOD_STOCK: - hbox2 = gtk_grid_new(); - gtk_widget_set_hexpand(hbox2, TRUE); - gtk_widget_set_halign(hbox2, GTK_ALIGN_END); - gtk_grid_set_column_spacing(GTK_GRID(hbox2), 4); - gtk_container_add(GTK_CONTAINER(hbox), hbox2); + hgrid2 = gtk_grid_new(); + gtk_widget_set_hexpand(hgrid2, TRUE); + gtk_widget_set_halign(hgrid2, GTK_ALIGN_END); + gtk_grid_set_column_spacing(GTK_GRID(hgrid2), 4); + gtk_grid_attach(GTK_GRID(hgrid), hgrid2, grid_col++, 0, 1, 1); spin = gtk_spin_button_new_with_range(0.0, 100.0, 1.0); g_signal_connect(spin, "value-changed", G_CALLBACK(objprop_widget_spin_button_changed), op); - gtk_container_add(GTK_CONTAINER(hbox2), spin); + gtk_grid_attach(GTK_GRID(hgrid2), spin, grid2_col++, 0, 1, 1); objprop_set_child_widget(op, "spin", spin); label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox2), label); + gtk_grid_attach(GTK_GRID(hgrid2), label, grid2_col++, 0, 1, 1); objprop_set_child_widget(op, "max-value-label", label); return; @@ -3046,7 +3048,8 @@ static void objprop_setup_widget(struct objprop *op) objprop_set_extviewer(op, ev); gtk_widget_set_hexpand(extviewer_get_panel_widget(ev), TRUE); gtk_widget_set_halign(extviewer_get_panel_widget(ev), GTK_ALIGN_END); - gtk_container_add(GTK_CONTAINER(hbox), extviewer_get_panel_widget(ev)); + gtk_grid_attach(GTK_GRID(hgrid), extviewer_get_panel_widget(ev), + grid_col++, 0, 1, 1); property_page_add_extviewer(objprop_get_property_page(op), ev); return; @@ -3067,7 +3070,7 @@ static void objprop_setup_widget(struct objprop *op) gtk_widget_set_halign(button, GTK_ALIGN_END); g_signal_connect(button, "toggled", G_CALLBACK(objprop_widget_toggle_button_changed), op); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); objprop_set_child_widget(op, "checkbutton", button); return; } @@ -3456,7 +3459,7 @@ static struct objprop *objprop_new(int id, static struct extviewer *extviewer_new(struct objprop *op) { struct extviewer *ev; - GtkWidget *hbox, *vbox, *label, *button, *scrollwin, *image; + GtkWidget *hgrid, *vgrid, *label, *button, *scrollwin, *image; GtkWidget *view = NULL; GtkTreeSelection *sel; GtkListStore *store = NULL; @@ -3464,6 +3467,8 @@ static struct extviewer *extviewer_new(struct objprop *op) GType *gtypes; enum object_property_ids propid; int num_cols; + int grid_col = 0; + int grid_row = 0; if (!op) { return NULL; @@ -3486,55 +3491,58 @@ static struct extviewer *extviewer_new(struct objprop *op) case OPID_PLAYER_INVENTIONS: case OPID_GAME_SCENARIO_AUTHORS: case OPID_GAME_SCENARIO_DESC: - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - ev->panel_widget = hbox; + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + ev->panel_widget = hgrid; label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); ev->panel_label = label; break; case OPID_PLAYER_NATION: case OPID_PLAYER_GOV: - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 4); - ev->panel_widget = vbox; + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); + ev->panel_widget = vgrid; label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); ev->panel_label = label; - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + hgrid = gtk_grid_new(); + grid_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); image = gtk_image_new(); gtk_widget_set_halign(image, GTK_ALIGN_START); gtk_widget_set_valign(image, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), image); + gtk_grid_attach(GTK_GRID(hgrid), image, grid_col++, 0, 1, 1); ev->panel_image = image; break; case OPID_TILE_VISION: - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - ev->panel_widget = hbox; + hgrid = gtk_grid_new(); + grid_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + ev->panel_widget = hgrid; break; default: log_error("Unhandled request to create panel widget " "for property %d (%s) in extviewer_new().", propid, objprop_get_name(op)); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - ev->panel_widget = hbox; + hgrid = gtk_grid_new(); + grid_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + ev->panel_widget = hgrid; break; } @@ -3545,7 +3553,7 @@ static struct extviewer *extviewer_new(struct objprop *op) } g_signal_connect(button, "clicked", G_CALLBACK(extviewer_panel_button_clicked), ev); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); ev->panel_button = button; @@ -3598,20 +3606,21 @@ static struct extviewer *extviewer_new(struct objprop *op) /* Create the view widget. */ - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + grid_row = 0; + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 4); - 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); - ev->view_widget = vbox; + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); + 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); + ev->view_widget = vgrid; label = gtk_label_new(objprop_get_name(op)); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); ev->view_label = label; if (store || textbuf) { @@ -3621,7 +3630,7 @@ static struct extviewer *extviewer_new(struct objprop *op) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(vbox), scrollwin); + gtk_grid_attach(GTK_GRID(vgrid), scrollwin, 0, grid_row++, 1, 1); if (store) { view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); @@ -3629,6 +3638,7 @@ static struct extviewer *extviewer_new(struct objprop *op) gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE); } else { const bool editable = !objprop_is_readonly(op); + view = gtk_text_view_new_with_buffer(textbuf); gtk_text_view_set_editable(GTK_TEXT_VIEW(view), editable); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view), editable); @@ -3636,7 +3646,7 @@ static struct extviewer *extviewer_new(struct objprop *op) gtk_widget_set_hexpand(view, TRUE); gtk_widget_set_vexpand(view, TRUE); - gtk_container_add(GTK_CONTAINER(scrollwin), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollwin), view); } switch (propid) { @@ -4706,7 +4716,7 @@ property_page_new(enum editor_object_type objtype, struct property_editor *pe) { struct property_page *pp; - GtkWidget *vbox, *vbox2, *hbox, *hbox2, *paned, *frame, *w; + GtkWidget *vgrid, *vgrid2, *hgrid, *hgrid2, *paned, *frame, *w; GtkWidget *scrollwin, *view, *label, *entry, *notebook; GtkWidget *button, *hsep; GtkTreeSelection *sel; @@ -4718,6 +4728,10 @@ property_page_new(enum editor_object_type objtype, int col_id = 1; const char *attr_type_str, *name, *tooltip; gchar *title; + int grid_row = 0; + int grid2_row = 0; + int grid_col = 0; + int grid2_col = 0; if (!(objtype < NUM_OBJTYPES)) { return NULL; @@ -4765,15 +4779,15 @@ property_page_new(enum editor_object_type objtype, /* Left side object list view. */ - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 4); - 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_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); + 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_paned_pack1(GTK_PANED(paned), vgrid, TRUE, TRUE); scrollwin = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(scrollwin), @@ -4781,7 +4795,7 @@ property_page_new(enum editor_object_type objtype, gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(vbox), scrollwin); + gtk_grid_attach(GTK_GRID(vgrid), scrollwin, 0, grid_row++, 1, 1); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pp->object_store)); gtk_widget_set_hexpand(view, TRUE); @@ -4834,13 +4848,13 @@ property_page_new(enum editor_object_type objtype, gtk_tree_selection_set_select_function(sel, property_page_selection_func, pp, NULL); - gtk_container_add(GTK_CONTAINER(scrollwin), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollwin), view); pp->object_view = view; if (!objtype_is_conserved(objtype)) { - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); button = gtk_button_new(); gtk_button_set_icon_name(GTK_BUTTON(button), "list-add"); @@ -4855,7 +4869,7 @@ property_page_new(enum editor_object_type objtype, "parameter affect unit creation.")); g_signal_connect(button, "clicked", G_CALLBACK(property_page_create_button_clicked), pp); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); button = gtk_button_new(); gtk_button_set_icon_name(GTK_BUTTON(button), "list-remove"); @@ -4867,60 +4881,61 @@ property_page_new(enum editor_object_type objtype, "list.")); g_signal_connect(button, "clicked", G_CALLBACK(property_page_destroy_button_clicked), pp); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); } /* Right side properties panel. */ - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - gtk_paned_pack2(GTK_PANED(paned), hbox, TRUE, TRUE); + hgrid = gtk_grid_new(); + grid_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + gtk_paned_pack2(GTK_PANED(paned), hgrid, TRUE, TRUE); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 4); - 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_container_add(GTK_CONTAINER(hbox), vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); + 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_grid_attach(GTK_GRID(hgrid), vgrid, grid_col++, 0, 1, 1); /* Extended property viewer to the right of the properties panel. * This needs to be created before property widgets, since some * might try to append themselves to this notebook. */ - vbox2 = gtk_grid_new(); - gtk_widget_set_hexpand(vbox2, TRUE); - gtk_widget_set_vexpand(vbox2, TRUE); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid2 = gtk_grid_new(); + gtk_widget_set_hexpand(vgrid2, TRUE); + gtk_widget_set_vexpand(vgrid, TRUE); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox2), 4); - gtk_container_add(GTK_CONTAINER(hbox), vbox2); + gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4); + gtk_grid_attach(GTK_GRID(hgrid), vgrid2, grid_col++, 0, 1, 1); notebook = gtk_notebook_new(); gtk_widget_set_vexpand(notebook, TRUE); gtk_widget_set_size_request(notebook, 256, -1); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE); gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE); - gtk_container_add(GTK_CONTAINER(vbox2), notebook); + gtk_grid_attach(GTK_GRID(vgrid2), notebook, 0, grid2_row++, 1, 1); pp->extviewer_notebook = notebook; hsep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(vbox2), hsep); + gtk_grid_attach(GTK_GRID(vgrid2), hsep, 0, grid2_row++, 1, 1); - hbox2 = gtk_grid_new(); - gtk_widget_set_margin_start(hbox2, 4); - gtk_widget_set_margin_end(hbox2, 4); - gtk_widget_set_margin_top(hbox2, 4); - gtk_widget_set_margin_bottom(hbox2, 4); - gtk_container_add(GTK_CONTAINER(vbox2), hbox2); + hgrid2 = gtk_grid_new(); + gtk_widget_set_margin_start(hgrid2, 4); + gtk_widget_set_margin_end(hgrid2, 4); + gtk_widget_set_margin_top(hgrid2, 4); + gtk_widget_set_margin_bottom(hgrid2, 4); + gtk_grid_attach(GTK_GRID(vgrid2), hgrid2, 0, grid2_row++, 1, 1); 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); - gtk_container_add(GTK_CONTAINER(hbox2), button); + gtk_grid_attach(GTK_GRID(hgrid2), button, grid2_col++, 0, 1, 1); /* Now create the properties panel. */ @@ -4931,7 +4946,7 @@ property_page_new(enum editor_object_type objtype, frame = gtk_frame_new(title); g_free(title); gtk_widget_set_size_request(frame, 256, -1); - gtk_container_add(GTK_CONTAINER(vbox), frame); + gtk_grid_attach(GTK_GRID(vgrid), frame, 0, grid_row++, 1, 1); scrollwin = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(scrollwin), @@ -4939,18 +4954,19 @@ property_page_new(enum editor_object_type objtype, gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(frame), scrollwin); + gtk_frame_set_child(GTK_FRAME(frame), scrollwin); - vbox2 = gtk_grid_new(); - gtk_widget_set_vexpand(vbox2, TRUE); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox2), + vgrid2 = gtk_grid_new(); + grid2_row = 0; + gtk_widget_set_vexpand(vgrid2, TRUE); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid2), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox2), 4); - gtk_widget_set_margin_start(vbox2, 4); - gtk_widget_set_margin_end(vbox2, 4); - gtk_widget_set_margin_top(vbox2, 4); - gtk_widget_set_margin_bottom(vbox2, 4); - gtk_container_add(GTK_CONTAINER(scrollwin), vbox2); + gtk_grid_set_row_spacing(GTK_GRID(vgrid2), 4); + gtk_widget_set_margin_start(vgrid2, 4); + gtk_widget_set_margin_end(vgrid2, 4); + gtk_widget_set_margin_top(vgrid2, 4); + gtk_widget_set_margin_bottom(vgrid2, 4); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrollwin), vgrid2); property_page_objprop_iterate(pp, op) { if (!objprop_has_widget(op)) { @@ -4960,21 +4976,22 @@ property_page_new(enum editor_object_type objtype, if (!w) { continue; } - gtk_container_add(GTK_CONTAINER(vbox2), w); + gtk_grid_attach(GTK_GRID(vgrid2), w, 0, grid2_row++, 1, 1); tooltip = objprop_get_tooltip(op); if (NULL != tooltip) { gtk_widget_set_tooltip_text(w, tooltip); } } property_page_objprop_iterate_end; - hbox2 = gtk_grid_new(); - gtk_widget_set_margin_top(hbox2, 4); - gtk_widget_set_margin_bottom(hbox2, 4); - gtk_grid_set_column_spacing(GTK_GRID(hbox2), 4); - gtk_container_add(GTK_CONTAINER(vbox), hbox2); + hgrid2 = gtk_grid_new(); + grid2_col = 0; + gtk_widget_set_margin_top(hgrid2, 4); + gtk_widget_set_margin_bottom(hgrid2, 4); + gtk_grid_set_column_spacing(GTK_GRID(hgrid2), 4); + gtk_grid_attach(GTK_GRID(vgrid), hgrid2, 0, grid_row++, 1, 1); label = gtk_label_new(_("Filter:")); - gtk_container_add(GTK_CONTAINER(hbox2), label); + gtk_grid_attach(GTK_GRID(hgrid2), label, grid2_col++, 0, 1, 1); entry = gtk_entry_new(); gtk_widget_set_tooltip_text(entry, @@ -4984,11 +5001,12 @@ property_page_new(enum editor_object_type objtype, "than |. A pattern may also be negated by prefixing it with !.")); g_signal_connect(entry, "changed", G_CALLBACK(property_page_quick_find_entry_changed), pp); - gtk_container_add(GTK_CONTAINER(hbox2), entry); + gtk_grid_attach(GTK_GRID(hgrid2), entry, grid2_col++, 0, 1, 1); - hbox2 = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox2), 4); - gtk_container_add(GTK_CONTAINER(vbox), hbox2); + hgrid2 = gtk_grid_new(); + grid2_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid2), 4); + gtk_grid_attach(GTK_GRID(vgrid), hgrid2, 0, grid_row++, 1, 1); button = gtk_button_new_with_mnemonic(_("_Refresh")); gtk_size_group_add_widget(sizegroup, button); @@ -4998,7 +5016,7 @@ property_page_new(enum editor_object_type objtype, "they have on the server).")); g_signal_connect(button, "clicked", G_CALLBACK(property_page_refresh_button_clicked), pp); - gtk_container_add(GTK_CONTAINER(hbox2), button); + gtk_grid_attach(GTK_GRID(hgrid2), button, grid2_col++, 0, 1, 1); button = gtk_button_new_with_mnemonic(_("_Apply")); gtk_size_group_add_widget(sizegroup, button); @@ -5009,7 +5027,7 @@ property_page_new(enum editor_object_type objtype, "panel.")); g_signal_connect(button, "clicked", G_CALLBACK(property_page_apply_button_clicked), pp); - gtk_container_add(GTK_CONTAINER(hbox2), button); + gtk_grid_attach(GTK_GRID(hgrid2), button, grid2_col++, 0, 1, 1); return pp; } @@ -6140,8 +6158,9 @@ property_editor_get_page(struct property_editor *pe, static struct property_editor *property_editor_new(void) { struct property_editor *pe; - GtkWidget *win, *notebook, *vbox; + GtkWidget *win, *notebook, *vgrid; enum editor_object_type objtype; + int grid_row = 0; pe = fc_calloc(1, sizeof(*pe)); @@ -6160,14 +6179,14 @@ static struct property_editor *property_editor_new(void) gtk_window_set_hide_on_close(GTK_WINDOW(win), TRUE); pe->widget = win; - vbox = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(win), vbox); + vgrid = gtk_grid_new(); + gtk_window_set_child(GTK_WINDOW(win), vgrid); /* Property pages. */ notebook = gtk_notebook_new(); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE); - gtk_container_add(GTK_CONTAINER(vbox), notebook); + gtk_grid_attach(GTK_GRID(vgrid), notebook, 0, grid_row++, 1, 1); pe->notebook = notebook; for (objtype = 0; objtype < NUM_OBJTYPES; objtype++) { diff --git a/client/gui-gtk-4.0/finddlg.c b/client/gui-gtk-4.0/finddlg.c index e40cd1bcbc..e6dc43d022 100644 --- a/client/gui-gtk-4.0/finddlg.c +++ b/client/gui-gtk-4.0/finddlg.c @@ -103,7 +103,7 @@ void popup_find_dialog(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(sw), find_view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), find_view); gtk_widget_set_hexpand(GTK_WIDGET(find_view), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(find_view), TRUE); diff --git a/client/gui-gtk-4.0/gamedlgs.c b/client/gui-gtk-4.0/gamedlgs.c index ff261301d0..31fe92c59b 100644 --- a/client/gui-gtk-4.0/gamedlgs.c +++ b/client/gui-gtk-4.0/gamedlgs.c @@ -398,6 +398,7 @@ static GtkWidget *create_rates_dialog(void) GtkWidget *shell, *content; GtkWidget *frame, *hgrid; int i; + int grid_col = 0; if (!can_client_issue_orders()) { return NULL; @@ -423,7 +424,7 @@ static GtkWidget *create_rates_dialog(void) hgrid = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10); - gtk_container_add(GTK_CONTAINER(frame), hgrid); + gtk_frame_set_child(GTK_FRAME(frame), hgrid); rates_tax_scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1); @@ -434,21 +435,22 @@ static GtkWidget *create_rates_dialog(void) gtk_widget_set_size_request(rates_tax_scale, 300, 40); gtk_scale_set_digits(GTK_SCALE(rates_tax_scale), 0); gtk_scale_set_draw_value(GTK_SCALE(rates_tax_scale), FALSE); - gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_scale); + gtk_grid_attach(GTK_GRID(hgrid), rates_tax_scale, grid_col++, 0, 1, 1); rates_tax_label = gtk_label_new(" 0%"); - gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_label); + gtk_grid_attach(GTK_GRID(hgrid), rates_tax_label, grid_col++, 0, 1, 1); gtk_widget_set_size_request(rates_tax_label, 40, -1); rates_tax_toggle = gtk_check_button_new_with_label( _("Lock") ); - gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_toggle); + gtk_grid_attach(GTK_GRID(hgrid), rates_tax_toggle, grid_col++, 0, 1, 1); frame = gtk_frame_new( _("Luxury") ); gtk_box_insert_child_after(GTK_BOX(content), frame, NULL); hgrid = gtk_grid_new(); + grid_col = 0; gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10); - gtk_container_add(GTK_CONTAINER(frame), hgrid); + gtk_frame_set_child(GTK_FRAME(frame), hgrid); rates_lux_scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1); @@ -459,21 +461,22 @@ static GtkWidget *create_rates_dialog(void) gtk_widget_set_size_request(rates_lux_scale, 300, 40); gtk_scale_set_digits(GTK_SCALE(rates_lux_scale), 0); gtk_scale_set_draw_value(GTK_SCALE(rates_lux_scale), FALSE); - gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_scale); + gtk_grid_attach(GTK_GRID(hgrid), rates_lux_scale, grid_col++, 0, 1, 1); rates_lux_label = gtk_label_new(" 0%"); - gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_label); + gtk_grid_attach(GTK_GRID(hgrid), rates_lux_label, grid_col++, 0, 1, 1); gtk_widget_set_size_request(rates_lux_label, 40, -1); rates_lux_toggle = gtk_check_button_new_with_label( _("Lock") ); - gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_toggle); + gtk_grid_attach(GTK_GRID(hgrid), rates_lux_toggle, grid_col++, 0, 1, 1); frame = gtk_frame_new( _("Science") ); gtk_box_insert_child_after(GTK_BOX(content), frame, NULL); hgrid = gtk_grid_new(); + grid_col = 0; gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10); - gtk_container_add(GTK_CONTAINER(frame), hgrid); + gtk_frame_set_child(GTK_FRAME(frame), hgrid); rates_sci_scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1); @@ -484,15 +487,14 @@ static GtkWidget *create_rates_dialog(void) gtk_widget_set_size_request(rates_sci_scale, 300, 40); gtk_scale_set_digits(GTK_SCALE(rates_sci_scale), 0); gtk_scale_set_draw_value(GTK_SCALE(rates_sci_scale), FALSE); - gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_scale); + gtk_grid_attach(GTK_GRID(hgrid), rates_sci_scale, grid_col++, 0, 1, 1); rates_sci_label = gtk_label_new(" 0%"); - gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_label); + gtk_grid_attach(GTK_GRID(hgrid), rates_sci_label, grid_col++, 0, 1, 1); gtk_widget_set_size_request(rates_sci_label, 40, -1); rates_sci_toggle = gtk_check_button_new_with_label( _("Lock") ); - gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_toggle); - + gtk_grid_attach(GTK_GRID(hgrid), rates_sci_toggle, grid_col++, 0, 1, 1); g_signal_connect(shell, "response", G_CALLBACK(rates_command_callback), NULL); diff --git a/client/gui-gtk-4.0/gotodlg.c b/client/gui-gtk-4.0/gotodlg.c index abda8667ed..87b2beef4a 100644 --- a/client/gui-gtk-4.0/gotodlg.c +++ b/client/gui-gtk-4.0/gotodlg.c @@ -133,9 +133,10 @@ static void goto_cmd_callback(GtkWidget *dlg, gint arg) **************************************************************************/ static void create_goto_dialog(void) { - GtkWidget *sw, *label, *frame, *vbox; + GtkWidget *sw, *label, *frame, *vgrid; GtkCellRenderer *rend; GtkTreeViewColumn *col; + int grid_row = 0; dshell = gtk_dialog_new_with_buttons(_("Goto/Airlift Unit"), NULL, @@ -171,11 +172,11 @@ static void create_goto_dialog(void) gtk_box_insert_child_after(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dshell))), frame, NULL); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 6); - gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 6); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); 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); @@ -226,15 +227,15 @@ static void create_goto_dialog(void) gtk_tree_view_column_set_sort_column_id(col, GD_COL_AIRLIFT); sw = gtk_scrolled_window_new(); - gtk_container_add(GTK_CONTAINER(sw), view); + 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_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); all_toggle = gtk_check_button_new_with_mnemonic(_("Show _All Cities")); - gtk_container_add(GTK_CONTAINER(vbox), all_toggle); + gtk_grid_attach(GTK_GRID(vgrid), all_toggle, 0, grid_row++, 1, 1); g_signal_connect(all_toggle, "toggled", G_CALLBACK(update_goto_dialog), NULL); diff --git a/client/gui-gtk-4.0/gtkcompat.h b/client/gui-gtk-4.0/gtkcompat.h index 45d9969c33..87d119cadb 100644 --- a/client/gui-gtk-4.0/gtkcompat.h +++ b/client/gui-gtk-4.0/gtkcompat.h @@ -34,14 +34,20 @@ void gtk_button_set_has_frame(GtkButton *btn, bool shadow); #define gtk_window_destroy(_wnd_) gtk_widget_destroy(GTK_WIDGET(_wnd_)) #define gtk_box_append(_box_, _child_) gtk_container_add(GTK_CONTAINER(_box_), _child_) #define gtk_box_remove(_box_, _child_) gtk_container_remove(GTK_CONTAINER(_box_), _child_) -#define gtk_grid_remove(_grid_, _child_) \ +#define gtk_grid_remove(_grid_, _child_) \ gtk_container_remove(GTK_CONTAINER(_grid_), _child_) #define gtk_frame_set_child(_frame_, _child_) \ gtk_container_add(GTK_CONTAINER(_frame_), _child_) #define gtk_window_set_child(_win_, _child_) \ gtk_container_add(GTK_CONTAINER(_win_), _child_) +#define gtk_scrolled_window_set_child(_sw_, _child_) \ + gtk_container_add(GTK_CONTAINER(_sw_), _child_) +#define gtk_combo_box_set_child(_cb_, _child_) \ + gtk_container_add(GTK_CONTAINER(_cb_), _child_) #define gtk_paned_set_end_child(_paned_, _child_) \ gtk_paned_pack2(_paned_, _child_, FALSE, TRUE) +#define gtk_button_set_child(_but_, _child_) \ + gtk_container_add(GTK_CONTAINER(_but_), _child_) #endif /* GTK version < 3.98.4 */ diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index c20f4948d8..c1e6276deb 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -854,9 +854,7 @@ static GtkWidget *detached_widget_fill(GtkWidget *tearbox) gtk_box_append(GTK_BOX(tearbox), b); g_signal_connect(b, "toggled", G_CALLBACK(tearoff_callback), tearbox); - fillbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(fillbox), - GTK_ORIENTATION_VERTICAL); + fillbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_box_append(GTK_BOX(tearbox), fillbox); @@ -931,8 +929,8 @@ static void populate_unit_image_table(void) gtk_widget_set_halign(more_arrow_pixmap_container, GTK_ALIGN_CENTER); gtk_widget_set_valign(more_arrow_pixmap_container, GTK_ALIGN_CENTER); g_object_ref(more_arrow_pixmap_container); - gtk_container_add(GTK_CONTAINER(more_arrow_pixmap_container), - more_arrow_pixmap); + gtk_frame_set_child(GTK_FRAME(more_arrow_pixmap_container), + more_arrow_pixmap); gtk_widget_set_size_request(more_arrow_pixmap_container, gdk_pixbuf_get_width(pix), -1); g_object_unref(G_OBJECT(pix)); @@ -1080,6 +1078,11 @@ static void setup_widgets(void) GtkWidget *notebook, *statusbar; GtkWidget *dtach_lowbox = NULL; struct sprite *spr; + int grid_row = 0; + int right_row = 0; + int top_row = 0; + int grid_col = 0; + int grid2_col = 0; message_buffer = gtk_text_buffer_new(NULL); @@ -1096,10 +1099,10 @@ static void setup_widgets(void) gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); - gtk_container_add(GTK_CONTAINER(toplevel), vgrid); - gtk_container_add(GTK_CONTAINER(vgrid), notebook); + gtk_window_set_child(GTK_WINDOW(toplevel), vgrid); + gtk_grid_attach(GTK_GRID(vgrid), notebook, 0, grid_row++, 1, 1); statusbar = create_statusbar(); - gtk_container_add(GTK_CONTAINER(vgrid), statusbar); + gtk_grid_attach(GTK_GRID(vgrid), statusbar, 0, grid_row++, 1, 1); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), create_main_page(), NULL); @@ -1137,15 +1140,16 @@ static void setup_widgets(void) /* The window is divided into two horizontal panels: overview + * civinfo + unitinfo, main view + message window. */ right_vbox = gtk_grid_new(); + right_row = 0; gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(hgrid), right_vbox); + gtk_grid_attach(GTK_GRID(hgrid), right_vbox, grid_col++, 0, 1, 1); paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(page), top_vbox); - gtk_container_add(GTK_CONTAINER(top_vbox), hgrid); - gtk_container_add(GTK_CONTAINER(right_vbox), paned); - gtk_container_add(GTK_CONTAINER(right_vbox), ingame_votebar); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(page), top_vbox); + gtk_grid_attach(GTK_GRID(top_vbox), hgrid, 0, top_row++, 1, 1); + gtk_grid_attach(GTK_GRID(right_vbox), paned, 0, right_row++, 1, 1); + gtk_grid_attach(GTK_GRID(right_vbox), ingame_votebar, 0, right_row++, 1, 1); /* Overview size designed for small displays (netbooks). */ overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK; @@ -1154,9 +1158,9 @@ static void setup_widgets(void) /* The window is divided into two vertical panes: overview + * + civinfo + unitinfo + main view, message window. */ paned = gtk_paned_new(GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(page), paned); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(page), paned); gtk_paned_pack1(GTK_PANED(paned), top_vbox, TRUE, FALSE); - gtk_container_add(GTK_CONTAINER(top_vbox), hgrid); + gtk_grid_attach(GTK_GRID(top_vbox), hgrid, 0, top_row++, 1, 1); /* Overview size designed for big displays (desktops). */ overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH; @@ -1170,6 +1174,7 @@ static void setup_widgets(void) * the chat/messages pane, or NULL which is OK */ gtk_grid_attach_next_to(GTK_GRID(hgrid), vbox, right_vbox, GTK_POS_LEFT, 1, 1); + grid_col++; /* overview canvas */ ahbox = detached_widget_new(); @@ -1196,10 +1201,10 @@ static void setup_widgets(void) gtk_widget_set_hexpand(overview_canvas, TRUE); gtk_widget_set_vexpand(overview_canvas, TRUE); - gtk_container_add(GTK_CONTAINER(avbox), overview_scrolled_window); + gtk_box_append(GTK_BOX(avbox), overview_scrolled_window); - gtk_container_add(GTK_CONTAINER(overview_scrolled_window), - overview_canvas); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(overview_scrolled_window), + overview_canvas); gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(overview_canvas), overview_canvas_draw, NULL, NULL); @@ -1221,14 +1226,15 @@ static void setup_widgets(void) /* Info on player's civilization, when game is running. */ frame = gtk_frame_new(""); - gtk_container_add(GTK_CONTAINER(avbox), frame); + gtk_box_append(GTK_BOX(avbox), frame); main_frame_civ_name = frame; vgrid = gtk_grid_new(); + grid_row = 0; gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(frame), vgrid); + gtk_frame_set_child(GTK_FRAME(frame), vgrid); gtk_widget_set_hexpand(vgrid, TRUE); label = gtk_label_new(NULL); @@ -1240,14 +1246,14 @@ static void setup_widgets(void) gtk_widget_set_margin_bottom(label, 2); g_signal_connect(label, "button_press_event", G_CALLBACK(show_info_popup), NULL); - gtk_container_add(GTK_CONTAINER(vgrid), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); main_label_info = label; /* Production status */ table = gtk_grid_new(); gtk_widget_set_halign(table, GTK_ALIGN_CENTER); gtk_grid_set_column_homogeneous(GTK_GRID(table), TRUE); - gtk_container_add(GTK_CONTAINER(avbox), table); + gtk_box_append(GTK_BOX(avbox), table); /* citizens for taxrates */ table2 = gtk_grid_new(); @@ -1329,7 +1335,7 @@ static void setup_widgets(void) frame = gtk_frame_new(NULL); gtk_grid_attach(GTK_GRID(table), frame, 4, 1, 6, 1); - gtk_container_add(GTK_CONTAINER(frame), timeout_label); + gtk_frame_set_child(GTK_FRAME(frame), timeout_label); /* turn done */ @@ -1350,7 +1356,7 @@ static void setup_widgets(void) * editgui.c replace_widget() code that removes and adds widgets from it. */ unit_info_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_widget_set_hexpand(unit_info_box, FALSE); - gtk_container_add(GTK_CONTAINER(avbox), unit_info_box); + gtk_box_append(GTK_BOX(avbox), unit_info_box); /* In edit mode the unit_info_box widget is replaced by the * editinfobox, so we need to add a ref here so that it is @@ -1365,7 +1371,7 @@ static void setup_widgets(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - gtk_container_add(GTK_CONTAINER(unit_info_frame), sw); + gtk_frame_set_child(GTK_FRAME(unit_info_frame), sw); label = gtk_label_new(NULL); gtk_widget_set_hexpand(label, TRUE); @@ -1375,7 +1381,7 @@ static void setup_widgets(void) gtk_widget_set_margin_end(label, 2); gtk_widget_set_margin_top(label, 2); gtk_widget_set_margin_bottom(label, 2); - gtk_container_add(GTK_CONTAINER(sw), label); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), label); unit_info_label = label; hgrid2 = gtk_grid_new(); @@ -1383,7 +1389,7 @@ static void setup_widgets(void) table = gtk_grid_new(); g_object_set(table, "margin", 5, NULL); - gtk_container_add(GTK_CONTAINER(hgrid2), table); + gtk_grid_attach(GTK_GRID(hgrid2), table, grid2_col++, 0, 1, 1); gtk_grid_set_row_spacing(GTK_GRID(table), 2); gtk_grid_set_column_spacing(GTK_GRID(table), 2); @@ -1403,24 +1409,27 @@ static void setup_widgets(void) gtk_paned_pack1(GTK_PANED(paned), top_notebook, TRUE, FALSE); } else if (GUI_GTK_OPTION(message_chat_location) == GUI_GTK_MSGCHAT_MERGED) { right_vbox = gtk_grid_new(); + right_row = 0; gtk_orientable_set_orientation(GTK_ORIENTABLE(right_vbox), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(right_vbox), top_notebook); - gtk_container_add(GTK_CONTAINER(right_vbox), ingame_votebar); - gtk_container_add(GTK_CONTAINER(hgrid), right_vbox); + gtk_grid_attach(GTK_GRID(right_vbox), top_notebook, 0, right_row++, 1, 1); + gtk_grid_attach(GTK_GRID(right_vbox), ingame_votebar, 0, right_row++, 1, 1); + gtk_grid_attach(GTK_GRID(hgrid), right_vbox, grid_col++, 0, 1, 1); } else { - gtk_container_add(GTK_CONTAINER(hgrid), top_notebook); + gtk_grid_attach(GTK_GRID(hgrid), top_notebook, grid_col++, 0, 1, 1); } map_widget = gtk_grid_new(); vgrid = gtk_grid_new(); + grid_row = 0; gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(vgrid), map_widget); + gtk_grid_attach(GTK_GRID(vgrid), map_widget, 0, grid_row++, 1, 1); - gtk_container_add(GTK_CONTAINER(vgrid), editgui_get_editbar()->widget); + gtk_grid_attach(GTK_GRID(vgrid), editgui_get_editbar()->widget, + 0, grid_row++, 1, 1); g_object_set(editgui_get_editbar()->widget, "margin", 4, NULL); label = gtk_label_new(Q_("?noun:View")); @@ -1446,7 +1455,7 @@ static void setup_widgets(void) setup_canvas_color_for_state(GTK_STATE_FLAG_BACKDROP); #endif /* 0 */ - gtk_container_add(GTK_CONTAINER(frame), map_canvas); + gtk_frame_set_child(GTK_FRAME(frame), map_canvas); map_horizontal_scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL); @@ -1491,19 +1500,20 @@ static void setup_widgets(void) avbox = detached_widget_fill(dtach_lowbox); vgrid = gtk_grid_new(); + grid_row = 0; gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); if (!GUI_GTK_OPTION(small_display_layout)) { - gtk_container_add(GTK_CONTAINER(vgrid), ingame_votebar); + gtk_grid_attach(GTK_GRID(vgrid), ingame_votebar, 0, grid_row++, 1, 1); } - gtk_container_add(GTK_CONTAINER(avbox), vgrid); + gtk_box_append(GTK_BOX(avbox), vgrid); if (GUI_GTK_OPTION(small_display_layout)) { hpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL); } else { hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); } - gtk_container_add(GTK_CONTAINER(vgrid), hpaned); + gtk_grid_attach(GTK_GRID(vgrid), hpaned, 0, grid_row++, 1, 1); g_object_set(hpaned, "margin", 4, NULL); bottom_hpaned = hpaned; @@ -1524,6 +1534,7 @@ static void setup_widgets(void) } vgrid = gtk_grid_new(); + grid_row = 0; gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); @@ -1533,7 +1544,7 @@ static void setup_widgets(void) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(vgrid), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); label = gtk_label_new(_("Chat")); gtk_notebook_append_page(GTK_NOTEBOOK(bottom_notebook), vgrid, label); @@ -1543,7 +1554,7 @@ static void setup_widgets(void) gtk_widget_set_vexpand(text, TRUE); set_message_buffer_view_link_handlers(text); gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); - gtk_container_add(GTK_CONTAINER(sw), text); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), text); g_signal_connect(text, "size-allocate", G_CALLBACK(main_message_area_size_allocate), NULL); @@ -1562,7 +1573,7 @@ static void setup_widgets(void) /* the chat line */ view = inputline_toolkit_view_new(); - gtk_container_add(GTK_CONTAINER(vgrid), view); + gtk_grid_attach(GTK_GRID(vgrid), view, 0, grid_row++, 1, 1); g_object_set(view, "margin", 3, NULL); button = gtk_check_button_new_with_label(_("Allies Only")); diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index b3fb69cb39..37f941edea 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -464,7 +464,7 @@ static void gui_dialog_detach(struct gui_dialog* dlg) gtk_window_set_title(GTK_WINDOW(window), dlg->title); setup_dialog(window, toplevel); - gtk_container_add(GTK_CONTAINER(window), dlg->grid); + gtk_window_set_child(GTK_WINDOW(window), dlg->grid); dlg->v.window = window; g_signal_connect(window, "close-request", G_CALLBACK(gui_dialog_delete_handler), dlg); @@ -581,7 +581,7 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gtk_widget_set_name(window, "Freeciv"); setup_dialog(window, toplevel); - gtk_container_add(GTK_CONTAINER(window), dlg->grid); + gtk_window_set_child(GTK_WINDOW(window), dlg->grid); dlg->v.window = window; g_signal_connect(window, "close-request", G_CALLBACK(gui_dialog_delete_handler), dlg); @@ -590,10 +590,11 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, break; case GUI_DIALOG_TAB: { - GtkWidget *hbox, *label, *button; + GtkWidget *hgrid, *label, *button; gchar *buf; + int grid_col = 0; - hbox = gtk_grid_new(); + hgrid = gtk_grid_new(); label = gtk_label_new(NULL); gtk_widget_set_halign(label, GTK_ALIGN_START); @@ -602,7 +603,7 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gtk_widget_set_margin_end(label, 4); gtk_widget_set_margin_top(label, 0); gtk_widget_set_margin_bottom(label, 0); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); button = gtk_button_new(); gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); @@ -615,11 +616,11 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gtk_button_set_icon_name(GTK_BUTTON(button), "window-close"); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); - gtk_widget_show(hbox); + gtk_widget_show(hgrid); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dlg->grid, hbox); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dlg->grid, hgrid); dlg->v.tab.handler_id = g_signal_connect(notebook, "switch-page", G_CALLBACK(gui_dialog_switch_page_handler), dlg); @@ -631,7 +632,7 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, dlg->v.tab.label = label; dlg->v.tab.notebook = GTK_WIDGET(notebook); - g_signal_connect(hbox, "button-press-event", + g_signal_connect(hgrid, "button-press-event", G_CALLBACK(click_on_tab_callback), dlg); } break; diff --git a/client/gui-gtk-4.0/happiness.c b/client/gui-gtk-4.0/happiness.c index d3cfde7963..0d1d4534a8 100644 --- a/client/gui-gtk-4.0/happiness.c +++ b/client/gui-gtk-4.0/happiness.c @@ -155,7 +155,7 @@ static gboolean show_happiness_popup(GtkWidget *w, gtk_window_set_transient_for(GTK_WINDOW(p), GTK_WINDOW(pdialog->win)); frame = gtk_frame_new(NULL); - gtk_container_add(GTK_CONTAINER(p), frame); + gtk_window_set_child(GTK_WINDOW(p), frame); label = gtk_label_new(buf); /* FIXME: there is no font option corresponding to this style name. @@ -165,7 +165,7 @@ static gboolean show_happiness_popup(GtkWidget *w, gtk_widget_set_margin_end(label, 4); gtk_widget_set_margin_top(label, 4); gtk_widget_set_margin_bottom(label, 4); - gtk_container_add(GTK_CONTAINER(frame), label); + gtk_frame_set_child(GTK_FRAME(frame), label); gtk_widget_show(p); } @@ -202,7 +202,7 @@ static struct happiness_dialog *create_happiness_dialog(struct city *pcity, GTK_ORIENTATION_VERTICAL); pdialog->cityname_label = gtk_frame_new(_("Happiness")); - gtk_container_add(GTK_CONTAINER(pdialog->shell), pdialog->cityname_label); + gtk_grid_attach(GTK_GRID(pdialog->shell), pdialog->cityname_label, 0, 0, 1, 1); table = gtk_grid_new(); g_object_set(table, "margin", 4, NULL); @@ -211,7 +211,7 @@ static struct happiness_dialog *create_happiness_dialog(struct city *pcity, intl_slist(ARRAY_SIZE(happiness_label_str), happiness_label_str, &happiness_label_str_done); - gtk_container_add(GTK_CONTAINER(pdialog->cityname_label), table); + gtk_frame_set_child(GTK_FRAME(pdialog->cityname_label), table); for (i = 0; i < NUM_HAPPINESS_MODIFIERS; i++) { GtkWidget *img; diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index d5158966b1..a8c826f23b 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -336,11 +336,12 @@ static GtkWidget *help_hyperlink_new(GtkWidget *label, enum help_page_type type) gtk_widget_set_halign(label, GTK_ALIGN_CENTER); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_widget_set_name(label, "help_link"); - gtk_container_add(GTK_CONTAINER(button), label); + gtk_button_set_child(GTK_BUTTON(button), label); gtk_widget_show(button); g_signal_connect_swapped(button, "clicked", G_CALLBACK(help_hyperlink_callback), label); g_object_set_data(G_OBJECT(label), "page_type", GUINT_TO_POINTER(type)); + return button; } @@ -459,7 +460,7 @@ static void activated_topic(GtkTreeView *view, gpointer data) **************************************************************************/ static void create_help_dialog(void) { - GtkWidget *hbox; + GtkWidget *hgrid; GtkWidget *button; GtkWidget *text; int i, j; @@ -468,6 +469,9 @@ static void create_help_dialog(void) GArray *array; GtkTreeStore *store; GtkTreeSelection *selection; + int grid_col = 0; + int help_box_row = 0; + int buttons_col = 0; help_history = g_ptr_array_new(); help_history_pos = -1; @@ -492,11 +496,11 @@ static void create_help_dialog(void) g_signal_connect(help_dialog_shell, "destroy", G_CALLBACK(help_destroy_callback), NULL); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 5); + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 5); gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(help_dialog_shell))), - hbox); - gtk_widget_show(hbox); + hgrid); + gtk_widget_show(hgrid); /* build tree store. */ store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); @@ -545,15 +549,15 @@ static void create_help_dialog(void) help_view_sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_view_sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request(help_view_sw, 190, -1); - gtk_container_add(GTK_CONTAINER(help_view_sw), help_view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_view_sw), help_view); gtk_widget_show(help_view); - gtk_container_add(GTK_CONTAINER(hbox), help_view_sw); + gtk_grid_attach(GTK_GRID(hgrid), help_view_sw, grid_col++, 0, 1, 1); gtk_widget_show(help_view_sw); help_frame = gtk_frame_new(""); - gtk_container_add(GTK_CONTAINER(hbox), help_frame); + gtk_grid_attach(GTK_GRID(hgrid), help_frame, grid_col++, 0, 1, 1); gtk_widget_set_size_request(help_frame, 520, 350); gtk_widget_show(help_frame); @@ -561,13 +565,13 @@ static void create_help_dialog(void) gtk_grid_set_row_spacing(GTK_GRID(help_box), 5); gtk_orientable_set_orientation(GTK_ORIENTABLE(help_box), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(help_frame), help_box); + gtk_frame_set_child(GTK_FRAME(help_frame), help_box); help_tile = gtk_image_new(); - gtk_container_add(GTK_CONTAINER(help_box), help_tile); + gtk_grid_attach(GTK_GRID(help_box), help_tile, 0, help_box_row++, 1, 1); help_itable = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(help_box), help_itable); + gtk_grid_attach(GTK_GRID(help_box), help_itable, 0, help_box_row++, 1, 1); for (i = 0; i < 6; i++) { help_ilabel[i] = @@ -585,7 +589,7 @@ static void create_help_dialog(void) } help_wtable = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(help_box), help_wtable); + gtk_grid_attach(GTK_GRID(help_box), help_wtable, 0, help_box_row++, 1, 1); for (i = 0; i < 6; i++) { help_wlabel[i] = @@ -604,7 +608,7 @@ static void create_help_dialog(void) help_utable = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(help_box), help_utable); + gtk_grid_attach(GTK_GRID(help_box), help_utable, 0, help_box_row++, 1, 1); for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { @@ -630,7 +634,7 @@ static void create_help_dialog(void) } help_ttable = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(help_box), help_ttable); + gtk_grid_attach(GTK_GRID(help_box), help_ttable, 0, help_box_row++, 1, 1); for (j = 0; j < 2; j++) { for (i = 0; i < 5; i++) { @@ -655,7 +659,7 @@ static void create_help_dialog(void) } help_etable = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(help_box), help_etable); + gtk_grid_attach(GTK_GRID(help_box), help_etable, 0, help_box_row++, 1, 1); for (i = 0; i < 6; i++) { help_elabel[i] = @@ -675,7 +679,7 @@ static void create_help_dialog(void) gtk_widget_set_margin_end(help_vgrid, 5); gtk_widget_set_margin_top(help_vgrid, 5); gtk_widget_set_margin_bottom(help_vgrid, 5); - gtk_container_add(GTK_CONTAINER(help_box), help_vgrid); + gtk_grid_attach(GTK_GRID(help_box), help_vgrid, 0, help_box_row++, 1, 1); text = gtk_text_view_new(); gtk_widget_set_hexpand(text, TRUE); @@ -694,8 +698,8 @@ static void create_help_dialog(void) help_text_sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_text_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(help_text_sw), text); - gtk_container_add(GTK_CONTAINER(help_box), help_text_sw); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_text_sw), text); + gtk_grid_attach(GTK_GRID(help_box), help_text_sw, 0, help_box_row++, 1, 1); /* build tech store. */ tstore = gtk_tree_store_new(4, @@ -736,9 +740,9 @@ static void create_help_dialog(void) help_tree_sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_tree_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(help_tree_sw), help_tree); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_tree_sw), help_tree); gtk_widget_show(help_tree); - gtk_container_add(GTK_CONTAINER(help_box), help_tree_sw); + gtk_grid_attach(GTK_GRID(help_box), help_tree_sw, 0, help_box_row++, 1, 1); help_tree_expand = gtk_button_new_with_label(_("Expand All")); @@ -750,9 +754,9 @@ static void create_help_dialog(void) G_CALLBACK(help_tech_tree_collapse_callback), help_tree); help_tree_buttons_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_container_add(GTK_CONTAINER(help_tree_buttons_hbox), help_tree_expand); - gtk_container_add(GTK_CONTAINER(help_tree_buttons_hbox), help_tree_collapse); - gtk_container_add(GTK_CONTAINER(help_box), help_tree_buttons_hbox); + gtk_grid_attach(GTK_GRID(help_tree_buttons_hbox), help_tree_expand, buttons_col++, 0, 1, 1); + gtk_grid_attach(GTK_GRID(help_tree_buttons_hbox), help_tree_collapse, buttons_col++, 0, 1, 1); + gtk_grid_attach(GTK_GRID(help_box), help_tree_buttons_hbox, 0, help_box_row++, 1, 1); gtk_widget_show(help_tree_buttons_hbox); } @@ -1056,13 +1060,15 @@ static void help_update_tech(const struct help_item *pitem, char *title) requirement_vector_iterate(&pgov->reqs, preq) { if (VUT_ADVANCE == preq->source.kind && preq->source.value.advance == padvance) { + int grid_col = 0; + hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Allows")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(government_name_translation(pgov), HELP_GOVERNMENT); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } } requirement_vector_iterate_end; @@ -1073,15 +1079,17 @@ static void help_update_tech(const struct help_item *pitem, char *title) requirement_vector_iterate(&pimprove->reqs, preq) { if (VUT_ADVANCE == preq->source.kind && preq->source.value.advance == padvance) { + int grid_col = 0; + hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Allows")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(improvement_name_translation(pimprove), is_great_wonder(pimprove) ? HELP_WONDER : HELP_IMPROVEMENT); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } } requirement_vector_iterate_end; @@ -1089,15 +1097,17 @@ static void help_update_tech(const struct help_item *pitem, char *title) if (pobs->source.kind == VUT_ADVANCE && pobs->source.value.advance == padvance && pobs->present) { + int grid_col = 0; + hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Obsoletes")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(improvement_name_translation(pimprove), is_great_wonder(pimprove) ? HELP_WONDER : HELP_IMPROVEMENT); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } } requirement_vector_iterate_end; @@ -1105,59 +1115,68 @@ static void help_update_tech(const struct help_item *pitem, char *title) } improvement_iterate_end; unit_type_iterate(punittype) { + int grid_col = 0; + if (padvance != punittype->require_advance) { continue; } hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Allows")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(utype_name_translation(punittype), HELP_UNIT); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } unit_type_iterate_end; advance_iterate_all(ptest) { if (padvance == advance_requires(ptest, AR_ONE)) { if (advance_by_number(A_NONE) == advance_requires(ptest, AR_TWO)) { + int grid_col = 0; + hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Allows")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(advance_name_translation(ptest), HELP_TECH); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } else { + int grid_col = 0; + hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Allows")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(advance_name_translation(ptest), HELP_TECH); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = gtk_label_new(_("with")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(advance_name_translation(advance_requires(ptest, AR_TWO)), HELP_TECH); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = gtk_label_new(Q_("?techhelp:")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } } if (padvance == advance_requires(ptest, AR_TWO)) { + int grid_col = 0; + hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(_("Allows")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(advance_name_translation(ptest), HELP_TECH); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = gtk_label_new(_("with")); - gtk_container_add(GTK_CONTAINER(hbox), w); - w = help_slink_new(advance_name_translation(advance_requires(ptest, AR_ONE)), + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); + w = help_slink_new(advance_name_translation(advance_requires(ptest, + AR_ONE)), HELP_TECH); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = gtk_label_new(Q_("?techhelp:")); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } } advance_iterate_all_end; @@ -1176,15 +1195,16 @@ static void add_act_help_for_terrain(const char *act_label, { GtkWidget *w; GtkWidget *hbox; + int grid_col = 0; hbox = gtk_grid_new(); help_box_add(hbox); w = gtk_label_new(act_label); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = help_slink_new(result_link_label, result_link_type); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); w = gtk_label_new(descr_label); - gtk_container_add(GTK_CONTAINER(hbox), w); + gtk_grid_attach(GTK_GRID(hbox), w, grid_col++, 0, 1, 1); gtk_widget_show(hbox); } diff --git a/client/gui-gtk-4.0/infradlg.c b/client/gui-gtk-4.0/infradlg.c index 64934c6590..4c5b455b3c 100644 --- a/client/gui-gtk-4.0/infradlg.c +++ b/client/gui-gtk-4.0/infradlg.c @@ -87,6 +87,7 @@ void infra_dialog_popup(void) GtkWidget *dlg; GtkWidget *main_box; GtkWidget *sep; + int grid_row = 0; if (infra_dialog_open()) { /* One infra dialog already open. */ @@ -106,19 +107,19 @@ void infra_dialog_popup(void) GTK_ORIENTATION_VERTICAL); instruction_label = gtk_label_new(_("First click a tile.")); - gtk_container_add(GTK_CONTAINER(main_box), instruction_label); + gtk_grid_attach(GTK_GRID(main_box), instruction_label, 0, grid_row++, 1, 1); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(main_box), sep); + gtk_grid_attach(GTK_GRID(main_box), sep, 0, grid_row++, 1, 1); points_label = gtk_label_new(_("- infrapoints")); - gtk_container_add(GTK_CONTAINER(main_box), points_label); + gtk_grid_attach(GTK_GRID(main_box), points_label, 0, grid_row++, 1, 1); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(main_box), sep); + gtk_grid_attach(GTK_GRID(main_box), sep, 0, grid_row++, 1, 1); infra_list_grid = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(main_box), infra_list_grid); + gtk_grid_attach(GTK_GRID(main_box), infra_list_grid, 0, grid_row++, 1, 1); gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), main_box); diff --git a/client/gui-gtk-4.0/inputdlg.c b/client/gui-gtk-4.0/inputdlg.c index c8a222be80..3049618f99 100644 --- a/client/gui-gtk-4.0/inputdlg.c +++ b/client/gui-gtk-4.0/inputdlg.c @@ -91,7 +91,7 @@ GtkWidget *input_dialog_create(GtkWindow *parent, const char *dialogname, label, NULL); input = gtk_entry_new(); - gtk_container_add(GTK_CONTAINER(label), input); + gtk_frame_set_child(GTK_FRAME(label), input); 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); diff --git a/client/gui-gtk-4.0/inteldlg.c b/client/gui-gtk-4.0/inteldlg.c index 7b5d1cf76b..0cd41ead7a 100644 --- a/client/gui-gtk-4.0/inteldlg.c +++ b/client/gui-gtk-4.0/inteldlg.c @@ -322,7 +322,7 @@ static struct intel_dialog *create_intel_dialog(struct player *p) sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -358,7 +358,7 @@ static struct intel_dialog *create_intel_dialog(struct player *p) sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -436,7 +436,7 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, diff --git a/client/gui-gtk-4.0/luaconsole.c b/client/gui-gtk-4.0/luaconsole.c index 1939fc6a6c..bfdcc9b9a7 100644 --- a/client/gui-gtk-4.0/luaconsole.c +++ b/client/gui-gtk-4.0/luaconsole.c @@ -182,7 +182,8 @@ void real_luaconsole_dialog_update(void) *****************************************************************************/ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) { - GtkWidget *entry, *vbox, *sw, *text, *notebook; + GtkWidget *entry, *vgrid, *sw, *text, *notebook; + int grid_row = 0; fc_assert_ret(NULL != pdialog); @@ -195,23 +196,23 @@ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) gui_dialog_new(&pdialog->shell, GTK_NOTEBOOK(notebook), pdialog, TRUE); gui_dialog_set_title(pdialog->shell, _("Client Lua Console")); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gui_dialog_add_content_widget(pdialog->shell, vbox); + gui_dialog_add_content_widget(pdialog->shell, vgrid); 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_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(vbox), sw); + gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1); text = gtk_text_view_new_with_buffer(pdialog->message_buffer); gtk_widget_set_hexpand(text, TRUE); gtk_widget_set_vexpand(text, TRUE); set_message_buffer_view_link_handlers(text); gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); - gtk_container_add(GTK_CONTAINER(sw), text); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), text); g_signal_connect(text, "size-allocate", G_CALLBACK(luaconsole_dialog_area_size_allocate), NULL); @@ -226,7 +227,7 @@ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) /* The lua console input line. */ entry = gtk_entry_new(); g_object_set(entry, "margin", 2, NULL); - gtk_container_add(GTK_CONTAINER(vbox), entry); + gtk_grid_attach(GTK_GRID(vgrid), entry, 0, grid_row++, 1, 1); g_signal_connect(entry, "activate", G_CALLBACK(luaconsole_input_return), NULL); g_signal_connect(entry, "key_press_event", diff --git a/client/gui-gtk-4.0/mapctrl.c b/client/gui-gtk-4.0/mapctrl.c index 056a7a4270..8a741e4541 100644 --- a/client/gui-gtk-4.0/mapctrl.c +++ b/client/gui-gtk-4.0/mapctrl.c @@ -78,7 +78,7 @@ static void popit(GdkEvent *ev, struct tile *ptile) gtk_widget_set_margin_top(p, 4); gtk_widget_set_margin_bottom(p, 4); gtk_window_set_transient_for(GTK_WINDOW(p), GTK_WINDOW(toplevel)); - gtk_container_add(GTK_CONTAINER(p), gtk_label_new(popup_info_text(ptile))); + gtk_window_set_child(GTK_WINDOW(p), gtk_label_new(popup_info_text(ptile))); punit = find_visible_unit(ptile); diff --git a/client/gui-gtk-4.0/messagedlg.c b/client/gui-gtk-4.0/messagedlg.c index 62ae41b4d7..958ea9637d 100644 --- a/client/gui-gtk-4.0/messagedlg.c +++ b/client/gui-gtk-4.0/messagedlg.c @@ -64,6 +64,7 @@ static void create_messageopt_dialog(void) { GtkWidget *form, *explanation; int n, i = 0, j; + int form_col = 0; gui_dialog_new(&shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE); gui_dialog_set_title(shell, _("Message Options")); @@ -154,11 +155,11 @@ static void create_messageopt_dialog(void) sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); - gtk_container_add(GTK_CONTAINER(sw), view); + 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_container_add(GTK_CONTAINER(form), sw); + gtk_grid_attach(GTK_GRID(form), sw, form_col++, 0, 1, 1); gtk_tree_view_focus(GTK_TREE_VIEW(view)); } diff --git a/client/gui-gtk-4.0/messagewin.c b/client/gui-gtk-4.0/messagewin.c index f3baa78e3e..0e225678bb 100644 --- a/client/gui-gtk-4.0/messagewin.c +++ b/client/gui-gtk-4.0/messagewin.c @@ -371,7 +371,7 @@ static void meswin_dialog_init(struct meswin_dialog *pdialog) "style", MESWIN_COL_STYLE, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); g_signal_connect(selection, "changed", diff --git a/client/gui-gtk-4.0/optiondlg.c b/client/gui-gtk-4.0/optiondlg.c index 0e41f082cf..24a921057b 100644 --- a/client/gui-gtk-4.0/optiondlg.c +++ b/client/gui-gtk-4.0/optiondlg.c @@ -301,7 +301,7 @@ static void option_color_set_button_color(GtkButton *button, cairo_surface_destroy(surface); } child = gtk_image_new_from_pixbuf(pixbuf); - gtk_container_add(GTK_CONTAINER(button), child); + gtk_button_set_child(GTK_BUTTON(button), child); gtk_widget_show(child); g_object_unref(G_OBJECT(pixbuf)); } @@ -494,6 +494,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, { const int category = option_category(poption); GtkWidget *main_hbox, *label, *w = NULL; + int main_col = 0; fc_assert(NULL == option_get_gui_data(poption)); @@ -514,12 +515,10 @@ static void option_dialog_option_add(struct option_dialog *pdialog, option_dialog_reorder_notebook(pdialog); } - pdialog->vboxes[category] = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(pdialog->vboxes[category]), - GTK_ORIENTATION_VERTICAL); + pdialog->vboxes[category] = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); g_object_set(pdialog->vboxes[category], "margin", 8, NULL); gtk_widget_set_hexpand(pdialog->vboxes[category], TRUE); - gtk_container_add(GTK_CONTAINER(sw), pdialog->vboxes[category]); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), pdialog->vboxes[category]); gtk_widget_show(sw); } @@ -528,11 +527,11 @@ static void option_dialog_option_add(struct option_dialog *pdialog, main_hbox = gtk_grid_new(); label = gtk_label_new(option_description(poption)); g_object_set(label, "margin", 2, NULL); - gtk_container_add(GTK_CONTAINER(main_hbox), label); + gtk_grid_attach(GTK_GRID(main_hbox), label, main_col++, 0, 1, 1); gtk_widget_set_tooltip_text(main_hbox, option_help_text(poption)); g_signal_connect(main_hbox, "button_press_event", G_CALLBACK(option_button_press_callback), poption); - gtk_container_add(GTK_CONTAINER(pdialog->vboxes[category]), main_hbox); + gtk_box_append(GTK_BOX(pdialog->vboxes[category]), main_hbox); switch (option_type(poption)) { case OT_BOOLEAN: @@ -597,7 +596,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, grid = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(grid), 4); gtk_grid_set_row_homogeneous(GTK_GRID(grid), TRUE); - gtk_container_add(GTK_CONTAINER(w), grid); + gtk_frame_set_child(GTK_FRAME(w), grid); for (i = 0; i < strvec_size(values); i++) { check = gtk_check_button_new(); gtk_grid_attach(GTK_GRID(grid), check, 0, i, 1, 1); @@ -618,6 +617,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, case OT_COLOR: { GtkWidget *button; + int grid_col = 0; w = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(w), 4); @@ -625,7 +625,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, /* Foreground color selector button. */ button = gtk_button_new(); - gtk_container_add(GTK_CONTAINER(w), button); + gtk_grid_attach(GTK_GRID(w), button, grid_col++, 0, 1, 1); gtk_widget_set_tooltip_text(GTK_WIDGET(button), _("Select the text color")); g_object_set_data(G_OBJECT(w), "fg_button", button); @@ -634,7 +634,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, /* Background color selector button. */ button = gtk_button_new(); - gtk_container_add(GTK_CONTAINER(w), button); + gtk_grid_attach(GTK_GRID(w), button, grid_col++, 0, 1, 1); gtk_widget_set_tooltip_text(GTK_WIDGET(button), _("Select the background color")); g_object_set_data(G_OBJECT(w), "bg_button", button); @@ -658,7 +658,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, g_object_set_data(G_OBJECT(w), "main_widget", main_hbox); gtk_widget_set_hexpand(w, TRUE); gtk_widget_set_halign(w, GTK_ALIGN_END); - gtk_container_add(GTK_CONTAINER(main_hbox), w); + gtk_grid_attach(GTK_GRID(main_hbox), w, main_col++, 0, 1, 1); } gtk_widget_show(main_hbox); diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index 7bf6b6bd21..a7eceb058a 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -225,24 +225,25 @@ static void intro_free(GtkWidget *w, gpointer *data) **************************************************************************/ GtkWidget *create_main_page(void) { - GtkWidget *widget, *vbox, *frame, *darea, *button, *table; + GtkWidget *widget, *vgrid, *frame, *darea, *button, *table; GtkSizeGroup *size; struct sprite *intro_in, *intro; int width, height; int sh; int space_needed; + int grid_row = 0; size = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - widget = vbox; + widget = vgrid; frame = gtk_frame_new(NULL); g_object_set(frame, "margin", 18, NULL); gtk_widget_set_halign(frame, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(vbox), frame); + gtk_grid_attach(GTK_GRID(vgrid), frame, 0, grid_row++, 1, 1); intro_in = load_gfxfile(tileset_main_intro_filename(tileset)); get_sprite_dimensions(intro_in, &width, &height); @@ -281,7 +282,7 @@ GtkWidget *create_main_page(void) G_CALLBACK(intro_expose), intro); g_signal_connect(widget, "destroy", G_CALLBACK(intro_free), intro); - gtk_container_add(GTK_CONTAINER(frame), darea); + gtk_frame_set_child(GTK_FRAME(frame), darea); #if IS_BETA_VERSION { @@ -292,7 +293,7 @@ GtkWidget *create_main_page(void) gtk_widget_set_halign(label, GTK_ALIGN_CENTER); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); } #endif /* IS_BETA_VERSION */ @@ -305,7 +306,7 @@ GtkWidget *create_main_page(void) gtk_grid_set_row_spacing(GTK_GRID(table), 8); gtk_grid_set_column_spacing(GTK_GRID(table), 18); - gtk_container_add(GTK_CONTAINER(vbox), table); + gtk_grid_attach(GTK_GRID(vgrid), table, 0, grid_row++, 1, 1); button = gtk_button_new_with_mnemonic(_("Start _New Game")); gtk_size_group_add_widget(size, button); @@ -569,6 +570,7 @@ 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); @@ -619,7 +621,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(sbox), label); + gtk_grid_attach(GTK_GRID(sbox), label, 0, grids_row++, 1, 1); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sw), 300); @@ -627,8 +629,8 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), view); - gtk_container_add(GTK_CONTAINER(sbox), sw); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + gtk_grid_attach(GTK_GRID(sbox), sw, 0, grids_row++, 1, 1); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); @@ -648,6 +650,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, pdialog->entry = GTK_ENTRY(entry); sbox = gtk_grid_new(); + grids_row = 0; g_object_set(sbox, "margin", 12, NULL); gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), GTK_ORIENTATION_VERTICAL); @@ -660,9 +663,9 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(sbox), label); + gtk_grid_attach(GTK_GRID(sbox), label, 0, grids_row++, 1, 1); - gtk_container_add(GTK_CONTAINER(sbox), entry); + gtk_grid_attach(GTK_GRID(sbox), entry, 0, grids_row++, 1, 1); gtk_box_append(vbox, sbox); save_dialog_update(pdialog); @@ -898,7 +901,7 @@ GtkWidget *create_statusbar(void) gtk_widget_set_margin_end(statusbar, 2); gtk_widget_set_margin_top(statusbar, 2); gtk_widget_set_margin_bottom(statusbar, 2); - gtk_container_add(GTK_CONTAINER(statusbar_frame), statusbar); + gtk_frame_set_child(GTK_FRAME(statusbar_frame), statusbar); statusbar_queue = g_queue_new(); statusbar_timer = g_timeout_add(2000, update_network_statusbar, NULL); @@ -1188,10 +1191,14 @@ static void update_network_page(void) **************************************************************************/ GtkWidget *create_network_page(void) { - GtkWidget *box, *sbox, *bbox, *hbox, *notebook; + GtkWidget *box, *sbox, *bbox, *hgrid, *notebook; GtkWidget *button, *label, *view, *sw, *table; GtkTreeSelection *selection; GtkListStore *store; + int box_row = 0; + int sbox_row = 0; + int grid_col = 0; + int bbox_col = 0; box = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(box), @@ -1202,7 +1209,7 @@ GtkWidget *create_network_page(void) gtk_widget_set_margin_bottom(box, 4); notebook = gtk_notebook_new(); - gtk_container_add(GTK_CONTAINER(box), notebook); + gtk_grid_attach(GTK_GRID(box), notebook, 0, box_row++, 1, 1); /* LAN pane. */ lan_store = gtk_list_store_new(7, G_TYPE_STRING, /* host */ @@ -1247,7 +1254,7 @@ GtkWidget *create_network_page(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), sw, label); @@ -1294,7 +1301,7 @@ GtkWidget *create_network_page(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); if (GUI_GTK_OPTION(metaserver_tab_first)) { gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook), sw, label); } else { @@ -1305,17 +1312,17 @@ GtkWidget *create_network_page(void) sbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(box), sbox); + gtk_grid_attach(GTK_GRID(box), sbox, 0, box_row++, 1, 1); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 12); - g_object_set(hbox, "margin", 8, NULL); - gtk_container_add(GTK_CONTAINER(sbox), hbox); + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 12); + g_object_set(hgrid, "margin", 8, NULL); + gtk_grid_attach(GTK_GRID(sbox), hgrid, 0, sbox_row++, 1, 1); table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 2); gtk_grid_set_column_spacing(GTK_GRID(table), 12); - gtk_container_add(GTK_CONTAINER(hbox), table); + gtk_grid_attach(GTK_GRID(hgrid), table, grid_col++, 0, 1, 1); network_host = gtk_entry_new(); g_signal_connect(network_host, "activate", @@ -1415,27 +1422,26 @@ GtkWidget *create_network_page(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), view); - gtk_container_add(GTK_CONTAINER(hbox), sw); - + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + gtk_grid_attach(GTK_GRID(hgrid), sw, grid_col++, 0, 1, 1); bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); g_object_set(bbox, "margin", 2, NULL); gtk_box_set_spacing(GTK_BOX(bbox), 12); - gtk_container_add(GTK_CONTAINER(sbox), bbox); + gtk_grid_attach(GTK_GRID(sbox), bbox, 0, sbox_row++, 1, 1); button = gtk_button_new_from_icon_name("view-refresh"); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_grid_attach(GTK_GRID(bbox), button, bbox_col++, 0, 1, 1); g_signal_connect(button, "clicked", G_CALLBACK(update_network_lists), NULL); button = gtk_button_new_with_mnemonic(_("_Cancel")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_grid_attach(GTK_GRID(bbox), button, bbox_col++, 0, 1, 1); g_signal_connect(button, "clicked", G_CALLBACK(main_callback), NULL); button = gtk_button_new_with_mnemonic(_("C_onnect")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_grid_attach(GTK_GRID(bbox), button, bbox_col++, 0, 1, 1); g_signal_connect(button, "clicked", G_CALLBACK(connect_callback), NULL); @@ -2627,7 +2633,7 @@ static void add_tree_col(GtkWidget *treeview, GType gtype, **************************************************************************/ GtkWidget *create_start_page(void) { - GtkWidget *box, *sbox, *table, *vbox; + GtkWidget *box, *sbox, *table, *vgrid; GtkWidget *view, *sw, *text, *toolkit_view, *button, *spin; GtkWidget *label; GtkTreeSelection *selection; @@ -2637,6 +2643,9 @@ GtkWidget *create_start_page(void) but this is set safely to the max */ static enum ai_level levels[AI_LEVEL_COUNT]; int i = 0; + int box_row = 0; + int sbox_col = 0; + int grid_row = 0; box = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(box), @@ -2649,22 +2658,22 @@ GtkWidget *create_start_page(void) sbox = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(sbox), 12); - gtk_container_add(GTK_CONTAINER(box), sbox); + gtk_grid_attach(GTK_GRID(box), sbox, 0, box_row++, 1, 1); - vbox = gtk_grid_new(); - g_object_set(vbox, "margin", 12, NULL); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + g_object_set(vgrid, "margin", 12, NULL); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 2); - gtk_widget_set_halign(vbox, GTK_ALIGN_CENTER); - gtk_widget_set_valign(vbox, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(sbox), vbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 2); + gtk_widget_set_halign(vgrid, GTK_ALIGN_CENTER); + gtk_widget_set_valign(vgrid, GTK_ALIGN_CENTER); + gtk_grid_attach(GTK_GRID(sbox), vgrid, sbox_col++, 0, 1, 1); table = gtk_grid_new(); start_options_table = table; gtk_grid_set_row_spacing(GTK_GRID(table), 2); gtk_grid_set_column_spacing(GTK_GRID(table), 12); - gtk_container_add(GTK_CONTAINER(vbox), table); + gtk_grid_attach(GTK_GRID(vgrid), table, 0, grid_row++, 1, 1); spin = gtk_spin_button_new_with_range(1, MAX_NUM_PLAYERS, 1); start_aifill_spin = spin; @@ -2741,7 +2750,7 @@ GtkWidget *create_start_page(void) gtk_widget_set_valign(button, GTK_ALIGN_CENTER); g_signal_connect(button, "clicked", G_CALLBACK(game_options_callback), NULL); - gtk_container_add(GTK_CONTAINER(vbox), button); + gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); connection_list_store = connection_list_store_new(); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(connection_list_store)); @@ -2785,16 +2794,15 @@ GtkWidget *create_start_page(void) GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200); - gtk_container_add(GTK_CONTAINER(sw), view); - gtk_container_add(GTK_CONTAINER(sbox), sw); - + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + gtk_grid_attach(GTK_GRID(sbox), sw, sbox_col++, 0, 1, 1); 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_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(box), sw); + gtk_grid_attach(GTK_GRID(box), sw, 0, box_row++, 1, 1); text = gtk_text_view_new_with_buffer(message_buffer); gtk_widget_set_hexpand(text, TRUE); @@ -2804,18 +2812,17 @@ GtkWidget *create_start_page(void) gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5); gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); - gtk_container_add(GTK_CONTAINER(sw), text); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), text); /* Vote widgets. */ if (pregame_votebar == NULL) { pregame_votebar = voteinfo_bar_new(TRUE); } - gtk_container_add(GTK_CONTAINER(box), pregame_votebar); - + gtk_grid_attach(GTK_GRID(box), pregame_votebar, 0, box_row++, 1, 1); toolkit_view = inputline_toolkit_view_new(); - gtk_container_add(GTK_CONTAINER(box), toolkit_view); + gtk_grid_attach(GTK_GRID(box), toolkit_view, 0, box_row++, 1, 1); button = gtk_button_new_with_mnemonic(_("_Cancel")); inputline_toolkit_view_append_button(toolkit_view, button); @@ -2913,6 +2920,8 @@ GtkWidget *create_load_page(void) GtkWidget *button, *label, *view, *sw; GtkCellRenderer *rend; + int box_row = 0; + int sbox_row = 0; box = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(box), @@ -2945,7 +2954,7 @@ GtkWidget *create_load_page(void) gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(sbox), 2); - gtk_container_add(GTK_CONTAINER(box), sbox); + gtk_grid_attach(GTK_GRID(box), sbox, 0, box_row++, 1, 1); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -2954,33 +2963,33 @@ GtkWidget *create_load_page(void) "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(sbox), label); + gtk_grid_attach(GTK_GRID(sbox), label, 0, sbox_row++, 1, 1); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sw), 300); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), view); - gtk_container_add(GTK_CONTAINER(sbox), sw); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + gtk_grid_attach(GTK_GRID(sbox), sw, 0, sbox_row++, 1, 1); bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_set_hexpand(bbox, TRUE); gtk_box_set_spacing(GTK_BOX(bbox), 12); - gtk_container_add(GTK_CONTAINER(box), bbox); + gtk_grid_attach(GTK_GRID(box), bbox, 0, box_row++, 1, 1); button = gtk_button_new_with_mnemonic(_("_Browse...")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(load_browse_callback), NULL); button = gtk_button_new_with_mnemonic(_("_Cancel")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(main_callback), NULL); button = gtk_button_new_with_mnemonic(_("_OK")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(load_callback), NULL); @@ -3172,19 +3181,23 @@ static void update_scenario_page(void) **************************************************************************/ GtkWidget *create_scenario_page(void) { - GtkWidget *vbox, *hbox, *sbox, *bbox, *filenamebox, *descbox; + GtkWidget *vgrid, *hbox, *sbox, *bbox, *filenamebox, *descbox; GtkWidget *versionbox, *vertext; GtkWidget *button, *label, *view, *sw, *swa, *text; GtkCellRenderer *rend; + int grid_row = 0; + int filenamecol = 0; + int vercol = 0; + int descrow = 0; - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 18); - 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_grid_set_row_spacing(GTK_GRID(vgrid), 18); + 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); scenario_store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, @@ -3217,7 +3230,7 @@ GtkWidget *create_scenario_page(void) "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(vbox), label); + gtk_grid_attach(GTK_GRID(vgrid), label, 0, grid_row++, 1, 1); sbox = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(sbox), 12); @@ -3225,7 +3238,7 @@ GtkWidget *create_scenario_page(void) gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(sbox), 2); - gtk_container_add(GTK_CONTAINER(vbox), sbox); + gtk_grid_attach(GTK_GRID(vgrid), sbox, 0, grid_row++, 1, 1); hbox = gtk_grid_new(); gtk_grid_set_column_homogeneous(GTK_GRID(hbox), TRUE); @@ -3235,7 +3248,7 @@ GtkWidget *create_scenario_page(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); gtk_grid_attach(GTK_GRID(sbox), sw, 0, 0, 1, 2); text = gtk_text_view_new(); @@ -3250,7 +3263,7 @@ GtkWidget *create_scenario_page(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sw), text); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), text); text = gtk_text_view_new(); gtk_widget_set_hexpand(text, TRUE); @@ -3264,7 +3277,7 @@ GtkWidget *create_scenario_page(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(swa), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swa), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(swa), text); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(swa), text); text = gtk_label_new(_("Filename:")); scenario_filename = gtk_label_new(""); @@ -3276,8 +3289,9 @@ GtkWidget *create_scenario_page(void) gtk_grid_set_column_spacing(GTK_GRID(hbox), 12); g_object_set(filenamebox, "margin", 5, NULL); - gtk_container_add(GTK_CONTAINER(filenamebox), text); - gtk_container_add(GTK_CONTAINER(filenamebox), scenario_filename); + gtk_grid_attach(GTK_GRID(filenamebox), text, filenamecol++, 0, 1, 1); + gtk_grid_attach(GTK_GRID(filenamebox), scenario_filename, + filenamecol++, 0, 1, 1); /* TRANS: Scenario format version */ vertext = gtk_label_new(_("Format:")); @@ -3290,39 +3304,42 @@ GtkWidget *create_scenario_page(void) gtk_grid_set_column_spacing(GTK_GRID(hbox), 12); g_object_set(versionbox, "margin", 5, NULL); - gtk_container_add(GTK_CONTAINER(versionbox), vertext); - gtk_container_add(GTK_CONTAINER(versionbox), scenario_version); + gtk_grid_attach(GTK_GRID(versionbox), vertext, vercol++, 0, 1, 1); + gtk_grid_attach(GTK_GRID(versionbox), scenario_version, + vercol++, 0, 1, 1); descbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(descbox), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(descbox), 6); - gtk_container_add(GTK_CONTAINER(descbox), sw); - gtk_container_add(GTK_CONTAINER(descbox), swa); - gtk_container_add(GTK_CONTAINER(descbox), filenamebox); - gtk_container_add(GTK_CONTAINER(descbox), versionbox); + gtk_grid_attach(GTK_GRID(descbox), sw, 0, descrow++, 1, 1); + gtk_grid_attach(GTK_GRID(descbox), swa, 0, descrow++, 1, 1); + gtk_grid_attach(GTK_GRID(descbox), filenamebox, + 0, descrow++, 1, 1); + gtk_grid_attach(GTK_GRID(descbox), versionbox, + 0, descrow++, 1, 1); gtk_grid_attach(GTK_GRID(sbox), descbox, 1, 0, 1, 2); bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_spacing(GTK_BOX(bbox), 12); - gtk_container_add(GTK_CONTAINER(vbox), bbox); + gtk_grid_attach(GTK_GRID(vgrid), bbox, 0, grid_row++, 1, 1); button = gtk_button_new_with_mnemonic(_("_Browse...")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(scenario_browse_callback), NULL); button = gtk_button_new_with_mnemonic(_("_Cancel")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(main_callback), NULL); button = gtk_button_new_with_mnemonic(_("_OK")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(scenario_callback), NULL); - return vbox; + return vgrid; } /**********************************************************************//** diff --git a/client/gui-gtk-4.0/plrdlg.c b/client/gui-gtk-4.0/plrdlg.c index 770919f016..1cdfa9b597 100644 --- a/client/gui-gtk-4.0/plrdlg.c +++ b/client/gui-gtk-4.0/plrdlg.c @@ -466,10 +466,11 @@ void create_players_dialog(void) GtkWidget *menu, *item; enum ai_level level; #endif /* MENUS_GTK3 */ - GtkWidget *vbox; + GtkWidget *vgrid; GtkEventController *left_controller; GtkEventController *right_controller; GtkGesture *gesture; + int grid_row = 0; gui_dialog_new(&players_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE); @@ -570,21 +571,21 @@ void create_players_dialog(void) gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_container_add(GTK_CONTAINER(sw), players_list); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), players_list); gui_dialog_add_content_widget(players_dialog_shell, sw); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(vbox), sep); + gtk_grid_attach(GTK_GRID(vgrid), sep, 0, grid_row++, 1, 1); menubar = gtk_aux_menu_bar_new(); - gtk_container_add(GTK_CONTAINER(vbox), menubar); + gtk_grid_attach(GTK_GRID(vgrid), menubar, 0, grid_row++, 1, 1); - gui_dialog_add_action_widget(players_dialog_shell, vbox); + gui_dialog_add_action_widget(players_dialog_shell, vgrid); #ifdef MENUS_GTK3 item = gtk_menu_item_new_with_mnemonic(_("Di_plomacy")); diff --git a/client/gui-gtk-4.0/rallypointdlg.c b/client/gui-gtk-4.0/rallypointdlg.c index 486f01d588..eb9f4f40eb 100644 --- a/client/gui-gtk-4.0/rallypointdlg.c +++ b/client/gui-gtk-4.0/rallypointdlg.c @@ -67,6 +67,7 @@ void rally_dialog_popup(void) GtkWidget *dlg; GtkWidget *main_box; GtkWidget *sep; + int grid_row = 0; if (rally_dialog_open()) { /* One rally point dialog already open. */ @@ -86,10 +87,10 @@ void rally_dialog_popup(void) GTK_ORIENTATION_VERTICAL); instruction_label = gtk_label_new(_("First click a city.")); - gtk_container_add(GTK_CONTAINER(main_box), instruction_label); + gtk_grid_attach(GTK_GRID(main_box), instruction_label, 0, grid_row++, 1, 1); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(main_box), sep); + gtk_grid_attach(GTK_GRID(main_box), sep, 0, grid_row++, 1, 1); gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), main_box); diff --git a/client/gui-gtk-4.0/repodlgs.c b/client/gui-gtk-4.0/repodlgs.c index 7e7964d39f..444cf7e984 100644 --- a/client/gui-gtk-4.0/repodlgs.c +++ b/client/gui-gtk-4.0/repodlgs.c @@ -574,7 +574,7 @@ static void science_report_init(struct science_report *preport) table = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(table), 4); - gtk_container_add(GTK_CONTAINER(frame), table); + gtk_frame_set_child(GTK_FRAME(frame), table); help_button = gtk_check_button_new_with_label(_("Help")); gtk_grid_attach(GTK_GRID(table), help_button, 5, 0, 1, 1); @@ -606,7 +606,7 @@ static void science_report_init(struct science_report *preport) table = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(table), 4); - gtk_container_add(GTK_CONTAINER(frame),table); + gtk_frame_set_child(GTK_FRAME(frame), table); store = science_report_store_new(); w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); @@ -651,7 +651,7 @@ static void science_report_init(struct science_report *preport) w = science_diagram_new(); gtk_widget_set_hexpand(w, TRUE); gtk_widget_set_vexpand(w, TRUE); - gtk_container_add(GTK_CONTAINER(sw), w); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), w); preport->drawing_area = GTK_FIXED(w); science_report_update(preport); @@ -1106,7 +1106,7 @@ static void economy_report_init(struct economy_report *preport) g_object_unref(store); gtk_widget_set_name(view, "small_font"); gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view)); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); preport->tree_view = GTK_TREE_VIEW(view); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); @@ -1637,7 +1637,7 @@ static void units_report_init(struct units_report *preport) g_object_unref(store); gtk_widget_set_name(view, "small_font"); gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view)); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); preport->tree_view = GTK_TREE_VIEW(view); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); @@ -1913,7 +1913,7 @@ static void endgame_report_init(struct endgame_report *preport) view = gtk_tree_view_new(); gtk_widget_set_name(view, "small_font"); - gtk_container_add(GTK_CONTAINER(sw), view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); preport->tree_view = GTK_TREE_VIEW(view); if (preport->shell->type == GUI_DIALOG_TAB) { diff --git a/client/gui-gtk-4.0/spaceshipdlg.c b/client/gui-gtk-4.0/spaceshipdlg.c index 1481fca445..3323d183e2 100644 --- a/client/gui-gtk-4.0/spaceshipdlg.c +++ b/client/gui-gtk-4.0/spaceshipdlg.c @@ -218,8 +218,9 @@ static void spaceship_response(struct gui_dialog *dlg, int response, struct spaceship_dialog *create_spaceship_dialog(struct player *pplayer) { struct spaceship_dialog *pdialog; - GtkWidget *hbox, *frame; + GtkWidget *hgrid, *frame; int w, h; + int grid_col = 0; pdialog = fc_malloc(sizeof(struct spaceship_dialog)); pdialog->pplayer = pplayer; @@ -236,19 +237,19 @@ struct spaceship_dialog *create_spaceship_dialog(struct player *pplayer) G_CALLBACK(spaceship_destroy_callback), pdialog); gui_dialog_response_set_callback(pdialog->shell, spaceship_response); - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 5); - gui_dialog_add_content_widget(pdialog->shell, hbox); + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 5); + gui_dialog_add_content_widget(pdialog->shell, hgrid); frame = gtk_frame_new(NULL); - gtk_container_add(GTK_CONTAINER(hbox), frame); + gtk_grid_attach(GTK_GRID(hgrid), frame, grid_col++, 0, 1, 1); pdialog->image_canvas = gtk_drawing_area_new(); gtk_widget_set_can_focus(pdialog->image_canvas, TRUE); get_spaceship_dimensions(&w, &h); gtk_widget_set_size_request(pdialog->image_canvas, w, h); - gtk_container_add(GTK_CONTAINER(frame), pdialog->image_canvas); + gtk_frame_set_child(GTK_FRAME(frame), pdialog->image_canvas); gtk_widget_realize(pdialog->image_canvas); g_signal_connect(pdialog->image_canvas, "draw", @@ -260,7 +261,7 @@ struct spaceship_dialog *create_spaceship_dialog(struct player *pplayer) gtk_widget_set_halign(pdialog->info_label, GTK_ALIGN_START); gtk_widget_set_valign(pdialog->info_label, GTK_ALIGN_START); - gtk_container_add(GTK_CONTAINER(hbox), pdialog->info_label); + gtk_grid_attach(GTK_GRID(hgrid), pdialog->info_label, grid_col++, 0, 1, 1); gtk_widget_set_name(pdialog->info_label, "spaceship_label"); dialog_list_prepend(dialog_list, pdialog); diff --git a/client/gui-gtk-4.0/unitselect.c b/client/gui-gtk-4.0/unitselect.c index 250baba069..82e6ac3925 100644 --- a/client/gui-gtk-4.0/unitselect.c +++ b/client/gui-gtk-4.0/unitselect.c @@ -387,10 +387,13 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, const char *title, enum unit_select_location_mode loc) { - GtkWidget *page, *label, *hbox, *vbox, *view, *sw; + GtkWidget *page, *label, *hgrid, *vgrid, *view, *sw; GtkTreeStore *store; static bool titles_done; int i; + int page_row = 0; + int grid_col = 0; + int grid_row = 0; page = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(page), @@ -404,8 +407,8 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, label = gtk_label_new_with_mnemonic(title); gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label); - hbox = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(page), hbox); + hgrid = gtk_grid_new(); + gtk_grid_attach(GTK_GRID(page), hgrid, 0, page_row++, 1, 1); store = usdlg_tab_store_new(); pdialog->tabs[loc].store = store; @@ -462,20 +465,21 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, 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_container_add(GTK_CONTAINER(sw), view); - gtk_container_add(GTK_CONTAINER(hbox), sw); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); + gtk_grid_attach(GTK_GRID(hgrid), sw, grid_col++, 0, 1, 1); - vbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(hbox), vbox); + gtk_grid_attach(GTK_GRID(hgrid), vgrid, grid_col++, 0, 1, 1); /* button box 1: ready, sentry */ pdialog->tabs[loc].cmd[USDLG_CMD_READY] = gtk_button_new_with_mnemonic(_("Ready")); - gtk_container_add(GTK_CONTAINER(vbox), - pdialog->tabs[loc].cmd[USDLG_CMD_READY]); + gtk_grid_attach(GTK_GRID(vgrid), + pdialog->tabs[loc].cmd[USDLG_CMD_READY], + 0, grid_row++, 1, 1); g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_READY], "clicked", G_CALLBACK(usdlg_cmd_ready), GINT_TO_POINTER(loc)); gtk_widget_set_sensitive( @@ -485,8 +489,9 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, = gtk_button_new_with_mnemonic(_("Sentry")); gtk_widget_set_margin_bottom( GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY]), 10); - gtk_container_add(GTK_CONTAINER(vbox), - pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY]); + gtk_grid_attach(GTK_GRID(vgrid), + pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY], + 0, grid_row++, 1, 1); g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY], "clicked", G_CALLBACK(usdlg_cmd_sentry), GINT_TO_POINTER(loc)); gtk_widget_set_sensitive( @@ -496,8 +501,9 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, pdialog->tabs[loc].cmd[USDLG_CMD_SELECT] = gtk_button_new_with_mnemonic(_("_Select")); - gtk_container_add(GTK_CONTAINER(vbox), - pdialog->tabs[loc].cmd[USDLG_CMD_SELECT]); + gtk_grid_attach(GTK_GRID(vgrid), + pdialog->tabs[loc].cmd[USDLG_CMD_SELECT], + 0, grid_row++, 1, 1); g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_SELECT], "clicked", G_CALLBACK(usdlg_cmd_select), GINT_TO_POINTER(loc)); gtk_widget_set_sensitive( @@ -507,8 +513,9 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, = gtk_button_new_with_mnemonic(_("_Deselect")); gtk_widget_set_margin_bottom( GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT]), 10); - gtk_container_add(GTK_CONTAINER(vbox), - pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT]); + gtk_grid_attach(GTK_GRID(vgrid), + pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT], + 0, grid_row++, 1, 1); g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT], "clicked", G_CALLBACK(usdlg_cmd_deselect), GINT_TO_POINTER(loc)); gtk_widget_set_sensitive( @@ -518,8 +525,9 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, pdialog->tabs[loc].cmd[USDLG_CMD_CENTER] = gtk_button_new_with_mnemonic(_("C_enter")); - gtk_container_add(GTK_CONTAINER(vbox), - pdialog->tabs[loc].cmd[USDLG_CMD_CENTER]); + gtk_grid_attach(GTK_GRID(vgrid), + pdialog->tabs[loc].cmd[USDLG_CMD_CENTER], + 0, grid_row++, 1, 1); g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_CENTER], "clicked", G_CALLBACK(usdlg_cmd_center), GINT_TO_POINTER(loc)); gtk_widget_set_sensitive( @@ -527,8 +535,9 @@ static void usdlg_tab_select(struct unit_select_dialog *pdialog, pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS] = gtk_button_new_with_mnemonic(_("_Focus")); - gtk_container_add(GTK_CONTAINER(vbox), - pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS]); + gtk_grid_attach(GTK_GRID(vgrid), + pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS], + 0, grid_row++, 1, 1); g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS], "clicked", G_CALLBACK(usdlg_cmd_focus), GINT_TO_POINTER(loc)); gtk_widget_set_sensitive( diff --git a/client/gui-gtk-4.0/unitselextradlg.c b/client/gui-gtk-4.0/unitselextradlg.c index 85e452bb99..c15adaf59b 100644 --- a/client/gui-gtk-4.0/unitselextradlg.c +++ b/client/gui-gtk-4.0/unitselextradlg.c @@ -125,6 +125,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, const struct unit_type *actor_type = unit_type_get(actor); int tcount; const struct extra_type *default_extra; + int main_row = 0; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -155,13 +156,13 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, lbl = gtk_label_new(utype_name_translation(actor_type)); gtk_grid_attach(GTK_GRID(box), lbl, 2, 0, 1, 1); - gtk_container_add(GTK_CONTAINER(main_box), box); + gtk_grid_attach(GTK_GRID(main_box), box, 0, main_row++, 1, 1); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(main_box), sep); + gtk_grid_attach(GTK_GRID(main_box), sep, 0, main_row++, 1, 1); lbl = gtk_label_new(tgt_label); - gtk_container_add(GTK_CONTAINER(main_box), lbl); + gtk_grid_attach(GTK_GRID(main_box), lbl, 0, main_row++, 1, 1); box = gtk_grid_new(); @@ -218,7 +219,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, tcount++; } extra_type_re_active_iterate_end; - gtk_container_add(GTK_CONTAINER(main_box), box); + gtk_grid_attach(GTK_GRID(main_box), box, 0, main_row++, 1, 1); fc_assert_ret_val(default_option, FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(default_option), TRUE); diff --git a/client/gui-gtk-4.0/unitselunitdlg.c b/client/gui-gtk-4.0/unitselunitdlg.c index 5d12e0785e..5f71d483d2 100644 --- a/client/gui-gtk-4.0/unitselunitdlg.c +++ b/client/gui-gtk-4.0/unitselunitdlg.c @@ -89,6 +89,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, const struct unit_type *actor_type = unit_type_get(actor); int tcount; const struct unit *default_unit; + int main_row = 0; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -119,13 +120,13 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, lbl = gtk_label_new(utype_name_translation(actor_type)); gtk_grid_attach(GTK_GRID(box), lbl, 2, 0, 1, 1); - gtk_container_add(GTK_CONTAINER(main_box), box); + gtk_grid_attach(GTK_GRID(main_box), box, 0, main_row++, 1, 1); sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); - gtk_container_add(GTK_CONTAINER(main_box), sep); + gtk_grid_attach(GTK_GRID(main_box), sep, 0, main_row++, 1, 1); lbl = gtk_label_new(tgt_label); - gtk_container_add(GTK_CONTAINER(main_box), lbl); + gtk_grid_attach(GTK_GRID(main_box), lbl, 0, main_row++, 1, 1); box = gtk_grid_new(); @@ -178,7 +179,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, tcount++; } unit_list_iterate_end; - gtk_container_add(GTK_CONTAINER(main_box), box); + gtk_grid_attach(GTK_GRID(main_box), box, 0, main_row++, 1, 1); fc_assert_ret_val(default_option, FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(default_option), TRUE); diff --git a/client/gui-gtk-4.0/voteinfo_bar.c b/client/gui-gtk-4.0/voteinfo_bar.c index 10b590695f..4ae1e589ac 100644 --- a/client/gui-gtk-4.0/voteinfo_bar.c +++ b/client/gui-gtk-4.0/voteinfo_bar.c @@ -92,31 +92,33 @@ static void voteinfo_bar_destroy(GtkWidget *w, gpointer userdata) **************************************************************************/ GtkWidget *voteinfo_bar_new(bool split_bar) { - GtkWidget *label, *button, *vbox, *hbox; + GtkWidget *label, *button, *vgrid, *hgrid; struct voteinfo_bar *vib; const int BUTTON_HEIGHT = 12; + int grid_row = 0; + int grid_col = 0; vib = fc_calloc(1, sizeof(struct voteinfo_bar)); if (!split_bar) { - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - g_object_set_data(G_OBJECT(hbox), "voteinfo_bar", vib); - g_signal_connect(hbox, "destroy", G_CALLBACK(voteinfo_bar_destroy), vib); - vib->box = hbox; - vbox = NULL; /* The compiler may require it. */ + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + g_object_set_data(G_OBJECT(hgrid), "voteinfo_bar", vib); + g_signal_connect(hgrid, "destroy", G_CALLBACK(voteinfo_bar_destroy), vib); + vib->box = hgrid; + vgrid = NULL; /* The compiler may require it. */ } else { - vbox = gtk_grid_new(); - gtk_grid_set_row_homogeneous(GTK_GRID(vbox), TRUE); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + vgrid = gtk_grid_new(); + gtk_grid_set_row_homogeneous(GTK_GRID(vgrid), TRUE); + gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid), GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 4); - g_object_set_data(G_OBJECT(vbox), "voteinfo_bar", vib); - g_signal_connect(vbox, "destroy", G_CALLBACK(voteinfo_bar_destroy), vib); - vib->box = vbox; - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4); + g_object_set_data(G_OBJECT(vgrid), "voteinfo_bar", vib); + g_signal_connect(vgrid, "destroy", G_CALLBACK(voteinfo_bar_destroy), vib); + vib->box = vgrid; + hgrid = gtk_grid_new(); + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); } label = gtk_label_new(""); @@ -128,14 +130,15 @@ GtkWidget *voteinfo_bar_new(bool split_bar) gtk_widget_set_margin_top(label, 4); gtk_widget_set_margin_bottom(label, 4); gtk_label_set_max_width_chars(GTK_LABEL(label), 80); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); gtk_widget_set_name(label, "vote label"); vib->label = label; if (split_bar) { - hbox = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hbox), 4); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + hgrid = gtk_grid_new(); + grid_col = 0; + gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4); + gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1); } button = gtk_button_new(); @@ -146,7 +149,7 @@ GtkWidget *voteinfo_bar_new(bool split_bar) gtk_widget_set_size_request(button, -1, BUTTON_HEIGHT); gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_focus_on_click(button, FALSE); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); vib->next_button = button; button = gtk_button_new_with_mnemonic(_("_YES")); @@ -154,14 +157,14 @@ GtkWidget *voteinfo_bar_new(bool split_bar) G_CALLBACK(voteinfo_bar_do_vote_callback), GINT_TO_POINTER(CVT_YES)); gtk_widget_set_focus_on_click(button, FALSE); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); gtk_widget_set_name(button, "vote yes button"); vib->yes_button = button; label = gtk_label_new("0"); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); vib->yes_count_label = label; button = gtk_button_new_with_mnemonic(_("_NO")); @@ -169,14 +172,14 @@ GtkWidget *voteinfo_bar_new(bool split_bar) G_CALLBACK(voteinfo_bar_do_vote_callback), GINT_TO_POINTER(CVT_NO)); gtk_widget_set_focus_on_click(button, FALSE); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); gtk_widget_set_name(button, "vote no button"); vib->no_button = button; label = gtk_label_new("0"); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); vib->no_count_label = label; button = gtk_button_new_with_mnemonic(_("_ABSTAIN")); @@ -184,20 +187,20 @@ GtkWidget *voteinfo_bar_new(bool split_bar) G_CALLBACK(voteinfo_bar_do_vote_callback), GINT_TO_POINTER(CVT_ABSTAIN)); gtk_widget_set_focus_on_click(button, FALSE); - gtk_container_add(GTK_CONTAINER(hbox), button); + gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1); gtk_widget_set_name(button, "vote abstain button"); vib->abstain_button = button; label = gtk_label_new("0"); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); vib->abstain_count_label = label; label = gtk_label_new("/0"); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); - gtk_container_add(GTK_CONTAINER(hbox), label); + gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1); vib->voter_count_label = label; return vib->box; diff --git a/client/gui-gtk-4.0/wldlg.c b/client/gui-gtk-4.0/wldlg.c index 367b200229..b76b054249 100644 --- a/client/gui-gtk-4.0/wldlg.c +++ b/client/gui-gtk-4.0/wldlg.c @@ -211,8 +211,9 @@ static void cell_edited(GtkCellRendererText *cell, static GtkWidget *create_worklists_report(void) { GtkWidget *shell, *list; - GtkWidget *vbox, *label, *sw; + GtkWidget *vgrid, *label, *sw; GtkCellRenderer *rend; + int grid_row = 0; shell = gtk_dialog_new_with_buttons(_("Edit worklists"), NULL, @@ -233,11 +234,11 @@ static GtkWidget *create_worklists_report(void) g_signal_connect(shell, "destroy", G_CALLBACK(worklists_destroy_callback), NULL); - vbox = gtk_grid_new(); - gtk_grid_set_row_spacing(GTK_GRID(vbox), 2); - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + 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))), vbox); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), vgrid); worklists_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); @@ -261,8 +262,8 @@ static GtkWidget *create_worklists_report(void) gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 200); 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_ALWAYS); - gtk_container_add(GTK_CONTAINER(sw), list); + GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), list); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -270,9 +271,9 @@ static GtkWidget *create_worklists_report(void) "label", _("_Worklists:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(vbox), label); - gtk_container_add(GTK_CONTAINER(vbox), sw); - gtk_widget_show(vbox); + 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); return shell; } @@ -1076,6 +1077,7 @@ GtkWidget *create_worklist(void) GtkSizeGroup *group; GtkListStore *src_store, *dst_store; struct worklist_data *ptr; + int editor_row = 0; ptr = fc_malloc(sizeof(*ptr)); @@ -1100,7 +1102,7 @@ GtkWidget *create_worklist(void) /* add source and target lists. */ table = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(editor), table); + gtk_grid_attach(GTK_GRID(editor), table, 0, editor_row++, 1, 1); group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); @@ -1118,7 +1120,7 @@ GtkWidget *create_worklist(void) gtk_widget_set_name(src_view, "small_font"); populate_view(GTK_TREE_VIEW(src_view), &ptr->pcity, &ptr->src_col); - gtk_container_add(GTK_CONTAINER(sw), src_view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), src_view); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -1142,7 +1144,7 @@ GtkWidget *create_worklist(void) gtk_grid_attach(GTK_GRID(table2), button, 0, 0, 1, 1); arrow = gtk_image_new_from_icon_name("pan-start-symbolic"); - gtk_container_add(GTK_CONTAINER(button), arrow); + gtk_button_set_child(GTK_BUTTON(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_prepend), ptr); gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE); @@ -1153,7 +1155,7 @@ GtkWidget *create_worklist(void) gtk_grid_attach(GTK_GRID(table2), button, 0, 1, 1, 1); arrow = gtk_image_new_from_icon_name("pan-up-symbolic"); - gtk_container_add(GTK_CONTAINER(button), arrow); + gtk_button_set_child(GTK_BUTTON(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_bubble_up), ptr); gtk_widget_set_sensitive(ptr->up_cmd, FALSE); @@ -1164,7 +1166,7 @@ GtkWidget *create_worklist(void) gtk_grid_attach(GTK_GRID(table2), button, 0, 2, 1, 1); arrow = gtk_image_new_from_icon_name("pan-down-symbolic"); - gtk_container_add(GTK_CONTAINER(button), arrow); + gtk_button_set_child(GTK_BUTTON(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_bubble_down), ptr); gtk_widget_set_sensitive(ptr->down_cmd, FALSE); @@ -1177,7 +1179,7 @@ GtkWidget *create_worklist(void) gtk_grid_attach(GTK_GRID(table2), button, 0, 3, 1, 1); arrow = gtk_image_new_from_icon_name("pan-start-symbolic"); - gtk_container_add(GTK_CONTAINER(button), arrow); + gtk_button_set_child(GTK_BUTTON(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_append), ptr); gtk_widget_set_sensitive(ptr->append_cmd, FALSE); @@ -1190,7 +1192,7 @@ GtkWidget *create_worklist(void) gtk_grid_attach(GTK_GRID(table2), button, 0, 4, 1, 1); arrow = gtk_image_new_from_icon_name("pan-end-symbolic"); - gtk_container_add(GTK_CONTAINER(button), arrow); + gtk_button_set_child(GTK_BUTTON(button), arrow); g_signal_connect_swapped(button, "clicked", G_CALLBACK(queue_remove), ptr); gtk_widget_set_sensitive(ptr->remove_cmd, FALSE); @@ -1209,7 +1211,7 @@ GtkWidget *create_worklist(void) gtk_widget_set_name(dst_view, "small_font"); populate_view(GTK_TREE_VIEW(dst_view), &ptr->pcity, &ptr->dst_col); - gtk_container_add(GTK_CONTAINER(sw), dst_view); + gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), dst_view); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -1221,10 +1223,10 @@ GtkWidget *create_worklist(void) /* add bottom menu and buttons. */ bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_spacing(GTK_BOX(bbox), 10); - gtk_container_add(GTK_CONTAINER(editor), bbox); + gtk_grid_attach(GTK_GRID(editor), bbox, 0, editor_row++, 1, 1); menubar = gtk_aux_menu_bar_new(); - gtk_container_add(GTK_CONTAINER(bbox), menubar); + gtk_box_append(GTK_BOX(bbox), menubar); #ifdef MENUS_GTK3 menu = gtk_menu_button_new(); @@ -1239,14 +1241,14 @@ GtkWidget *create_worklist(void) gtk_widget_set_sensitive(ptr->add_cmd, FALSE); button = icon_label_button_new("help-browser", _("Help")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(help_callback), ptr); ptr->help_cmd = button; gtk_widget_set_sensitive(ptr->help_cmd, FALSE); button = gtk_button_new_with_mnemonic(_("Change Prod_uction")); - gtk_container_add(GTK_CONTAINER(bbox), button); + gtk_box_append(GTK_BOX(bbox), button); g_signal_connect(button, "clicked", G_CALLBACK(change_callback), ptr); ptr->change_cmd = button; -- 2.33.0