[epiphany/wip/exalm/gtk4-cleanups-2: 22/24] window: Stop using gtk_dialog_run() for closing windows with modified forms
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/gtk4-cleanups-2: 22/24] window: Stop using gtk_dialog_run() for closing windows with modified forms
- Date: Tue, 30 Nov 2021 20:23:48 +0000 (UTC)
commit 8f7111351b1ea3fa319be51142bad313974815e6
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 30 19:19:07 2021 +0500
window: Stop using gtk_dialog_run() for closing windows with modified forms
This code has been very fragile in the past, so the similar rework when
closing a tab will be in a separate commit.
Copypaste the original function - without gtk_dialog_run() sharing it
between the 2 code paths isn't worth it.
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1035>
src/ephy-window.c | 49 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 9 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index d87a88836..f288bcc3d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -4178,30 +4178,62 @@ window_has_modified_forms_data_free (WindowHasModifiedFormsData *data)
}
static void
-continue_window_close_after_modified_forms_check (WindowHasModifiedFormsData *data)
+finish_window_close_after_modified_forms_check (WindowHasModifiedFormsData *data)
{
gboolean should_close;
+ data->window->force_close = TRUE;
+ should_close = ephy_window_close (data->window);
+ data->window->force_close = FALSE;
+ if (should_close)
+ gtk_widget_destroy (GTK_WIDGET (data->window));
+
+ window_has_modified_forms_data_free (data);
+}
+
+static void
+confirm_close_window_with_modified_forms_cb (GtkDialog *dialog,
+ GtkResponseType response,
+ WindowHasModifiedFormsData *data)
+{
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ finish_window_close_after_modified_forms_check (data);
+ else
+ window_has_modified_forms_data_free (data);
+}
+
+static void
+continue_window_close_after_modified_forms_check (WindowHasModifiedFormsData *data)
+{
data->window->checking_modified_forms = FALSE;
g_clear_handle_id (&data->window->modified_forms_timeout_id, g_source_remove);
if (data->modified_embed) {
+ GtkWidget *dialog;
+
/* jump to the first tab with modified forms */
impl_set_active_child (EPHY_EMBED_CONTAINER (data->window),
data->modified_embed);
- if (!confirm_close_with_modified_forms (data->window))
- return;
+
+ dialog = construct_confirm_close_dialog (data->window,
+ _("Do you want to leave this website?"),
+ _("A form you modified has not been submitted."),
+ _("_Discard form"));
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (confirm_close_window_with_modified_forms_cb),
+ data);
+ gtk_window_present (GTK_WINDOW (dialog));
+
+ return;
}
/* FIXME: We only checked the first tab with modified forms. If more tabs
* have modified forms, they will be lost and the user will not be warned.
*/
- data->window->force_close = TRUE;
- should_close = ephy_window_close (data->window);
- data->window->force_close = FALSE;
- if (should_close)
- gtk_widget_destroy (GTK_WIDGET (data->window));
+ finish_window_close_after_modified_forms_check (data);
}
static void
@@ -4227,7 +4259,6 @@ window_has_modified_forms_cb (EphyWebView *view,
return;
continue_window_close_after_modified_forms_check (data);
- window_has_modified_forms_data_free (data);
}
/* This function checks an entire EphyWindow to see if it contains any tab with
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]