pidgin/pidgin

Close wait request when dialog is destroyed

14 months ago, Elliott Sales de Andrade
4313c029db44
Parents 9f746a79d7c4
Children 470d4d3c6faf
Close wait request when dialog is destroyed

Because the request was previously only closed when the Cancel button was
clicked, the request was dangling if the user clicked the window Close button,
or pressed Escape.

Testing Done:
Opened a wait request, then closed the dialog with Escape/the close button, and confirmed the cancel callback was triggered.

Reviewed at https://reviews.imfreedom.org/r/2293/
--- a/pidgin/gtkrequest.c Sun Feb 26 00:15:53 2023 -0600
+++ b/pidgin/gtkrequest.c Sun Feb 26 00:17:06 2023 -0600
@@ -918,7 +918,8 @@
}
static void
-wait_cancel_cb(G_GNUC_UNUSED GtkWidget *button, PidginRequestData *data)
+wait_response_cb(G_GNUC_UNUSED GtkDialog *dialog, G_GNUC_UNUSED gint id,
+ PidginRequestData *data)
{
generic_response_start(data);
@@ -936,7 +937,7 @@
{
PidginRequestData *data;
GtkWidget *dialog, *content;
- GtkWidget *hbox, *vbox, *img, *label, *button;
+ GtkWidget *hbox, *vbox, *img, *label;
gchar *primary_esc, *secondary_esc, *label_text;
data = g_new0(PidginRequestData, 1);
@@ -949,6 +950,9 @@
data->dialog = dialog = gtk_dialog_new();
+ g_signal_connect(G_OBJECT(dialog), "response",
+ G_CALLBACK(wait_response_cb), data);
+
gtk_window_set_deletable(GTK_WINDOW(data->dialog), cancel_cb != NULL);
if (title != NULL)
@@ -980,9 +984,7 @@
gtk_box_append(GTK_BOX(hbox), img);
/* Cancel button */
- button = gtk_dialog_add_button(GTK_DIALOG(dialog), _("Cancel"), GTK_RESPONSE_CANCEL);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(wait_cancel_cb), data);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), _("Cancel"), GTK_RESPONSE_CANCEL);
/* Vertical box */
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);