commit: c323b97f353e6f5b0d363fb460f0de92028bad29
parent: 71c47bfd0512ebe544faacef3d20f62b2351d5d1
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 1 Apr 2019 21:51:08 +0200
badwolf.c: Close the WebView
WebKitNetworkProcess seems to be remnant but at least the
view closes more properly
Diffstat:
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -29,7 +29,7 @@ struct Client
struct Window *window;
};
-static gboolean WebViewCb_close(WebKitWebView *webView, GtkWidget *window);
+static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data);
static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView,
WebKitWebProcessTerminationReason reason);
static gboolean
@@ -63,10 +63,22 @@ int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser);
GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser);
int main(int argc, char *argv[]);
-static gboolean WebViewCb_close(WebKitWebView *webView, GtkWidget *window)
+static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data)
{
(void)webView;
- gtk_widget_destroy(window);
+ struct Client *browser = (struct Client *)user_data;
+ GtkNotebook *notebook = GTK_NOTEBOOK(browser->window->notebook);
+ GValue position = G_VALUE_INIT;
+ g_value_init(&position, G_TYPE_INT);
+
+ gtk_container_child_get_property(GTK_CONTAINER(notebook), browser->box, "position", &position);
+
+ gtk_notebook_remove_page(notebook, g_value_get_int(&position));
+
+ gtk_widget_destroy(browser->box);
+
+ free(browser);
+
return TRUE;
}
@@ -428,14 +440,8 @@ void closeCb_clicked(GtkButton *close, gpointer user_data)
{
(void)close;
struct Client *browser = (struct Client *)user_data;
- GtkNotebook *notebook = GTK_NOTEBOOK(browser->window->notebook);
- GValue position = G_VALUE_INIT;
- g_value_init(&position, G_TYPE_INT);
- gtk_container_child_get_property(GTK_CONTAINER(notebook), browser->box, "position", &position);
-
- gtk_notebook_remove_page(notebook, g_value_get_int(&position));
- free(browser);
+ webkit_web_view_try_close(browser->webView);
}
int main(int argc, char *argv[])