[epiphany/wip/exalm/gtk4-cleanups-2: 27/27] window: Stop using gtk_dialog_run() for closing multiple windows
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/gtk4-cleanups-2: 27/27] window: Stop using gtk_dialog_run() for closing multiple windows
- Date: Tue, 30 Nov 2021 15:11:10 +0000 (UTC)
commit dd987c32762e2e7f94a7a1ac52b45dc92b8a1915
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 30 20:10:46 2021 +0500
window: Stop using gtk_dialog_run() for closing multiple windows
src/ephy-window.c | 45 +++++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 18 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 0625ec654..046360e12 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -193,6 +193,7 @@ struct _EphyWindow {
guint updating_address : 1;
guint force_close : 1;
guint checking_modified_forms : 1;
+ guint confirmed_close_with_multiple_tabs : 1;
guint present_on_insert : 1;
guint32 present_on_insert_user_time;
@@ -275,23 +276,6 @@ construct_confirm_close_dialog (EphyWindow *window,
return dialog;
}
-static gboolean
-confirm_close_with_multiple_tabs (EphyWindow *window)
-{
- GtkWidget *dialog;
- int response;
-
- dialog = construct_confirm_close_dialog (window,
- _("There are multiple tabs open."),
- _("If you close this window, all open tabs will be lost"),
- _("C_lose tabs"));
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
-
- return response == GTK_RESPONSE_ACCEPT;
-}
-
static void
impl_remove_child (EphyEmbedContainer *container,
EphyEmbed *child)
@@ -4310,6 +4294,19 @@ ephy_window_check_modified_forms (EphyWindow *window)
g_list_free (tabs);
}
+static void
+window_close_with_multiple_tabs_cb (GtkDialog *dialog,
+ GtkResponseType response,
+ EphyWindow *window)
+{
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (response == GTK_RESPONSE_ACCEPT) {
+ window->confirmed_close_with_multiple_tabs = TRUE;
+ gtk_window_close (GTK_WINDOW (window));
+ }
+}
+
/**
* ephy_window_close:
* @window: an #EphyWindow
@@ -4349,7 +4346,19 @@ ephy_window_close (EphyWindow *window)
if (ephy_shell_get_n_windows (ephy_shell_get_default ()) > 1 &&
ephy_tab_view_get_n_pages (window->tab_view) > 1 &&
!ephy_session_is_closing (session) &&
- !confirm_close_with_multiple_tabs (window)) {
+ !window->confirmed_close_with_multiple_tabs) {
+ GtkWidget *dialog;
+
+ dialog = construct_confirm_close_dialog (window,
+ _("There are multiple tabs open."),
+ _("If you close this window, all open tabs will be lost"),
+ _("C_lose tabs"));
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (window_close_with_multiple_tabs_cb),
+ window);
+ gtk_window_present (GTK_WINDOW (dialog));
+
/* stop window close */
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]