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