GtkSource = imports.gi.GtkSource;
WebKit = imports.gi.WebKit;
Vte = imports.gi.Vte;
-//GtkClutter = imports.gi.GtkClutter;
console = imports.console;
XObject = imports.XObject.XObject;
Window=new XObject({
},
show : function (self) {
- imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
+ imports.ProjectManager.ProjectManager.loadConfig();
print("HIDEWIN - calling MidPropTree hidewin")
this.get('/MidPropTree').hideWin();
};
this.targetList = new Gtk.TargetList();
this.targetList.add( this.atoms["STRING"], 0, 0);
- //imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
+ //imports.ProjectManager.ProjectManager.loadConfig();
Gtk.rc_parse_string(
"style \"gtkcombobox-style\" {\n" +
" GtkComboBox::appears-as-list = 1\n" +
this.get('/LeftProjectTree').showNoProjectSelected();
return true;
}
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ var pm = imports.ProjectManager.ProjectManager;
this.get('/DialogNewComponent').show({
project : pm.getByFn(fn)
});
this.get('/StandardErrorDialog').show("Select a project")
return;
}
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ var pm = imports.ProjectManager.ProjectManager;
var pr = pm.getByFn(fn);
// confirm..
File.write( target+ '/builder.html', html);
this.get('/Terminal').feed("RUN DIR:" + target);
-
- this.get('/Terminal').el.fork_command( null , [], [], target
- , false,false,false);
+ var out = {};
+ this.get('/Terminal').el.fork_command_full(
+ Vte.PtyFlags.DEFAULT,
+ target ,
+ [], //argv
+ [], // env
+ 0, //spawn flags
+ null, // user func
+ null, // child setupdata
+ out
+ );
var cmd = "firefox file://" + target + "/builder.html \n";
this.get('/Terminal').el.feed_child(cmd, cmd.length);
return false;
if (!this.get('/Editor').save()) {
// popup!! - click handled..
return true;
- }
+ }
if (!this.el.expanded) {
this.onExpand();
},
onExpand : function() {
var nb = this.get('/LeftTopPanel.notebook');
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ var pm = imports.ProjectManager.ProjectManager;
var model = this.get('/LeftProjectTree.combomodel');
},
getPaleteProvider : function() {
var model = this.get('model');
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ var pm = imports.ProjectManager.ProjectManager;
return pm.getPalete(model.file.getType());
},
getRenderer : function() {
// it may not be loaded yet..
return true;
}
- pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
- this.get('/LeftTree.model').listAllTypes()));
+ pm.load(
+ this.get('/LeftTree').getPaleteProvider().gatherList(
+ this.get('/LeftTree.model').listAllTypes()
+ )
+ );
if (render && render.redraw) {
render.redraw();
}
var _this = this;
function addall(li)
{
- li.forEach(function(el) {
+ var el;
+ for (var i =0 ; i < li.length; i++ ) {
+ el = li[i];
+
// this is specific to roo!!!?
if (!el) { // skip empty?
return;
addall(el.items);
}
- });
+ };
}
} else {
this.el.append(ret);
}
- print(JSON.stringify(ret,null,4));
- print('call nodeToJSON: ' + tr[i]);
+ //print(JSON.stringify(ret,null,4));
+ //print('call nodeToJSON: ' + tr[i]);
var body = this.nodeToJSON(tr[i]);
- print(body);
+ //print(body);
//this.el.set_value(ret.iter, 0, '' _ [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
//this.el.set_value(ret.iter, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
//this.el.set_value(ret.iter, 2, [GObject.TYPE_STRING, body ]);
},
loadFile : function(f) {
//console.dump(f);
+ print("LOADFILE");
this.el.clear();
this.file = f;
return;
}
print("LOAD");
- print(JSON.stringify(f.items, null,4));
+ //print(JSON.stringify(f.items, null,4));
//console.dump(f.items);
this.load(f.items);
this.get('/LeftTree.view').el.expand_all();
//this.get('/RightEditor').el.hide();
this.get('/Editor').el.hide();
print("set current tree");
+
this.currentTree = this.toJS(false, false)[0];
- console.dump(this.currentTree);
+
+
+ //console.dump(this.currentTree);
this.currentTree = this.currentTree || { items: [] };
this.get('/LeftTree').renderView();
- console.dump(this.map);
+ // console.dump(this.map);
//var RightPalete = imports.Builder.RightPalete.RightPalete;
var pm = this.get('/RightPalete.model');
// set up provider..
},
nodeToJS : function (treepath, with_id)
{
- print("nodeToJS : WITHID: "+ with_id);
+ //print("nodeToJS : WITHID: "+ with_id);
var iter = treepath; // API used to be iter here..
if (typeof(iter) == 'string') {
var ret = {};
var iv = this.getIterValue(iter, 2);
// print("IV" + iv);
var k = JSON.parse(iv);
- if (k.json && !this.el.iter_parent( pret, iter )) {
+ if (k && k.json && !this.el.iter_parent( pret, iter )) {
delete k.json;
}
},
toJS : function(treepath, with_id)
{
- print("toJS : WITHID: "+ with_id);
+ //print("toJS : WITHID: "+ with_id);
+
var iter = treepath; // API used to be iter here..
+
if (typeof(iter) == 'string') {
var ret = {};
if (!this.el.get_iter(ret, new Gtk.TreePath.from_string(treepath))) {
return false;
}
iter = ret.iter;
- }
+ }
+
var first = false;
+
if (!iter) {
this.treemap = { };
listeners : {
changed : function (self) {
var fn = this.getValue();
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ var pm = imports.ProjectManager.ProjectManager;
this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
}
},
if (ix < 0 ) {
return false;
}
- var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
+ var data = imports.ProjectManager.ProjectManager.projects;
if (typeof(data[ix]) == 'undefined') {
return false;
}
{
var el = this.el;
el.set_active(-1);
- var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
+ var data = imports.ProjectManager.ProjectManager.projects;
data.forEach(function(n, ix) {
if (fn == n.fn) {
el.set_active(ix);
pack : "set_model",
init : function() {
XObject.prototype.init.call(this);
- this.el.set_column_types ( 2, [
+ this.el.set_column_types ( 2, [
GObject.TYPE_STRING, // real key
GObject.TYPE_STRING // real type
] );
// this.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);
- var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ var pm = imports.ProjectManager.ProjectManager;
var _this = this;
pm.on('changed', function() {
- print("caught changed hook on project manager - reloading data");
- _this.loadData(pm.projects);
+ print("caught changed hook on project manager - reloading data");
+ _this.loadData(pm.projects);
});
},
data.forEach(function(p) {
el.append(na);
- print(JSON.stringify(XObject.keys(na)));
- print(typeof(na.iter));
+ //print(JSON.stringify(XObject.keys(na)));
+ //print(typeof(na.iter));
//print(JSON.stringify(iter))
el.set_value(na.iter, 0, p.fn);
el.set_value(na.iter, 1, p.name);
items : [
{
xtype: Gtk.TreeView,
+
listeners : {
cursor_changed : function (self) {
- var ret = {};
- if (this.selection.count_selected_rows() < 1) {
- //XN.get('Builder.LeftTree.model').
- this.get('/LeftTree.model').load( false);
-
- return;
- }
- var model = this.get('/LeftProjectTree.model');
- //console.log('changed');
- var s = this.selection;
- s.get_selected(ret);
- var value = ''+ ret.model.get_value(ret.iter, 2).value.get_string();
- //console.log(JSON.stringify(value,null,4));// id..
- console.log("OUT?" + value);// id..
- var file = this.get('/LeftProjectTree').project.getById(value);
-
- file.items = false;
- console.log(file);
+
+ var model = this.get('/LeftProjectTree.model');
+
+
+
+ if (model.loading) {
-
-
- var nb = this.get('/LeftTopPanel.expander');
- nb.el.expanded = false;
- nb.onCollapse();
- //nb.listeners.activate.call(nb);
- //_expander.el.set_expanded(false);
-
- var ltm = this.get('/LeftTree.model');
- ltm.loadFile(file);
+
+ return;
+ }
+ print("LOADING IS FALSE");
+ var ret = {};
+ if (this.selection.count_selected_rows() < 1) {
+ //XN.get('Builder.LeftTree.model').
+ this.get('/LeftTree.model').load( false);
- return true;
+ return;
+ }
+ //console.log('changed');
+ var s = this.selection;
+ s.get_selected(ret);
+ var value = ''+ ret.model.get_value(ret.iter, 2).value.get_string();
+ //console.log(JSON.stringify(value,null,4));// id..
+ console.log("OUT?" + value);// id..
+ var file = this.get('/LeftProjectTree').project.getById(value);
+
+ file.items = false;
+ console.log(file);
+
+
+
+ var nb = this.get('/LeftTopPanel.expander');
+ nb.el.expanded = false;
+ nb.onCollapse();
+ //nb.listeners.activate.call(nb);
+ //_expander.el.set_expanded(false);
+
+ var ltm = this.get('/LeftTree.model');
+ ltm.loadFile(file);
+
+ return true;
}
},
id : "view",
xtype: Gtk.TreeStore,
pack : "set_model",
id : "model",
+ loading : false,
init : function() {
XObject.prototype.init.call(this);
this.el.set_column_types ( 3, [
},
loadProject : function(pr) {
print("LOAD PROJECT");
- this.el.clear();
- if (!pr) {
- return;
- }
-
- this.get('/LeftProjectTree').project = pr;
- this.load(pr.toTree());
- this.get('/LeftProjectTree.view').el.expand_all();
+ var model = this.get('/LeftProjectTree.model');
+ model.loading = true;
+
+ this.el.clear();
+ if (!pr) {
+ return;
+ }
+
+ this.get('/LeftProjectTree').project = pr;
+
+ this.load(pr.toTree());
+
+ this.get('/LeftProjectTree.view').el.expand_all();
+ model.loading = false;
+
},
load : function(tr,iter) {
// console.dump(tr);
- console.log('Project tree load: ' + tr.length);
- var cret = {};
- //this.insert(citer,iter,0);
-
- var _this = this;
- tr.forEach(function (r) {
- if (!iter) {
- _this.el.append(cret);
- } else {
- _this.el.insert(cret,iter,-1);
- }
- _this.el.set_value(cret.iter, 0, '' + r.getTitle() ); // title
- _this.el.set_value(cret.iter, 1, '' + r.getTitleTip()); // tip
- _this.el.set_value(cret.iter, 2, '' + r.id ); //id
- if (r.cn && r.cn.length) {
- _this.load(r.cn, cret.iter);
- }
-
- });
+
+
+ console.log('Project tree load: ' + tr.length);
+ var cret = {};
+ //this.insert(citer,iter,0);
+
+ var _this = this;
+ // recursive...
+ tr.forEach(function (r) {
+ if (!iter) {
+ _this.el.append(cret);
+ } else {
+ _this.el.insert(cret,iter,-1);
+ }
+ _this.el.set_value(cret.iter, 0, '' + r.getTitle() ); // title
+ _this.el.set_value(cret.iter, 1, '' + r.getTitleTip()); // tip
+ _this.el.set_value(cret.iter, 2, '' + r.id ); //id
+ if (r.cn && r.cn.length) {
+ _this.load(r.cn, cret.iter);
+ }
+
+ });
+
},
getValue : function(iter, col) {
var gval = ''+ this.el.get_value(iter, col).value.get_string();
label : "ID",
listeners : {
activate : function (self) {
-
+
this.get('/LeftPanel.model').add( {
key : 'id',
type : 'string',
init : function() {
XObject.prototype.init.call(this);
this.el.add_attribute(this.items[0].el , 'text', 3 );
- this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
+ //this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
//this.el.add_attribute(this.items[0].el , 'editable', 3 );
// this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
xtype: Gtk.TreeView,
listeners : {
cursor_changed : function (self) {
+ // this is getting fired when we are loading elements..
+ if (this.get('/MidPropTree.model').loading) {
+ return;
+ }
+
var iret = {};
- //console.log('changed');
+ //console.log('changed');
var m = this.get('model');
- if (!this.selection){
- this.selection = this.el.get_selection();
- }
-
+ if (!this.selection){
+ this.selection = this.el.get_selection();
+ }
+
var s = this.selection;
if (!s.get_selected(iret)) {
- return;
- }
+ return;
+ }
var tp = m.el.get_path(iret.iter).to_string();
if (etype != 'events') {
key = '|' + key;
}
-
+ print("cursor_changed: ADDding to left panel model");
this.get('/LeftPanel.model').add({
key : key,
type : type,
//if (type.indexOf('.') > -1 || type.toLowerCase() == 'boolean') {
// key = '|' + key;
// }
-
+ print("cursor_changed: ADDding to left panel model");
this.get('/LeftPanel.model').add( {
key : key,
type : type,
xtype: Gtk.ListStore,
id : "model",
pack : "set_model",
+ loading : false,
getValue : function(treepath, col)
{
var tp = new Gtk.TreePath.from_string (treepath);
] );
},
showData : function(type) {
- this.el.clear();
+
+
+ this.loading = true;
+ this.el.clear();
if (!this.get('/MidPropTree').activeElement || !type) {
+ this.loading = false;
return; // no active element
}
print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
// console.dump(elementList);
+ // scope of this is off..??
for(var i =0 ; i < elementList.length; i++) {
this.el.set_value(iret.iter, 5, type);
}
-
+ this.loading = false;
}
},
{
xtype: Gtk.Button,
listeners : {
clicked : function (self) {
- this.get('/RightBrowser.view').redraws = 99;
- this.get('/RightBrowser.view').renderJS(null,true);
- }
+
+ var view = this.get('/RightBrowser.view');
+ //this.get('/RightBrowser.view').redraws = 99;
+ view.refreshRequired = true;
+ view.lastRedraw = false;
+ view.renderedData = false;
+ view.renderJS(null,true);
+
+ }
},
label : "Full Redraw",
pack : "pack_start,false,false,0"
this.ready = true;
- if (this.pendingRedraw) {
- this.pendingRedraw = false;
- this.refreshRequired = true;
- }
+ //if (this.pendingRedraw) {
+ // this.pendingRedraw = false;
+ // this.refreshRequired = true;
+ //}
//var js = this.get('/LeftTree.model').toJS();
//if (js && js[0]) {
// this.renderJS(js[0]);
return true; // do not display anything...
},
console_message : function (self, object, p0, p1) {
- print(object);
- // console.log(object);
+ print(object);
+ // console.log(object);
-
- if (object.match(/variable/) && object.match(/Builder/)) {
- print("got builder missing message");
- this.refreshRequired = true;
- this.lastRedraw = 0;
- this.runRefresh();
- return true;
- }
+
+ if (object.match(/variable/) && object.match(/Builder/)) {
+ print("got builder missing message");
+ this.refreshRequired = true;
+ this.lastRedraw = 0;
+ this.runRefresh();
+ return true;
+ }
if (!object.match(/^\{/)) {
this.get('/LeftTree.view').selectNode(tg[0]);
ret = true;
- }
+ }
+
if (ret && typeof(val['set']) != 'undefined') {
- this.get('/LeftPanel.model').add({
- key : val['set'],
- val : val['value']
- });
+ print("console messages: ADDding to left panel model");
+ //
+ //this.get('/LeftPanel.model').add({
+ // key : val['set'],
+ // val : val['value']
+ // });
//console.log('active node: ' + this.activeNode);
}
if (!this.refreshRequired) {
- // print("no refresh required");
+ // print("no refresh required");
return;
}
this.get('/BottomPane').el.show();
this.get('/BottomPane').el.set_current_page(2);// webkit inspector
+ // before
+
+
+
var js = this.get('/LeftTree.model').toJS();
if (!js || !js.length) {
print("no data");
return;
}
var data = js[0];
+
+
this.redraws++;
var project = this.get('/Window.LeftTree').getActiveFile().project;
this.runhtml = this.runhtml || '';
- if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
+ var file = this.get('/LeftTree.model').file;
+ var items = file.items;
+ file.items = this.get('/LeftTree.model').toJS(false, false);
+ //file.items[0].background = false;
+ //var p = file.parent;
+ //file.parent = false;
+
+ var js_src = file.toSourcePreview();
+ if (this.renderedData && js_src == this.renderedData && project.runhtml == this.runhtml) {
+ // unless it' sforced..
+
+ return;
+ }
+
+ this.renderedData = js_src;
+ // restore stuff..
+ //file.parent = p;
+ //file.items = items;
+ //print("send source as " + js_src);
+
+ js_src += "\n" +
+ "Roo.onReady(function() {\n" +
+ "if (" + file.name +".show) " + file.name +".show({});\n" +
+ "Roo.XComponent.build();\n" +
+ "});\n";
+
+
+
+
+
+ //if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
// then we need to reload the browser using
// load_html_string..
// then trigger a redraw once it's loaded..
this.pendingRedraw = true;
- var runhtml = '<script type="text/javascript">' + "\n" ;
- runhtml +=imports.File.File.read(__script_path__ + '/../builder.html.js') + "\n";
- runhtml += '</script>'+ "\n" ;
+ var runhtml = '<script type="text/javascript">' + "\n" ;
+ runhtml +=imports.File.File.read(__script_path__ + '/../builder.html.js') + "\n";
+ runhtml += '</script>'+ "\n" ;
this.runhtml = project.runhtml;
// need to modify paths
-
+ this.lastRedraw= new Date();
var html = imports.File.File.read(__script_path__ + '/../builder.html');
- html = html.replace('</head>', runhtml + this.runhtml + '</head>');
- print("LOAD HTML " + html);
+ html = html.replace('</head>',
+ runhtml +
+ this.runhtml +
+ '<script type="text/javascript">' + "\n" +
+ js_src + "\n" +
+ '</script>' +
+
+ '</head>');
+ //print("LOAD HTML " + html);
this.el.load_html_string( html ,
//fixme - should be a config option!
'http://localhost/app.Builder/'
// should trigger load_finished! - which in truns shoudl set refresh Required;
return;
- }
-
- this.renderedData = data;
- var str = JSON.stringify(data) ;
+ // not used.
+ //this.renderedData = data;
+ //var str = JSON.stringify(data) ;
if (!this.ready) {
console.log('not loaded yet');
}
this.lastRedraw = new Date();
-
- this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
- print( "before render" + this.lastRedraw);
+
+ this.el.execute_script("Builder.render(" +
+ JSON.stringify(js_src) +
+ "," +
+ JSON.stringify(file.name) +
+ ");");
+
+ print( "before render" + this.lastRedraw);
print( "after render" + (new Date()));
}
return;
}
- console.dump(args);
+ //console.dump(args);
args.unshift(el);
//if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
//Seed.print('args: ' + args.length);
}
var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
this.get('/Terminal').feed("RUN DIR:" + dir);
-
- this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
- , false,false,false);
+ var out = {};
+
+ this.get('/Terminal').el.fork_command_full(
+ Vte.PtyFlags.DEFAULT,
+ GLib.path_get_dirname (__script_path__) ,
+ [ 'echo' , "hello"], //argv
+ [], // env
+ 0, //spawn flags
+ null, // user func
+ null, // child setupdata
+ out
+ );
+
var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
this.get('/Terminal').el.feed_child(cmd, cmd.length);
return false;