From cd9c5e42cb7da130f5bf6b05c77dcae946f4f72b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 13 Nov 2021 23:42:39 +0200 Subject: [PATCH 34/34] gtk3x: Add choice_dialog_destroy() It's based on gtk_window_destroy() Use it where appropriate, instead of old gtk_widget_destroy() that goes away in gtk-3.98.4. See osdn #43212 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/action_dialog.c | 20 ++++++++++---------- client/gui-gtk-4.0/choice_dialog.c | 10 ++++++++++ client/gui-gtk-4.0/choice_dialog.h | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/client/gui-gtk-4.0/action_dialog.c b/client/gui-gtk-4.0/action_dialog.c index b4b995c879..33397bf90c 100644 --- a/client/gui-gtk-4.0/action_dialog.c +++ b/client/gui-gtk-4.0/action_dialog.c @@ -334,7 +334,7 @@ static void simple_action_callback(GtkWidget *w, gpointer data) } /* Clean up. */ - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); /* No follow up questions. */ act_sel_dialog_data = NULL; FC_FREE(args); @@ -409,7 +409,7 @@ static void request_action_details_callback(GtkWidget *w, gpointer data) is_more_user_input_needed = TRUE; /* Clean up. */ - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); /* No client side follow up questions. */ act_sel_dialog_data = NULL; FC_FREE(args); @@ -425,7 +425,7 @@ static void found_city_callback(GtkWidget *w, gpointer data) dsend_packet_city_name_suggestion_req(&client.conn, args->actor_unit_id); - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); free(args); } @@ -448,7 +448,7 @@ static void upgrade_callback(GtkWidget *w, gpointer data) unit_list_destroy(as_list); } - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); free(args); } @@ -897,7 +897,7 @@ pvictim to NULL and account for !pvictim in create_advances_list. -- Syela */ * needs to know what action to take. */ is_more_user_input_needed = TRUE; - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); } /**********************************************************************//** @@ -1070,7 +1070,7 @@ static void act_sel_new_unit_tgt_callback(GtkWidget *w, gpointer data) did_not_decide = TRUE; action_selection_restart = TRUE; - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); free(args); } @@ -1168,7 +1168,7 @@ static void act_sel_new_extra_tgt_callback(GtkWidget *w, gpointer data) did_not_decide = TRUE; action_selection_restart = TRUE; - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); free(args); } @@ -1215,7 +1215,7 @@ static void act_sel_destroy_callback(GtkWidget *w, gpointer data) **************************************************************************/ static void act_sel_cancel_callback(GtkWidget *w, gpointer data) { - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); free(act_sel_dialog_data); } @@ -1224,7 +1224,7 @@ static void act_sel_cancel_callback(GtkWidget *w, gpointer data) **************************************************************************/ static void act_sel_close_callback(GtkWidget *w, gpointer data) { - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); free(act_sel_dialog_data); } @@ -1727,6 +1727,6 @@ void action_selection_close(void) { if (act_sel_dialog != NULL) { did_not_decide = TRUE; - gtk_widget_destroy(act_sel_dialog); + choice_dialog_destroy(act_sel_dialog); } } diff --git a/client/gui-gtk-4.0/choice_dialog.c b/client/gui-gtk-4.0/choice_dialog.c index 4d036f6110..0c8fe260e4 100644 --- a/client/gui-gtk-4.0/choice_dialog.c +++ b/client/gui-gtk-4.0/choice_dialog.c @@ -240,3 +240,13 @@ GtkWidget *popup_choice_dialog(GtkWindow *parent, const gchar *dialogname, return dshell; } + +/*******************************************************************//** + Free choice dialog. +***********************************************************************/ +void choice_dialog_destroy(GtkWidget *dlg) +{ + if (dlg != NULL) { + gtk_window_destroy(dlg); + } +} diff --git a/client/gui-gtk-4.0/choice_dialog.h b/client/gui-gtk-4.0/choice_dialog.h index 8aef5ea656..3e1051f2ce 100644 --- a/client/gui-gtk-4.0/choice_dialog.h +++ b/client/gui-gtk-4.0/choice_dialog.h @@ -22,6 +22,7 @@ void choice_dialog_set_hide(GtkWidget *dshell, gboolean setting); GtkWidget *choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text); +void choice_dialog_destroy(GtkWidget *dlg); void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip); -- 2.33.0