From 9fad7c408a27ecfae60cd76a95e655e7a95bfc59 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 4 Dec 2021 07:48:07 +0200 Subject: [PATCH 43/43] gtk3x: Replace gtk_widget_destroy() calls It's going away in gtk-3.98.4 See osdn #43330 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/action_dialog.c | 12 ++++++------ client/gui-gtk-4.0/chatline.c | 2 +- client/gui-gtk-4.0/choice_dialog.c | 2 +- client/gui-gtk-4.0/citizensinfo.c | 3 ++- client/gui-gtk-4.0/citydlg.c | 20 +++++++++++++------- client/gui-gtk-4.0/cityrep.c | 4 ++-- client/gui-gtk-4.0/cma_fe.c | 2 +- client/gui-gtk-4.0/dialogs.c | 23 ++++++++++++----------- client/gui-gtk-4.0/editgui.c | 2 +- client/gui-gtk-4.0/gamedlgs.c | 6 ++++-- client/gui-gtk-4.0/gotodlg.c | 2 +- client/gui-gtk-4.0/gtkcompat.c | 11 +++++++++++ client/gui-gtk-4.0/gtkcompat.h | 4 +++- client/gui-gtk-4.0/gui_main.c | 15 +++++++++++---- client/gui-gtk-4.0/gui_stuff.c | 6 +++--- client/gui-gtk-4.0/happiness.c | 3 ++- client/gui-gtk-4.0/helpdlg.c | 4 ++-- client/gui-gtk-4.0/infradlg.c | 2 +- client/gui-gtk-4.0/inputdlg.c | 2 +- client/gui-gtk-4.0/inteldlg.c | 4 ++-- client/gui-gtk-4.0/luaconsole.c | 7 ++++--- client/gui-gtk-4.0/menu.c | 2 +- client/gui-gtk-4.0/optiondlg.c | 20 +++++++++----------- client/gui-gtk-4.0/pages.c | 8 +++++--- client/gui-gtk-4.0/plrdlg.c | 2 +- client/gui-gtk-4.0/rallypointdlg.c | 2 +- client/gui-gtk-4.0/repodlgs.c | 8 ++++---- 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/transportdlg.c | 2 +- client/gui-gtk-4.0/unitselect.c | 2 +- client/gui-gtk-4.0/wldlg.c | 6 +++--- 33 files changed, 114 insertions(+), 82 deletions(-) diff --git a/client/gui-gtk-4.0/action_dialog.c b/client/gui-gtk-4.0/action_dialog.c index 188590d3ea..8c1a8e25e6 100644 --- a/client/gui-gtk-4.0/action_dialog.c +++ b/client/gui-gtk-4.0/action_dialog.c @@ -464,7 +464,7 @@ static void bribe_response(GtkWidget *w, gint response, gpointer data) args->target_unit_id, 0, ""); } - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); free(args); /* The user have answered the follow up question. Move on. */ @@ -535,7 +535,7 @@ static void spy_advances_response(GtkWidget *w, gint response, } } - gtk_widget_destroy(spy_tech_shell); + gtk_window_destroy(GTK_WINDOW(spy_tech_shell)); spy_tech_shell = NULL; free(data); @@ -721,7 +721,7 @@ static void spy_improvements_response(GtkWidget *w, gint response, gpointer data } } - gtk_widget_destroy(spy_sabotage_shell); + gtk_window_destroy(GTK_WINDOW(spy_sabotage_shell)); spy_sabotage_shell = NULL; free(args); @@ -949,7 +949,7 @@ static void incite_response(GtkWidget *w, gint response, gpointer data) args->target_city_id, 0, ""); } - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); free(args); /* The user have answered the follow up question. Move on. */ @@ -1043,7 +1043,7 @@ static void tgt_unit_change_callback(GtkWidget *dlg, gint arg) action_selection_no_longer_in_progress(au_id); } - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); } /**********************************************************************//** @@ -1114,7 +1114,7 @@ static void tgt_extra_change_callback(GtkWidget *dlg, gint arg) action_selection_no_longer_in_progress(au_id); } - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); } /**********************************************************************//** diff --git a/client/gui-gtk-4.0/chatline.c b/client/gui-gtk-4.0/chatline.c index 033c70ba90..8e431798f5 100644 --- a/client/gui-gtk-4.0/chatline.c +++ b/client/gui-gtk-4.0/chatline.c @@ -1130,7 +1130,7 @@ static void color_selected(GtkDialog *dialog, gint res, gpointer data) color_set(G_OBJECT(data), color_target, &new_color, button); } - gtk_widget_destroy(GTK_WIDGET(dialog)); + gtk_window_destroy(GTK_WINDOW(dialog)); } /**********************************************************************//** diff --git a/client/gui-gtk-4.0/choice_dialog.c b/client/gui-gtk-4.0/choice_dialog.c index 0bbab4b0b6..bb079f07c7 100644 --- a/client/gui-gtk-4.0/choice_dialog.c +++ b/client/gui-gtk-4.0/choice_dialog.c @@ -150,7 +150,7 @@ static void choice_dialog_clicked(GtkWidget *w, gpointer data) if (g_object_get_data(G_OBJECT(data), "hide")) { gtk_widget_hide(GTK_WIDGET(data)); } else { - gtk_widget_destroy(GTK_WIDGET(data)); + gtk_window_destroy(GTK_WINDOW(data)); } } diff --git a/client/gui-gtk-4.0/citizensinfo.c b/client/gui-gtk-4.0/citizensinfo.c index 252c5ae7cf..80053f46e9 100644 --- a/client/gui-gtk-4.0/citizensinfo.c +++ b/client/gui-gtk-4.0/citizensinfo.c @@ -371,7 +371,8 @@ void citizens_dialog_close(const struct city *pcity) dialog_list_remove(dialog_list, pdialog); - gtk_widget_destroy(pdialog->shell); + gtk_box_remove(GTK_BOX(gtk_widget_get_parent(pdialog->shell)), + pdialog->shell); free(pdialog); } diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index d12aac3715..71aa0194a2 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -140,7 +140,9 @@ struct city_dialog { cairo_surface_t *map_canvas_store_unscaled; GtkWidget *notebook; +#ifdef MENUS_GTK3 GtkWidget *popup_menu; +#endif GtkWidget *citizen_images; cairo_surface_t *citizen_surface; @@ -1579,8 +1581,9 @@ static struct city_dialog *create_city_dialog(struct city *pcity) gtk_window_set_default_size(GTK_WINDOW(pdialog->shell), GUI_GTK_OPTION(citydlg_xsize), GUI_GTK_OPTION(citydlg_ysize)); - +#ifdef MENUS_GTK3 pdialog->popup_menu = gtk_menu_button_new(); +#endif vbox = gtk_dialog_get_content_area(GTK_DIALOG(pdialog->shell)); hgrid = gtk_grid_new(); @@ -3079,7 +3082,8 @@ static void buy_callback_response(GtkWidget *w, gint response, gpointer data) if (response == GTK_RESPONSE_YES) { city_buy_production(pdialog->pcity); } - gtk_widget_destroy(w); + + gtk_window_destroy(GTK_WINDOW(w)); } /***********************************************************************//** @@ -3126,7 +3130,7 @@ static void buy_callback(GtkWidget *w, gpointer data) name, value, buf); setup_dialog(shell, pdialog->shell); gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!")); - g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), + g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy), NULL); gtk_window_present(GTK_WINDOW(shell)); } @@ -3199,7 +3203,7 @@ static void sell_callback_response(GtkWidget *w, gint response, gpointer data) if (response == GTK_RESPONSE_YES) { city_sell_improvement(pdialog->pcity, pdialog->sell_id); } - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); pdialog->sell_shell = NULL; } @@ -3386,9 +3390,11 @@ static void city_destroy_callback(GtkWidget *w, gpointer data) last_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(pdialog->notebook)); +#ifdef MENUS_GTK3 if (pdialog->popup_menu) { gtk_widget_destroy(pdialog->popup_menu); } +#endif /* MENUS_GTK3 */ dialog_list_remove(dialog_list, pdialog); @@ -3396,10 +3402,10 @@ static void city_destroy_callback(GtkWidget *w, gpointer data) unit_node_vector_free(&pdialog->overview.present_units); if (pdialog->sell_shell) { - gtk_widget_destroy(pdialog->sell_shell); + gtk_window_destroy(GTK_WINDOW(pdialog->sell_shell)); } if (pdialog->rename_shell) { - gtk_widget_destroy(pdialog->rename_shell); + gtk_window_destroy(GTK_WINDOW(pdialog->rename_shell)); } cairo_surface_destroy(pdialog->map_canvas_store_unscaled); @@ -3416,7 +3422,7 @@ static void city_destroy_callback(GtkWidget *w, gpointer data) ***************************************************************************/ static void close_city_dialog(struct city_dialog *pdialog) { - gtk_widget_destroy(pdialog->shell); + gtk_window_destroy(GTK_WINDOW(pdialog->shell)); } /***********************************************************************//** diff --git a/client/gui-gtk-4.0/cityrep.c b/client/gui-gtk-4.0/cityrep.c index abd78e7385..bbea639e65 100644 --- a/client/gui-gtk-4.0/cityrep.c +++ b/client/gui-gtk-4.0/cityrep.c @@ -643,7 +643,7 @@ static void select_impr_or_unit_callback(GtkWidget *wdg, gpointer data) GTK_BUTTONS_YES_NO, "%s", buf); g_free(buf); res = blocking_dialog(w); /* Synchron. */ - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); if (res == GTK_RESPONSE_NO) { break; } @@ -668,7 +668,7 @@ static void select_impr_or_unit_callback(GtkWidget *wdg, gpointer data) } g_signal_connect(w, "response", - G_CALLBACK(gtk_widget_destroy), NULL); + G_CALLBACK(gtk_window_destroy), NULL); gtk_window_present(GTK_WINDOW(w)); /* Asynchron. */ } break; diff --git a/client/gui-gtk-4.0/cma_fe.c b/client/gui-gtk-4.0/cma_fe.c index 7c1568c620..a475186a6b 100644 --- a/client/gui-gtk-4.0/cma_fe.c +++ b/client/gui-gtk-4.0/cma_fe.c @@ -694,7 +694,7 @@ static void cma_preset_remove_response(GtkWidget *w, gint response, /* if this or other cities have this set, reset to "custom" */ city_report_dialog_update(); } - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); pdialog->preset_remove_shell = NULL; } diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index 54f6fbc304..0f9b5d8cea 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -175,7 +175,8 @@ static void notify_goto_response(GtkWidget *w, gint response) } break; } - gtk_widget_destroy(w); + + gtk_window_destroy(GTK_WINDOW(w)); } /**********************************************************************//** @@ -183,7 +184,7 @@ static void notify_goto_response(GtkWidget *w, gint response) **************************************************************************/ static void notify_connect_msg_response(GtkWidget *w, gint response) { - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); } /**********************************************************************//** @@ -270,7 +271,7 @@ static void revolution_response(GtkWidget *w, gint response, gpointer data) } } if (w) { - gtk_widget_destroy(w); + gtk_window_destroy(GTK_WINDOW(w)); } } @@ -325,7 +326,7 @@ static void pillage_callback(GtkWidget *dlg, gint arg) } } - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); } /**********************************************************************//** @@ -1234,7 +1235,7 @@ void popup_races_dialog(struct player *pplayer) void popdown_races_dialog(void) { if (races_shell) { - gtk_widget_destroy(races_shell); + gtk_window_destroy(GTK_WINDOW(races_shell)); } /* We're probably starting a new game, maybe with a new ruleset. @@ -1456,8 +1457,8 @@ void popup_upgrade_dialog(struct unit_list *punits) "%s", buf); gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Unit!")); setup_dialog(shell, toplevel); - g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), - NULL); + g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy), + NULL); gtk_window_present(GTK_WINDOW(shell)); } else { shell = gtk_message_dialog_new(NULL, 0, @@ -1473,7 +1474,7 @@ void popup_upgrade_dialog(struct unit_list *punits) request_unit_upgrade(punit); } unit_list_iterate_end; } - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } } @@ -1495,7 +1496,7 @@ void popup_disband_dialog(struct unit_list *punits) "%s", buf); gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units")); setup_dialog(shell, toplevel); - g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), + g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy), NULL); gtk_window_present(GTK_WINDOW(shell)); } else { @@ -1514,7 +1515,7 @@ void popup_disband_dialog(struct unit_list *punits) } } unit_list_iterate_end; } - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } } @@ -1561,7 +1562,7 @@ void show_tileset_error(const char *msg) blocking_dialog(dialog); - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); } } diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index 4388e944d7..1b7d22f83c 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -190,7 +190,7 @@ static void try_to_set_editor_tool(enum editor_tool_type ett) "objects corresponding to this editor tool.")); gtk_window_set_title(GTK_WINDOW(dialog), editor_tool_get_name(ett)); blocking_dialog(dialog); - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); } else { editor_set_tool(ett); } diff --git a/client/gui-gtk-4.0/gamedlgs.c b/client/gui-gtk-4.0/gamedlgs.c index 59e209c78b..73bedd6706 100644 --- a/client/gui-gtk-4.0/gamedlgs.c +++ b/client/gui-gtk-4.0/gamedlgs.c @@ -210,7 +210,8 @@ static void rates_command_callback(GtkWidget *w, gint response_id) dsend_packet_player_rates(&client.conn, rates_tax_value, rates_lux_value, rates_sci_value); } - gtk_widget_destroy(rates_dialog_shell); + + gtk_window_destroy(GTK_WINDOW(rates_dialog_shell)); } /**********************************************************************//** @@ -257,7 +258,8 @@ static void multipliers_command_callback(GtkWidget *w, gint response_id) mul.count = multiplier_count(); send_packet_player_multiplier(&client.conn, &mul); } - gtk_widget_destroy(multiplier_dialog_shell); + + gtk_window_destroy(GTK_WINDOW(multiplier_dialog_shell)); } /**********************************************************************//** diff --git a/client/gui-gtk-4.0/gotodlg.c b/client/gui-gtk-4.0/gotodlg.c index c27da93165..37cb7a9b3e 100644 --- a/client/gui-gtk-4.0/gotodlg.c +++ b/client/gui-gtk-4.0/gotodlg.c @@ -124,7 +124,7 @@ static void goto_cmd_callback(GtkWidget *dlg, gint arg) break; } - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); dshell = NULL; } diff --git a/client/gui-gtk-4.0/gtkcompat.c b/client/gui-gtk-4.0/gtkcompat.c index c9c4f82045..cd25cf8f60 100644 --- a/client/gui-gtk-4.0/gtkcompat.c +++ b/client/gui-gtk-4.0/gtkcompat.c @@ -49,6 +49,17 @@ void gtk_button_set_has_frame(GtkButton *btn, bool shadow) #endif /* GTK version < 3.98.3 */ +#if !GTK_CHECK_VERSION(3,98,4) + +/************************************************************************//** + Version of gtk_window_destroy() for gtk < 3.98.4 +****************************************************************************/ +void gtk_window_destroy(GtkWindow *wnd) +{ + gtk_widget_destroy(GTK_WIDGET(wnd)); +} + +#endif /* GTK version < 3.98.3 */ #if !GTK_CHECK_VERSION(3,99,0) diff --git a/client/gui-gtk-4.0/gtkcompat.h b/client/gui-gtk-4.0/gtkcompat.h index 6982e2d1b9..c29f9d0f36 100644 --- a/client/gui-gtk-4.0/gtkcompat.h +++ b/client/gui-gtk-4.0/gtkcompat.h @@ -31,7 +31,9 @@ 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(GTK_WIDGET(_wnd_)) +/* Can't be simple macro, as in some places we need the address of the function. */ +void gtk_window_destroy(GtkWindow *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_) \ diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index eff4dd63be..ffe9ac507d 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -779,13 +779,12 @@ static void tearoff_destroy(GtkWidget *w, gpointer data) static void tearoff_callback(GtkWidget *b, gpointer data) { GtkWidget *box = GTK_WIDGET(data); + GtkWidget *old_parent = gtk_widget_get_parent(box); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) { - GtkWidget *old_parent; GtkWidget *w; GtkWidget *temp_hide; - old_parent = gtk_widget_get_parent(box); w = gtk_window_new(); setup_dialog(w, toplevel); gtk_widget_set_name(w, "Freeciv"); @@ -808,7 +807,13 @@ static void tearoff_callback(GtkWidget *b, gpointer data) gtk_widget_show(temp_hide); } } else { - gtk_widget_destroy(gtk_widget_get_parent(box)); + if (GTK_IS_BOX(old_parent)) { + gtk_box_remove(GTK_BOX(old_parent), box); + } else { + fc_assert(GTK_IS_PANED(old_parent)); + + gtk_paned_set_end_child(GTK_PANED(old_parent), NULL); + } } } @@ -1017,7 +1022,9 @@ void enable_menus(bool enable) menus_init(); gtk_widget_show(main_menubar); } else { +#ifdef MENUS_GTK3 gtk_widget_destroy(main_menubar); +#endif } } @@ -2200,7 +2207,7 @@ void remove_net_input(void) **************************************************************************/ static void quit_dialog_response(GtkWidget *dialog, gint response) { - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); if (response == GTK_RESPONSE_YES) { start_quitting(); if (client.conn.used) { diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index d268d1c6fd..b3ed48b6f3 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -257,11 +257,11 @@ GtkWidget *gtk_aux_menu_bar_new(void) } /**********************************************************************//** - Generic close callback for all widgets + Generic close callback for all dialogs **************************************************************************/ static void close_callback(GtkDialog *dialog, gpointer data) { - gtk_widget_destroy(GTK_WIDGET(dialog)); + gtk_window_destroy(GTK_WINDOW(dialog)); } /**********************************************************************//** @@ -921,7 +921,7 @@ void gui_dialog_destroy(struct gui_dialog *dlg) { switch (dlg->type) { case GUI_DIALOG_WINDOW: - gtk_widget_destroy(dlg->v.window); + gtk_window_destroy(GTK_WINDOW(dlg->v.window)); break; case GUI_DIALOG_TAB: { diff --git a/client/gui-gtk-4.0/happiness.c b/client/gui-gtk-4.0/happiness.c index 0d1d4534a8..3713e4b247 100644 --- a/client/gui-gtk-4.0/happiness.c +++ b/client/gui-gtk-4.0/happiness.c @@ -321,7 +321,8 @@ void close_happiness_dialog(struct city *pcity) dialog_list_remove(dialog_list, pdialog); - gtk_widget_destroy(pdialog->shell); + gtk_box_remove(GTK_BOX(gtk_widget_get_parent(pdialog->shell)), + pdialog->shell); for (i = 0; i < NUM_HAPPINESS_MODIFIERS; i++) { cairo_surface_destroy(pdialog->feeling_surfaces[i]); diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index 7940d4961e..722b629995 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -158,7 +158,7 @@ static void set_title_topic(char *topic) void popdown_help_dialog(void) { if (help_dialog_shell) { - gtk_widget_destroy(help_dialog_shell); + gtk_window_destroy(GTK_WINDOW(help_dialog_shell)); } } @@ -1695,6 +1695,6 @@ static void help_command_callback(GtkWidget *w, gint response_id) help_command_update(); } } else { - gtk_widget_destroy(help_dialog_shell); + gtk_window_destroy(GTK_WINDOW(help_dialog_shell)); } } diff --git a/client/gui-gtk-4.0/infradlg.c b/client/gui-gtk-4.0/infradlg.c index 4c5b455b3c..a459c08196 100644 --- a/client/gui-gtk-4.0/infradlg.c +++ b/client/gui-gtk-4.0/infradlg.c @@ -65,7 +65,7 @@ static void infra_response_callback(GtkWidget *dlg, gint arg) client_infratile_set(NULL); - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); } /************************************************************************//** diff --git a/client/gui-gtk-4.0/inputdlg.c b/client/gui-gtk-4.0/inputdlg.c index 3049618f99..289fb1d85c 100644 --- a/client/gui-gtk-4.0/inputdlg.c +++ b/client/gui-gtk-4.0/inputdlg.c @@ -49,7 +49,7 @@ static void input_dialog_response(GtkDialog *shell, gint response, gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(winput)))); /* Any response is final */ - gtk_widget_destroy(GTK_WIDGET(shell)); + gtk_window_destroy(GTK_WINDOW(shell)); FC_FREE(cb); } diff --git a/client/gui-gtk-4.0/inteldlg.c b/client/gui-gtk-4.0/inteldlg.c index 0cd41ead7a..482e5984e6 100644 --- a/client/gui-gtk-4.0/inteldlg.c +++ b/client/gui-gtk-4.0/inteldlg.c @@ -265,7 +265,7 @@ static struct intel_dialog *create_intel_dialog(struct player *p) g_signal_connect(shell, "destroy", G_CALLBACK(intel_destroy_callback), pdialog); g_signal_connect(shell, "response", - G_CALLBACK(gtk_widget_destroy), NULL); + G_CALLBACK(gtk_window_destroy), NULL); notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM); @@ -400,7 +400,7 @@ static struct intel_wonder_dialog *create_intel_wonder_dialog(struct player *p) g_signal_connect(shell, "destroy", G_CALLBACK(intel_wonder_destroy_callback), pdialog); g_signal_connect(shell, "response", - G_CALLBACK(gtk_widget_destroy), NULL); + G_CALLBACK(gtk_window_destroy), NULL); /* columns: 0 - wonder name, 1 - location (city/unknown/lost), * 2 - strikethrough (for lost or obsolete), diff --git a/client/gui-gtk-4.0/luaconsole.c b/client/gui-gtk-4.0/luaconsole.c index eeee0beb83..c18e2c07b6 100644 --- a/client/gui-gtk-4.0/luaconsole.c +++ b/client/gui-gtk-4.0/luaconsole.c @@ -329,11 +329,11 @@ static void luaconsole_load_file_popup(void) /*************************************************************************//** Callback for luaconsole_load_file_popup(). *****************************************************************************/ -static void luaconsole_load_file_callback(GtkWidget *widget, gint response, +static void luaconsole_load_file_callback(GtkWidget *dlg, gint response, gpointer data) { if (response == GTK_RESPONSE_OK) { - GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(widget)); + GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(dlg)); if (file != NULL) { gchar *filename = g_file_get_parse_name(file); @@ -347,7 +347,8 @@ static void luaconsole_load_file_callback(GtkWidget *widget, gint response, g_object_unref(file); } } - gtk_widget_destroy(widget); + + gtk_window_destroy(GTK_WINDOW(dlg)); } /*************************************************************************//** diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index 14584b50fa..5cca3320e9 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -644,7 +644,7 @@ static void save_mapimg_as_callback(GtkMenuItem *item, gpointer data) ****************************************************************************/ static void leave_local_game_response(GtkWidget *dialog, gint response) { - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); if (response == GTK_RESPONSE_OK) { /* It might be killed already */ if (client.conn.used) { diff --git a/client/gui-gtk-4.0/optiondlg.c b/client/gui-gtk-4.0/optiondlg.c index d6f0ba44a5..25e8ca9e17 100644 --- a/client/gui-gtk-4.0/optiondlg.c +++ b/client/gui-gtk-4.0/optiondlg.c @@ -101,11 +101,11 @@ static void option_dialog_reponse_callback(GtkDialog *dialog, switch (response_id) { case RESPONSE_CANCEL: - gtk_widget_destroy(GTK_WIDGET(dialog)); + gtk_window_destroy(GTK_WINDOW(dialog)); break; case RESPONSE_OK: option_dialog_foreach(pdialog, option_dialog_option_apply); - gtk_widget_destroy(GTK_WIDGET(dialog)); + gtk_window_destroy(GTK_WINDOW(dialog)); break; case RESPONSE_APPLY: option_dialog_foreach(pdialog, option_dialog_option_apply); @@ -268,9 +268,7 @@ static void option_color_set_button_color(GtkButton *button, if (NULL == new_color) { if (NULL != current_color) { g_object_set_data(G_OBJECT(button), "color", NULL); - if ((child = gtk_button_get_child(button))) { - gtk_widget_destroy(child); - } + gtk_button_set_child(button, NULL); } } else { GdkPixbuf *pixbuf; @@ -285,9 +283,7 @@ static void option_color_set_button_color(GtkButton *button, g_object_set_data_full(G_OBJECT(button), "color", current_color, option_color_destroy_notify); } - if ((child = gtk_button_get_child(button))) { - gtk_widget_destroy(child); - } + gtk_button_set_child(button, NULL); /* Update the button. */ { @@ -326,7 +322,7 @@ static void color_selector_response_callback(GtkDialog *dialog, option_color_set_button_color(GTK_BUTTON(data), &new_color); } - gtk_widget_destroy(GTK_WIDGET(dialog)); + gtk_window_destroy(GTK_WINDOW(dialog)); } /************************************************************************//** @@ -429,7 +425,7 @@ static void option_dialog_destroy(struct option_dialog *pdialog) if (NULL != shell) { /* Maybe already destroyed, see also option_dialog_destroy_callback(). */ pdialog->shell = NULL; - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } free(pdialog->vboxes); @@ -656,6 +652,7 @@ static void option_dialog_option_add(struct option_dialog *pdialog, option_number(poption), option_name(poption)); } else { g_object_set_data(G_OBJECT(w), "main_widget", main_hbox); + g_object_set_data(G_OBJECT(w), "parent_of_main", pdialog->vboxes[category]); gtk_widget_set_hexpand(w, TRUE); gtk_widget_set_halign(w, GTK_ALIGN_END); gtk_grid_attach(GTK_GRID(main_hbox), w, main_col++, 0, 1, 1); @@ -679,7 +676,8 @@ static void option_dialog_option_remove(struct option_dialog *pdialog, const int category = option_category(poption); option_set_gui_data(poption, NULL); - gtk_widget_destroy(GTK_WIDGET(g_object_get_data(object, "main_widget"))); + gtk_box_remove(GTK_BOX(g_object_get_data(object, "parent_of_main")), + GTK_WIDGET(g_object_get_data(object, "main_widget"))); /* Remove category if needed. */ if (0 == --pdialog->box_children[category]) { diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index 20a5af9b9b..af2c6d0188 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -440,7 +440,8 @@ static void save_dialog_file_chooser_callback(GtkWidget *widget, g_object_unref(file); } } - gtk_widget_destroy(widget); + + gtk_window_destroy(GTK_WINDOW(widget)); } /**********************************************************************//** @@ -513,7 +514,8 @@ static void save_dialog_response_callback(GtkWidget *w, gint response, default: break; } - gtk_widget_destroy(GTK_WIDGET(pdialog->shell)); + + gtk_window_destroy(GTK_WINDOW(pdialog->shell)); } /**********************************************************************//** @@ -1788,7 +1790,7 @@ static void show_conn_popup(struct player *pplayer, struct connection *pconn) "%s", buf); gtk_window_set_title(GTK_WINDOW(popup), _("Player/conn info")); setup_dialog(popup, toplevel); - g_signal_connect(popup, "response", G_CALLBACK(gtk_widget_destroy), NULL); + g_signal_connect(popup, "response", G_CALLBACK(gtk_window_destroy), NULL); gtk_window_present(GTK_WINDOW(popup)); } diff --git a/client/gui-gtk-4.0/plrdlg.c b/client/gui-gtk-4.0/plrdlg.c index 0cb7ac110f..5605ba5de1 100644 --- a/client/gui-gtk-4.0/plrdlg.c +++ b/client/gui-gtk-4.0/plrdlg.c @@ -839,7 +839,7 @@ static void confirm_cancel_pact(enum clause_type clause, int plrno, if (blocking_dialog(shell) == GTK_RESPONSE_YES) { dsend_packet_diplomacy_cancel_pact(&client.conn, plrno, clause); } - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); FC_FREE(title); FC_FREE(question); } diff --git a/client/gui-gtk-4.0/rallypointdlg.c b/client/gui-gtk-4.0/rallypointdlg.c index eb9f4f40eb..ab6a201569 100644 --- a/client/gui-gtk-4.0/rallypointdlg.c +++ b/client/gui-gtk-4.0/rallypointdlg.c @@ -56,7 +56,7 @@ static void rally_response_callback(GtkWidget *dlg, gint arg) rally_dialog = FALSE; instruction_label = NULL; - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); } /************************************************************************//** diff --git a/client/gui-gtk-4.0/repodlgs.c b/client/gui-gtk-4.0/repodlgs.c index b8be433a1b..16d4a95422 100644 --- a/client/gui-gtk-4.0/repodlgs.c +++ b/client/gui-gtk-4.0/repodlgs.c @@ -981,7 +981,7 @@ static void economy_report_command_callback(struct gui_dialog *pdialog, if (GTK_RESPONSE_YES == blocking_dialog(shell)) { sell_all_improvements(pimprove, redundant, buf, sizeof(buf)); } - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } } break; @@ -1008,7 +1008,7 @@ static void economy_report_command_callback(struct gui_dialog *pdialog, if (GTK_RESPONSE_YES == blocking_dialog(shell)) { disband_all_units(putype, FALSE, buf, sizeof(buf)); } - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } } break; @@ -1021,7 +1021,7 @@ static void economy_report_command_callback(struct gui_dialog *pdialog, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s", buf); setup_dialog(shell, gui_dialog_get_toplevel(pdialog)); - g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy), + g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy), NULL); gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results")); gtk_window_present(GTK_WINDOW(shell)); @@ -1604,7 +1604,7 @@ static void units_report_command_callback(struct gui_dialog *pdialog, dsend_packet_unit_type_upgrade(&client.conn, utype_number(utype)); } - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } } diff --git a/client/gui-gtk-4.0/soundset_dlg.c b/client/gui-gtk-4.0/soundset_dlg.c index 67c6a2360e..f7c5653281 100644 --- a/client/gui-gtk-4.0/soundset_dlg.c +++ b/client/gui-gtk-4.0/soundset_dlg.c @@ -82,7 +82,7 @@ void popup_soundset_suggestion_dialog(void) * of the correct soundset. */ soundset_suggestion_response(blocking_dialog(dialog)); - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); } /************************************************************************//** @@ -132,5 +132,5 @@ void popup_musicset_suggestion_dialog(void) * of the correct musicset. */ musicset_suggestion_response(blocking_dialog(dialog)); - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); } diff --git a/client/gui-gtk-4.0/theme_dlg.c b/client/gui-gtk-4.0/theme_dlg.c index b4754979cf..14c1cabc89 100644 --- a/client/gui-gtk-4.0/theme_dlg.c +++ b/client/gui-gtk-4.0/theme_dlg.c @@ -78,7 +78,7 @@ bool popup_theme_suggestion_dialog(const char *theme_name) theme_suggestion_response(blocking_dialog(dialog)); - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); return load_theme; } diff --git a/client/gui-gtk-4.0/tileset_dlg.c b/client/gui-gtk-4.0/tileset_dlg.c index d299c4b0e9..af6eb8eb78 100644 --- a/client/gui-gtk-4.0/tileset_dlg.c +++ b/client/gui-gtk-4.0/tileset_dlg.c @@ -87,5 +87,5 @@ void popup_tileset_suggestion_dialog(void) * of the correct tileset. */ tileset_suggestion_response(blocking_dialog(dialog)); - gtk_widget_destroy(dialog); + gtk_window_destroy(GTK_WINDOW(dialog)); } diff --git a/client/gui-gtk-4.0/transportdlg.c b/client/gui-gtk-4.0/transportdlg.c index 7dbed5060e..62c8bb59ef 100644 --- a/client/gui-gtk-4.0/transportdlg.c +++ b/client/gui-gtk-4.0/transportdlg.c @@ -72,7 +72,7 @@ static void transport_response_callback(GtkWidget *dlg, gint arg) } } - gtk_widget_destroy(dlg); + gtk_window_destroy(GTK_WINDOW(dlg)); } /************************************************************************//** diff --git a/client/gui-gtk-4.0/unitselect.c b/client/gui-gtk-4.0/unitselect.c index 82e6ac3925..7c8722bd3a 100644 --- a/client/gui-gtk-4.0/unitselect.c +++ b/client/gui-gtk-4.0/unitselect.c @@ -292,7 +292,7 @@ static struct unit_select_dialog *usdlg_create(void) static void usdlg_destroy(void) { if (unit_select_dlg) { - gtk_widget_destroy(GTK_WIDGET(unit_select_dlg->shell)); + gtk_window_destroy(GTK_WINDOW(unit_select_dlg->shell)); free(unit_select_dlg); } unit_select_dlg = NULL; diff --git a/client/gui-gtk-4.0/wldlg.c b/client/gui-gtk-4.0/wldlg.c index b76b054249..d87043f3db 100644 --- a/client/gui-gtk-4.0/wldlg.c +++ b/client/gui-gtk-4.0/wldlg.c @@ -172,7 +172,7 @@ static void worklists_response(GtkWidget *w, gint response) return; default: - gtk_widget_destroy(worklists_shell); + gtk_window_destroy(GTK_WINDOW(worklists_shell)); return; } } @@ -383,7 +383,7 @@ static void delete_worklist(int global_worklist_id) ****************************************************************************/ static void worklist_response(GtkWidget *shell, gint response) { - gtk_widget_destroy(shell); + gtk_window_destroy(GTK_WINDOW(shell)); } /************************************************************************//** @@ -429,7 +429,7 @@ static void popdown_worklist(struct global_worklist *pgwl) GtkWidget *parent; parent = gtk_widget_get_ancestor(shell, GTK_TYPE_WINDOW); - gtk_widget_destroy(parent); + gtk_window_destroy(GTK_WINDOW(parent)); } } -- 2.33.0