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: (call with wrapper to set up directories..)
14  *    sh builder.sh
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 // sort out import path - this is  a bit of a mess..
30 GIRepository = imports.gi.GIRepository;
31 GLib        = imports.gi.GLib;
32 /* use builder.sh
33 GIRepository.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
34 */
35
36 Gtk         = imports.gi.Gtk;
37 Gdk         = imports.gi.Gdk;
38 Pango       = imports.gi.Pango;
39
40 Gio         = imports.gi.Gio;
41 GObject     = imports.gi.GObject;
42 GtkSource   = imports.gi.GtkSource;
43 WebKit      = imports.gi.WebKit;
44 Vte         = imports.gi.Vte;
45
46 GtkClutter  = imports.gi.GtkClutter;
47
48 if (GtkClutter) {    
49     GtkClutter.init(Seed.argv);
50 }
51
52 File    = imports.File.File;
53
54 XObject = imports.XObject.XObject;
55 //XObject.debug = true;
56 Gtk.init(Seed.argv);
57
58
59 imports.searchPath.push('/'); // allow global paths..
60 // error checking todo..
61 var files = File.list(Seed.argv[2]);
62 var olist = [];
63
64 var gtkbuilder = false;
65 files.forEach(function(f) {
66     var fp = Seed.argv[2] + '/' + f;
67     if (!fp.match(/\.bjs$/)) {
68         return;
69     }
70     var js = fp.replace(/\.bjs$/, '.js');
71     if (File.isFile(js)) {
72         // check file time.. = bjs is less than compiled file..
73         if (File.mtime(fp) < File.mtime(js)) {
74             XObject.log("LOADING" + js);
75             olist.push(imports[js]);
76             return;
77         }
78         
79         
80     }
81     var gtkbuilder =  new imports.Builder.Provider.File.Gtk.Gtk({ path : fp });
82     gtkbuilder.loadItems(function() { });
83     XObject.log("COMPILING" + js);
84     var fn = gtkbuilder.saveJS();
85     if (fn === false) { // skip files that do not contain anythng!
86         return;
87     }
88     olist.push(imports[fn]);
89     
90     
91 });
92
93
94
95           
96 Gtk.main();
97