Revert "File.js"
[app.Builder.js] / Builder3 / Window.js
index 72162b3..c72c8cf 100644 (file)
@@ -1,4 +1,4 @@
-Gtk = imports.gi.Gtk;
+       Gtk = imports.gi.Gtk;
 Gdk = imports.gi.Gdk;
 Pango = imports.gi.Pango;
 GLib = imports.gi.GLib;
@@ -9,6 +9,9 @@ WebKit = imports.gi.WebKit;
 Vte = imports.gi.Vte;
 console = imports.console;
 XObject = imports.XObject.XObject;
+
+
 Window=new XObject({
     xtype: Gtk.Window,
     listeners : {
@@ -19,15 +22,15 @@ Window=new XObject({
            Gtk.main_quit();
         },
         show : function (self) {
-          
-        imports.ProjectManager.ProjectManager.loadConfig();
-          
-        print("HIDEWIN - calling MidPropTree hidewin")
-               this.get('/MidPropTree').hideWin();
-            this.get('/RightPalete').hide();
-            this.get('/BottomPane').el.hide();
-            //this.get('/Editor').el.show_all();
-        
+                       
+                 imports.ProjectManager.ProjectManager.loadConfig();
+                       
+                 print("HIDEWIN - calling MidPropTree hidewin")
+                         this.get('/MidPropTree').hideWin();
+                         this.get('/RightPalete').hide();
+                         this.get('/BottomPane').el.hide();
+                         //this.get('/Editor').el.show_all();
+                 
         }
     },
     border_width : 0,
@@ -35,24 +38,7 @@ Window=new XObject({
     default_width : 800,
     id : "Window",
     title : "Application Builder",
-    init : function() {
-         this.atoms = {
-               "STRING" : Gdk.atom_intern("STRING")
-       };
-       this.targetList = new Gtk.TargetList();
-       this.targetList.add( this.atoms["STRING"], 0, 0);
-       //imports.ProjectManager.ProjectManager.loadConfig();
-    Gtk.rc_parse_string(
-                "style \"gtkcombobox-style\" {\n" + 
-                "    GtkComboBox::appears-as-list = 1\n" +
-                "}\n"+
-                "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
-        XObject.prototype.init.call(this);
-        this.el.show_all();
-        
-       
-                  
-    },
     setTitle : function(str) {
         this.el.set_title(this.title + ' - ' + str);
     },
@@ -346,6 +332,10 @@ Window=new XObject({
                                             items : [
                                                 {
                                                     xtype: Gtk.Expander,
+                                                                                                       events : [
+                                                                                                               Gdk.EventMask.BUTTON_MOTION_MASK 
+                                                                                                       ],
+                                                                                                        
                                                     listeners : {
                                                         activate : function (self) {
                                                             // this does not actually expand it..
@@ -364,7 +354,7 @@ Window=new XObject({
                                                             }
                                                             return true;
                                                                  
-                                                        },
+                                                        } /*,
                                                         enter_notify_event : function (self, event) {
                                                             return true;
                                                              this.el.expanded = !this.el.expanded;
@@ -374,14 +364,12 @@ Window=new XObject({
                                                         
                                                         return true;
                                                         }
+                                                        */
                                                     },
                                                     id : "expander",
                                                     label : "Select Project or File",
                                                     pack : "pack_start,false,true",
-                                                    init : function() {
-                                                        XObject.prototype.init.call(this);
-                                                       this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
-                                                    },
+                                                  
                                                     onCollapse : function() {
                                                         
                                                         var nb = this.get('/LeftTopPanel.notebook');
@@ -394,6 +382,7 @@ Window=new XObject({
                                                        
                                                         var model = this.get('/LeftProjectTree.combomodel');
                                                         //  print ("loading Projects?")
+                                                                                                               //print(JSON.stringify(pm.projects, null,4));Seed.quit();
                                                         //console.dump(pm.projects);
                                                         model.loadData(pm.projects);
                                                          
@@ -410,11 +399,8 @@ Window=new XObject({
                                                     xtype: Gtk.Notebook,
                                                     id : "notebook",
                                                     pack : "pack_start,true,true",
-                                                    init : function() {
-                                                        XObject.prototype.init.call(this);
-                                                       this.el.set_current_page(0);
-                                                    
-                                                    },
+                                                                                                       current_page : 0,
+                                                     
                                                     show_border : false,
                                                     show_tabs : false,
                                                     items : [
@@ -461,12 +447,10 @@ Window=new XObject({
                                                                        case 'Gtk':
                                                                            return this.get('/RightGtkView');
                                                                }
+                                                                                                                               return false;
                                                             
                                                             },
-                                                            init : function() {
-                                                                XObject.prototype.init.call(this);
-                                                                this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
-                                                            },
+                                                            
                                                             renderView : function() {
                                                                 var render = this.getRenderer();
                                                                 var model = this.get('model');
@@ -498,7 +482,9 @@ Window=new XObject({
                                                                                 var res = {}; 
                                                                                 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
                                                                                 
-                                                                                if (!this.get('/LeftTreeMenu').el)  { this.get('/LeftTreeMenu').init(); }
+                                                                                if (!this.get('/LeftTreeMenu').el)  {
+                                                                                                                                                                       this.get('/LeftTreeMenu').init();
+                                                                                                                                                               }
                                                                                 
                                                                                 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
                                                                                 this.get('/LeftTreeMenu').el.show_all();
@@ -621,7 +607,7 @@ Window=new XObject({
                                                                                 Gdk.drag_status(ctx, 0, time);
                                                                                 return true;
                                                                             }
-                                                                              print(JSON.stringify(tg,null,4));
+                                                                            //  print(JSON.stringify(tg,null,4));
                                                                             //console.dump(tg);
                                                                             this.targetData = tg;    
                                                                             
@@ -636,7 +622,7 @@ Window=new XObject({
                                                                                 w.drag_get_data
                                                                                 (          /* will receive 'drag-data-received' signal */
                                                                                         ctx,        /* represents the current state of the DnD */
-                                                                                        this.get('/Window').atoms["STRING"],    /* the target type we want */
+                                                                                        imports.Builder3.Globals.atoms["STRING"],    /* the target type we want */
                                                                                         time            /* time stamp */
                                                                                 );
                                                                                 
@@ -717,8 +703,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();
                                                                                 }
@@ -777,7 +766,7 @@ Window=new XObject({
                                                                             },
                                                                             
                                                                     init : function() {
-                                                                               XObject.prototype.init.call(this);
+                                                                        XObject.prototype.init.call(this);
                                                                        var description = new Pango.FontDescription.c_new();
                                                                        description.set_size(8000);
                                                                        this.el.modify_font(description);
@@ -800,7 +789,7 @@ Window=new XObject({
                                                                                Gdk.DragAction.COPY   | Gdk.DragAction.MOVE           /* what to do with data after dropped */
                                                                        );
                                                                      
-                                                                       this.el.drag_source_set_target_list(this.get('/Window').targetList);
+                                                                       this.el.drag_source_set_target_list(imports.Builder3.Globals.targetList);
                                                                     
                                                                        this.el.drag_source_add_text_targets(); 
                                                                        this.el.drag_dest_set
@@ -811,7 +800,7 @@ Window=new XObject({
                                                                            Gdk.DragAction.COPY   | Gdk.DragAction.MOVE       /* what to do with data after dropped */
                                                                        );
                                                                     
-                                                                       this.el.drag_dest_set_target_list(  this.get('/Window').targetList);
+                                                                       this.el.drag_dest_set_target_list(  imports.Builder3.Globals.targetList);
                                                                        this.el.drag_dest_add_text_targets( );
                                                                     },
                                                                     selectNode : function(treepath_str) {
@@ -1073,14 +1062,14 @@ Window=new XObject({
                                                                                 
                                                                                 
                                                                             },
-                                                                            init : function() {
-                                                                                XObject.prototype.init.call(this);
-                                                                             this.el.set_column_types ( 3, [
+                                                                           columns : [
                                                                                         GObject.TYPE_STRING, // title 
                                                                                         GObject.TYPE_STRING, // tip
                                                                                         GObject.TYPE_STRING // source..
-                                                                                        ] );
-                                                                            },
+                                                                             ] ,
+                                                                                                                                                       
+                                                                                                                                                       
+                                                                           
                                                                             listAllTypes : function() {
                                                                                 var s = this.get('/LeftTree.view').selection;
                                                                                 print ("LIST ALL TYPES: " + s.count_selected_rows() );
@@ -1107,7 +1096,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;
@@ -1122,7 +1114,7 @@ Window=new XObject({
                                                                                             addall(el.items);
                                                                                         }
                                                                                         
-                                                                                    });
+                                                                                    };
                                                                                     
                                                                                     
                                                                                 }
@@ -1150,10 +1142,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 ]);
@@ -1167,6 +1159,7 @@ Window=new XObject({
                                                                                     },
                                                                             loadFile : function(f) {
                                                                                 //console.dump(f);
+                                                                                  print("LOADFILE");
                                                                                         this.el.clear();
                                                                                         this.file = f;
                                                                                         
@@ -1193,7 +1186,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();
@@ -1220,10 +1213,10 @@ Window=new XObject({
                                                                                         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..
@@ -1251,7 +1244,7 @@ Window=new XObject({
                                                                                 s.get_selected( oret);
                                                                                 var node = this.nodeToJS(oret.iter,false);
                                                                                     //console.dump(node);
-                                                                                print(JSON.stringify(node, null,4)); 
+                                                                                //print(JSON.stringify(node, null,4)); 
                                                                                     
                                                                                     // needs to drop first, otherwise the target_data 
                                                                                         // treepath will be invalid.
@@ -1332,7 +1325,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 = {};
@@ -1393,7 +1386,7 @@ 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..
                                                                                 
@@ -1564,33 +1557,29 @@ Window=new XObject({
                                                                                     xtype: Gtk.ListStore,
                                                                                     id : "combomodel",
                                                                                     pack : "set_model",
-                                                                                    init : function() {
-                                                                                        XObject.prototype.init.call(this);
-                                                                                      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.ProjectManager.ProjectManager;
-                                                                                       var _this = this;
-                                                                                       pm.on('changed', function() {
-                                                                                           print("caught changed hook on project manager - reloading data");
-                                                                                       _this.loadData(pm.projects);
+                                                                                                                                                                       
+                                                                                                                                                                       columns : [
+                                                                                                                                                                               GObject.TYPE_STRING,   
+                                                                                        GObject.TYPE_STRING
+                                                                                                                                                                       ],
+                                                                                                                                                                       
+                                                                                                                                                                       
                                                                                     
-                                                                                       });
-                                                                                    },
                                                                                     loadData : function(data) {
-                                                                                         var ov = this.get('/LeftProjectTree.combo').getValue();
+                                                                                                                                                                               //print("load data called");Seed.quit();
+                                                                                                                                                                               //print(data);Seed.quit();
+                                                                                                                                                                               
+                                                                                        var ov = this.get('/LeftProjectTree.combo').getValue();
                                                                                         this.el.clear();
                                                                                         var el = this.el;
                                                                                         var na = {};
-                                                                                        data.forEach(function(p) {
+                                                                                        
+                                                                                                                                                                               
+                                                                                                                                                                               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);
@@ -1608,46 +1597,54 @@ Window=new XObject({
                                                                     xtype: Gtk.ScrolledWindow,
                                                                     pack : "add",
                                                                     shadow_type : Gtk.ShadowType.IN,
-                                                                    init : function() {
-                                                                        XObject.prototype.init.call(this);
-                                                                        this.el.set_policy  (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
-                                                                    },
+                                                                  
                                                                     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",
@@ -1668,47 +1665,57 @@ Window=new XObject({
                                                                                     xtype: Gtk.TreeStore,
                                                                                     pack : "set_model",
                                                                                     id : "model",
-                                                                                    init : function() {
-                                                                                        XObject.prototype.init.call(this);
-                                                                                      this.el.set_column_types ( 3, [
+                                                                                    loading : false,
+                                                                                                                                                                       columns :  [
                                                                                                         GObject.TYPE_STRING, // title 
                                                                                                         GObject.TYPE_STRING, // tip
                                                                                                         GObject.TYPE_STRING // id..
-                                                                                                        ] );
-                                                                                       
-                                                                                    },
+                                                                                                        ] ,
+                                                                                                                                                                        
+                                                                                    
                                                                                     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();
@@ -1861,7 +1868,7 @@ Window=new XObject({
                                                                             label : "ID",
                                                                             listeners : {
                                                                                 activate : function (self) {
-                                                                                
+                                                                                    
                                                                                     this.get('/LeftPanel.model').add( {
                                                                                         key : 'id', 
                                                                                         type : 'string',
@@ -1993,10 +2000,7 @@ Window=new XObject({
                                                     editing : false,
                                                     id : "LeftPanel",
                                                     pack : "add",
-                                                    init : function() {
-                                                        XObject.prototype.init.call(this);
-                                                       this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
-                                                    },
+                                                    
                                                     shadow_type : Gtk.ShadowType.IN,
                                                     items : [
                                                         {
@@ -2181,7 +2185,7 @@ Window=new XObject({
                                                                     
                                                                         this.el.set_value(ret.iter, 5, type + ' : ' + str);
                                                                         // update the tree...  
-                                                                        print("new data: "  + JSON.stringify(this.toJS() , null,4));
+                                                                        //print("new data: "  + JSON.stringify(this.toJS() , null,4));
                                                                         this.get('/LeftTree.model').setFromNode(false,this.toJS());
                                                                         this.get('/LeftTree.model').changed(doRefresh); 
                                                                                  
@@ -2260,9 +2264,7 @@ Window=new XObject({
                                                                         }
                                                                                                 
                                                                     },
-                                                                    init : function() {
-                                                                        XObject.prototype.init.call(this);
-                                                                    this.el.set_column_types ( 6, [
+                                                                                                                                       columns :  [
                                                                                                     GObject.TYPE_STRING,  // 0 real key
                                                                                                     GObject.TYPE_STRING, // 1 real value 
                                                                                                      GObject.TYPE_STRING,  // 2 visable key
@@ -2270,9 +2272,9 @@ Window=new XObject({
                                                                                                      GObject.TYPE_STRING, // 4 need to store type of!!!
                                                                                                       GObject.TYPE_STRING // 5 tooltip
                                                                                                   
-                                                                                                ]);
-                                                                    },
-                                                                    load : function(ar) {
+                                                                                                ],
+                                                                                                                                       
+                                                                     load : function(ar) {
                                                                     // might casue problesm..
                                                                         // this.get('/Editor.RightEditor').save();
                                                                     
@@ -2653,18 +2655,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();
                                                         
                                                         
@@ -2684,7 +2691,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,
@@ -2697,7 +2704,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,
@@ -2730,6 +2737,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);
@@ -2752,8 +2760,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
                                                                 }
                                                     
@@ -2777,6 +2789,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++) {
@@ -2798,7 +2811,7 @@ Window=new XObject({
                                                                     this.el.set_value(iret.iter, 5, type);
                                                                     
                                                                 }
-                                                                                 
+                                                                this.loading = false;              
                                                     }
                                                 },
                                                 {
@@ -2899,9 +2912,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"
@@ -2933,10 +2952,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]);
@@ -2949,17 +2968,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(/^\{/)) {
@@ -2992,12 +3011,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);
                                                                                                     
                                                                                                 }
@@ -3054,7 +3076,7 @@ Window=new XObject({
                                                                                                 w.drag_get_data
                                                                                                 (          /* will receive 'drag-data-received' signal */
                                                                                                         ctx,        /* represents the current state of the DnD */
-                                                                                                        this.get('/Window').atoms["STRING"],    /* the target type we want */
+                                                                                                        imports.Builder3.Globals.atoms["STRING"],    /* the target type we want */
                                                                                                         time            /* time stamp */
                                                                                                 );
                                                                                                                 
@@ -3148,7 +3170,7 @@ Window=new XObject({
                                                                                         );
                                                                                                                 
                                                                                        // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
-                                                                                        this.el.drag_dest_set_target_list(  this.get('/Window').targetList);
+                                                                                        this.el.drag_dest_set_target_list(  imports.Builder3.Globals.targetList);
                                                                                         
                                                                                         GLib.timeout_add_seconds(0, 1, function() {
                                                                                             //    print("run refresh?");
@@ -3176,7 +3198,7 @@ Window=new XObject({
                                                                                       
                                                                                         
                                                                                         if (!this.refreshRequired) {
-                                                                                           // print("no refresh required");
+                                                                                            // print("no refresh required");
                                                                                             return;
                                                                                         }
                                                                                     
@@ -3223,24 +3245,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/'
@@ -3249,19 +3308,7 @@ Window=new XObject({
                                                                                             // should trigger load_finished! - which in truns shoudl set refresh Required;
                                                                                             return;
                                                                                         
-                                                                                        }
-                                                                                                                                                                               var file = this.get('/LeftTree.model').file;
-                                                                                                                                                                               var items = file.items;
-                                                                                        file.items = this.get('/LeftTree.model').toJS(false, false);
-                                                                                                                                                                               var p = file.parent;
-                                                                                                                                                                               file.parent = false;
-                                                                                                                                                                               var bg = file.items[0].
-                                                                                                                                                                               
-                                                                                        var js_src = file.toSource();
-                                                                                                                                                                               // restore stuff..
-                                                                                                                                                                               file.parent = p;
-                                                                                                                                                                               file.items = items;
-                                                                                                                                                                               print("send source as " + js_src);
+                                                                                        
                                                                                                                                                                                // not used.
                                                                                         //this.renderedData = data;
                                                                                         //var str = JSON.stringify(data) ;
@@ -3507,7 +3554,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);
@@ -3745,7 +3792,7 @@ Window=new XObject({
                                                                                                                 );
                                                                                                                 
                                                                                                                // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
-                                                                                                                this.el.drag_dest_set_target_list( this.get('/Window').targetList);
+                                                                                                                this.el.drag_dest_set_target_list( imports.Builder3.Globals.targetList);
                                                                                                     },
                                                                                                     ready : false,
                                                                                                     getActiveNode : function(x,y)
@@ -3800,7 +3847,7 @@ Window=new XObject({
                                                                                                                 self.drag_get_data
                                                                                                                 (  /* will receive 'drag-data-received' signal */
                                                                                                                         ctx,        /* represents the current state of the this.gDnD */
-                                                                                                                        this.get('/Window').atoms["STRING"],    /* the target type we want */
+                                                                                                                        imports.Builder3.Globals.atoms["STRING"],    /* the target type we want */
                                                                                                                         time            /* time stamp */
                                                                                                                 );
                                                                                                                 
@@ -3975,7 +4022,7 @@ Window=new XObject({
                                         this.get('buttonbar').el.hide();
                                         this.get('viewbox').el.show();
                                         var ce = this.get('/Window.centereast').el;
-                                        print(JSON.stringify(XObject.keys(ce) ,null,4));
+                                        //print(JSON.stringify(XObject.keys(ce) ,null,4));
                                         ce.set_position(ce.get_allocated_width() - 150);
                                            
                                        // this.get('model').expanded();
@@ -4156,7 +4203,7 @@ Window=new XObject({
                                                                 );
                                                                 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
                                                                
-                                                                this.el.drag_source_set_target_list(  this.get('/Window').targetList);
+                                                                this.el.drag_source_set_target_list( imports.Builder3.Globals.targetList);
                                                                 this.el.drag_source_add_text_targets( ); 
                                                                 /*
                                                                 print("RP: TARGET:" + LeftTree.atoms["STRING"]);