"destroy" : "() => {\n Gtk.main_quit();\n}",
"show" : "() => {\n\t\n\tprint(\"resizing window\\n\");\n\tthis.el.resize(1200,500);\n\tprint(\"loading url\\n\");\n\tthis.view.el.load_uri(webkitpdf.opt_url);\n\t\n\t// if we have not finished in 25 seconds\n\t// call printit...\n\t GLib.Timeout.add_seconds(25, () => { \n\t\t\t_this.view.printit();\n\t\t\treturn true;\n\t});\n\t\n\n}"
},
- "id" : "window",
"xtype" : "Window",
"$ xns" : "Gtk",
"Gtk.WindowType type" : "Gtk.WindowType.TOPLEVEL",
"load_finished" : "( ) => {\n\t\t \n this.printit();\n \n}"
},
"id" : "view",
- "| void printit" : "() {\n print(\"load_finsihed\\n\");\n \n if (this.print_started) {\n print(\"load_finsihed - already printing..\\n\");\n return;\n }\n \n this.print_started = true; // flag to stop double call.\n \n \n\t// inject any javascript if needed..\n\tif (webkitpdf.opt_inject_js != null) {\n\t\n\t\tprint(\"injecting javascript files \\n\");\n\t\tforeach(var inject_js in webkitpdf.opt_inject_js) {\n\t\tprint(\"inject? %s\\n\", inject_js);\n\t\t\tstring str;\n\t\t\ttry {\n\t\t\t\tFileUtils.get_contents( inject_js, out str);\n\t\t\t} catch(FileError e) {\n\t\t\t\tprint(\"Failed to inject %s\\n\", inject_js);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.el.execute_script(str);\n\t\t}\n\t}\n\t\n\t\n\t\n\tprint(\"calling print in %d seconds\\n\", (int)webkitpdf.opt_delay);\n\tif (webkitpdf.opt_target_pdf != null) {\n\t\tGLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { \n\n\t\t\tthis.printpdf();\n\t\t\t return false;\n\t\t}, GLib.Priority.DEFAULT);\n\t}\n\t\t\n\t\t\n GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { \n \n\t\t\n\t\t// ----------------- JPEG \n\t\t// resize the window...\n\t\t// window.document.documentElement.scrollHeight\n\t\tvar scroll_height = (int) _this.view.el.get_dom_document().document_element.scroll_height;\n\t\tprint(\"Scroll height %d\\n\", scroll_height);\n\t\tif (scroll_height> 1024 || webkitpdf.opt_width > 0 || webkitpdf.opt_height > 0 ) {\n\t\t\tvar w = webkitpdf.opt_width > 0 ? webkitpdf.opt_width : 1200;\n\t\t\tvar h = webkitpdf.opt_height > 0 ? webkitpdf.opt_height : int.min(scroll_height, 6000);\n\t\t\t_this.scrolled_window.el.set_size_request( w, h); \n\t\t\t_this.window.el.set_default_size (w+50, h+50);\n\t\t\tprint(\"Resize to %d, %d\\n\", w,h);\n\t\t GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { \n\t\t\t\tthis.printpng();\n\t\t\t\treturn false;\n\t\t\t }, GLib.Priority.DEFAULT);\n \t\t return false;\n\t\t}\n\t\tthis.printpng();\t\t\n\t\treturn false;\n\t }, GLib.Priority.DEFAULT);\n\n\n \n \n}\n",
+ "| void printit" : "() {\n print(\"load_finsihed\\n\");\n \n if (this.print_started) {\n print(\"load_finsihed - already printing..\\n\");\n return;\n }\n \n this.print_started = true; // flag to stop double call.\n \n \n\t// inject any javascript if needed..\n\tif (webkitpdf.opt_inject_js != null) {\n\t\n\t\tprint(\"injecting javascript files \\n\");\n\t\tforeach(var inject_js in webkitpdf.opt_inject_js) {\n\t\tprint(\"inject? %s\\n\", inject_js);\n\t\t\tstring str;\n\t\t\ttry {\n\t\t\t\tFileUtils.get_contents( inject_js, out str);\n\t\t\t} catch(FileError e) {\n\t\t\t\tprint(\"Failed to inject %s\\n\", inject_js);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.el.execute_script(str);\n\t\t}\n\t}\n\t\n\t\n\t\n\tprint(\"calling print in %d seconds\\n\", (int)webkitpdf.opt_delay);\n\tif (webkitpdf.opt_target_pdf != null) {\n\t\tGLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { \n\n\t\t\tthis.printpdf();\n\t\t\t return false;\n\t\t}, GLib.Priority.DEFAULT);\n\t}\n\t\t\n\t\t\n GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { \n \n\t\t\n\t\t// ----------------- JPEG \n\t\t// resize the window...\n\t\t// window.document.documentElement.scrollHeight\n\t\tvar scroll_height = (int) _this.view.el.get_dom_document().document_element.scroll_height;\n\t\tprint(\"Scroll height %d\\n\", scroll_height);\n\t\tif (scroll_height> 1024 || webkitpdf.opt_width > 0 || webkitpdf.opt_height > 0 ) {\n\t\t\tvar w = webkitpdf.opt_width > 0 ? webkitpdf.opt_width : 1200;\n\t\t\tvar h = webkitpdf.opt_height > 0 ? webkitpdf.opt_height : int.min(scroll_height, 6000);\n\t\t\t_this.scrolled_window.el.set_size_request( w, h); \n\t\t\t_this.el.set_default_size (w+50, h+50);\n\t\t\tprint(\"Resize to %d, %d\\n\", w,h);\n\t\t GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => { \n\t\t\t\tthis.printpng();\n\t\t\t\treturn false;\n\t\t\t }, GLib.Priority.DEFAULT);\n \t\t return false;\n\t\t}\n\t\tthis.printpng();\t\t\n\t\treturn false;\n\t }, GLib.Priority.DEFAULT);\n\n\n \n \n}\n",
"* pack" : "add",
"xtype" : "WebView",
"| bool printpdf" : "() {\n\t \n\t\tvar pe = new Gtk.PrintOperation();\n\t\tpe.export_filename = webkitpdf.opt_target_pdf;\n\t\tprint(\"got callback for print\");\n\t\tpe.ref();\n\t\t/*pe.failed.connect(() => {\n\t\t\tprint(\"print failed\\n\");\n\t\t\t Gtk.main_quit();\n \t\t\n\t\t})\n\t\t*/;\n\t\t pe.done.connect(() => {\n\t\t\tprint(\"print completed\\n\");\n\t\t\t Gtk.main_quit();\n \t\t\n\t\t});\n\t\t\n\t\t//pe.run_dialog(_this.el);\n\t \n\t\t\n\t var list = Gtk.PaperSize.get_paper_sizes(false);\n\t var psetup = new Gtk.PageSetup();\n\t for(var i = 0; i < list.length(); i++ ) {\n\t var entry = list.nth_data(i).copy();\n\t if (entry.get_name() == \"iso_a2\") {\n\t psetup.set_paper_size(entry);\n\t }\n\t }\n\t \n\n\n\t pe.set_default_page_setup(psetup);\n\t print(\"Calling Print?\\n\");\n\t //pe.run_dialog(_this.el);\n\t try {\n\t\t this.el.get_main_frame().print_full(pe,Gtk.PrintOperationAction.EXPORT);\n\t } catch (Error e) {\n\t\t\t// print failed...\n\t\t}\n\t \n\t \n\t \n\t\treturn false;\n}\n",
-static Xcls_window _window;
+static BrowserWindow _BrowserWindow;
-public class Xcls_window : Object
+public class BrowserWindow : Object
{
public Gtk.Window el;
- private Xcls_window _this;
+ private BrowserWindow _this;
- public static Xcls_window singleton()
+ public static BrowserWindow singleton()
{
- if (_window == null) {
- _window= new Xcls_window();
+ if (_BrowserWindow == null) {
+ _BrowserWindow= new BrowserWindow();
}
- return _window;
+ return _BrowserWindow;
}
public Xcls_scrolled_window scrolled_window;
public Xcls_view view;
// my vars (def)
// ctor
- public Xcls_window()
+ public BrowserWindow()
{
_this = this;
this.el = new Gtk.Window( Gtk.WindowType.TOPLEVEL );
public class Xcls_scrolled_window : Object
{
public Gtk.ScrolledWindow el;
- private Xcls_window _this;
+ private BrowserWindow _this;
// my vars (def)
// ctor
- public Xcls_scrolled_window(Xcls_window _owner )
+ public Xcls_scrolled_window(BrowserWindow _owner )
{
_this = _owner;
_this.scrolled_window = this;
public class Xcls_view : Object
{
public WebKit.WebView el;
- private Xcls_window _this;
+ private BrowserWindow _this;
// my vars (def)
public bool print_started;
// ctor
- public Xcls_view(Xcls_window _owner )
+ public Xcls_view(BrowserWindow _owner )
{
_this = _owner;
_this.view = this;
var w = webkitpdf.opt_width > 0 ? webkitpdf.opt_width : 1200;
var h = webkitpdf.opt_height > 0 ? webkitpdf.opt_height : int.min(scroll_height, 6000);
_this.scrolled_window.el.set_size_request( w, h);
- _this.window.el.set_default_size (w+50, h+50);
+ _this.el.set_default_size (w+50, h+50);
print("Resize to %d, %d\n", w,h);
GLib.Timeout.add_seconds(webkitpdf.opt_delay, () => {
this.printpng();