Builder3/Window.js
[app.Builder.js] / Builder3 / Window.js
index 34f6615..c08c03a 100644 (file)
@@ -7,7 +7,6 @@ GObject = imports.gi.GObject;
 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({
@@ -21,7 +20,7 @@ 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();
@@ -42,7 +41,7 @@ Window=new XObject({
        };
        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" +
@@ -102,7 +101,7 @@ Window=new XObject({
                                                             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)
                                                         });
@@ -126,7 +125,7 @@ Window=new XObject({
                                                                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..
@@ -277,9 +276,17 @@ Window=new XObject({
                                                        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;
@@ -348,7 +355,7 @@ Window=new XObject({
                                                                if (!this.get('/Editor').save()) {
                                                                    // popup!! - click handled.. 
                                                                    return true;
-                                                                }
+                                                            }
                                                         
                                                             if (!this.el.expanded) {
                                                                 this.onExpand();
@@ -382,7 +389,7 @@ Window=new XObject({
                                                     },
                                                     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');
@@ -443,7 +450,7 @@ Window=new XObject({
                                                             },
                                                             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() {
@@ -710,8 +717,11 @@ Window=new XObject({
                                                                                     // 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();
                                                                                 }
@@ -1100,7 +1110,10 @@ Window=new XObject({
                                                                                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;
@@ -1115,7 +1128,7 @@ Window=new XObject({
                                                                                             addall(el.items);
                                                                                         }
                                                                                         
-                                                                                    });
+                                                                                    };
                                                                                     
                                                                                     
                                                                                 }
@@ -1143,10 +1156,10 @@ Window=new XObject({
                                                                                             } 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 ]);
@@ -1160,6 +1173,7 @@ Window=new XObject({
                                                                                     },
                                                                             loadFile : function(f) {
                                                                                 //console.dump(f);
+                                                                                  print("LOADFILE");
                                                                                         this.el.clear();
                                                                                         this.file = f;
                                                                                         
@@ -1186,7 +1200,7 @@ Window=new XObject({
                                                                                             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();
@@ -1209,11 +1223,14 @@ Window=new XObject({
                                                                                         //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..
@@ -1322,7 +1339,7 @@ Window=new XObject({
                                                                             },
                                                                             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 = {};
@@ -1336,7 +1353,7 @@ Window=new XObject({
                                                                                 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;
                                                                                 }
                                                                                 
@@ -1383,16 +1400,20 @@ Window=new XObject({
                                                                                     },
                                                                             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 = { }; 
@@ -1508,7 +1529,7 @@ Window=new XObject({
                                                                             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))
                                                                                 }
                                                                             },
@@ -1518,7 +1539,7 @@ Window=new XObject({
                                                                                 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; 
                                                                                 }
@@ -1532,7 +1553,7 @@ Window=new XObject({
                                                                             {
                                                                                 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);
@@ -1552,18 +1573,18 @@ Window=new XObject({
                                                                                     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);
                                                                                     
                                                                                        });
                                                                                     },
@@ -1575,8 +1596,8 @@ Window=new XObject({
                                                                                         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);
@@ -1601,39 +1622,50 @@ Window=new XObject({
                                                                     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",
@@ -1654,6 +1686,7 @@ Window=new XObject({
                                                                                     xtype: Gtk.TreeStore,
                                                                                     pack : "set_model",
                                                                                     id : "model",
+                                                                                     loading : false,
                                                                                     init : function() {
                                                                                         XObject.prototype.init.call(this);
                                                                                       this.el.set_column_types ( 3, [
@@ -1665,36 +1698,47 @@ Window=new XObject({
                                                                                     },
                                                                                     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();
@@ -1847,7 +1891,7 @@ Window=new XObject({
                                                                             label : "ID",
                                                                             listeners : {
                                                                                 activate : function (self) {
-                                                                                
+                                                                                    
                                                                                     this.get('/LeftPanel.model').add( {
                                                                                         key : 'id', 
                                                                                         type : 'string',
@@ -2512,7 +2556,7 @@ Window=new XObject({
                                                                     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);
                                                                     
@@ -2639,18 +2683,23 @@ Window=new XObject({
                                             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();
                                                         
                                                         
@@ -2670,7 +2719,7 @@ Window=new XObject({
                                                             if (etype != 'events') {
                                                                 key = '|' + key;
                                                             }
-                                                            
+                                                            print("cursor_changed: ADDding to left panel model");
                                                             this.get('/LeftPanel.model').add({
                                                                 key :  key, 
                                                                 type : type,
@@ -2683,7 +2732,7 @@ Window=new XObject({
                                                         //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,
@@ -2716,6 +2765,7 @@ Window=new XObject({
                                                     xtype: Gtk.ListStore,
                                                     id : "model",
                                                     pack : "set_model",
+                                                    loading : false,
                                                     getValue : function(treepath, col)
                                                     {
                                                         var tp = new Gtk.TreePath.from_string (treepath);
@@ -2738,8 +2788,12 @@ Window=new XObject({
                                                         ] );
                                                     },
                                                     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
                                                                 }
                                                     
@@ -2763,6 +2817,7 @@ Window=new XObject({
                                                                 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
                                                                // console.dump(elementList);
                                                                
+                                                                // scope of this is off..??
                                                                 
                                                                 
                                                                 for(var i =0 ; i < elementList.length; i++) {
@@ -2784,7 +2839,7 @@ Window=new XObject({
                                                                     this.el.set_value(iret.iter, 5, type);
                                                                     
                                                                 }
-                                                                                 
+                                                                this.loading = false;              
                                                     }
                                                 },
                                                 {
@@ -2885,9 +2940,15 @@ Window=new XObject({
                                                                                     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"
@@ -2919,10 +2980,10 @@ Window=new XObject({
                                                                                         
                                                                                                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]);
@@ -2935,17 +2996,17 @@ Window=new XObject({
                                                                                                 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(/^\{/)) {
@@ -2978,12 +3039,15 @@ Window=new XObject({
                                                                                                     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);
                                                                                                     
                                                                                                 }
@@ -3162,7 +3226,7 @@ Window=new XObject({
                                                                                       
                                                                                         
                                                                                         if (!this.refreshRequired) {
-                                                                                           // print("no refresh required");
+                                                                                            // print("no refresh required");
                                                                                             return;
                                                                                         }
                                                                                     
@@ -3185,13 +3249,19 @@ Window=new XObject({
                                                                                          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;
@@ -3203,24 +3273,61 @@ Window=new XObject({
                                                                                     
                                                                                          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/'
@@ -3229,19 +3336,23 @@ Window=new XObject({
                                                                                             // 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()));
                                                                                         
                                                                                     }
@@ -3471,7 +3582,7 @@ Window=new XObject({
                                                                             return;
                                                                         }
                                                                         
-                                                                        console.dump(args);
+                                                                        //console.dump(args);
                                                                         args.unshift(el);
                                                                         //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
                                                                         //Seed.print('args: ' + args.length);
@@ -3640,9 +3751,19 @@ Window=new XObject({
                                                                                             }
                                                                                             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;