From c6d069a4e46513558b982d1f4e90863aa6d55b1f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 10 Nov 2021 17:34:19 +0200 Subject: [PATCH 24/24] gtk3x: Replace gtk_container_add() used for dialog content areas gtk-3.98.4 drops gtk_container_add(). Reduce its use by using gtk_box_append() in cases where we want to add to dialog content area. Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/action_dialog.c | 4 ++-- client/gui-gtk-4.0/citydlg.c | 4 ++-- client/gui-gtk-4.0/dialogs.c | 6 +++--- client/gui-gtk-4.0/gamedlgs.c | 8 ++++---- client/gui-gtk-4.0/gtkcompat.h | 1 + client/gui-gtk-4.0/helpdlg.c | 3 ++- client/gui-gtk-4.0/infradlg.c | 4 ++-- client/gui-gtk-4.0/inteldlg.c | 5 ++--- client/gui-gtk-4.0/pages.c | 9 +++++---- client/gui-gtk-4.0/rallypointdlg.c | 4 ++-- client/gui-gtk-4.0/soundset_dlg.c | 4 ++-- client/gui-gtk-4.0/theme_dlg.c | 2 +- client/gui-gtk-4.0/tileset_dlg.c | 2 +- client/gui-gtk-4.0/unitselextradlg.c | 5 ++--- client/gui-gtk-4.0/unitselunitdlg.c | 5 ++--- client/gui-gtk-4.0/wldlg.c | 4 ++-- 16 files changed, 35 insertions(+), 35 deletions(-) diff --git a/client/gui-gtk-4.0/action_dialog.c b/client/gui-gtk-4.0/action_dialog.c index fa326c44c3..b4b995c879 100644 --- a/client/gui-gtk-4.0/action_dialog.c +++ b/client/gui-gtk-4.0/action_dialog.c @@ -592,7 +592,7 @@ static void create_advances_list(struct player *pplayer, GTK_RESPONSE_ACCEPT); label = gtk_frame_new(_("Select Advance to Steal")); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))), label); vbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), @@ -778,7 +778,7 @@ static void create_improvements_list(struct player *pplayer, GTK_RESPONSE_ACCEPT); label = gtk_frame_new(_("Select Improvement to Sabotage")); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(spy_sabotage_shell))), label); vbox = gtk_grid_new(); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index eb4bbc0d54..d7faa0dedd 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -1566,7 +1566,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) vbox = gtk_dialog_get_content_area(GTK_DIALOG(pdialog->shell)); hbox = gtk_grid_new(); gtk_grid_set_column_homogeneous(GTK_GRID(hbox), TRUE); - gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_box_append(GTK_BOX(vbox), hbox); /**** Citizens bar here ****/ cbox = gtk_grid_new(); @@ -1601,7 +1601,7 @@ static struct city_dialog *create_city_dialog(struct city *pcity) pdialog->notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(pdialog->notebook), GTK_POS_BOTTOM); - gtk_container_add(GTK_CONTAINER(vbox), pdialog->notebook); + gtk_box_append(GTK_BOX(vbox), pdialog->notebook); create_and_append_overview_page(pdialog); create_and_append_map_page(pdialog); diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index a642e32aab..3d7e9643f6 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -220,7 +220,7 @@ void popup_notify_goto_dialog(const char *headline, const char *lines, gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CLOSE); label = gtk_label_new(lines); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), label); gtk_widget_show(label); g_object_set_data(G_OBJECT(shell), "tile", ptile); @@ -244,7 +244,7 @@ void popup_connect_msg(const char *headline, const char *message) label = gtk_label_new(message); gtk_label_set_selectable(GTK_LABEL(label), 1); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), label); gtk_widget_show(label); gtk_dialog_add_button(GTK_DIALOG(shell), _("_Close"),GTK_RESPONSE_CLOSE); @@ -880,7 +880,7 @@ static void create_races_dialog(struct player *pplayer) gtk_window_set_default_size(GTK_WINDOW(shell), -1, 590); frame = gtk_frame_new(_("Select a nation")); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), frame); + 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); diff --git a/client/gui-gtk-4.0/gamedlgs.c b/client/gui-gtk-4.0/gamedlgs.c index 88992c6939..ff261301d0 100644 --- a/client/gui-gtk-4.0/gamedlgs.c +++ b/client/gui-gtk-4.0/gamedlgs.c @@ -307,8 +307,8 @@ void real_multipliers_dialog_update(void *unused) **************************************************************************/ static GtkWidget *create_multiplier_dialog(void) { - GtkWidget *shell, *content; - GtkWidget *label, *scale; + GtkWidget *shell, *content; + GtkWidget *label, *scale; if (can_client_issue_orders()) { shell = gtk_dialog_new_with_buttons(_("Change policies"), @@ -395,8 +395,8 @@ void popup_multiplier_dialog(void) **************************************************************************/ static GtkWidget *create_rates_dialog(void) { - GtkWidget *shell, *content; - GtkWidget *frame, *hgrid; + GtkWidget *shell, *content; + GtkWidget *frame, *hgrid; int i; if (!can_client_issue_orders()) { diff --git a/client/gui-gtk-4.0/gtkcompat.h b/client/gui-gtk-4.0/gtkcompat.h index a7a42ca6b3..0bce9b39cf 100644 --- a/client/gui-gtk-4.0/gtkcompat.h +++ b/client/gui-gtk-4.0/gtkcompat.h @@ -32,6 +32,7 @@ void gtk_button_set_has_frame(GtkButton *btn, bool shadow); #if !GTK_CHECK_VERSION(3,98,4) #define gtk_window_destroy(_wnd_) gtk_widget_destroy(_wnd_) +#define gtk_box_append(_box_, _child_) gtk_container_add(GTK_CONTAINER(_box_), _child_) #endif /* GTK version < 3.98.4 */ diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index bfc4661d78..d90d83d912 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -471,7 +471,8 @@ static void create_help_dialog(void) hbox = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(hbox), 5); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(help_dialog_shell))), hbox); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(help_dialog_shell))), + hbox); gtk_widget_show(hbox); /* build tree store. */ diff --git a/client/gui-gtk-4.0/infradlg.c b/client/gui-gtk-4.0/infradlg.c index bc779d1259..64934c6590 100644 --- a/client/gui-gtk-4.0/infradlg.c +++ b/client/gui-gtk-4.0/infradlg.c @@ -120,8 +120,8 @@ void infra_dialog_popup(void) infra_list_grid = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(main_box), infra_list_grid); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), - main_box); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), + main_box); g_signal_connect(dlg, "destroy", G_CALLBACK(infra_response_callback), NULL); g_signal_connect(dlg, "response", G_CALLBACK(infra_response_callback), NULL); diff --git a/client/gui-gtk-4.0/inteldlg.c b/client/gui-gtk-4.0/inteldlg.c index b8d351d46f..7b5d1cf76b 100644 --- a/client/gui-gtk-4.0/inteldlg.c +++ b/client/gui-gtk-4.0/inteldlg.c @@ -269,7 +269,7 @@ static struct intel_dialog *create_intel_dialog(struct player *p) notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), notebook); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), notebook); /* overview tab. */ table = gtk_grid_new(); @@ -442,8 +442,7 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), - sw); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), sw); gtk_widget_show(gtk_dialog_get_content_area(GTK_DIALOG(shell))); diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index 4dc579e089..7bf6b6bd21 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -564,7 +564,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, save_dialog_files_fn_t files) { GtkWidget *shell, *sbox, *sw, *label, *view, *entry; - GtkContainer *vbox; + GtkBox *vbox; GtkListStore *store; GtkCellRenderer *rend; GtkTreeSelection *selection; @@ -593,7 +593,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, g_signal_connect(shell, "response", G_CALLBACK(save_dialog_response_callback), pdialog); pdialog->shell = GTK_DIALOG(shell); - vbox = GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))); + vbox = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))); /* Tree view. */ store = save_dialog_store_new(); @@ -610,7 +610,7 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing(GTK_GRID(sbox), 2); - gtk_container_add(vbox, sbox); + gtk_box_append(vbox, sbox); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, @@ -663,11 +663,12 @@ static GtkWidget *save_dialog_new(const char *title, const char *savelabel, gtk_container_add(GTK_CONTAINER(sbox), label); gtk_container_add(GTK_CONTAINER(sbox), entry); - gtk_container_add(vbox, sbox); + gtk_box_append(vbox, sbox); save_dialog_update(pdialog); gtk_window_set_focus(GTK_WINDOW(shell), entry); gtk_widget_show(GTK_WIDGET(vbox)); + return shell; } diff --git a/client/gui-gtk-4.0/rallypointdlg.c b/client/gui-gtk-4.0/rallypointdlg.c index 57fe67961c..486f01d588 100644 --- a/client/gui-gtk-4.0/rallypointdlg.c +++ b/client/gui-gtk-4.0/rallypointdlg.c @@ -91,8 +91,8 @@ void rally_dialog_popup(void) sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); gtk_container_add(GTK_CONTAINER(main_box), sep); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), - main_box); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), + main_box); g_signal_connect(dlg, "destroy", G_CALLBACK(rally_response_callback), NULL); g_signal_connect(dlg, "response", G_CALLBACK(rally_response_callback), NULL); diff --git a/client/gui-gtk-4.0/soundset_dlg.c b/client/gui-gtk-4.0/soundset_dlg.c index 2ad061fca7..e3b029436e 100644 --- a/client/gui-gtk-4.0/soundset_dlg.c +++ b/client/gui-gtk-4.0/soundset_dlg.c @@ -76,7 +76,7 @@ void popup_soundset_suggestion_dialog(void) game.control.preferred_soundset, sound_set_name); label = gtk_label_new(buf); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_widget_show(label); @@ -129,7 +129,7 @@ void popup_musicset_suggestion_dialog(void) game.control.preferred_musicset, music_set_name); label = gtk_label_new(buf); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_widget_show(label); diff --git a/client/gui-gtk-4.0/theme_dlg.c b/client/gui-gtk-4.0/theme_dlg.c index 25242266b3..c1fb3c3b08 100644 --- a/client/gui-gtk-4.0/theme_dlg.c +++ b/client/gui-gtk-4.0/theme_dlg.c @@ -73,7 +73,7 @@ bool popup_theme_suggestion_dialog(const char *theme_name) theme_name, current_name); label = gtk_label_new(buf); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_widget_show(label); diff --git a/client/gui-gtk-4.0/tileset_dlg.c b/client/gui-gtk-4.0/tileset_dlg.c index 5dca1bf785..f794a6f4a1 100644 --- a/client/gui-gtk-4.0/tileset_dlg.c +++ b/client/gui-gtk-4.0/tileset_dlg.c @@ -79,7 +79,7 @@ void popup_tileset_suggestion_dialog(void) game.control.preferred_tileset, tileset_basename(tileset)); label = gtk_label_new(buf); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_widget_show(label); diff --git a/client/gui-gtk-4.0/unitselextradlg.c b/client/gui-gtk-4.0/unitselextradlg.c index 19daf9876e..85e452bb99 100644 --- a/client/gui-gtk-4.0/unitselextradlg.c +++ b/client/gui-gtk-4.0/unitselextradlg.c @@ -223,9 +223,8 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, fc_assert_ret_val(default_option, FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(default_option), TRUE); - gtk_container_add( - GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), - main_box); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), + main_box); g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); diff --git a/client/gui-gtk-4.0/unitselunitdlg.c b/client/gui-gtk-4.0/unitselunitdlg.c index 1d6f78ee1d..5d12e0785e 100644 --- a/client/gui-gtk-4.0/unitselunitdlg.c +++ b/client/gui-gtk-4.0/unitselunitdlg.c @@ -183,9 +183,8 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, fc_assert_ret_val(default_option, FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(default_option), TRUE); - gtk_container_add( - GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), - main_box); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), + main_box); g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); diff --git a/client/gui-gtk-4.0/wldlg.c b/client/gui-gtk-4.0/wldlg.c index acc40ea8f1..367b200229 100644 --- a/client/gui-gtk-4.0/wldlg.c +++ b/client/gui-gtk-4.0/wldlg.c @@ -237,7 +237,7 @@ static GtkWidget *create_worklists_report(void) gtk_grid_set_row_spacing(GTK_GRID(vbox), 2); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), vbox); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), vbox); worklists_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); @@ -408,7 +408,7 @@ static void popup_worklist(struct global_worklist *pgwl) reset_global_worklist(editor, pgwl); insert_worklist(global_worklist_id(pgwl), editor); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(shell))), editor); + gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), editor); gtk_widget_show(editor); refresh_worklist(editor); -- 2.33.0