1 //<Script type="text/javascript">
4 GLib = imports.gi.GLib;
6 XObject = imports.XObject.XObject;
7 File = imports.File.File;
9 //----------------------- our roo verison
10 Base = imports.JsRender.Base.Base;
20 //"name":"Edit Module Details",
22 //"btype":"FORM", // was to be components...
24 //"module":"Pman.Tab.BuilderTop2"
26 cfg.parent = cfg.parent || '';
27 if (!cfg.name || !cfg.fullname ) {
29 // name is in theory filename without .bjs (or .js eventually...)
30 cfg.name = cfg.path.split('/').pop().replace(/\.(bjs|js)$/, '');
32 cfg.fullname = (cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name;
38 var jstr = JSON.parse(cfg.json);
39 this.items = [ jstr ];
40 //console.log(cfg.items.length);
41 delete cfg.json; // not needed!
45 var p = cfg.items && cfg.items.length && cfg.items[0].parent ? cfg.items[0].parent : false;
47 // ensure real data is set...
58 Gtk.superclass.constructor.call(this, cfg);
62 this.id = 'file-gtk-' + gid++;
64 // various loader methods..
70 setNSID : function(id)
73 this.items[0]['*class'] = id;
81 loadItems : function(cb)
85 if (this.items !== false) {
90 name: "ArgumentError",
91 message : "no callback for loadItems"
94 Seed.print("load: " + this.path);
100 var src = File.read(this.path);
102 var cfg = JSON.parse(src);
103 print("loaded data");
106 //_this.name = cfg.name; -- this should not happen - name should always match filename!!
107 _this.parent = cfg.parent;
108 _this.title = cfg.title;
109 _this.items = cfg.items || [];
119 * convert xtype for munged output..
122 mungeXtype : function(xtype, els)
124 els.push('xtype: '+ xtype);
127 toSource : function()
130 if (!this.items[0]) {
133 var data = JSON.parse(JSON.stringify(this.items[0]));
134 // we should base this on the objects in the tree really..
135 var i = [ 'Gtk', 'Gdk', 'Pango', 'GLib', 'Gio', 'GObject',
136 'GtkSource', 'WebKit', 'Vte' ]; //, 'GtkClutter' , 'Gdl'];
138 i.forEach(function(e) {
139 src += e+" = imports.gi." + e +";\n";
142 src += "console = imports.console;\n"; // path?!!?
143 src += "XObject = imports.XObject.XObject;\n"; // path?!!?
146 src += this.name + '=new XObject('+ this.mungeToString(data) + ");\n";
147 src += this.name + '.init();\n';
148 // register it in the cache
149 src += "XObject.cache['/" + this.name + "'] = " + this.name + ";\n";
157 Base.prototype.save.call(this);
164 * save as a javascript file.
165 * why is this not save...???
172 var fn = GLib.path_get_dirname(this.path) + '/' + this.name + '.js';
173 print("WRITE : " + fn);
174 File.write(fn, this.toSource());
179 getTree : function( o ) {
185 getHelpUrl : function(cls)
187 return 'http://devel.akbkhome.com/seed/' + cls + '.html';