Revert "File.js"
[app.Builder.js] / Sample / Window.js
index 1f45375..04aaf2c 100644 (file)
@@ -8,13 +8,33 @@ GtkSource = imports.gi.GtkSource;
 WebKit = imports.gi.WebKit;
 Vte = imports.gi.Vte;
 GtkClutter = imports.gi.GtkClutter;
+Gdl = imports.gi.Gdl;
 console = imports.console;
 XObject = imports.XObject.XObject;
 Window=new XObject({
     xtype: Gtk.Window,
-    type : Gtk.WindowType.TOPLEVEL,
-    title : "Application Builder",
+    listeners : {
+        delete_event : function (self, event) {
+            return false;
+        },
+        destroy : function (self) {
+           Gtk.main_quit();
+        },
+        show : function (self) {
+          print("WINDOW SHOWING - trying to hide");
+        imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
+               this.get('/MidPropTree').hideWin();
+            this.get('/RightPalete').hide();
+            this.get('/BottomPane').el.hide();
+            //this.get('/Editor').el.show_all();
+        
+        }
+    },
     border_width : 0,
+    default_height : 500,
+    default_width : 800,
+    id : "Window",
+    title : "Application Builder",
     init : function() {
          this.atoms = {
                "STRING" : Gdk.atom_intern("STRING")
@@ -33,28 +53,10 @@ Window=new XObject({
        
                   
     },
-    default_width : 800,
-    default_height : 500,
-    id : "Window",
     setTitle : function(str) {
         this.el.set_title(this.title + ' - ' + str);
     },
-    listeners : {
-        delete_event : function (self, event) {
-            return false;
-        },
-        destroy : function (self) {
-           Gtk.main_quit();
-        },
-        show : function (self) {
-          print("WINDOW SHOWING - trying to hide");
-        imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
-               this.get('/MidPropTree').hideWin();
-            this.get('/RightPalete').hide();
-            this.get('/BottomPane').el.hide();
-        
-        }
-    },
+    type : Gtk.WindowType.TOPLEVEL,
     items : [
         {
             xtype: Gtk.VBox,
@@ -213,7 +215,7 @@ Window=new XObject({
                                                 activate : function (self, event) {
                                                       var js = this.get('/LeftTree.model').toJS();
                                                     if (js && js[0]) {
-                                                        this.get('/RightBrowser.view').renderJS(js[0]);
+                                                        this.get('/RightBrowser.view').renderJS(js[0], true);
                                                     } 
                                                     return false;
                                                 }
@@ -338,29 +340,24 @@ Window=new XObject({
                                                     xtype: Gtk.Expander,
                                                     listeners : {
                                                         activate : function (self) {
-                                                               var nb = this.get('/LeftTopPanel.notebook');
-                                                               if (this.el.expanded) {
-                                                                   // now expanded..
-                                                                    
-                                                                   var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
-                                                                   
-                                                                  
-                                                                   var model = this.get('/LeftProjectTree.combomodel');
-                                                                 //  print ("loading Projects?")
-                                                               //console.dump(pm.projects);
-                                                                   model.loadData(pm.projects);
-                                                                    
-                                                                   
-                                                                   nb.el.set_current_page(1);
-                                                                   //pm.on('changed', function() {
-                                                                       //console.log("CAUGHT project manager change");
-                                                                   //    _combo.model.loadData(pm.projects);
-                                                                   //}
-                                                                   return;
-                                                               }
-                                                               nb.el.set_current_page(0);
+                                                            // this does not actually expand it..
+                                                            // that is done by GTK..
+                                                            
+                                                            
+                                                               if (!this.get('/Editor').save()) {
+                                                                   // popup!! - click handled.. 
+                                                                   return true;
+                                                                }
+                                                        
+                                                            if (!this.el.expanded) {
+                                                                this.onExpand();
+                                                            } else {
+                                                                this.onCollapse();
+                                                            }
+                                                                 
                                                         },
                                                         enter_notify_event : function (self, event) {
+                                                        return;
                                                              this.el.expanded = !this.el.expanded;
                                                         //if (this.el.expanded ) {
                                                             this.listeners.activate.call(this);
@@ -375,19 +372,42 @@ Window=new XObject({
                                                     init : function() {
                                                         XObject.prototype.init.call(this);
                                                        this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
+                                                    },
+                                                    onCollapse : function() {
+                                                        
+                                                        var nb = this.get('/LeftTopPanel.notebook');
+                                                        nb.el.set_current_page(0);
+                                                    },
+                                                    onExpand : function() {
+                                                        var nb = this.get('/LeftTopPanel.notebook');            
+                                                        var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
+                                                        
+                                                       
+                                                        var model = this.get('/LeftProjectTree.combomodel');
+                                                        //  print ("loading Projects?")
+                                                        //console.dump(pm.projects);
+                                                        model.loadData(pm.projects);
+                                                         
+                                                        
+                                                        nb.el.set_current_page(1);
+                                                        //pm.on('changed', function() {
+                                                       //console.log("CAUGHT project manager change");
+                                                        //    _combo.model.loadData(pm.projects);
+                                                        //}
+                                                        return;
                                                     }
                                                 },
                                                 {
                                                     xtype: Gtk.Notebook,
                                                     id : "notebook",
-                                                    show_border : false,
-                                                    show_tabs : false,
                                                     pack : "pack_start,true,true",
                                                     init : function() {
                                                         XObject.prototype.init.call(this);
                                                        this.el.set_current_page(0);
                                                     
                                                     },
+                                                    show_border : false,
+                                                    show_tabs : false,
                                                     items : [
                                                         {
                                                             xtype: Gtk.ScrolledWindow,
@@ -456,6 +476,12 @@ Window=new XObject({
                                                                     listeners : {
                                                                         button_press_event : function (self, ev) {
                                                                                console.log("button press?");
+                                                                               
+                                                                               if (!this.get('/Editor').save()) {
+                                                                                   // popup!! - click handled.. 
+                                                                                   return true;
+                                                                                }
+                                                                               
                                                                                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
                                                                                     print("click" + ev.type);
                                                                                     return false;
@@ -465,7 +491,7 @@ 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();
@@ -779,7 +805,7 @@ Window=new XObject({
                                                                             id : "model",
                                                                             pack : "set_model",
                                                                             changed : function(n, refresh) {
-                                                                                     print("MODEL CHANGED CALLED" + this.activePath);
+                                                                                //     print("MODEL CHANGED CALLED" + this.activePath);
                                                                                      if (this.activePath) {
                                                                                         var iter = new Gtk.TreeIter();
                                                                                         this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
@@ -789,8 +815,10 @@ Window=new XObject({
                                                                                         this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
                                                                                     }
                                                                                         //this.currentTree = this.toJS(false, true)[0];
+                                                                                    var d = new Date();
                                                                                     this.file.items = this.toJS(false, false);
-                                                                                    print("AFTER CHANGED");
+                                                                                    print ("TO JS in " + ((new Date()) - d) + "ms");
+                                                                                  //  print("AFTER CHANGED");
                                                                                     //console.dump(this.file.items);
                                                                                     this.file.save();
                                                                                     this.currentTree = this.file.items[0];
@@ -1119,8 +1147,8 @@ Window=new XObject({
                                                                                         
                                                                                         if (f.items.length && typeof(f.items[0]) == 'string') {
                                                                                         
-                                                                                            this.get('/RightEditor').el.show();
-                                                                                            this.get('/RightEditor.view').load( f.items[0]);
+                                                                                            //this.get('/RightEditor').el.show();
+                                                                                            //this.get('/RightEditor.view').load( f.items[0]);
                                                                                             return;
                                                                                         }
                                                                                         print("LOAD");
@@ -1144,7 +1172,8 @@ Window=new XObject({
                                                                                         
                                                                                         
                                                                                         //print("hide right editior");
-                                                                                        this.get('/RightEditor').el.hide();
+                                                                                        //this.get('/RightEditor').el.hide();
+                                                                                        this.get('/Editor').el.hide();
                                                                                         //print("set current tree");
                                                                                         this.currentTree = this.toJS(false, false)[0];
                                                                                         //console.dump(this.currentTree);
@@ -1439,11 +1468,14 @@ Window=new XObject({
                                                                     items : [
                                                                         {
                                                                             xtype: Gtk.ComboBox,
-                                                                            id : "combo",
-                                                                            init : function() {
-                                                                                XObject.prototype.init.call(this);
-                                                                                this.el.add_attribute(this.get('render').el , 'markup', 1 );  
+                                                                            listeners : {
+                                                                                changed : function (self) {
+                                                                                       var fn = this.getValue();
+                                                                                       var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
+                                                                                       this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
+                                                                                }
                                                                             },
+                                                                            id : "combo",
                                                                             getValue : function() {
                                                                                 var ix = this.el.get_active();
                                                                                 if (ix < 0 ) {
@@ -1455,6 +1487,10 @@ Window=new XObject({
                                                                                 }
                                                                                 return data[ix].fn;
                                                                             },
+                                                                            init : function() {
+                                                                                XObject.prototype.init.call(this);
+                                                                                this.el.add_attribute(this.get('render').el , 'markup', 1 );  
+                                                                            },
                                                                             setValue : function(fn)
                                                                             {
                                                                                 var el = this.el;
@@ -1467,13 +1503,6 @@ Window=new XObject({
                                                                                     }
                                                                                 });
                                                                             },
-                                                                            listeners : {
-                                                                                changed : function (self) {
-                                                                                       var fn = this.getValue();
-                                                                                       var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
-                                                                                       this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
-                                                                                }
-                                                                            },
                                                                             items : [
                                                                                 {
                                                                                     xtype: Gtk.CellRendererText,
@@ -1482,6 +1511,7 @@ Window=new XObject({
                                                                                 },
                                                                                 {
                                                                                     xtype: Gtk.ListStore,
+                                                                                    id : "combomodel",
                                                                                     pack : "set_model",
                                                                                     init : function() {
                                                                                         XObject.prototype.init.call(this);
@@ -1491,6 +1521,7 @@ Window=new XObject({
                                                                                             
                                                                                             
                                                                                         ] );
+                                                                                       // this.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);
                                                                                        var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
                                                                                        var _this = this;
                                                                                        pm.on('changed', function() {
@@ -1515,8 +1546,7 @@ Window=new XObject({
                                                                                         });
                                                                                         
                                                                                         this.get('/LeftProjectTree.combo').setValue(ov);
-                                                                                    },
-                                                                                    id : "combomodel"
+                                                                                    }
                                                                                 }
                                                                             ]
                                                                         }
@@ -1561,7 +1591,8 @@ Window=new XObject({
                                                                                 
                                                                                         var nb = this.get('/LeftTopPanel.expander');
                                                                                         nb.el.expanded = false;
-                                                                                        nb.listeners.activate.call(nb);
+                                                                                        nb.onCollapse();
+                                                                                        //nb.listeners.activate.call(nb);
                                                                                         //_expander.el.set_expanded(false);
                                                                                 
                                                                                         var ltm = this.get('/LeftTree.model');
@@ -1699,13 +1730,18 @@ Window=new XObject({
                                                         },
                                                         {
                                                             xtype: Gtk.Button,
-                                                            pack : "add",
                                                             listeners : {
                                                                 button_press_event : function (self, event) {
-                                                                    this.get('/MidPropTree.model').showData('events');
+                                                                    
+                                                                       if (!this.get('/Editor').save()) {
+                                                                           // popup!! - click handled.. 
+                                                                           return true;
+                                                                        }
+                                                                        this.get('/MidPropTree.model').showData('events');
                                                                     return false;
                                                                 }
                                                             },
+                                                            pack : "add",
                                                             items : [
                                                                 {
                                                                     xtype: Gtk.HBox,
@@ -1728,9 +1764,14 @@ Window=new XObject({
                                                         },
                                                         {
                                                             xtype: Gtk.Button,
-                                                            pack : "add",
                                                             listeners : {
                                                                 button_press_event : function (self, ev) {
+                                                                
+                                                                       if (!this.get('/Editor').save()) {
+                                                                           // popup!! - click handled.. 
+                                                                           return true;
+                                                                        }
+                                                                        
                                                                        var p = this.get('/AddPropertyPopup');
                                                                        if (!p.el) {
                                                                                p.init();
@@ -1741,6 +1782,7 @@ Window=new XObject({
                                                                     return true;
                                                                 }
                                                             },
+                                                            pack : "add",
                                                             items : [
                                                                 {
                                                                     xtype: Gtk.HBox,
@@ -1900,21 +1942,110 @@ Window=new XObject({
                                                 },
                                                 {
                                                     xtype: Gtk.ScrolledWindow,
+                                                    editing : false,
                                                     id : "LeftPanel",
                                                     pack : "add",
-                                                    shadow_type : Gtk.ShadowType.IN,
-                                                    editing : false,
                                                     init : function() {
                                                         XObject.prototype.init.call(this);
                                                        this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
                                                     },
+                                                    shadow_type : Gtk.ShadowType.IN,
                                                     items : [
                                                         {
                                                             xtype: Gtk.TreeView,
+                                                            listeners : {
+                                                                button_press_event : function (self, ev) {
+                                                                
+                                                                    
+                                                                    if (!this.get('/Editor').save()) {
+                                                                        // popup!! - click handled.. 
+                                                                        return true;
+                                                                    }
+                                                                    var res = { }; 
+                                                                    
+                                                                    if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
+                                                                        return false; //not on a element.
+                                                                    }
+                                                                    
+                                                                     // right click.
+                                                                     if (ev.type == Gdk.EventType.BUTTON_PRESS  && ev.button.button == 3) {    
+                                                                        // show popup!.   
+                                                                        if (res.column.title == 'value' && this.get('/LeftPanel').editing) {
+                                                                            return false;
+                                                                        }
+                                                                        //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
+                                                                        var p = this.get('/LeftPanelPopup');
+                                                                        if (!p.el) {
+                                                                            p.init();
+                                                                        }
+                                                                
+                                                                        p.el.set_screen(Gdk.Screen.get_default());
+                                                                        p.el.show_all();
+                                                                        p.el.popup(null, null, null, null, 3, ev.button.time);
+                                                                        //Seed.print("click:" + res.column.title);
+                                                                        
+                                                                        
+                                                                        return false;
+                                                                    }
+                                                                    
+                                                                     
+                                                                    if (res.column.title != 'value') {
+                                                                          //  XObject.error("column is not value?");
+                                                                        return false; // ignore.. - key click.. ??? should we do this??
+                                                                    }
+                                                                    
+                                                                    // currently editing???
+                                                                //    if (  this.activePath) {
+                                                                        
+                                                                     //   this.activePath = false;
+                                                                       // stop editing!!!!
+                                                                        if (this.get('/Editor').dirty) {
+                                                                            //if (!this.get('/Editor.buffer').checkSyntax()) {
+                                                                            //   this.get('/StandardErrorDialog').show("Fix errors in code and save.."); 
+                                                                            //   return true;
+                                                                            //    // error Dialog
+                                                                            //}
+                                                                            if (!this.get('/Editor.view').save()) {
+                                                                                return true;
+                                                                            }
+                                                                        }   
+                                                                        this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
+                                                                        this.get('/LeftPanel').editing = false;
+                                                                    
+                                                                    //    XObject.error("Currently editing?");
+                                                                     //   return false;
+                                                                   // }
+                                                                    
+                                                                    var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
+                                                                    
+                                                                    var type = this.get('/LeftPanel.model').getType(res.path.to_string());
+                                                                        
+                                                                    // get options for this type -- this is to support option lists etc..
+                                                                    var provider = this.get('/LeftTree').getPaleteProvider();
+                                                                    var opts = provider.findOptions(type);
+                                                                    
+                                                                    if (opts === false) {
+                                                                        // it's text etnry
+                                                                         this.get('/LeftPanel').editableColumn.setOptions([]);
+                                                                        renderer.has_entry = true;
+                                                                    } else {
+                                                                         this.get('/LeftPanel').editableColumn.setOptions(opts);
+                                                                        renderer.has_entry = false;
+                                                                    }
+                                                                    this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1);
+                                                                        
+                                                                   //Seed.print("click" + ev.type);
+                                                                    //console.dump(res);
+                                                                    return false;
+                                                                
+                                                                              
+                                                                   
+                                                                }
+                                                            },
                                                             id : "view",
                                                             tooltip_column : 5,
-                                                            headers_visible : false,
                                                             enable_tree_lines : true,
+                                                            headers_visible : false,
                                                             init : function() {
                                                                  XObject.prototype.init.call(this); 
                                                                                    
@@ -1926,68 +2057,6 @@ Window=new XObject({
                                                                                 description.set_size(8000);
                                                                                 this.el.modify_font(description);
                                                             },
-                                                            listeners : {
-                                                                button_press_event : function (self, ev) {
-                                                                    
-                                                                                
-                                                                                var res = { }; 
-                                                                                if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
-                                                                                    return false; //not on a element.
-                                                                                }
-                                                                                
-                                                                                
-                                                                                if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
-                                                                                    
-                                                                                    if (res.column.title != 'value') {
-                                                                                        return false; // ignore..
-                                                                                    }
-                                                                                    if (  this.get('/LeftPanel').editing) {
-                                                                                        return false;
-                                                                                    }
-                                                                                    var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
-                                                                                    this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
-                                                                                    var type = this.get('/LeftPanel.model').getType(res.path.to_string());
-                                                                                    
-                                                                                     
-                                                                
-                                                                                    var provider = this.get('/LeftTree').getPaleteProvider();
-                                                                                    
-                                                                                    var opts = provider.findOptions(type);
-                                                                                    
-                                                                                    if (opts === false) {
-                                                                                         this.get('/LeftPanel').editableColumn.setOptions([]);
-                                                                                        renderer.has_entry = true;
-                                                                                    } else {
-                                                                                        LeftPanel.editableColumn.setOptions(opts);
-                                                                                        renderer.has_entry = false;
-                                                                                    }
-                                                                                    
-                                                                                    
-                                                                                   //Seed.print("click" + ev.type);
-                                                                                    //console.dump(res);
-                                                                                    return false;
-                                                                                }
-                                                                              
-                                                                            
-                                                                               
-                                                                                if (res.column.title == 'value') {
-                                                                                    return false;
-                                                                                }
-                                                                                //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
-                                                                               var p = this.get('/LeftPanelPopup');
-                                                                               if (!p.el) {
-                                                                                       p.init();
-                                                                               }
-                                                                
-                                                                                p.el.set_screen(Gdk.Screen.get_default());
-                                                                                p.el.show_all();
-                                                                                p.el.popup(null, null, null, null, 3, ev.button.time);
-                                                                                //Seed.print("click:" + res.column.title);
-                                                                                
-                                                                                
-                                                                                return false;
-                                                                }
-                                                            },
                                                             items : [
                                                                 {
                                                                     xtype: Gtk.TreeStore,
@@ -2098,61 +2167,6 @@ Window=new XObject({
                                                                         this.load(data);
                                                                         this.get('/LeftTree.model').changed(data, true);
                                                                         
-                                                                    },
-                                                                    editSelected : function(e) {
-                                                                        print("EDIT SELECTED?");
-                                                                        var iter = new Gtk.TreeIter();
-                                                                        var s = this.get('/LeftPanel.view').selection;
-                                                                        s.get_selected(this.get('/LeftPanel.model').el, iter);
-                                                                        var m = this.get('/LeftPanel.model')
-                                                                       
-                                                                        var gval = new GObject.Value('');
-                                                                        this.el.get_value(iter, 0 ,gval);
-                                                                        var val = '' + gval.value;
-                                                                        
-                                                                        gval = new GObject.Value('');
-                                                                        this.el.get_value(iter, 1 ,gval);
-                                                                        var rval = gval.value;
-                                                                        var activePath = this.el.get_path(iter).to_string(); 
-                                                                        this.activePath = activePath ;
-                                                                        // was activeIter...
-                                                                        //  not listener...
-                                                                    
-                                                                        var showEditor = false;
-                                                                        
-                                                                        if (val[0] == '!') {
-                                                                            showEditor = true;
-                                                                        }
-                                                                        if (val[0] == '|') {
-                                                                            if (rval.match(/function/g) || rval.match(/\n/g) || rval.length > 20) {
-                                                                                showEditor = true;
-                                                                            }
-                                                                        }
-                                                                        
-                                                                        if (showEditor) {
-                                                                            var _this = this;
-                                                                            this.activePath = false;
-                                                                            GLib.timeout_add(0, 1, function() {
-                                                                                //   Gdk.threads_enter();
-                                                                                _this.get('/BottomPane').el.show();
-                                                                                _this.get('/RightEditor').el.show();
-                                                                                _this.get('/RightEditor.view').load( rval );
-                                                                                
-                                                                                e.editing_done();
-                                                                                e.remove_widget();
-                                                                                _this.activePath = activePath ;
-                                                                                
-                                                                         //       Gdk.threads_leave();
-                                                                                return false;
-                                                                            });
-                                                                            return;
-                                                                        }
-                                                                          this.get('/BottomPane').el.hide();
-                                                                        this.get('/RightEditor').el.hide();
-                                                                    
-                                                                            //var type = this.getValue(this.el.get_path(iter).to_string(),4);
-                                                                            
-                                                                            
                                                                     },
                                                                     getIterValue : function(iter, col) {
                                                                          var gval = new GObject.Value('');
@@ -2162,18 +2176,22 @@ Window=new XObject({
                                                                     getType : function(treepath) {
                                                                          return this.getValue(treepath, 4);
                                                                     },
-                                                                    getValue : function(treepath_str, col) {
-                                                                          var iter = new Gtk.TreeIter();
+                                                                    getValue : function(treepath_str, col) 
+                                                                    {
+                                                                       // get's the  value in a row.. - keys - returns string, values - formats it..
+                                                                    
+                                                                        var iter = new Gtk.TreeIter();
                                                                         this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
                                                                         
                                                                         var gval = new GObject.Value('');
                                                                         this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
                                                                         var val = '' + gval.value;
+                                                                       
                                                                         if (col != 1) {
                                                                             return val;
                                                                         }
                                                                         var type = this.getType(this.el.get_path(iter).to_string());
-                                                                        print("TYPE: " +type + " -  val:" + val);
+                                                                        //print("TYPE: " +type + " -  val:" + val);
                                                                         switch(type.toLowerCase()) {
                                                                             case 'number':
                                                                             case 'uint':
@@ -2206,9 +2224,16 @@ Window=new XObject({
                                                                                                 ]);
                                                                     },
                                                                     load : function(ar) {
+                                                                    // might casue problesm..
+                                                                        // this.get('/Editor.RightEditor').save();
+                                                                    
+                                                                           this.get('/Editor').el.hide();
+                                                                         this.get('/Editor').activePath = false;
+                                                                    
+                                                                    
                                                                       this.el.clear();
-                                                                                            
-                                                                        this.get('/RightEditor').el.hide();
+                                                                                  
+                                                                        //this.get('/RightEditor').el.hide();
                                                                         if (ar === false) {
                                                                             return ;
                                                                         }
@@ -2260,13 +2285,16 @@ Window=new XObject({
                                                                         return ret;
                                                                     },
                                                                     startEditing : function(path,col) {
+                                                                        
+                                                                        // alled by menu 'edit' currently..
                                                                         /**
                                                                         * start editing path (or selected if not set..)
                                                                         * @param {String|false} path  (optional) treepath to edit - selected tree gets
                                                                         *     edited by default.
                                                                         * @param {Number} 0 or 1 (optional)- column to edit. 
                                                                         */
-                                                                         var tp;
+                                                                        // fix tp to be the 'treepath' string (eg. 0/1/2...)
+                                                                        var tp;
                                                                         if (typeof(path) == 'string') {
                                                                             tp = new Gtk.TreePath.from_string(path);
                                                                         } else {
@@ -2280,8 +2308,12 @@ Window=new XObject({
                                                                        
                                                                         // which colum is to be edited..
                                                                         var colObj = false;
+                                                                        
+                                                                        // not sure what this does..
+                                                                        
                                                                         if (typeof(col) == 'undefined') {
                                                                             var k = this.getValue(path, 0);
+                                                                            col = 1;
                                                                             colObj = (!k.length || k == '|') ? 
                                                                                 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
                                                                         } else {
@@ -2290,25 +2322,69 @@ Window=new XObject({
                                                                         
                                                                         // make sure the pulldown is set correctly..
                                                                         // not really needed for second col...
-                                                                    
-                                                                        var provider = this.get('/LeftTree').getPaleteProvider();
-                                                                       
-                                                                        var type = this.get('/LeftPanel.model').getType(path);
-                                                                        var opts = provider.findOptions(type);
-                                                                        var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
+                                                                        var showEditor = false;
+                                                                        this.get('/Editor').activePath = false;
+                                                                        this.get('/Editor').el.hide();
+                                                                         
+                                                                        if (col) {
+                                                                            var provider = this.get('/LeftTree').getPaleteProvider();
+                                                                            var type = this.get('/LeftPanel.model').getType(path);
+                                                                            var opts = provider.findOptions(type);
+                                                                            var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
+                                                                            
+                                                                            if (opts === false) {
+                                                                                this.get('/LeftPanel').editableColumn.setOptions([]);
+                                                                                renderer.has_entry = true; 
+                                                                            } else {
+                                                                                this.get('/LeftPanel').editableColumn.setOptions(opts);
+                                                                                renderer.has_entry = false;/// - pulldowns do not have entries
+                                                                            }
+                                                                            // determine if we should use the Text editor...
+                                                                            var keyname = this.getValue(path, 0);
+                                                                            var data_value = this.getValue(path, 1);
                                                                         
-                                                                        if (opts === false) {
-                                                                            this.get('/LeftPanel').editableColumn.setOptions([]);
-                                                                            renderer.has_entry = true; /// probably does not have any effect.
-                                                                        } else {
-                                                                            this.get('/LeftPanel').editableColumn.setOptions(opts);
-                                                                            renderer.has_entry = false;
+                                                                            if ((keyname[0] == '|') || 
+                                                                                (   
+                                                                                    (typeof(data_value) == 'string' ) && 
+                                                                                    ( data_value.match(/function/g) || data_value.match(/\n/g)) // || (data_value.length > 20))
+                                                                                )) {
+                                                                                showEditor = true;
+                                                                            }
+                                                                            print("SHOW EDITOR" + showEditor ? 'YES' :'no');
+                                                                            
+                                                                        }
+                                                                        var _this = this;    
+                                                                        // end editing..
+                                                                       // this.get('/BottomPane').el.hide();
+                                                                        //this.get('/RightEditor').el.hide();
+                                                                         
+                                                                        
+                                                                        if (showEditor) {
+                                                                    
+                                                                            this.activePath = false;
+                                                                            
+                                                                            _this.get('/Editor').el.show_all();
+                                                                            GLib.timeout_add(0, 1, function() {
+                                                                    
+                                                                                //_this.get('/BottomPane').el.show();
+                                                                                 //_this.get('/RightEditor').el.show();
+                                                                                
+                                                                                _this.get('/Editor.RightEditor.view').load( _this.getValue(path, 1) );
+                                                                                
+                                                                                _this.get('/Editor').activePath = path;
+                                                                                _this.activePath = path ;
+                                                                              
+                                                                                return false;
+                                                                            });
+                                                                            return;
                                                                         }
+                                                                          
                                                                         
-                                                                        var _this=this;
+                                                                        
+                                                                    
                                                                         // iter now has row...
                                                                         GLib.timeout_add(0, 100, function() {
-                                                                            
+                                                                            _this.activePath = path;
                                                                             colObj.items[0].el.editable = true; // esp. need for col 0..
                                                                             _this.get('/LeftPanel.view').el.set_cursor_on_cell(
                                                                                 tp,
@@ -2391,11 +2467,12 @@ Window=new XObject({
                                                                 {
                                                                     xtype: Gtk.TreeViewColumn,
                                                                     pack : "append_column",
+                                                                    title : "value",
                                                                     init : function() {
                                                                         XObject.prototype.init.call(this);
                                                                        this.el.add_attribute(this.items[0].el , 'text', 3 );
                                                                        this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
-                                                                       this.el.add_attribute(this.items[0].el , 'editable', 3 );
+                                                                       //this.el.add_attribute(this.items[0].el , 'editable', 3 );
                                                                               // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
                                                                     
                                                                        this.get('/LeftPanel').editableColumn= this;
@@ -2414,34 +2491,38 @@ Window=new XObject({
                                                                     items : [
                                                                         {
                                                                             xtype: Gtk.CellRendererCombo,
-                                                                            pack : "pack_start",
-                                                                            editable : true,
-                                                                            has_entry : true,
-                                                                            text_column : 0,
-                                                                            init : function() {
-                                                                                XObject.prototype.init.call(this);
-                                                                               this.el.model = new Gtk.ListStore();
-                                                                                this.el.model.set_column_types ( 1, [
-                                                                                    GObject.TYPE_STRING  // 0 real key
-                                                                                  ]);
-                                                                            },
                                                                             listeners : {
                                                                                 edited : function (self, object, p0) {
                                                                                        this.get('/LeftPanel').editing = false;
-                                                                                       print("EDITED? p:" + p0 + " t:" + p0);
+                                                                                       var ap = this.get('/LeftPanel.model').activePath
+                                                                                       print("EDITED? "  + ap + " - p:" + p0 + " t:" + p0);
                                                                                         this.get('/LeftPanel.model').changed(p0, true);
                                                                                         this.get('/LeftPanel.model').activePath = false;
+                                                                                        this.el.editable = false;
                                                                                 },
                                                                                 editing_started : function (self, editable, path) {
                                                                                    this.get('/LeftPanel').editing  = true;
                                                                                        //  console.log('editing started');
                                                                                        // r.has_entry = false;
-                                                                                   this.get('/LeftPanel.model').editSelected(editable);
+                                                                                
+                                                                                    this.el.editable = false; // make sure it's not editor...
+                                                                                   
                                                                                 }
-                                                                            }
-                                                                        }
-                                                                    ]
-                                                                }
+                                                                            },
+                                                                            editable : false,
+                                                                            pack : "pack_start",
+                                                                            text_column : 0,
+                                                                            has_entry : true,
+                                                                            init : function() {
+                                                                                XObject.prototype.init.call(this);
+                                                                               this.el.model = new Gtk.ListStore();
+                                                                                this.el.model.set_column_types ( 1, [
+                                                                                    GObject.TYPE_STRING  // 0 real key
+                                                                                  ]);
+                                                                            }
+                                                                        }
+                                                                    ]
+                                                                }
                                                             ]
                                                         },
                                                         {
@@ -2642,7 +2723,7 @@ Window=new XObject({
                                                                   //  console.log( '<b>' + p.name +'</b> ['+p.type+']');
                                                                         //GObject.TYPE_STRING,  // real key
                                                                         // GObject.TYPE_STRING, // real type
-                                                                        // GObject.TYPE_STRING, // docs ?
+                                                                        // GObject.TYPE_STRING, // docs ?this.el.set_value(iter, 0, p.name);et_value(iter, 0, p.name);
                                                                         // GObject.TYPE_STRING // func def?
                                                                         
                                                                     
@@ -2659,6 +2740,7 @@ Window=new XObject({
                                                 },
                                                 {
                                                     xtype: Gtk.TreeViewColumn,
+                                                    pack : false,
                                                     init : function() {
                                                         this.el = new Gtk.TreeViewColumn();
                                                         this.parent.el.append_column(this.el);
@@ -2666,7 +2748,6 @@ Window=new XObject({
                                                         XObject.prototype.init.call(this);
                                                         this.el.add_attribute(this.items[0].el , 'markup', 4  );
                                                     },
-                                                    pack : false,
                                                     items : [
                                                         {
                                                             xtype: Gtk.CellRendererText,
@@ -2722,6 +2803,45 @@ Window=new XObject({
                                                                     id : "RightBrowser",
                                                                     pack : "add",
                                                                     items : [
+                                                                        {
+                                                                            xtype: Gtk.HBox,
+                                                                            pack : "pack_start,false,true,0",
+                                                                            items : [
+                                                                                {
+                                                                                    xtype: Gtk.Button,
+                                                                                    listeners : {
+                                                                                        clicked : function (self) {
+                                                                                          this.get('/RightBrowser.view').renderJS(null,true);
+                                                                                        }
+                                                                                    },
+                                                                                    label : "Redraw",
+                                                                                    pack : "pack_start,false,false,0"
+                                                                                },
+                                                                                {
+                                                                                    xtype: Gtk.CheckButton,
+                                                                                    listeners : {
+                                                                                        toggled : function (self, state) {
+                                                                                            this.el.set_label(this.el.active  ? "Auto Redraw On" : "Auto Redraw Off");
+                                                                                        }
+                                                                                    },
+                                                                                    active : true,
+                                                                                    id : "AutoRedraw",
+                                                                                    label : "Auto Redraw On",
+                                                                                    pack : "pack_start,false,false,0"
+                                                                                },
+                                                                                {
+                                                                                    xtype: Gtk.Button,
+                                                                                    listeners : {
+                                                                                        clicked : function (self) {
+                                                                                          this.get('/RightBrowser.view').redraws = 99;
+                                                                                          this.get('/RightBrowser.view').renderJS(null,true);
+                                                                                        }
+                                                                                    },
+                                                                                    label : "Full Redraw",
+                                                                                    pack : "pack_start,false,false,0"
+                                                                                }
+                                                                            ]
+                                                                        },
                                                                         {
                                                                             xtype: Gtk.ScrolledWindow,
                                                                             pack : "add",
@@ -2746,9 +2866,11 @@ Window=new XObject({
                                                                                                }
                                                                                         
                                                                                                this.ready = true;
-                                                                                                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]);
@@ -2763,11 +2885,26 @@ Window=new XObject({
                                                                                         console_message : function (self, object, p0, p1) {
                                                                                             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(/^\{/)) {
                                                                                                 
                                                                                                     //this.get('/Terminal').feed(object);
                                                                                                     return true; // do not handle!!! -> later maybe in console..
                                                                                                 }
+                                                                                                
+                                                                                                
+                                                                                                
+                                                                                                
                                                                                                // console.log(object);
                                                                                                 var val =  JSON.parse(object);
                                                                                         
@@ -2906,15 +3043,86 @@ Window=new XObject({
                                                                                     },
                                                                                     id : "view",
                                                                                     pack : "add",
+                                                                                    redraws : 0,
+                                                                                    init : function() {
+                                                                                        XObject.prototype.init.call(this);
+                                                                                        // this may not work!?
+                                                                                        var settings =  this.el.get_settings();
+                                                                                        settings.enable_developer_extras = true;
+                                                                                        
+                                                                                        // this was an attempt to change the url perms.. did not work..
+                                                                                        // settings.enable_file_access_from_file_uris = true;
+                                                                                        // settings.enable_offline_web_application_cache - true;
+                                                                                        // settings.enable_universal_access_from_file_uris = true;
+                                                                                        var _this = this;
+                                                                                         
+                                                                                         // init inspector..
+                                                                                        this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {
+                                                                                             _this.get('/BottomPane.inspector').el.show();
+                                                                                             return _this.get('/BottomPane.inspector').el;
+                                                                                        
+                                                                                        });
+                                                                                         
+                                                                                         // FIXME - base url of script..
+                                                                                         // we need it so some of the database features work.
+                                                                                        this.el.load_html_string( "Render not ready" , 
+                                                                                                //fixme - should be a config option!
+                                                                                                // or should we catch stuff and fix it up..
+                                                                                                'http://localhost/app.Builder/'
+                                                                                        );
+                                                                                            
+                                                                                            
+                                                                                       //this.el.open('file:///' + __script_path__ + '/../builder.html');
+                                                                                                              
+                                                                                        Gtk.drag_dest_set
+                                                                                        (
+                                                                                                this.el,              /* widget that will accept a drop */
+                                                                                                Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
+                                                                                                null,            /* lists of target to support */
+                                                                                                0,              /* size of list */
+                                                                                                Gdk.DragAction.COPY         /* what to do with data after dropped */
+                                                                                        );
+                                                                                                                
+                                                                                       // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
+                                                                                        Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
+                                                                                        
+                                                                                        GLib.timeout_add_seconds(0, 1, function() {
+                                                                                            //    print("run refresh?");
+                                                                                             _this.runRefresh(); 
+                                                                                             return true;
+                                                                                         });
+                                                                                        
+                                                                                        
+                                                                                    },
+                                                                                    renderJS : function(data, force) {
+                                                                                    
+                                                                                        // this is the public redraw call..
+                                                                                        // we refresh in a loop privately..
+                                                                                        var autodraw = this.get('/RightBrowser.AutoRedraw').el.active;
+                                                                                        if (!autodraw && !force) {
+                                                                                            print("Skipping redraw - no force, and autodraw off");
+                                                                                            return;
+                                                                                        }
+                                                                                        this.refreshRequired  = true;
+                                                                                    },
                                                                                     runRefresh : function() 
                                                                                     {
                                                                                         // this is run every 2 seconds from the init..
+                                                                                    
+                                                                                      
                                                                                         
                                                                                         if (!this.refreshRequired) {
-                                                                                            print("no refresh required");
+                                                                                           // print("no refresh required");
                                                                                             return;
                                                                                         }
                                                                                     
+                                                                                        if (this.lastRedraw) {
+                                                                                           // do not redraw if last redraw was less that 5 seconds ago.
+                                                                                           if (((new Date()) -  this.lastRedraw) < 5000) {
+                                                                                                return;
+                                                                                            }
+                                                                                        }
+                                                                                        
                                                                                         
                                                                                         
                                                                                         
@@ -2922,19 +3130,19 @@ Window=new XObject({
                                                                                             return;
                                                                                          }
                                                                                          this.refreshRequired = false;
-                                                                                         print("HTML RENDERING");
+                                                                                       //  print("HTML RENDERING");
                                                                                          
                                                                                          this.get('/BottomPane').el.show();
-                                                                                         this.get('/BottomPane').el.set_current_page(2);// webkit view!
+                                                                                         this.get('/BottomPane').el.set_current_page(2);// webkit inspector
                                                                                     
                                                                                         
-                                                                                            var js = this.get('/LeftTree.model').toJS();
-                                                                                            if (!js || !js.length) {
-                                                                                                print("no data");
-                                                                                                return;
-                                                                                               }
-                                                                                               data = js[0];
-                                                                                        
+                                                                                        var js = this.get('/LeftTree.model').toJS();
+                                                                                        if (!js || !js.length) {
+                                                                                            print("no data");
+                                                                                            return;
+                                                                                        }
+                                                                                        var  data = js[0];
+                                                                                        this.redraws++;
                                                                                         
                                                                                          var project = this.get('/Window.LeftTree').getActiveFile().project;
                                                                                          //print (project.fn);
@@ -2945,7 +3153,7 @@ Window=new XObject({
                                                                                     
                                                                                          this.runhtml  = this.runhtml || '';
                                                                                         
-                                                                                         if (project.runhtml != this.runhtml) {
+                                                                                         if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
                                                                                             // then we need to reload the browser using
                                                                                             // load_html_string..
                                                                                             
@@ -2965,16 +3173,14 @@ Window=new XObject({
                                                                                             print("LOAD HTML " + html);
                                                                                             this.el.load_html_string( html , 
                                                                                                 //fixme - should be a config option!
-                                                                                                'http://www.akbkhome.com/e/'
+                                                                                                'http://localhost/app.Builder/'
                                                                                             );
-                                                                                            
+                                                                                            this.redraws = 0;
                                                                                             // should trigger load_finished! - which in truns shoudl set refresh Required;
                                                                                             return;
                                                                                         
                                                                                         }
                                                                                         
-                                                                                        this.pendingRedraw = false;    // needed any more?
-                                                                                         return;
                                                                                         
                                                                                         this.renderedData = data;
                                                                                         var str = JSON.stringify(data) ;
@@ -2982,61 +3188,12 @@ Window=new XObject({
                                                                                         if (!this.ready) {
                                                                                             console.log('not loaded yet');
                                                                                         }
-                                                                                     
+                                                                                        this.lastRedraw = new Date();
+                                                                                    
                                                                                         this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
+                                                                                         print( "before render" +    this.lastRedraw);
+                                                                                        print( "after render" +    (new Date()));
                                                                                         
-                                                                                    },
-                                                                                    init : function() {
-                                                                                        XObject.prototype.init.call(this);
-                                                                                        // this may not work!?
-                                                                                        var settings =  this.el.get_settings();
-                                                                                        settings.enable_developer_extras = true;
-                                                                                        
-                                                                                        // this was an attempt to change the url perms.. did not work..
-                                                                                        // settings.enable_file_access_from_file_uris = true;
-                                                                                        // settings.enable_offline_web_application_cache - true;
-                                                                                        // settings.enable_universal_access_from_file_uris = true;
-                                                                                        var _this = this;
-                                                                                         
-                                                                                         // init inspector..
-                                                                                        this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {
-                                                                                             _this.get('/BottomPane.inspector').el.show();
-                                                                                             return _this.get('/BottomPane.inspector').el;
-                                                                                        
-                                                                                        });
-                                                                                         
-                                                                                         // FIXME - base url of script..
-                                                                                         // we need it so some of the database features work.
-                                                                                        this.el.load_html_string( "Render not ready" , 
-                                                                                                //fixme - should be a config option!
-                                                                                                'http://www.akbkhome.com/e/'
-                                                                                        );
-                                                                                            
-                                                                                            
-                                                                                       //this.el.open('file:///' + __script_path__ + '/../builder.html');
-                                                                                                              
-                                                                                        Gtk.drag_dest_set
-                                                                                        (
-                                                                                                this.el,              /* widget that will accept a drop */
-                                                                                                Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
-                                                                                                null,            /* lists of target to support */
-                                                                                                0,              /* size of list */
-                                                                                                Gdk.DragAction.COPY         /* what to do with data after dropped */
-                                                                                        );
-                                                                                                                
-                                                                                       // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
-                                                                                        Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
-                                                                                        
-                                                                                        GLib.timeout_add_seconds(0, 2, function() {
-                                                                                            print("run refresh?");
-                                                                                             _this.runRefresh(); 
-                                                                                             return true;
-                                                                                         });
-                                                                                        
-                                                                                        
-                                                                                    },
-                                                                                    renderJS : function(data) {
-                                                                                        this.refreshRequired  = true;
                                                                                     }
                                                                                 }
                                                                             ]
@@ -3147,21 +3304,30 @@ Window=new XObject({
                                                                     */
                                                                     },
                                                                     viewAdd : function(item, par)
-                                                                            {
+                                                                    {
+                                                                    
                                                                         // does something similar to xobject..
-                                                                        item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;
+                                                                        //item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;
                                                                         
+                                                                        // pack is forced to 'false'
                                                                         if (item.pack===false || item.pack === 'false') {  // no ;
                                                                             return;
                                                                         }
+                                                                        
                                                                         print("CREATE: " + item['|xns'] + '.' + item['xtype']);
+                                                                        
+                                                                        
                                                                         var type = item['|xns'] + '.' + item['xtype'];
                                                                         
                                                                         if (item['|xns'] == 'GtkClutter') { // we can not add this yet!
                                                                             return false;
                                                                         }
+                                                                        
                                                                         var ns = imports.gi[item['|xns']];
-                                                                        var ctr = ns[item['xtype']];
+                                                                        var ctr = ns[item['xtype']]; // why are we using array here..?
+                                                                        
+                                                                    
+                                                                        
                                                                         var ctr_args = { };
                                                                         for(var k in item) {
                                                                             var kv = item[k];
@@ -3179,13 +3345,13 @@ Window=new XObject({
                                                                             ) {
                                                                                 continue;
                                                                             }
-                                                                    
+                                                                            // value is a function..
                                                                        if (k[0] == '|' && typeof(kv) == 'string') {
                                                                     
                                                                                if (kv.match(new RegExp('function'))) {
                                                                                        continue;
                                                                                     }
-                                                                                print("WASL " + k + '=' + kv);
+                                                                               print("WASL " + k + '=' + kv);
                                                                                try {
                                                                                        eval( 'kv = ' + kv);
                                                                                } catch(e) {    continue; }
@@ -3205,10 +3371,18 @@ Window=new XObject({
                                                                             ctr_args[k] = kv;
                                                                             
                                                                         } 
-                                                                        
+                                                                        var altctr =  XObject.baseXObject({ xtype:  ctr} );
+                                                                        var pack_m  = false;
+                                                                        if (!item.pack && altctr) {
+                                                                            // try XObject.
+                                                                            print("SETTING PACK TO XObjectBase method");
+                                                                            pack_m = altctr.prototype.pack;
+                                                                            
+                                                                            
+                                                                        }
                                                                         
                                                                         var el = new ctr(ctr_args);
-                                                                        
+                                                                        item.el = el;
                                                                         print("PACK" + item.pack);
                                                                         //console.dump(item.pack);
                                                                         
@@ -3216,26 +3390,27 @@ Window=new XObject({
                                                                         
                                                                         
                                                                         var args = [];
-                                                                        var pack_m  = false;
-                                                                        if (typeof(item.pack) == 'string') {
-                                                                             
-                                                                            item.pack.split(',').forEach(function(e, i) {
+                                                                        if (!pack_m) {
+                                                                            item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;
+                                                                            if (typeof(item.pack) == 'string') {
+                                                                                 
+                                                                                item.pack.split(',').forEach(function(e, i) {
+                                                                                    
+                                                                                    if (e == 'false') { args.push( false); return; }
+                                                                                    if (e == 'true') {  args.push( true);  return; }
+                                                                                    if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
+                                                                                    args.push(e);
+                                                                                });
+                                                                                //print(args.join(","));
                                                                                 
-                                                                                if (e == 'false') { args.push( false); return; }
-                                                                                if (e == 'true') {  args.push( true);  return; }
-                                                                                if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
-                                                                                args.push(e);
-                                                                            });
-                                                                            //print(args.join(","));
-                                                                            
-                                                                            pack_m = args.shift();
-                                                                        } else {
-                                                                            pack_m = item.pack.shift();
-                                                                            args = item.pack;
+                                                                                pack_m = args.shift();
+                                                                            } else {
+                                                                                pack_m = item.pack.shift();
+                                                                                args = item.pack;
+                                                                            }
                                                                         }
-                                                                        
                                                                         // handle error.
-                                                                        if (pack_m && typeof(par[pack_m]) == 'undefined') {
+                                                                        if (typeof(pack_m) == 'string' && typeof(par[pack_m]) == 'undefined') {
                                                                             throw {
                                                                                     name: "ArgumentError", 
                                                                                     message : 'pack method not available : ' + par.id + " : " + par + '.' +  pack_m +
@@ -3250,17 +3425,21 @@ Window=new XObject({
                                                                         args.unshift(el);
                                                                         //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
                                                                         //Seed.print('args: ' + args.length);
-                                                                        if (pack_m) {
+                                                                        if (typeof(pack_m) == 'string') {
                                                                             par[pack_m].apply(par, args);
+                                                                        } else if (pack_m) {
+                                                                            pack_m.call(item, par, item);
                                                                         }
                                                                         
                                                                         var _this = this;
                                                                         item.items = item.items || [];
                                                                         item.items.forEach(function(ch,n) {
                                                                     
-                                                                              print ("type:" + type);
+                                                                             print ("type:" + type);
                                                                               
-                                                                               print ("ch.pack:" + ch.pack);
+                                                                             print ("ch.pack:" + ch.pack);
+                                                                               
+                                                                               
                                                                              if (type == 'Gtk.Table' && ch.pack == 'add') {
                                                                                 var c = n % item.n_columns;
                                                                                 var r = Math.floor(n/item.n_columns);
@@ -3288,7 +3467,7 @@ Window=new XObject({
                                                                             el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item  ], true));
                                                                             el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item  ], true));
                                                                             el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item  ], true ));
-                                                                      el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item  ], true ));
+                                                                            el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item  ], true ));
                                                                         } catch(e) {
                                                                             // ignore!
                                                                            }
@@ -3639,94 +3818,11 @@ Window=new XObject({
                                             pack : "add",
                                             init : function() {
                                                 XObject.prototype.init.call(this);
-                                               this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
-                                                       this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
-                                                       this.el.set_tab_label(this.items[2].el, new Gtk.Label({ label : "Inspector" }));
+                                               //this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
+                                                       this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Console" }));
+                                                       this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Inspector" }));
                                             },
                                             items : [
-                                                {
-                                                    xtype: Gtk.ScrolledWindow,
-                                                    pack : "add",
-                                                    id : "RightEditor",
-                                                    items : [
-                                                        {
-                                                            xtype: GtkSource.View,
-                                                            pack : "add",
-                                                            id : "view",
-                                                            init : function() {
-                                                                XObject.prototype.init.call(this);
-                                                                 var description = Pango.Font.description_from_string("monospace")
-                                                                description.set_size(8000);
-                                                                this.el.modify_font(description);
-                                                            
-                                                            },
-                                                            load : function(str) {
-                                                            
-                                                            // show the help page for the active node..
-                                                               this.get('/Help').show();
-                                                            
-                                                            
-                                                               this.get('/BottomPane').el.set_current_page(0);
-                                                                this.el.get_buffer().set_text(str, str.length);
-                                                                var lm = GtkSource.LanguageManager.get_default();
-                                                                
-                                                                this.el.get_buffer().set_language(lm.get_language('js'));
-                                                                var buf = this.el.get_buffer();
-                                                                var cursor = buf.get_mark("insert");
-                                                                var iter= new Gtk.TextIter;
-                                                                buf.get_iter_at_mark(iter, cursor);
-                                                                iter.set_line(1);
-                                                                iter.set_line_offset(4);
-                                                                buf.move_mark(cursor, iter);
-                                                                
-                                                                
-                                                                cursor = buf.get_mark("selection_bound");
-                                                                iter= new Gtk.TextIter;
-                                                                buf.get_iter_at_mark(iter, cursor);
-                                                                iter.set_line(1);
-                                                                iter.set_line_offset(4);
-                                                                buf.move_mark(cursor, iter);
-                                                                 
-                                                                this.el.grab_focus();
-                                                            },
-                                                            insert_spaces_instead_of_tabs : true,
-                                                            indent_width : 4,
-                                                            auto_indent : true,
-                                                            show_line_numbers : true,
-                                                            items : [
-                                                                {
-                                                                    xtype: GtkSource.Buffer,
-                                                                    pack : "set_buffer",
-                                                                    listeners : {
-                                                                        changed : function (self) {
-                                                                            var s = new Gtk.TextIter();
-                                                                            var e = new Gtk.TextIter();
-                                                                            this.el.get_start_iter(s);
-                                                                            this.el.get_end_iter(e);
-                                                                            var str = this.el.get_text(s,e,true);
-                                                                            try {
-                                                                                Seed.check_syntax('var e = ' + str);
-                                                                            } catch (e) {
-                                                                                this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
-                                                                                    red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
-                                                                                   }));
-                                                                                print("SYNTAX ERROR IN EDITOR");   
-                                                                                print(e);
-                                                                                console.dump(e);
-                                                                                return;
-                                                                            }
-                                                                            this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
-                                                                                    red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
-                                                                                   }));
-                                                                            
-                                                                             this.get('/LeftPanel.model').changed(  str , false);
-                                                                        }
-                                                                    }
-                                                                }
-                                                            ]
-                                                        }
-                                                    ]
-                                                },
                                                 {
                                                     xtype: Gtk.ScrolledWindow,
                                                     pack : "add",
@@ -3870,48 +3966,6 @@ Window=new XObject({
                                                     items : [
                                                         {
                                                             xtype: Gtk.TreeView,
-                                                            pack : "add",
-                                                            init : function() {
-                                                                XObject.prototype.init.call(this);
-                                                              this.el.set_size_request(150,-1);
-                                                                                      //  set_reorderable: [1]
-                                                                                              
-                                                                        var description = new Pango.FontDescription.c_new();
-                                                                description.set_size(8000);
-                                                                this.el.modify_font(description);
-                                                                
-                                                                this.selection = this.el.get_selection();
-                                                                this.selection.set_mode( Gtk.SelectionMode.SINGLE);
-                                                               // this.selection.signal['changed'].connect(function() {
-                                                                //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
-                                                                //});
-                                                                // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
-                                                                 
-                                                                Gtk.drag_source_set (
-                                                                        this.el,            /* widget will be drag-able */
-                                                                        Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
-                                                                        null,            /* lists of target to support */
-                                                                        0,              /* size of list */
-                                                                        Gdk.DragAction.COPY         /* what to do with data after dropped */
-                                                                );
-                                                                //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
-                                                               
-                                                                Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
-                                                                Gtk.drag_source_add_text_targets(this.el); 
-                                                                /*
-                                                                print("RP: TARGET:" + LeftTree.atoms["STRING"]);
-                                                                targets = new Gtk.TargetList();
-                                                                targets.add( LeftTree.atoms["STRING"], 0, 0);
-                                                                targets.add_text_targets( 1 );
-                                                                Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
-                                                                
-                                                                //if you want to allow text to be output elsewhere..
-                                                                //Gtk.drag_source_add_text_targets(this.el);
-                                                                */
-                                                                return true; 
-                                                            },
-                                                            headers_visible : false,
-                                                            enable_tree_lines : true,
                                                             listeners : {
                                                                 drag_begin : function (self, ctx) {
                                                                     // we could fill this in now...
@@ -3964,8 +4018,58 @@ Window=new XObject({
                                                                        this.el.dropList = false;
                                                                        this.get('/LeftTree.view').highlight(false);
                                                                        return true;
+                                                                },
+                                                                button_press_event : function (self, event) {
+                                                                
+                                                                       if (!this.get('/Editor').save()) {
+                                                                           // popup!! - click handled.. 
+                                                                           return true;
+                                                                        }
+                                                                    return false;
                                                                 }
                                                             },
+                                                            pack : "add",
+                                                            enable_tree_lines : true,
+                                                            headers_visible : false,
+                                                            init : function() {
+                                                                XObject.prototype.init.call(this);
+                                                              this.el.set_size_request(150,-1);
+                                                                                      //  set_reorderable: [1]
+                                                                                              
+                                                                        var description = new Pango.FontDescription.c_new();
+                                                                description.set_size(8000);
+                                                                this.el.modify_font(description);
+                                                                
+                                                                this.selection = this.el.get_selection();
+                                                                this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                                                               // this.selection.signal['changed'].connect(function() {
+                                                                //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
+                                                                //});
+                                                                // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
+                                                                 
+                                                                Gtk.drag_source_set (
+                                                                        this.el,            /* widget will be drag-able */
+                                                                        Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
+                                                                        null,            /* lists of target to support */
+                                                                        0,              /* size of list */
+                                                                        Gdk.DragAction.COPY         /* what to do with data after dropped */
+                                                                );
+                                                                //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
+                                                               
+                                                                Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
+                                                                Gtk.drag_source_add_text_targets(this.el); 
+                                                                /*
+                                                                print("RP: TARGET:" + LeftTree.atoms["STRING"]);
+                                                                targets = new Gtk.TargetList();
+                                                                targets.add( LeftTree.atoms["STRING"], 0, 0);
+                                                                targets.add_text_targets( 1 );
+                                                                Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
+                                                                
+                                                                //if you want to allow text to be output elsewhere..
+                                                                //Gtk.drag_source_add_text_targets(this.el);
+                                                                */
+                                                                return true; 
+                                                            },
                                                             items : [
                                                                 {
                                                                     xtype: Gtk.ListStore,