1 static BrowserWindow _BrowserWindow;
3 public class BrowserWindow : Object
6 private BrowserWindow _this;
8 public static BrowserWindow singleton()
10 if (_BrowserWindow == null) {
11 _BrowserWindow= new BrowserWindow();
13 return _BrowserWindow;
15 public Xcls_view view;
20 public BrowserWindow()
23 this.el = new Gtk.Window( Gtk.WindowType.TOPLEVEL );
28 var child_0 = new Xcls_ScrolledWindow2( _this );
30 this.el.add ( child_0.el );
33 this.el.destroy.connect( () => {
36 this.el.show.connect( () => {
37 this.el.resize(1200,500);
38 this.view.el.load_uri(webkitpdf.opt_url);
43 // user defined functions
44 public class Xcls_ScrolledWindow2 : Object
46 public Gtk.ScrolledWindow el;
47 private BrowserWindow _this;
53 public Xcls_ScrolledWindow2(BrowserWindow _owner )
56 this.el = new Gtk.ScrolledWindow( null, null );
61 var child_0 = new Xcls_view( _this );
63 this.el.add ( child_0.el );
68 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
72 // user defined functions
74 public class Xcls_view : Object
76 public WebKit.WebView el;
77 private BrowserWindow _this;
83 public Xcls_view(BrowserWindow _owner )
87 this.el = new WebKit.WebView();
94 this.el.load_finished.connect( ( ) => {
96 print("load_finsihed\n");
98 // inject any javascript if needed..
99 if (webkitpdf.opt_inject_js != null) {
100 for(var i =0; i < webkitpdf.opt_inject_js.length;i++)
102 FileUtils.get_contents( webkitpdf.opt_inject_js[i], out str);
103 this.el.execute_string(str);
107 print("calling print in %d seconds\n", (int)webkitpdf.opt_delay);
108 GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => {
110 var pe = new Gtk.PrintOperation();
111 pe.export_filename = webkitpdf.opt_target_pdf;
112 print("got callback for print");
114 /*pe.failed.connect(() => {
115 print("print failed\n");
120 pe.done.connect(() => {
121 print("print completed\n");
126 //pe.run_dialog(_this.el);
129 var list = Gtk.PaperSize.get_paper_sizes(false);
130 var psetup = new Gtk.PageSetup();
131 for(var i = 0; i < list.length(); i++ ) {
132 var entry = list.nth_data(i).copy();
133 if (entry.get_name() == "iso_a2") {
134 psetup.set_paper_size(entry);
140 pe.set_default_page_setup(psetup);
141 print("Calling Print?\n");
142 //pe.run_dialog(_this.el);
143 this.el.get_main_frame().print_full(pe,Gtk.PrintOperationAction.EXPORT);
148 }, GLib.Priority.DEFAULT);
153 // user defined functions