[Xfce4-commits] <tumbler:jeromeg/webkit-thumbnailer> Use notify::load-status signal to handle page load.

Jérôme Guelfucci noreply at xfce.org
Sat Jun 4 14:28:02 CEST 2011


Updating branch refs/heads/jeromeg/webkit-thumbnailer
         to 9e139130c65f0324663496f01d3432b67902eb00 (commit)
       from 3c65a449a6905782dc5230499b5f6f74ce9bf250 (commit)

commit 9e139130c65f0324663496f01d3432b67902eb00
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sat Jun 4 14:26:48 2011 +0200

    Use notify::load-status signal to handle page load.
    
    This allows us to also handle errors on page loading which was not done
    before.

 plugins/webkit-thumbnailer/webkit-thumbnailer.c |   38 +++++++++++++++-------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/plugins/webkit-thumbnailer/webkit-thumbnailer.c b/plugins/webkit-thumbnailer/webkit-thumbnailer.c
index b0b6a02..f490dd9 100644
--- a/plugins/webkit-thumbnailer/webkit-thumbnailer.c
+++ b/plugins/webkit-thumbnailer/webkit-thumbnailer.c
@@ -119,17 +119,31 @@ cb_view_loaded_idle (gpointer webkit_thumbnailer)
 
 
 static void
-cb_view_load_finished (GtkWidget         *web_view,
-                       WebKitWebFrame    *web_frame,
-                       WebkitThumbnailer *thumbnailer)
+cb_view_load_status (GtkWidget         *web_view,
+                     GParamSpec        *pspec,
+                     WebkitThumbnailer *thumbnailer)
 {
-  /* force a redraw of the offscreen window to make sure we snapshot
-   * the latest visual changes */
-  gtk_widget_queue_draw (thumbnailer->view);
-  gdk_window_process_updates (gtk_widget_get_window (thumbnailer->offscreen),
-                              TRUE);
-
-  g_idle_add (cb_view_loaded_idle, thumbnailer);
+  switch (webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (web_view)))
+    {
+      case WEBKIT_LOAD_FINISHED:
+        /* force a redraw of the offscreen window to make sure we snapshot
+         * the latest visual changes */
+        gtk_widget_queue_draw (thumbnailer->view);
+        gdk_window_process_updates (gtk_widget_get_window (thumbnailer->offscreen),
+                                    TRUE);
+
+        /* capture the web view content in an idle handler */
+        g_idle_add (cb_view_loaded_idle, thumbnailer);
+        break;
+
+      case WEBKIT_LOAD_FAILED:
+        /* exit the main loop, an error will be returned */
+        gtk_main_quit ();
+        break;
+
+      default:
+        break;
+    }
 }
 
 
@@ -171,8 +185,8 @@ webkit_thumbnailer_init (WebkitThumbnailer *thumbnailer)
 
   /* signal to retrieve thumbnails once the page is loaded */
   g_signal_connect (thumbnailer->view,
-                    "load-finished",
-                    G_CALLBACK (cb_view_load_finished),
+                    "notify::load-status",
+                    G_CALLBACK (cb_view_load_status),
                     thumbnailer);
 
   gtk_container_add (GTK_CONTAINER (thumbnailer->offscreen),



More information about the Xfce4-commits mailing list