tazweb rev 80

Fix window title when new webview is requested
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 24 12:30:41 2011 +0200 (2011-04-24)
parents a206cb059181
children faa4ee68950b
files src/main.c
line diff
     1.1 --- a/src/main.c	Sun Apr 24 03:21:36 2011 +0200
     1.2 +++ b/src/main.c	Sun Apr 24 12:30:41 2011 +0200
     1.3 @@ -51,7 +51,7 @@
     1.4  
     1.5  /* Loader area */
     1.6  static void
     1.7 -draw_loader()
     1.8 +update_loader()
     1.9  {
    1.10  	GdkGC* gc;
    1.11  	GdkColor fg;
    1.12 @@ -74,36 +74,38 @@
    1.13  static gboolean
    1.14  expose_loader_cb(GtkWidget *loader, GdkEventExpose *event, gpointer data)
    1.15  {
    1.16 -	draw_loader();
    1.17 +	update_loader();
    1.18  	return TRUE;
    1.19  }
    1.20  
    1.21 -/* Update title and loader */
    1.22 +/* Update title */
    1.23  static void
    1.24 -update()
    1.25 +update_title(GtkWindow* window, WebKitWebView* webview)
    1.26  {
    1.27 -	gchar* title = g_strdup(pagetitle);
    1.28 -	if(! pagetitle)
    1.29 -		title = g_strdup_printf("Unknow - TazWeb", pagetitle);
    1.30 -	draw_loader();
    1.31 -	gtk_window_set_title(GTK_WINDOW(mainwindow), title);
    1.32 +	GString *string = g_string_new(webkit_web_view_get_title(webview));
    1.33 +	gdouble loadprogress = webkit_web_view_get_progress(webview) * 100;
    1.34 +	//g_string_append(string, " - TazWeb");
    1.35 +	gchar *title = g_string_free(string, FALSE);
    1.36 +	gtk_window_set_title(window, title);
    1.37  	g_free(title);
    1.38  }
    1.39  
    1.40  /* Get the page title */
    1.41  static void
    1.42 -notify_title_cb(WebKitWebView* webview, GParamSpec* pspec, gpointer data)
    1.43 +notify_title_cb(WebKitWebView* webview, GParamSpec* pspec, GtkWidget* window)
    1.44  {
    1.45  	pagetitle = g_strdup(webkit_web_view_get_title(webview));
    1.46 -	update();
    1.47 +	update_title(GTK_WINDOW(window), webview);
    1.48 +	update_loader();
    1.49  }
    1.50  
    1.51  /* Request progress in window title */
    1.52  static void
    1.53 -notify_progress_cb(WebKitWebView* webview, GParamSpec* pspec, gpointer data)
    1.54 +notify_progress_cb(WebKitWebView* webview, GParamSpec* pspec, GtkWidget* window)
    1.55  {
    1.56  	progress = webkit_web_view_get_progress(webview) * 100;
    1.57 -	update();
    1.58 +	update_title(GTK_WINDOW(window), webview);
    1.59 +	update_loader();
    1.60  }
    1.61  
    1.62  /* Notify loader and url entry */
    1.63 @@ -116,7 +118,7 @@
    1.64  		break;
    1.65  	case WEBKIT_LOAD_FINISHED:
    1.66  		progress = 0;
    1.67 -		update();
    1.68 +		update_loader();
    1.69  		break;
    1.70  	}
    1.71  	frame = webkit_web_view_get_main_frame(webview);
    1.72 @@ -326,11 +328,11 @@
    1.73  
    1.74  	/* Connect WebKit events */
    1.75  	g_signal_connect(webview, "notify::title",
    1.76 -			G_CALLBACK(notify_title_cb), webview);
    1.77 +			G_CALLBACK(notify_title_cb), window);
    1.78  	g_signal_connect(webview, "notify::progress",
    1.79 -			G_CALLBACK(notify_progress_cb), webview);
    1.80 +			G_CALLBACK(notify_progress_cb), window);
    1.81  	g_signal_connect(webview, "notify::load-status",
    1.82 -			G_CALLBACK(notify_load_status_cb), webview);
    1.83 +			G_CALLBACK(notify_load_status_cb), window);
    1.84  	g_signal_connect(webview, "download-requested",
    1.85  			G_CALLBACK(download_requested_cb), NULL);
    1.86  	g_signal_connect(webview, "create-web-view",