resources/RooUsage.txt
[app.Builder.js] / old-javascript / 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 GIRepository.Repository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.2');
35 //print(JSON.stringify(GIRepository.IRepository.get_search_path()));
36
37 Gtk         = imports.gi.Gtk;
38 Gdk         = imports.gi.Gdk;
39 Pango       = imports.gi.Pango;
40
41 Gio         = imports.gi.Gio;
42 GObject     = imports.gi.GObject;
43 GtkSource   = imports.gi.GtkSource;
44 WebKit      = imports.gi.WebKit;
45 Vte         = imports.gi.Vte;
46  
47 //Gdl         = imports.gi.Gdl;
48
49 //GtkClutter  = imports.gi.GtkClutter;
50
51
52 if (typeof(GtkClutter) != 'undefined') {    
53     GtkClutter.init(Seed.argv);
54 }
55
56
57 File    = imports.File.File;
58
59 XObject = imports.XObject.XObject;
60 //XObject.debug = true;
61 Gtk.init(Seed.argv);
62
63 Globals = imports.Globals;
64
65
66 imports.searchPath.push('/'); // allow global paths..
67 // error checking todo..
68 var files = File.list(Seed.argv[2]);
69 var olist = [];
70
71 var gtkbuilder = false;
72 files.forEach(function(f) {
73     var fp = Seed.argv[2] + '/' + f;
74     
75     
76     
77     if (!fp.match(/\.js$/)) {
78         return;
79     }
80     var js = fp; //.replace(/\.js$/, '.js');
81     if (File.isFile(js)) {
82         // check file time.. = bjs is less than compiled file..
83         //if (File.mtime(fp) < File.mtime(js)) {
84             XObject.log("LOADING" + js);
85             olist.push(imports[js]);
86             return;
87         //}
88         // Compiling BJS is depreciated..
89         //olist.push(imports[js]);
90         //return;
91         
92     }
93     
94     return;
95     /*
96     var gtkbuilder =  new imports.Builder.Provider.File.Gtk.Gtk({ path : fp });
97     gtkbuilder.loadItems(function() { });
98     XObject.log("COMPILING" + js);
99     var fn = gtkbuilder.saveJS();
100     if (fn === false) { // skip files that do not contain anythng!
101         return;
102     }
103     olist.push(imports[fn]);
104     */
105     
106 });
107
108
109
110           
111 Gtk.main();
112