From 0fda625f18cbd8b04bc5f848f48422206d798f28 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 13 Nov 2021 22:19:35 +0200 Subject: [PATCH 32/32] gtk3x: Add gui_dialog_vgrid_add() Use it instead of gtk_container_add() to add widgets to gui_dialog. It's implemented using gtk_grid_attach() instead of the gtk_container_add() that's going to be dropped from gtk-3.98.4 See osdn #43210 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/cityrep.c | 2 +- client/gui-gtk-4.0/dialogs.c | 2 +- client/gui-gtk-4.0/diplodlg.c | 16 +++----- client/gui-gtk-4.0/finddlg.c | 6 +-- client/gui-gtk-4.0/gui_stuff.c | 62 +++++++++++++++++-------------- client/gui-gtk-4.0/gui_stuff.h | 5 ++- client/gui-gtk-4.0/luaconsole.c | 6 +-- client/gui-gtk-4.0/messagedlg.c | 4 +- client/gui-gtk-4.0/messagewin.c | 4 +- client/gui-gtk-4.0/plrdlg.c | 2 +- client/gui-gtk-4.0/repodlgs.c | 22 ++++------- client/gui-gtk-4.0/spaceshipdlg.c | 4 +- 12 files changed, 66 insertions(+), 69 deletions(-) diff --git a/client/gui-gtk-4.0/cityrep.c b/client/gui-gtk-4.0/cityrep.c index 0876ad098b..92a3d752a1 100644 --- a/client/gui-gtk-4.0/cityrep.c +++ b/client/gui-gtk-4.0/cityrep.c @@ -1243,7 +1243,7 @@ static void create_city_report_dialog(bool make_modal) GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_container_add(GTK_CONTAINER(sw), city_view); - gtk_container_add(GTK_CONTAINER(city_dialog_shell->vbox), sw); + gui_dialog_vgrid_add(city_dialog_shell, sw); city_model_fill(city_model, NULL, NULL); gui_dialog_show_all(city_dialog_shell); diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index 3d7e9643f6..13ec07e98a 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -115,7 +115,7 @@ void popup_notify_dialog(const char *caption, const char *headline, gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(vbox), 2); - gtk_container_add(GTK_CONTAINER(shell->vbox), vbox); + gui_dialog_vgrid_add(shell, vbox); headline_label = gtk_label_new(headline); gtk_container_add(GTK_CONTAINER(vbox), headline_label); diff --git a/client/gui-gtk-4.0/diplodlg.c b/client/gui-gtk-4.0/diplodlg.c index 46121025c8..3af99d2bb9 100644 --- a/client/gui-gtk-4.0/diplodlg.c +++ b/client/gui-gtk-4.0/diplodlg.c @@ -484,7 +484,7 @@ static struct Diplomacy_notebook *diplomacy_main_create(void) { /* Collect all meetings in one main tab. */ if (!dipl_main) { - GtkWidget *dipl_box, *dipl_sw; + GtkWidget *dipl_sw; dipl_main = fc_malloc(sizeof(*dipl_main)); gui_dialog_new(&(dipl_main->dialog), GTK_NOTEBOOK(top_notebook), @@ -510,8 +510,7 @@ static struct Diplomacy_notebook *diplomacy_main_create(void) gui_dialog_response_set_callback(dipl_main->dialog, diplomacy_main_response); - dipl_box = dipl_main->dialog->vbox; - gtk_container_add(GTK_CONTAINER(dipl_box), dipl_sw); + gui_dialog_vgrid_add(dipl_main->dialog, dipl_sw); gui_dialog_show_all(dipl_main->dialog); gui_dialog_present(dipl_main->dialog); @@ -682,15 +681,12 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, if (fc_strcasecmp(buf, prev_label) < 0) { gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook), - pdialog->dialog->vbox, i); + pdialog->dialog->vgrid, i); break; } } g_free(buf); - /* Content. */ - mainbox = pdialog->dialog->vbox; - /* us. */ vbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), @@ -700,7 +696,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, gtk_widget_set_margin_end(vbox, 2); gtk_widget_set_margin_top(vbox, 2); gtk_widget_set_margin_bottom(vbox, 2); - gtk_container_add(GTK_CONTAINER(mainbox), vbox); + gui_dialog_vgrid_add(pdialog->dialog, vbox); /* Our nation. */ label = gtk_label_new(NULL); @@ -787,7 +783,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, gtk_widget_set_margin_end(vbox, 2); gtk_widget_set_margin_top(vbox, 2); gtk_widget_set_margin_bottom(vbox, 2); - gtk_container_add(GTK_CONTAINER(mainbox), vbox); + gui_dialog_vgrid_add(pdialog->dialog, vbox); /* Their nation. */ label = gtk_label_new(NULL); @@ -869,7 +865,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, mainbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(mainbox), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(pdialog->dialog->vbox), mainbox); + gui_dialog_vgrid_add(pdialog->dialog, mainbox); store = gtk_list_store_new(1, G_TYPE_STRING); pdialog->store = store; diff --git a/client/gui-gtk-4.0/finddlg.c b/client/gui-gtk-4.0/finddlg.c index 0722d8fa30..fe665536a6 100644 --- a/client/gui-gtk-4.0/finddlg.c +++ b/client/gui-gtk-4.0/finddlg.c @@ -79,7 +79,7 @@ void popup_find_dialog(void) gui_dialog_response_set_callback(find_dialog_shell, find_response); - g_signal_connect(find_dialog_shell->vbox, "destroy", + g_signal_connect(find_dialog_shell->vgrid, "destroy", G_CALLBACK(find_destroy_callback), NULL); store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); @@ -113,8 +113,8 @@ void popup_find_dialog(void) "mnemonic-widget", find_view, "label", _("Ci_ties:"), "xalign", 0.0, "yalign", 0.5, NULL); - gtk_container_add(GTK_CONTAINER(find_dialog_shell->vbox), label); - gtk_container_add(GTK_CONTAINER(find_dialog_shell->vbox), sw); + gui_dialog_vgrid_add(find_dialog_shell, label); + gui_dialog_vgrid_add(find_dialog_shell, sw); g_signal_connect(selection, "changed", G_CALLBACK(find_selection_callback), store); diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index 0f6b17f182..4fa08c2263 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -422,7 +422,7 @@ static void gui_dialog_switch_page_handler(GtkNotebook *notebook, { gint n; - n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vbox); + n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vgrid); if (n == num) { GtkStyleContext *context = gtk_widget_get_style_context(dlg->v.tab.label); @@ -448,14 +448,14 @@ static void gui_dialog_detach(struct gui_dialog* dlg) /* Create a new reference to the main widget, so it won't be * destroyed in gtk_notebook_remove_page() */ - g_object_ref(dlg->vbox); + g_object_ref(dlg->vgrid); /* Remove widget from the notebook */ notebook = dlg->v.tab.notebook; handler_id = dlg->v.tab.handler_id; g_signal_handler_disconnect(notebook, handler_id); - n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vbox); + n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vgrid); gtk_notebook_remove_page(GTK_NOTEBOOK(dlg->v.tab.notebook), n); @@ -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->vbox); + gtk_container_add(GTK_CONTAINER(window), dlg->vgrid); dlg->v.window = window; g_signal_connect(window, "close-request", G_CALLBACK(gui_dialog_delete_handler), dlg); @@ -512,7 +512,7 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top) { struct gui_dialog *dlg; - GtkWidget *vbox, *action_area; + GtkWidget *action_area; static int dialog_id_counter; dlg = fc_malloc(sizeof(*dlg)); @@ -537,7 +537,8 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, } dlg->gui_button = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); - vbox = gtk_grid_new(); + dlg->vgrid = gtk_grid_new(); + dlg->row = 0; action_area = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(action_area), 4); gtk_grid_set_column_spacing(GTK_GRID(action_area), 4); @@ -551,18 +552,18 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, } else { /* We expect this to be reasonably tall; maximise usable width by * putting buttons along the bottom */ - gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), + gtk_orientable_set_orientation(GTK_ORIENTABLE(dlg->vgrid), GTK_ORIENTATION_VERTICAL); } - gtk_widget_show(vbox); - gtk_container_add(GTK_CONTAINER(vbox), action_area); + gtk_widget_show(dlg->vgrid); + gui_dialog_vgrid_add(dlg, action_area); gtk_widget_show(action_area); - 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); + gtk_widget_set_margin_start(dlg->vgrid, 2); + gtk_widget_set_margin_end(dlg->vgrid, 2); + gtk_widget_set_margin_top(dlg->vgrid, 2); + gtk_widget_set_margin_bottom(dlg->vgrid, 2); gtk_widget_set_margin_start(action_area, 2); gtk_widget_set_margin_end(action_area, 2); @@ -578,7 +579,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), vbox); + gtk_container_add(GTK_CONTAINER(window), dlg->vgrid); dlg->v.window = window; g_signal_connect(window, "close-request", G_CALLBACK(gui_dialog_delete_handler), dlg); @@ -616,11 +617,11 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gtk_widget_show(hbox); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, hbox); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dlg->vgrid, hbox); dlg->v.tab.handler_id = g_signal_connect(notebook, "switch-page", G_CALLBACK(gui_dialog_switch_page_handler), dlg); - dlg->v.tab.child = vbox; + dlg->v.tab.child = dlg->vgrid; gtk_style_context_add_provider(gtk_widget_get_style_context(label), GTK_STYLE_PROVIDER(dlg_tab_provider), @@ -634,7 +635,6 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, break; } - dlg->vbox = vbox; dlg->action_area = action_area; dlg->response_callback = gui_dialog_destroyed; @@ -643,12 +643,12 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, dialog_id_counter++; dlg->return_dialog_id = -1; - g_signal_connect(vbox, "destroy", + g_signal_connect(dlg->vgrid, "destroy", G_CALLBACK(gui_dialog_destroy_handler), dlg); - g_signal_connect(vbox, "key_press_event", + g_signal_connect(dlg->vgrid, "key_press_event", G_CALLBACK(gui_dialog_key_press_handler), dlg); - g_object_set_data(G_OBJECT(vbox), "gui-dialog-data", dlg); + g_object_set_data(G_OBJECT(dlg->vgrid), "gui-dialog-data", dlg); } /**********************************************************************//** @@ -681,7 +681,7 @@ static void gui_dialog_pack_button(struct gui_dialog *dlg, GtkWidget *button, GClosure *closure; closure = g_cclosure_new_object(G_CALLBACK(action_widget_activated), - G_OBJECT(dlg->vbox)); + G_OBJECT(dlg->vgrid)); g_signal_connect_closure_by_id(button, signal_id, 0, closure, FALSE); } @@ -749,7 +749,7 @@ void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, **************************************************************************/ GtkWidget *gui_dialog_get_toplevel(struct gui_dialog *dlg) { - return gtk_widget_get_ancestor(dlg->vbox, GTK_TYPE_WINDOW); + return gtk_widget_get_ancestor(dlg->vgrid, GTK_TYPE_WINDOW); } /**********************************************************************//** @@ -757,7 +757,7 @@ GtkWidget *gui_dialog_get_toplevel(struct gui_dialog *dlg) **************************************************************************/ void gui_dialog_show_all(struct gui_dialog *dlg) { - gtk_widget_show(dlg->vbox); + gtk_widget_show(dlg->vgrid); if (dlg->type == GUI_DIALOG_TAB) { GList *children; @@ -809,7 +809,7 @@ void gui_dialog_present(struct gui_dialog *dlg) gint current, n; current = gtk_notebook_get_current_page(notebook); - n = gtk_notebook_page_num(notebook, dlg->vbox); + n = gtk_notebook_page_num(notebook, dlg->vgrid); if (current != n) { GtkWidget *label = dlg->v.tab.label; @@ -838,7 +838,7 @@ void gui_dialog_raise(struct gui_dialog *dlg) GtkNotebook *notebook = GTK_NOTEBOOK(dlg->v.tab.notebook); gint n; - n = gtk_notebook_page_num(notebook, dlg->vbox); + n = gtk_notebook_page_num(notebook, dlg->vgrid); gtk_notebook_set_current_page(notebook, n); } break; @@ -861,7 +861,7 @@ void gui_dialog_alert(struct gui_dialog *dlg) gint current, n; current = gtk_notebook_get_current_page(notebook); - n = gtk_notebook_page_num(notebook, dlg->vbox); + n = gtk_notebook_page_num(notebook, dlg->vgrid); if (current != n) { GtkWidget *label = dlg->v.tab.label; @@ -924,7 +924,7 @@ void gui_dialog_destroy(struct gui_dialog *dlg) { gint n; - n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vbox); + n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->vgrid); gtk_notebook_remove_page(GTK_NOTEBOOK(dlg->v.tab.notebook), n); } break; @@ -1123,3 +1123,11 @@ void dlg_tab_provider_prepare(void) "}\n", -1); } + +/**********************************************************************//** + Add widget to the gui_dialog vgrid +**************************************************************************/ +void gui_dialog_vgrid_add(struct gui_dialog *dlg, GtkWidget *wdg) +{ + gtk_grid_attach(GTK_GRID(dlg->vgrid), wdg, 0, dlg->row++, 1, 1); +} diff --git a/client/gui-gtk-4.0/gui_stuff.h b/client/gui-gtk-4.0/gui_stuff.h index 450352d709..37bc0cf80e 100644 --- a/client/gui-gtk-4.0/gui_stuff.h +++ b/client/gui-gtk-4.0/gui_stuff.h @@ -68,7 +68,7 @@ typedef void (*GUI_DIALOG_RESPONSE_FUN)(struct gui_dialog *, int, gpointer); struct gui_dialog { /* public. */ - GtkWidget *vbox; + GtkWidget *vgrid; GtkWidget *action_area; /* private. */ @@ -80,6 +80,8 @@ struct gui_dialog int default_width; int default_height; + int row; + union { GtkWidget *window; struct { @@ -107,6 +109,7 @@ GtkWidget *gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response); GtkWidget *gui_dialog_add_widget(struct gui_dialog *dlg, GtkWidget *widget); +void gui_dialog_vgrid_add(struct gui_dialog *dlg, GtkWidget *wdg); void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height); void gui_dialog_set_title(struct gui_dialog *dlg, const char *title); diff --git a/client/gui-gtk-4.0/luaconsole.c b/client/gui-gtk-4.0/luaconsole.c index 9a294710f2..3cb2976e31 100644 --- a/client/gui-gtk-4.0/luaconsole.c +++ b/client/gui-gtk-4.0/luaconsole.c @@ -182,7 +182,7 @@ void real_luaconsole_dialog_update(void) *****************************************************************************/ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) { - GtkWidget *entry, *box, *vbox, *sw, *text, *notebook; + GtkWidget *entry, *vbox, *sw, *text, *notebook; fc_assert_ret(NULL != pdialog); @@ -195,12 +195,10 @@ 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")); - box = pdialog->shell->vbox; - vbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(box), vbox); + gui_dialog_vgrid_add(pdialog->shell, vbox); sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE); diff --git a/client/gui-gtk-4.0/messagedlg.c b/client/gui-gtk-4.0/messagedlg.c index 0a8f4112a9..da461659fa 100644 --- a/client/gui-gtk-4.0/messagedlg.c +++ b/client/gui-gtk-4.0/messagedlg.c @@ -81,11 +81,11 @@ static void create_messageopt_dialog(void) "Messages window ; " "Popup individual window")); gtk_widget_set_name(explanation, "comment_label"); - gtk_container_add(GTK_CONTAINER(shell->vbox), explanation); + gui_dialog_vgrid_add(shell, explanation); gtk_widget_show(explanation); form = gtk_grid_new(); - gtk_container_add(GTK_CONTAINER(shell->vbox), form); + gui_dialog_vgrid_add(shell, form); for (n = 0; n < NUM_LISTS; n++) { models[n] = gtk_list_store_new(5, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, diff --git a/client/gui-gtk-4.0/messagewin.c b/client/gui-gtk-4.0/messagewin.c index c9b7a0f960..a26d8e965f 100644 --- a/client/gui-gtk-4.0/messagewin.c +++ b/client/gui-gtk-4.0/messagewin.c @@ -323,7 +323,6 @@ static void meswin_dialog_response_callback(struct gui_dialog *pgui_dialog, static void meswin_dialog_init(struct meswin_dialog *pdialog) { GtkWidget *view, *sw, *cmd, *notebook; - GtkContainer *vbox; GtkListStore *store; GtkTreeSelection *selection; GtkCellRenderer *renderer; @@ -339,13 +338,12 @@ static void meswin_dialog_init(struct meswin_dialog *pdialog) gui_dialog_new(&pdialog->shell, GTK_NOTEBOOK(notebook), pdialog, TRUE); gui_dialog_set_title(pdialog->shell, _("Messages")); - vbox = GTK_CONTAINER(pdialog->shell->vbox); 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(vbox, sw); + gui_dialog_vgrid_add(pdialog->shell, sw); store = meswin_dialog_store_new(); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); diff --git a/client/gui-gtk-4.0/plrdlg.c b/client/gui-gtk-4.0/plrdlg.c index 7b61bd982e..d08f31330f 100644 --- a/client/gui-gtk-4.0/plrdlg.c +++ b/client/gui-gtk-4.0/plrdlg.c @@ -572,7 +572,7 @@ void create_players_dialog(void) GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_container_add(GTK_CONTAINER(sw), players_list); - gtk_container_add(GTK_CONTAINER(players_dialog_shell->vbox), sw); + gui_dialog_vgrid_add(players_dialog_shell, sw); vbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), diff --git a/client/gui-gtk-4.0/repodlgs.c b/client/gui-gtk-4.0/repodlgs.c index 12ab4b89cf..30e9963ad9 100644 --- a/client/gui-gtk-4.0/repodlgs.c +++ b/client/gui-gtk-4.0/repodlgs.c @@ -550,7 +550,6 @@ static void science_report_init(struct science_report *preport) { GtkWidget *frame, *table, *help_button, *show_all_button, *sw, *w; GtkSizeGroup *group; - GtkContainer *vbox; GtkListStore *store; GtkCellRenderer *renderer; @@ -563,16 +562,15 @@ static void science_report_init(struct science_report *preport) gui_dialog_add_button(preport->shell, "window-close", _("_Close"), GTK_RESPONSE_CLOSE); - vbox = GTK_CONTAINER(preport->shell->vbox); group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); w = gtk_label_new(NULL); - gtk_container_add(vbox, w); + gui_dialog_vgrid_add(preport->shell, w); preport->main_label = GTK_LABEL(w); /* Current research target line. */ frame = gtk_frame_new(_("Researching")); - gtk_container_add(vbox, frame); + gui_dialog_vgrid_add(preport->shell, frame); table = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(table), 4); @@ -604,7 +602,7 @@ static void science_report_init(struct science_report *preport) /* Research goal line. */ frame = gtk_frame_new( _("Goal")); - gtk_container_add(vbox, frame); + gui_dialog_vgrid_add(preport->shell, frame); table = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(table), 4); @@ -648,7 +646,7 @@ static void science_report_init(struct science_report *preport) sw = gtk_scrolled_window_new(); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(vbox, sw); + gui_dialog_vgrid_add(preport->shell, sw); w = science_diagram_new(); gtk_widget_set_hexpand(w, TRUE); @@ -1087,7 +1085,6 @@ static void economy_report_init(struct economy_report *preport) GtkWidget *view, *sw, *label, *button; GtkListStore *store; GtkTreeSelection *selection; - GtkContainer *vbox; const char *title; enum economy_report_columns i; @@ -1095,14 +1092,13 @@ static void economy_report_init(struct economy_report *preport) gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE); gui_dialog_set_title(preport->shell, _("Economy")); - vbox = GTK_CONTAINER(preport->shell->vbox); sw = gtk_scrolled_window_new(); gtk_widget_set_halign(sw, GTK_ALIGN_CENTER); 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); + gui_dialog_vgrid_add(preport->shell, sw); store = economy_report_store_new(); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); @@ -1157,7 +1153,7 @@ static void economy_report_init(struct economy_report *preport) } label = gtk_label_new(NULL); - gtk_container_add(vbox, label); + gui_dialog_vgrid_add(preport->shell, label); gtk_widget_set_margin_start(label, 5); gtk_widget_set_margin_end(label, 5); gtk_widget_set_margin_top(label, 5); @@ -1620,7 +1616,6 @@ static void units_report_init(struct units_report *preport) GtkWidget *view, *sw, *button; GtkListStore *store; GtkTreeSelection *selection; - GtkContainer *vbox; GtkTreeViewColumn *col = NULL; enum units_report_columns i; @@ -1628,14 +1623,13 @@ static void units_report_init(struct units_report *preport) gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE); gui_dialog_set_title(preport->shell, _("Units")); - vbox = GTK_CONTAINER(preport->shell->vbox); sw = gtk_scrolled_window_new(); gtk_widget_set_halign(sw, GTK_ALIGN_CENTER); 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); + gui_dialog_vgrid_add(preport->shell, sw); store = units_report_store_new(); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); @@ -1915,7 +1909,7 @@ static void endgame_report_init(struct endgame_report *preport) 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(preport->shell->vbox), sw); + gui_dialog_vgrid_add(preport->shell, sw); view = gtk_tree_view_new(); gtk_widget_set_name(view, "small_font"); diff --git a/client/gui-gtk-4.0/spaceshipdlg.c b/client/gui-gtk-4.0/spaceshipdlg.c index 87d8c4caa7..0d29e45a1f 100644 --- a/client/gui-gtk-4.0/spaceshipdlg.c +++ b/client/gui-gtk-4.0/spaceshipdlg.c @@ -232,13 +232,13 @@ struct spaceship_dialog *create_spaceship_dialog(struct player *pplayer) gui_dialog_add_button(pdialog->shell, NULL, _("_Launch"), GTK_RESPONSE_ACCEPT); - g_signal_connect(pdialog->shell->vbox, "destroy", + g_signal_connect(pdialog->shell->vgrid, "destroy", 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); - gtk_container_add(GTK_CONTAINER(pdialog->shell->vbox), hbox); + gui_dialog_vgrid_add(pdialog->shell, hbox); frame = gtk_frame_new(NULL); gtk_container_add(GTK_CONTAINER(hbox), frame); -- 2.33.0