Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
WebKit = imports.gi.WebKit;
TabbedBrowser = imports.TabbedBrowser;
var maxQueue = 0;
var injected = {};
- var storedir = '/tmp/wkqueue';
+ var storedir = '/home/alan/wkqueue';
if (!File.exists(storedir)) {
File.mkdir(storedir);
}
//}
//injected[this.uri]++;
var fn = __script_path__ + "/nsinject.js";
- if (File.exists(fn)) {
+ //if (File.exists(fn)) {
print("Adding inject");
var newjs = File.read(__script_path__ + "/nsinject.js");
TabbedBrowser.browser.current_tab().get_web_view().execute_script(
newjs
);
- }
+ //}
}
var load_finished = function ()
{
print("load finished");
- tab.get_toolbar().set_progress(0);
-
-
+ GLib.timeout_add(GLib.PRIORITY_LOW, 1000, function() {
+
+// _t.open("http://sg.lifestyleasia.com/videos/video-british-polo-day-singapore-2012/");
+ var mf = _t.get_main_frame();
+
+ var ar = Gtk.PaperSize.get_paper_sizes();
+ var psetup = new Gtk.PageSetup();
+ for(var i = 0; i < ar.length; i++) {
+// print(ar[i].get_name());
+ if (ar[i].get_name() =='iso_a2') {
+ psetup.set_paper_size(ar[i]);
+ }
+ }
+
+
+
+ var p = new Gtk.PrintOperation({ export_filename : '/home/chris/test_pdf/test2.pdf' });
+
+ //s.set_paper_size('iso_a4');
+
+ p.set_default_page_setup(psetup);
+ p.set_scale(0.5);
+ //var s = p.get_print_settings();
+ //print(s);
+ //p.set_print_settings(s);
+ mf.print_full(p, Gtk.PrintOperationAction.EXPORT)
+ //Seed.quit();
+ });
+
+ return;
+ tab.get_toolbar().set_progress(0);
_t.add_inject(true);
print(typeof(Seed.argv[2]));
if (Seed.argv[2] == null) {
print("NEED ID!");
- Seed.exit();
+ Seed.quit();
}
_t.nsdownloadNext(Seed.argv[2] * 1)
};
var nsqueue = false;
- this.nsdownloadNext = function(pg)
+ this.nsdownloadNext = function()
{
/*if (nsqueue === false) {
nsqueue = [
}
var pg = nsqueue.shift() ;
+
+ */
+
+ //print(typeof(Seed.argv[2]));
+ if (!Seed.argv[2]) {
+ print("NEED ID!");
+ Seed.quit();
+
+ }
+ var pg = Seed.argv[2] * 1;
if ( File.exists( storedir+'/output/' + pg + '.csv')) {
- this.nsdownloadNext();
+ print("DONE : " + storedir+'/output/' + pg + '.csv');
+ Seed.quit();
return;
}
- */
+
var pd = JSON.parse(File.read('/home/alan/.nspasswd'));
+ print("downloadnext : " + pg);
this.execute_script(
'NS.login(' + JSON.stringify(pd.username) + ',' + JSON.stringify(pd.password) + ',' + pg + ' );'
// Implementation
//this.set_scroll_adjustments(null, null);
-
+
this.signal.title_changed.connect(update_title);
this.signal.load_committed.connect(load_committed);
this.signal.load_finished.connect(load_finished);
this.signal.load_progress_changed.connect(update_progress);
-
+
// For some reason, this segfaults seed in the instance init closure handler
// Once that's fixed, uncommenting the next line will give middle-click-open-in-new tab
//this.signal.navigation_policy_decision_requested.connect(clicked_link);
this.signal.create_web_view.connect(create_new_tab);
+
print("ADDing console message sig handler");
}
print("got method : " + ret.method);
+ if (ret.method == 'exit') {
+ Seed.quit();
+ }
+
+
if (ret.method == 'nsdownloadpage'){
try {
var mt = ret.contentType.split(';').shift();
switch(mt) {
case '':
- _t.nsdownloadNext();
+ print("CONSOLE GOT BLANK - call download next?");
+ Seed.quit();
+ //_t.nsdownloadNext();
// _t.moveToDone(ret.requesturl);
break;
File.writeBinaryArray(target,ret.data);
print("Wrote to file: " + target);
// get next..
- _t.nsdownloadNext();
+ return true;
+ //Seed.quit();
+ //_t.nsdownloadNext();