[epiphany/wip/exalm/gtk4-cleanups-2: 19/27] window-commands: Stop using gtk_dialog_run() for check-form-and-reload




commit ded85b0e9b83f4001371e9758ec68c8db74a5d42
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Nov 30 16:50:16 2021 +0500

    window-commands: Stop using gtk_dialog_run() for check-form-and-reload

 src/window-commands.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/window-commands.c b/src/window-commands.c
index ec50c3316..20b77e879 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1158,6 +1158,23 @@ window_cmd_stop (GSimpleAction *action,
   webkit_web_view_stop_loading (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
 }
 
+static void
+check_tab_has_modified_forms_confirm_cb (GtkDialog       *dialog,
+                                         GtkResponseType  response,
+                                         EphyEmbed       *embed)
+{
+  WebKitWebView *view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+
+  gtk_widget_destroy (GTK_WIDGET (dialog));
+
+  if (response == GTK_RESPONSE_ACCEPT) {
+    gtk_widget_grab_focus (GTK_WIDGET (embed));
+    webkit_web_view_reload (view);
+  }
+
+  g_object_unref (embed);
+}
+
 static void
 check_tab_has_modified_forms_and_reload_cb (EphyWebView  *view,
                                             GAsyncResult *result,
@@ -1167,7 +1184,6 @@ check_tab_has_modified_forms_and_reload_cb (EphyWebView  *view,
   GtkWidget *dialog;
   GtkWidget *button;
   gboolean has_modified_forms;
-  int response = GTK_RESPONSE_ACCEPT;
 
   has_modified_forms = ephy_web_view_has_modified_forms_finish (view, result, NULL);
   if (has_modified_forms) {
@@ -1186,18 +1202,18 @@ check_tab_has_modified_forms_and_reload_cb (EphyWebView  *view,
 
     gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (window)),
                                  GTK_WINDOW (dialog));
-    response = gtk_dialog_run (GTK_DIALOG (dialog));
 
-    gtk_widget_destroy (dialog);
-  }
+    g_signal_connect (dialog, "response",
+                      G_CALLBACK (check_tab_has_modified_forms_confirm_cb), embed);
 
-  if (response == GTK_RESPONSE_ACCEPT) {
-    WebKitWebView *view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+    gtk_window_present (GTK_WINDOW (dialog));
 
-    gtk_widget_grab_focus (GTK_WIDGET (embed));
-    webkit_web_view_reload (view);
+    return;
   }
 
+  gtk_widget_grab_focus (GTK_WIDGET (embed));
+  webkit_web_view_reload (WEBKIT_WEB_VIEW (view));
+
   g_object_unref (embed);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]