From 29324fa435bd65f8fc76c7c44f501811567eac7c Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Tue, 22 Oct 2013 20:06:25 +0200 Subject: [PATCH] Show load progress in window title. This make it easier to see if the page is loaded event if its in a background tab. --- src/main.c | 19 ++++++++++++++++++- src/main.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index d835899..339bc57 100644 --- a/src/main.c +++ b/src/main.c @@ -67,6 +67,7 @@ static gboolean mimetype_decision_cb(WebKitWebView *webview, static void download_progress_cp(WebKitDownload *download, GParamSpec *pspec); /* functions */ +static void update_title(void); static void run_user_script(WebKitWebFrame *frame); static char *jsref_to_string(JSContextRef context, JSValueRef ref); static void init_core(void); @@ -390,6 +391,7 @@ static void webview_progress_cb(WebKitWebView *view, GParamSpec *pspec) { vb.state.progress = webkit_web_view_get_progress(view) * 100; vb_update_statusbar(); + update_title(); } static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec) @@ -456,6 +458,7 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) /* update load progress in statusbar */ vb.state.progress = 100; vb_update_statusbar(); + update_title(); if (strncmp(uri, "about:", 6)) { dom_check_auto_insert(view); @@ -879,7 +882,21 @@ static void hover_link_cb(WebKitWebView *webview, const char *title, const char static void title_changed_cb(WebKitWebView *webview, WebKitWebFrame *frame, const char *title) { - gtk_window_set_title(GTK_WINDOW(vb.gui.window), title); + OVERWRITE_STRING(vb.state.title, title); + update_title(); +} + +static void update_title(void) +{ + char *title; + /* show load status of page or the downloads */ + if (vb.state.progress != 100) { + title = g_strdup_printf("[%i%%] %s", vb.state.progress, vb.state.title); + gtk_window_set_title(GTK_WINDOW(vb.gui.window), title); + g_free(title); + } else { + gtk_window_set_title(GTK_WINDOW(vb.gui.window), vb.state.title); + } } static gboolean mimetype_decision_cb(WebKitWebView *webview, diff --git a/src/main.h b/src/main.h index 865d246..30eabb7 100644 --- a/src/main.h +++ b/src/main.h @@ -269,6 +269,7 @@ typedef struct { gboolean is_inspecting; GList *downloads; gboolean processed_key; + char *title; /* holds the window title */ } State; typedef struct { -- 2.20.1