honour delay in webkit2 printing
[app.webkitpdf] / BrowserWindow.vala
index e1f421c..280047f 100644 (file)
@@ -292,8 +292,12 @@ public class BrowserWindow : Object
                        
         
         #if GTK3
-               print("PNG not supported in webkit2\n");
-               return;
+               GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { 
+                               print("delay done URL: %s\n", this.el.uri);
+                               this.printpng();        
+                               return false;
+                       }, GLib.Priority.DEFAULT);
+                       return;
         #else
                        
             GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { 
@@ -415,6 +419,16 @@ public class BrowserWindow : Object
         
              print("making screenshot\n");
         #if GTK3
+        GLib.MainLoop mainloop = new GLib.MainLoop();
+          _this.view.el.get_snapshot.begin(WebKit.SnapshotRegion.FULL_DOCUMENT, WebKit.SnapshotOptions.NONE, null, (obj, res) => {
+                        var sf = _this.view.el.get_snapshot.end(res);
+                        sf.write_to_png(webkitpdf.opt_target_png);
+               print("Saved to %s\n", webkitpdf.opt_target_png);
+                        mainloop.quit();
+                        
+          });
+        
+               mainloop.run();
         
         #else     
             // fix vapi - get_snapshot add '?' to all null.
@@ -438,10 +452,12 @@ public class BrowserWindow : Object
         
             //    sf.write_to_png(Browser.opt_target_png);
             //});
+        #endif       
            this.delete_cookiefile(); 
+           
             Gtk.main_quit();
              
-        #endif   
+