commit: 911b61968acb8d85584a047a123e1e80c6b46b1c
parent: 7dc84b19ba98cc3f44c5fed97a4913af51546230
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 13 Apr 2019 20:34:31 +0200
Merge branch 'feaatures/tab-title-crash-reason' into develop
Diffstat:
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -41,7 +41,7 @@ static gboolean
WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data);
static gboolean
WebViewCb_notify__is__playing__audio(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data);
-void webView_tab_label_change(struct Client *browser);
+void webView_tab_label_change(struct Client *browser, const gchar *title);
static gboolean WebViewCb_notify__estimated_load_progress(WebKitWebView *webView,
GParamSpec *pspec,
gpointer user_data);
@@ -87,19 +87,18 @@ static gboolean
WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason)
{
(void)webView;
- char *str_reason;
switch(reason)
{
- case WEBKIT_WEB_PROCESS_CRASHED: str_reason = "the web process crashed."; break;
+ case WEBKIT_WEB_PROCESS_CRASHED: g_fprintf(stderr, "the web process crashed."; webView_tab_label_change(browser, "Crashed"); break;
case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT:
- str_reason = "the web process exceeded the memory limit.";
+ g_fprintf(stderr, "the web process exceeded the memory limit.";
+ webView_tab_label_change(browser, "Out of Memory");
break;
- default: str_reason = "the web process terminated for an unknown reason.";
+ default: g_fprintf(stderr, "the web process terminated for an unknown reason.");
+ webView_tab_label_change(browser, "Unknown Crash");
}
- g_fprintf(stderr, "BadWolf [signal: web-process-terminated]: %s\n", str_reason);
-
return FALSE;
}
@@ -156,7 +155,7 @@ WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user
(void)pspec;
struct Client *browser = (struct Client *)user_data;
- webView_tab_label_change(browser);
+ webView_tab_label_change(browser, NULL);
return TRUE;
}
@@ -168,22 +167,21 @@ WebViewCb_notify__is__playing__audio(WebKitWebView *webView, GParamSpec *pspec,
(void)pspec;
struct Client *browser = (struct Client *)user_data;
- webView_tab_label_change(browser);
+ webView_tab_label_change(browser, NULL);
return TRUE;
}
void
-webView_tab_label_change(struct Client *browser)
+webView_tab_label_change(struct Client *browser, const gchar *title)
{
- const gchar *title;
GtkWidget *notebook = browser->window->notebook;
- title = webkit_web_view_get_title(browser->webView);
+ if(title == NULL || title == "") title = webkit_web_view_get_title(browser->webView);
- if(title == NULL) title = webkit_web_view_get_uri(browser->webView);
+ if(title == NULL || title == "") title = webkit_web_view_get_uri(browser->webView);
- if(title == NULL) title = "BadWolf";
+ if(title == NULL || title == "") title = "BadWolf";
gtk_notebook_set_tab_label(
GTK_NOTEBOOK(notebook), browser->box, badwolf_new_tab_box(title, browser));
@@ -405,7 +403,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
g_signal_connect(browser->webView,
"web-process-terminated",
G_CALLBACK(WebViewCb_web_process_terminated),
- NULL);
+ browser);
g_signal_connect(browser->webView, "notify::uri", G_CALLBACK(WebViewCb_notify__uri), browser);
g_signal_connect(browser->webView, "notify::title", G_CALLBACK(WebViewCb_notify__title), browser);
g_signal_connect(browser->webView,