Builder3/Window.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
33 // we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
34 if (GIRepository.IRepository) { 
35     GIRepository.IRepository.prepend_search_path(
36         GLib.get_home_dir() + '/.Builder/girepository-1.1');
37 }
38 //print(JSON.stringify(GIRepository.IRepository.get_search_path()));
39
40 Gtk         = imports.gi.Gtk;
41 Gdk         = imports.gi.Gdk;
42 Pango       = imports.gi.Pango;
43
44 Gio         = imports.gi.Gio;
45 GObject     = imports.gi.GObject;
46 GtkSource   = imports.gi.GtkSource;
47 WebKit      = imports.gi.WebKit;
48 Vte         = imports.gi.Vte;
49
50 // we do not use these yet..
51 //Gdl         = imports.gi.Gdl;
52 GtkClutter  = imports.gi.GtkClutter;
53
54 if (GtkClutter) {    
55     GtkClutter.init(Seed.argv);
56 }
57
58 File    = imports.File.File;
59
60 XObject = imports.XObject.XObject;
61 //XObject.debug = true;
62 Gtk.init(Seed.argv);
63
64
65 imports.searchPath.push('/'); // allow global paths..
66 // error checking todo..
67 var files = File.list(Seed.argv[2]);
68 var olist = [];
69
70 var gtkbuilder = false;
71 files.forEach(function(f) {
72     var fp = Seed.argv[2] + '/' + f;
73     if (!fp.match(/\.bjs$/)) {
74         return;
75     }
76     var js = fp.replace(/\.bjs$/, '.js');
77     if (File.isFile(js)) {
78         // check file time.. = bjs is less than compiled file..
79         if (File.mtime(fp) < File.mtime(js)) {
80             XObject.log("LOADING" + js);
81             olist.push(imports[js]);
82             return;
83         }
84         
85         
86     }
87     var gtkbuilder =  new imports.Builder.Provider.File.Gtk.Gtk({ path : fp });
88     gtkbuilder.loadItems(function() { });
89     XObject.log("COMPILING" + js);
90     var fn = gtkbuilder.saveJS();
91     if (fn === false) { // skip files that do not contain anythng!
92         return;
93     }
94     olist.push(imports[fn]);
95     
96     
97 });
98
99
100
101           
102 Gtk.main();
103