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