1 //<Script type="text/javascript">
4 GLib = imports.gi.GLib;
5 console = imports.console;
6 XObject = imports.XObject.XObject;
7 File = imports.File.File;
9 //----------------------- our roo verison
10 Base = imports.Builder.Provider.File.Base.Base;
18 //"name":"Edit Module Details",
20 //"btype":"FORM", // was to be components...
22 //"module":"Pman.Tab.BuilderTop2"
24 cfg.parent = cfg.parent || '';
25 if (!cfg.name || !cfg.fullname ) {
27 // name is in theory filename without .bjs (or .js eventually...)
28 cfg.name = cfg.path.split('/').pop().replace(/\.(bjs|js)$/, '');
30 cfg.fullname = (cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name;
36 var jstr = JSON.parse(cfg.json);
37 this.items = [ jstr ];
38 //console.log(cfg.items.length);
39 delete cfg.json; // not needed!
43 var p = cfg.items && cfg.items.length && cfg.items[0].parent ? cfg.items[0].parent : false;
45 // ensure real data is set...
56 Gtk.superclass.constructor.call(this, cfg);
60 this.id = 'file-gtk-' + gid++;
62 // various loader methods..
68 setNSID : function(id)
71 this.items[0]['*class'] = id;
79 loadItems : function(cb)
82 console.log("load Items!");
83 if (this.items !== false) {
88 name: "ArgumentError",
89 message : "no callback for loadItems"
92 Seed.print("load: " + this.path);
98 var src = File.read(this.path);
100 var cfg = JSON.parse(src);
101 print("loaded data");
104 //_this.name = cfg.name; -- this should not happen - name should always match filename!!
105 _this.parent = cfg.parent;
106 _this.title = cfg.title;
107 _this.items = cfg.items || [];
113 // update to new JSDOC api!?
115 var tstream = new JSDOC.TextStream(src);
116 var tr = new JSDOC.TokenReader( {
120 var toks = tr.tokenize(tstream);
121 //console.dump(toks);
123 var ts = new JSDOC.Collapse(toks);
124 //console.dump(ts.tokens);
125 var rd = new JSDOC.GtkFile(ts.tokens);
130 _this.items = [ src ];
135 console.dump(rd.cfg);
136 //!!??? have we got engouth!
137 // try parsing self..
138 _this.items = [ rd.cfg ];
139 _this.imports = rd.imports;
140 _this.giImports = rd.giImports ;
151 * convert xtype for munged output..
154 mungeXtype : function(xtype, els)
156 els.push('xtype: '+ xtype);
163 * save as a javascript file.
170 if (!this.items[0]) {
173 var data = JSON.parse(JSON.stringify(this.items[0]));
174 var i = [ 'Gtk', 'Gdk', 'Pango', 'GLib', 'Gio', 'GObject',
175 'GtkSource', 'WebKit', 'Vte' , 'GtkClutter' , 'Gdl'];
177 i.forEach(function(e) {
178 src += e+" = imports.gi." + e +";\n";
181 src += "console = imports.console;\n"; // path?!!?
182 src += "XObject = imports.XObject.XObject;\n"; // path?!!?
185 src += this.name + '=new XObject('+ this.mungeToString(data) + ");\n";
186 src += this.name + '.init();\n';
187 // register it in the cache
188 src += "XObject.cache['/" + this.name + "'] = " + this.name + ";\n";
191 var fn = GLib.path_get_dirname(this.path) + '/' + this.name + '.js';
192 print("WRITE : " + fn);
198 getTree : function( o ) {
204 getHelpUrl : function(cls)
206 return 'http://devel.akbkhome.com/seed/' + cls + '.html';