logo

badwolf

Unnamed repository; edit this file 'description' to name the repository.
commit: 61b316b14a139c3905f3ccf78e8caf2e5551e8d8
parent: edf42bcc6f542fbaff599f0a9b6c1b764970c5e7
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  7 Jan 2019 17:52:58 +0100

badwolf.c: Handle notify::title

Diffstat:

Mbadwolf.c18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/badwolf.c b/badwolf.c @@ -52,6 +52,23 @@ static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, return TRUE; } +static gboolean WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data) { + const gchar *title; + struct Client *browser = (struct Client *)user_data; + + title = webkit_web_view_get_title(browser->webView); + + if (title == NULL) + title = webkit_web_view_get_uri(browser->webView); + + if (title == NULL) + title = "BadWolf"; + + gtk_window_set_title(GTK_WINDOW(browser->main_window), title); + + return TRUE; +} + int main(int argc, char *argv[]) { struct Client *browser = calloc(1, sizeof(struct Client)); @@ -76,6 +93,7 @@ int main(int argc, char *argv[]) g_signal_connect(browser->webView, "close", G_CALLBACK(WebViewCb_close), browser->main_window); g_signal_connect(browser->webView, "web-process-terminated", G_CALLBACK(WebViewCb_web_process_terminated), NULL); 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); WebKitSettings *settings = webkit_web_view_get_settings(browser->webView);