gtkrun.js
[app.Builder.js] / gtkrun.js
1 #!/usr/bin/seed
2 //<Script type="text/javascript">
3 /**
4  * runtime file
5  * takes a gtk project directory, and turns it into an application!
6  * by compling the files into JS files..
7  * 
8  * Initially developed for runtime testing. (the vte runner)
9  * 
10  * Might be the way to go for full runtime 
11  * 
12  * 
13  * Usage
14  * gtkrun.js /path/to/myproject
15  * 
16  * Concepts.. 
17  * a) load dependancies.. (eg. gi's..) - derived later?
18  * Gtk.init()
19  * 
20  * loop the files (find .bjs)
21  *   - comple to js (if not exist // or force enabled..)
22  * b) load all the files
23  * 
24  * Gtk.main();
25  * 
26  */
27 // autogen?
28  
29 Gtk = imports.gi.Gtk;
30 Gdk = imports.gi.Gdk;
31 Pango = imports.gi.Pango;
32 GLib = imports.gi.GLib;
33 Gio = imports.gi.Gio;
34 GObject = imports.gi.GObject;
35 GtkSource = imports.gi.GtkSource;
36 WebKit = imports.gi.WebKit;
37 Vte = imports.gi.Vte;
38
39 File = imports.File.File;
40
41 XObject = imports.XObject.XObject;
42 XObject.debug = true;
43 Gtk.init(Seed.argv);
44
45 // error checking todo..
46 var files = File.list(Seed.argv[2]);
47 var olist = [];
48
49 var gtkbuilder = false;
50 files.forEach(function(f) {
51     var fp = Seed.argv[2] + '/' + f;
52     if (!fp.match(/\.bjs$/)) {
53         return;
54     }
55     var js = fp.replace(/\.bjs$/, '.js');
56     if (File.isFile(js)) {
57         // check file time.. = bjs is less than compiled file..
58         if (File.mtime(fp) < File.mtime(js)) {
59             print ("LOADING" + js);
60             olist.push(imports[js]);
61             return;
62         }
63         
64         
65     }
66     var gtkbuilder =  new imports.Builder.Provider.File.Gtk.Gtk({ path : fp });
67     gtkbuilder.loadItems(function() { });
68     print ("COMPILING" + js);
69     var fn = gtkbuilder.saveJS();
70     if (fn === false) { // skip files that do not contain anythng!
71         return;
72     }
73     olist.push(imports[fn]);
74     
75     
76 });
77
78
79
80           
81 Gtk.main();
82