sync
[app.Builder.js] / Sample / Window.js
index d0dc949..022dd00 100644 (file)
@@ -47,6 +47,7 @@ Window=new XObject({
         imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
                this.get('/MidPropTree').hideWin();
             this.get('/RightPalete').hide();
+            this.get('/BottomPane').el.hide();
         
         }
     },
@@ -61,7 +62,8 @@ Window=new XObject({
                     items : [
                         {
                             xtype: Gtk.MenuItem,
-                            label : "File",
+                            use_underline : true,
+                            label : "_File",
                             items : [
                                 {
                                     xtype: Gtk.Menu,
@@ -69,12 +71,14 @@ Window=new XObject({
                                     items : [
                                         {
                                             xtype: Gtk.MenuItem,
-                                            label : "New Project",
+                                            use_underline : true,
+                                            label : "New _Project",
                                             listeners : {
                                                 "activate":function (self) {
+                                                         var _this = this;
                                                        this.get('/EditProject').show({
                                                            success : function(pr) {
-                                                                    this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
+                                                                    _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
                                                            }
                                                        });
                                                 }
@@ -82,7 +86,8 @@ Window=new XObject({
                                         },
                                         {
                                             xtype: Gtk.MenuItem,
-                                            label : "New File",
+                                            label : "_New File",
+                                            use_underline : true,
                                             listeners : {
                                                 "activate":function (self) {
                                                        var fn = this.get('/LeftProjectTree.combo').getValue();
@@ -103,36 +108,26 @@ Window=new XObject({
                                         },
                                         {
                                             xtype: Gtk.MenuItem,
-                                            label : "Add Directory to Project",
+                                            use_underline : true,
                                             pack : "add",
+                                            label : "D_elete Project",
                                             listeners : {
                                                 "activate":function (self) {
-                                                       var fn = this.get('/LeftProjectTree').get('combo').getValue();
-                                                        if (!fn) {
-                                                            this.get('/LeftProjectTree').showNoProjectSelected();
-                                                            return true;
-                                                        }
-                                                        
-                                                        
-                                                        var dc = new Gtk.FileChooserDialog({
-                                                            action : Gtk.FileChooserAction.SELECT_FOLDER,
-                                                            modal: true,
-                                                            'select-multiple' : false,
-                                                            "show-hidden" : true,
-                                                        });
-                                                        dc.add_button("Add To Project", Gtk.ResponseType.ACCEPT );
-                                                        dc.add_button("Cancel",Gtk.ResponseType.CANCEL);
-                                                        
-                                                        if (dc.run() != Gtk.ResponseType.ACCEPT) {
-                                                            
-                                                            dc.destroy();
-                                                            return;
+                                                
+                                                       var fn =  this.get('/LeftProjectTree').get('combo').getValue();
+                                                       if (!fn.length) {
+                                                               this.get('/StandardErrorDialog').show("Select a project")
+                                                               return;
                                                         }
-                                                            
-                                                        //Seed.print(dc.get_filename());
-                                                        var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;
-                                                        pm.getByFn(fn).add(dc.get_filename(), 'dir');
-                                                        dc.destroy();
+                                                       var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+                                                       var pr  = pm.getByFn(fn);
+                                                
+                                                       // confirm..
+                                                       this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
+                                                               pm.deleteProject(fn);
+                                                               print("DELETE?");
+                                                       });
+                                                
                                                 }
                                             }
                                         },
@@ -142,11 +137,12 @@ Window=new XObject({
                                         },
                                         {
                                             xtype: Gtk.MenuItem,
-                                            label : "Quit",
                                             pack : "add",
+                                            label : "_Quit",
+                                            use_underline : true,
                                             listeners : {
                                                 "activate":function (self) {
-                                                       Gtk.main_quit();
+                                                   Gtk.main_quit();
                                                 }
                                             }
                                         }
@@ -247,14 +243,51 @@ Window=new XObject({
                                                                 return pm.getPalete(model.file.getType());
                                                             },
                                                             renderView : function() {
-                                                                        var model = this.get('model');
-                                                               print("RENDER VIEW?" + model.file.getType());
-                                                               switch( model.file.getType()) {
+                                                                var render = this.getRenderer();
+                                                                var model = this.get('model');
+                                                                if (render) {
+                                                                    render.renderJS(model.toJS(false,true)[0]);
+                                                                } else {
+                                                                    print("NO RENDER JS METHOD?");
+                                                                }
+                                                            },
+                                                            getRenderer : function() {
+                                                            
+                                                               switch( this.getActiveFile().getType()) {
                                                                        case 'Roo':
-                                                                           this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
+                                                                           return this.get('/RightBrowser.view');
                                                                        case 'Gtk':
-                                                                           this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
+                                                                           return this.get('/RightGtkView');
                                                                }
+                                                            
+                                                            },
+                                                            getActivePath : function() {
+                                                                var model = this.get('model');
+                                                                var view = this.get('view');
+                                                                if (view.selection.count_selected_rows() < 1) {
+                                                                    return false;
+                                                                }
+                                                                var iter = new Gtk.TreeIter();
+                                                            
+                                                                view.selection.get_selected(model.el, iter);
+                                                                return model.el.get_path(iter).to_string();
+                                                            },
+                                                            getActiveFile : function() {
+                                                                return this.get('model').file;
+                                                            },
+                                                            getActiveElement : function() {
+                                                            
+                                                                 var path = this.getActivePath();
+                                                                 if (!path) {
+                                                                    return false;
+                                                                 }
+                                                                 var iter = new Gtk.TreeIter();
+                                                                 this.get('model').el.get_iter_from_string(iter, path);
+                                                                 
+                                                                 var value = new GObject.Value('');
+                                                                 this.get('model').el.get_value(iter, 2, value);
+                                                                    
+                                                                 return JSON.parse(value.value);
                                                             },
                                                             items : [
                                                                 {
@@ -263,7 +296,7 @@ Window=new XObject({
                                                                     id : "view",
                                                                     headers_visible : false,
                                                                     enable_tree_lines : true,
-                                                                    tooltip_column : 0,
+                                                                    tooltip_column : 1,
                                                                     init : function() {
                                                                                XObject.prototype.init.call(this);
                                                                        var description = new Pango.FontDescription.c_new();
@@ -273,6 +306,8 @@ Window=new XObject({
                                                                        this.selection = this.el.get_selection();
                                                                        this.selection.set_mode( Gtk.SelectionMode.SINGLE);
                                                                        var _this = this;
+                                                                    
+                                                                       // is this really needed??
                                                                        this.selection.signal['changed'].connect(function() {
                                                                                _this.get('/LeftTree.view').listeners.cursor_changed.apply(
                                                                                    _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
@@ -303,8 +338,10 @@ Window=new XObject({
                                                                        Gtk.drag_dest_add_text_targets(this.el);
                                                                     },
                                                                     highlight : function(treepath_ar) {
-                                                                                        if (treepath_ar.length && treepath_ar[0].length ) {
-                                                                                    this.el.set_drag_dest_row( 
+                                                                    
+                                                                            // highlighting for drag/drop
+                                                                            if (treepath_ar.length && treepath_ar[0].length ) {
+                                                                                this.el.set_drag_dest_row( 
                                                                                         new  Gtk.TreePath.from_string( treepath_ar[0] ),  treepath_ar[1]);
                                                                                 } else {
                                                                                     this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
@@ -320,22 +357,22 @@ Window=new XObject({
                                                                     listeners : {
                                                                         "button_press_event":function (self, ev) {
                                                                                console.log("button press?");
-                                                                                        if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
-                                                                                            print("click" + ev.type);
-                                                                                            return false;
-                                                                                        }
-                                                                                      
-                                                                                    
-                                                                                        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();
-                                                                                        
-                                                                                        this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
-                                                                                        this.get('/LeftTreeMenu').el.show_all();
-                                                                                        this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
-                                                                                        print("click:" + res.path.to_string());
-                                                                                        return false;
+                                                                                if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
+                                                                                    print("click" + ev.type);
+                                                                                    return false;
+                                                                                }
+                                                                              
+                                                                            
+                                                                                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();
+                                                                                
+                                                                                this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
+                                                                                this.get('/LeftTreeMenu').el.show_all();
+                                                                                this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
+                                                                                print("click:" + res.path.to_string());
+                                                                                return false;
                                                                         },
                                                                         "drag_begin":function (self, drag_context) {
                                                                                print('SOURCE: drag-begin');
@@ -516,51 +553,60 @@ Window=new XObject({
                                                                                         return true;
                                                                         },
                                                                         "cursor_changed":function (self) {
-                                                                         var iter = new Gtk.TreeIter();
-                                                                                        
-                                                                                        if (this.selection.count_selected_rows() < 1) {
-                                                                                            this.get('/LeftPanel.model').load( false);
-                                                                                            this.get('/MidPropTree').activeElement =  false;
-                                                                                            this.get('/MidPropTree').hideWin();
+                                                                             if (this.blockChanges) { // probably not needed.. 
+                                                                               return true;
+                                                                             }
+                                                                             var render = this.get('/LeftTree').getRenderer();                
+                                                                           
+                                                                            
+                                                                            if (this.selection.count_selected_rows() < 1) {
+                                                                                this.get('/LeftPanel.model').load( false);
+                                                                                this.get('/MidPropTree').activeElement =  false;
+                                                                                this.get('/MidPropTree').hideWin();
                                                                         
-                                                                                            var pm = this.get('/RightPalete.model');
-                                                                                            if (!this.get('/LeftTree').getPaleteProvider()) {
-                                                                                                // it may not be loaded yet..
-                                                                                                return  true;
-                                                                                            }
-                                                                                            pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
-                                                                                                this.get('/LeftTree.model').listAllTypes()));
-                                                                                           
-                                                                                            return true;
-                                                                                        }
-                                                                                        
-                                                                                        //console.log('changed');
-                                                                                        var s = this.selection;
-                                                                                        s.get_selected(this.get('/LeftTree.model').el, iter);
-                                                                                        
-                                                                                        
-                                                                                        // var val = "";
-                                                                                        value = new GObject.Value('');
-                                                                                        this.get('/LeftTree.model').el.get_value(iter, 2, value);
-                                                                                        this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
-                                                                                        
-                                                                                        var data = JSON.parse(value.value);
-                                                                                        this.get('/MidPropTree').activeElement =  data;
-                                                                                        this.get('/MidPropTree').hideWin();
-                                                                                        this.get('/LeftPanel.model').load( data);
-                                                                                        
-                                                                                        console.log(value.value);
-                                                                                       // _g.button.set_label(''+value.get_string());
+                                                                                var pm = this.get('/RightPalete.model');
+                                                                                if (!this.get('/LeftTree').getPaleteProvider()) {
+                                                                                    // it may not be loaded yet..
+                                                                                    return  true;
+                                                                                }
+                                                                                pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
+                                                                                    this.get('/LeftTree.model').listAllTypes()));
+                                                                                if (render && render.redraw) {
+                                                                                    render.redraw();
+                                                                                }
+                                                                                return true;
+                                                                            }
+                                                                                    
+                                                                                    //console.log('changed');
+                                                                                var s = this.selection;
+                                                                                  var iter = new Gtk.TreeIter();
+                                                                                s.get_selected(this.get('/LeftTree.model').el, iter);
+                                                                                
+                                                                                
+                                                                                // var val = "";
+                                                                                var value = new GObject.Value('');
+                                                                                this.get('/LeftTree.model').el.get_value(iter, 2, value);
+                                                                                this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
+                                                                                
+                                                                                var data = JSON.parse(value.value);
+                                                                                this.get('/MidPropTree').activeElement =  data;
+                                                                                this.get('/MidPropTree').hideWin();
+                                                                                this.get('/LeftPanel.model').load( data);
+                                                                                
+                                                                                console.log(value.value);
+                                                                               // _g.button.set_label(''+value.get_string());
                                                                         
-                                                                                        var pm =this.get('/RightPalete.model');
-                                                                                        pm.load( this.get('/RightPalete').provider.gatherList(
-                                                                                             this.get('/LeftTree.model').listAllTypes()));
-                                                                                       
-                                                                                        
-                                                                                       
-                                                                                       
-                                                                                        //Seed.print( value.get_string());
-                                                                                        return true;
+                                                                                var pm =this.get('/RightPalete.model');
+                                                                                pm.load( this.get('/RightPalete').provider.gatherList(
+                                                                                     this.get('/LeftTree.model').listAllTypes()));
+                                                                               
+                                                                                
+                                                                                   if (render && render.redraw) {
+                                                                                    render.redraw();
+                                                                                }
+                                                                                   
+                                                                                    //Seed.print( value.get_string());
+                                                                                    return true;
                                                                                         
                                                                         }
                                                                     },
@@ -581,35 +627,35 @@ Window=new XObject({
                                                                             changed : function(n, refresh) {
                                                                                      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))
-                                                                                            this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
-                                                                                            this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
-                                                                                            
-                                                                                            this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
-                                                                                        }
-                                                                                            //this.currentTree = this.toJS(false, true)[0];
-                                                                                        this.file.items = this.toJS(false, false);
-                                                                                        print("AFTER CHANGED");
-                                                                                        //console.dump(this.file.items);
-                                                                                        this.file.save();
-                                                                                        this.currentTree = this.file.items[0];
-                                                                                        //console.log(this.file.toSource());
-                                                                                        
-                                                                                        if (refresh) {
-                                                                                            print("REDNER BROWSER?!");
-                                                                                            this.get('/LeftTree').renderView();
+                                                                                        var iter = new Gtk.TreeIter();
+                                                                                        this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
+                                                                                        this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
+                                                                                        this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
+                                                                                        
+                                                                                        this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
+                                                                                    }
+                                                                                        //this.currentTree = this.toJS(false, true)[0];
+                                                                                    this.file.items = this.toJS(false, false);
+                                                                                    print("AFTER CHANGED");
+                                                                                    //console.dump(this.file.items);
+                                                                                    this.file.save();
+                                                                                    this.currentTree = this.file.items[0];
+                                                                                    //console.log(this.file.toSource());
+                                                                                    
+                                                                                    if (refresh) {
+                                                                                        print("REDNER BROWSER?!");
+                                                                                        this.get('/LeftTree').renderView();
                                                                             
-                                                                                            var pm = this.get('/RightPalete.model');
-                                                                                            if (!this.get('/RightPalete').provider) {
-                                                                                                pm.load([]);
-                                                                                                return;
-                                                                                            }
-                                                                                            
-                                                                                            
-                                                                                            pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
-                                                                                            //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
+                                                                                        var pm = this.get('/RightPalete.model');
+                                                                                        if (!this.get('/RightPalete').provider) {
+                                                                                            pm.load([]);
+                                                                                            return;
                                                                                         }
+                                                                                        
+                                                                                        
+                                                                                        pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
+                                                                                        //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
+                                                                                    }
                                                                                          
                                                                             },
                                                                             loadFile : function(f) {
@@ -871,19 +917,20 @@ Window=new XObject({
                                                                                                             
                                                                                         }
                                                                                         
-                                                                                        this.activeIter = false;
+                                                                                        this.activePath= false;
                                                                                         this.changed(false,true);
                                                                             },
                                                                             deleteSelected : function() {
-                                                                                        
+                                                                                        this.get('/LeftTree.view').blockChanges = true;
                                                                                         var old_iter = new Gtk.TreeIter();
                                                                                         var s = this.get('/LeftTree.view').selection;
                                                                                         s.get_selected(this.el, old_iter);
                                                                                         var path = this.el.get_path(old_iter).to_string();
-                                                                                       this.activeIter = false;      
+                                                                            
+                                                                                        this.activePath= false;      
                                                                                         s.unselect_all();
                                                                             
-                                                                                        this.activeIter = false;      
+                                                                                        this.activePath= false;      
                                                                                    var iter = new Gtk.TreeIter();
                                                                                         this.el.get_iter_from_string(iter, path);
                                                                                         this.el.remove(iter);
@@ -892,8 +939,9 @@ Window=new XObject({
                                                                                         this.map = {};
                                                                                         this.treemap = { };
                                                                                         //this.toJS(null, true) // does not do anything?
-                                                                                  
+                                                                                    this.activePath= false;      
                                                                                         this.changed(false,true);
+                                                                                      this.get('/LeftTree.view').blockChanges = false;
                                                                             },
                                                                             currentTree : false,
                                                                             listAllTypes : function() {
@@ -1087,13 +1135,42 @@ Window=new XObject({
                                                                                             }
                                                                                             
                                                                                             this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
-                                                                                            this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
+                                                                                            this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
                                                                                             this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
                                                                                             if (tr[i].items && tr[i].items.length) {
                                                                                                 this.load(tr[i].items, citer);
                                                                                             }
                                                                                         }     
+                                                                                    },
+                                                                            nodeTip : function(c) {
+                                                                                var ret = this.nodeTitle(c);
+                                                                                var funcs = '';
+                                                                            
+                                                                                
+                                                                                for( var i in c) {
+                                                                            
+                                                                                    if (!i.length || i[0] != '|') {
+                                                                                        continue;
+                                                                                    }
+                                                                                    if (i == '|init') { 
+                                                                                        continue;
                                                                                     }
+                                                                                    if (typeof(c[i]) != 'string') {
+                                                                                       continue;
+                                                                                    }
+                                                                                    //print("prop : " + i + ':' + c[i]);
+                                                                                    if (!c[i].match(new RegExp('function'))) {
+                                                                                        continue;
+                                                                                    }
+                                                                                    funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
+                                                                                        
+                                                                                }
+                                                                                if (funcs.length) {
+                                                                                    ret+="\n\nMethods:" + funcs;
+                                                                                }
+                                                                                return ret;
+                                                                                
+                                                                            }
                                                                         },
                                                                         {
                                                                             xtype: Gtk.TreeViewColumn,
@@ -1164,6 +1241,9 @@ Window=new XObject({
                                                                                     return false;
                                                                                 }
                                                                                 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
+                                                                                if (typeof(data[ix]) == 'undefined') {
+                                                                               return false; 
+                                                                                }
                                                                                 return data[ix].fn;
                                                                             },
                                                                             setValue : function(fn)
@@ -1202,7 +1282,13 @@ Window=new XObject({
                                                                                             
                                                                                             
                                                                                         ] );
-                                                                                            
+                                                                                       var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+                                                                                       var _this = this;
+                                                                                       pm.on('changed', function() {
+                                                                                           print("caught changed hook on project manager - reloading data");
+                                                                                       _this.loadData(pm.projects);
+                                                                                    
+                                                                                       });
                                                                                     },
                                                                                     loadData : function(data) {
                                                                                          var ov = this.get('/LeftProjectTree.combo').getValue();
@@ -1303,16 +1389,18 @@ Window=new XObject({
                                                                                        
                                                                                     },
                                                                                     loadProject : function(pr) {
+                                                                                    print("LOAD PROJECT");
                                                                                                this.el.clear();
                                                                                                 if (!pr) {
                                                                                                     return;
                                                                                                 }
+                                                                                                
                                                                                                 this.get('/LeftProjectTree').project = pr;
                                                                                                 this.load(pr.toTree());
                                                                                                 this.get('/LeftProjectTree.view').el.expand_all();
                                                                                     },
                                                                                     load : function(tr,iter) {
-                                                                                        console.dump(tr);
+                                                                                      //  console.dump(tr);
                                                                                                 console.log('Project tree load: ' + tr.length);
                                                                                                 var citer = new Gtk.TreeIter();
                                                                                                 //this.insert(citer,iter,0);
@@ -1968,6 +2056,8 @@ Window=new XObject({
                                                                             case 'number':
                                                                             case 'uint':
                                                                             case 'int':
+                                                                            case 'float':
+                                                                            case 'gfloat':
                                                                                 return parseFloat(val); // Nan ?? invalid!!?
                                                                             case 'boolean':
                                                                                 return val == 'true' ? true : false;
@@ -1978,57 +2068,58 @@ Window=new XObject({
                                                                     },
                                                                     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)) {
-                                                                                        showEditor = true;
-                                                                                    }
-                                                                                }
-                                                                                
-                                                                                if (showEditor) {
-                                                                                    var _this = this;
-                                                                                    this.activePath = false;
-                                                                                    GLib.timeout_add(0, 1, function() {
-                                                                                        //   Gdk.threads_enter();
-                                                                                        _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('/RightEditor').el.hide();
+                                                                        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 type = this.getValue(this.el.get_path(iter).to_string(),4);
-                                                                                
-                                                                                
+                                                                        var showEditor = false;
+                                                                        
+                                                                        if (val[0] == '!') {
+                                                                            showEditor = true;
+                                                                        }
+                                                                        if (val[0] == '|') {
+                                                                            if (rval.match(/function/g) || rval.match(/\n/g)) {
+                                                                                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);
+                                                                            
+                                                                            
                                                                     }
                                                                 },
                                                                 {
@@ -2375,675 +2466,883 @@ Window=new XObject({
                                                 {
                                                     xtype: Gtk.Notebook,
                                                     pack : "pack_start,true,true",
-                                                    id : "view-notebook",
-                                                    tab_border : 0,
+                                                    id : "view-help-nb",
                                                     init : function() {
                                                         XObject.prototype.init.call(this);
-                                                        this.el.set_current_page(0);
-                                                        print("SET LABEL?")
-                                                        this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
-                                                        this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
+                                                       this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
+                                                        this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
                                                     },
-                                                    show_tabs : false,
                                                     items : [
                                                         {
-                                                            xtype: Gtk.VBox,
+                                                            xtype: Gtk.Notebook,
                                                             pack : "add",
-                                                            id : "RightBrowser",
+                                                            id : "view-notebook",
+                                                            tab_border : 0,
+                                                            init : function() {
+                                                                XObject.prototype.init.call(this);
+                                                                this.el.set_current_page(0);
+                                                                print("SET LABEL?")
+                                                                this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
+                                                                this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
+                                                            },
+                                                            show_tabs : false,
                                                             items : [
                                                                 {
-                                                                    xtype: Gtk.HBox,
-                                                                    pack : "pack_start,false,true,0",
-                                                                    items : [
-                                                                        {
-                                                                            xtype: Gtk.Button,
-                                                                            pack : "pack_start,false,false,0",
-                                                                            label : "Dump HTML to console",
-                                                                            listeners : {
-                                                                                "activate":function (self) {
-                                                                                       this.get('/RightBrowser.view').el.execute_script(
-                                                                                            "console.log(document.body.innerHTML);");
-                                                                                        this.get('/RightBrowser.view').el.execute_script(
-                                                                                           "console.log(Builder.dump(Builder));");   
-                                                                                }
-                                                                            }
-                                                                        }
-                                                                    ]
-                                                                },
-                                                                {
-                                                                    xtype: Gtk.ScrolledWindow,
+                                                                    xtype: Gtk.VBox,
                                                                     pack : "add",
-                                                                    shadow_type : Gtk.ShadowType.IN,
-                                                                    init : function() {
-                                                                        XObject.prototype.init.call(this);
-                                                                      this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+                                                                    id : "RightBrowser",
+                                                                    listeners : {
+                                                                        
                                                                     },
                                                                     items : [
                                                                         {
-                                                                            xtype: WebKit.WebView,
-                                                                            pack : "add",
-                                                                            id : "view",
-                                                                            init : function() {
-                                                                                XObject.prototype.init.call(this);
-                                                                                // this may not work!?
-                                                                                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);
-                                                                            },
-                                                                            renderJS : function(data) {
-                                                                                this.renderedData = data;
-                                                                                var str = JSON.stringify(data) ;
-                                                                                
-                                                                                if (!this.ready) {
-                                                                                    console.log('not loaded yet');
-                                                                                }
-                                                                                Seed.print("RENDER:" + str);
-                                                                                imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
-                                                                                this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
-                                                                            },
-                                                                            listeners : {
-                                                                                "load_finished":function (self, object) {
-                                                                                        if (this.ready) { // dont do it twice!
-                                                                                           return; 
-                                                                                       }
-                                                                                       this.ready = true;
-                                                                                
-                                                                                       this.renderJS(this.get('/LeftTree.model').toJS()[0]);
-                                                                                },
-                                                                                "script_alert":function (self, object, p0) {
-                                                                                       print(p0);
-                                                                                        return false;
-                                                                                        return true; // do not display anything...
-                                                                                },
-                                                                                "console_message":function (self, object, p0, p1) {
-                                                                                     console.log(object);
-                                                                                        if (!object.match(/^\{/)) {
-                                                                                            return false; // do not handle!!! -> later maybe in console..
-                                                                                        }
-                                                                                        console.log(object);
-                                                                                        var val =  JSON.parse(object);
-                                                                                
-                                                                                        if (typeof(val['hover-node']) != 'undefined') {
-                                                                                            this.activeNode = val['hover-node'];
-                                                                                            console.log('active node: ' + this.activeNode);
-                                                                                            return true;
-                                                                                        }
-                                                                                
-                                                                                         var ret = false;
-                                                                                         if (typeof(val['id']) != 'undefined') {
-                                                                                           // this.activeNode = val['id'];
-                                                                                            var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); 
-                                                                                            if (!tg) {
-                                                                                                return false;
-                                                                                            }
-                                                                                            this.get('/LeftTree.view').selectNode(tg[0]);
-                                                                                            ret  = true;
-                                                                                            
-                                                                                        } 
-                                                                                        if (ret && typeof(val['set']) != 'undefined') {
-                                                                                           this.get('/LeftPanel.model').add({
-                                                                                                key : val['set'],
-                                                                                                val : val['value']
-                                                                                            });
-                                                                                            //console.log('active node: ' + this.activeNode);
-                                                                                            
+                                                                            xtype: Gtk.HBox,
+                                                                            pack : "pack_start,false,true,0",
+                                                                            items : [
+                                                                                {
+                                                                                    xtype: Gtk.Button,
+                                                                                    pack : "pack_start,false,false,0",
+                                                                                    label : "Redraw",
+                                                                                    listeners : {
+                                                                                        "button_press_event":function (self, event) {
+                                                                                              var js = this.get('/LeftTree.model').toJS();
+                                                                                            if (js && js[0]) {
+                                                                                                this.get('/RightBrowser.view').renderJS(js[0]);
+                                                                                            } 
+                                                                                            return false;
                                                                                         }
-                                                                                        //Seed.print('a:'+a);
-                                                                                        //Seed.print('b:'+b);
-                                                                                        //Seed.print('c:'+c);
-                                                                                        return ret;
+                                                                                    }
                                                                                 },
-                                                                                "drag_motion":function (w, ctx,  x,   y,   time, ud) {
-                                                                                   // console.log('DRAG MOTION'); 
-                                                                                        // status:
-                                                                                        // if lastCurrentNode == this.currentNode.. -- don't change anything..
-                                                                                        this.targetData = [];
-                                                                                        this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
-                                                                                        
-                                                                                        // A) find out from drag all the places that node could be dropped.
-                                                                                        var src = Gtk.drag_get_source_widget(ctx);
-                                                                                        if (!src.dropList) {
-                                                                                            Gdk.drag_status(ctx, 0, time);
-                                                                                            return true;
-                                                                                        }
-                                                                                        // b) get what we are over.. (from activeNode)
-                                                                                        // tree is empty.. - list should be correct..
-                                                                                        if (!this.get('/LeftTree.model').currentTree) {
-                                                                                            Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
-                                                                                            return true;
-                                                                                            
+                                                                                {
+                                                                                    xtype: Gtk.Button,
+                                                                                    pack : "pack_start,false,false,0",
+                                                                                    label : "Set extra HTML in render",
+                                                                                    listeners : {
+                                                                                        "button_press_event":function (self, event) {
+                                                                                            this.get('/RooProjectProperties').show();
+                                                                                            return false;
                                                                                         }
-                                                                                        // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
+                                                                                    }
+                                                                                },
+                                                                                {
+                                                                                    xtype: Gtk.Button,
+                                                                                    pack : "pack_start,false,false,0",
+                                                                                    label : "test in Firefox",
+                                                                                    listeners : {
+                                                                                        "button_press_event":function (self, event) 
+                                                                                        {
+                                                                                                /* Firefox testing for debugging..
+                                                                                                  - we can create a /tmp directory, and put.
+                                                                                                    builder.html, builder.html.js, link roojs1 
+                                                                                                    add at the end of builder.html Roo.onload(function() {
+                                                                                                 */
+                                                                                                if (!this.get('/Window.LeftTree').getActiveFile()) {
+                                                                                                    return;
+                                                                                                }
+                                                                                                
+                                                                                                var js = this.get('/LeftTree.model').toJS();
+                                                                                                 if (!js ||  !js[0]) {
+                                                                                                    return;
+                                                                                                }
+                                                                                                var project = this.get('/Window.LeftTree').getActiveFile().project;
+                                                                                                //print (project.fn);
+                                                                                                
+                                                                                                project.runhtml  = project.runhtml || '';
                                                                                         
-                                                                                        var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
-                                                                                        console.dump(tg);
-                                                                                        if (!tg.length) {
-                                                                                            Gdk.drag_status(ctx, 0,time);
-                                                                                            this.get('/LeftTree.view').highlight(false);
-                                                                                            return true;
-                                                                                        }
-                                                                                         
-                                                                                        // if we have a target..
-                                                                                        // -> highlight it! (in browser)
-                                                                                        // -> highlight it! (in tree)
                                                                                         
-                                                                                        Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
-                                                                                        this.get('/LeftTree.view').highlight(tg);
-                                                                                        this.targetData = tg;
-                                                                                        // for tree we should handle this...
-                                                                                        return true;
-                                                                                },
-                                                                                "drag_drop":function (w, ctx, x, y,time, ud) {
-                                                                                       print("TARGET: drag-drop");
-                                                                                        var is_valid_drop_site = true;
+                                                                                               var File = imports.File.File;
+                                                                                               
+                                                                                               var target = "/tmp/firetest"; // fixme..
+                                                                                               if (!File.isDirectory(target)) {
+                                                                                                   File.mkdir(target);
+                                                                                                }
+                                                                                               File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);
+                                                                                               if (!File.exists( target+ '/roojs1')) {
+                                                                                                    File.link( target+ '/roojs1', __script_path__ + '/../roojs1');
+                                                                                               }
+                                                                                                
+                                                                                                
+                                                                                                
+                                                                                                var html = imports.File.File.read(__script_path__ + '/../builder.html');
+                                                                                                html = html.replace('</head>', project.runhtml + '</head>');
+                                                                                                
+                                                                                               
+                                                                                                var     jsstr = JSON.stringify(js[0]);
+                                                                                               
+                                                                                                var runbuilder = '<script type="text/javascript">' + "\n" + 
+                                                                                                    "Roo.onReady(function() { Builder.render(" + jsstr + "); });\n" +
+                                                                                                    '</script>';
+                                                                                                
+                                                                                                html = html.replace('</body>', runbuilder + '</body>');
                                                                                         
-                                                                                         
-                                                                                        Gtk.drag_get_data
-                                                                                        (
-                                                                                                w,         /* will receive 'drag-data-received' signal */
-                                                                                                ctx,        /* represents the current state of the DnD */
-                                                                                                this.get('/Window').atoms["STRING"],    /* the target type we want */
-                                                                                                time            /* time stamp */
-                                                                                        );
-                                                                                                        
-                                                                                                        
-                                                                                                        /* No target offered by source => error */
-                                                                                                       
-                                                                                
-                                                                                       return  is_valid_drop_site;
-                                                                                },
-                                                                                "drag_data_received":function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
-                                                                                    {
-                                                                                        print("Browser: drag-data-received");
-                                                                                        var delete_selection_data = false;
-                                                                                        vardnd_success = false;
-                                                                                        /* Deal with what we are given from source */
-                                                                                        if( sel_data && sel_data.length ) {
-                                                                                            
-                                                                                            if (ctx.action == Gdk.DragAction.ASK)  {
-                                                                                                /* Ask the user to move or copy, then set the ctx action. */
-                                                                                            }
-                                                                                
-                                                                                            if (ctx.action == Gdk.DragAction.MOVE) {
-                                                                                                delete_selection_data = true;
-                                                                                            }
-                                                                                            var source = Gtk.drag_get_source_widget(ctx);
-                                                                                
-                                                                                            print("Browser: source.DRAGDATA? " + source.dragData);
-                                                                                            if (this.targetData) {
-                                                                                                print(this.targetData);
-                                                                                                this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
-                                                                                            }
-                                                                                            
+                                                                                               File.write( target+ '/builder.html', html);
+                                                                                               
+                                                                                               
+                                                                                             return false;
+                                                                                        }
+                                                                                    }
+                                                                                }
+                                                                            ]
+                                                                        },
+                                                                        {
+                                                                            xtype: Gtk.ScrolledWindow,
+                                                                            pack : "add",
+                                                                            shadow_type : Gtk.ShadowType.IN,
+                                                                            init : function() {
+                                                                                XObject.prototype.init.call(this);
+                                                                              this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+                                                                            },
+                                                                            items : [
+                                                                                {
+                                                                                    xtype: WebKit.WebView,
+                                                                                    pack : "add",
+                                                                                    id : "view",
+                                                                                    init : function() {
+                                                                                        XObject.prototype.init.call(this);
+                                                                                        // this may not work!?
+                                                                                        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);
+                                                                                    },
+                                                                                    renderJS : function(data) {
+                                                                                        print("HTML RENDERING");
+                                                                                        /// prevent looping..
+                                                                                        //if (this.pendingRedraw) {
+                                                                                        //   print("pending redraw active?!");
+                                                                                         //   return;
+                                                                                        //}
+                                                                                        
+                                                                                        
+                                                                                        if (!this.get('/Window.LeftTree').getActiveFile()) {
+                                                                                            return;
+                                                                                        }
+                                                                                        
+                                                                                        var project = this.get('/Window.LeftTree').getActiveFile().project;
+                                                                                        //print (project.fn);
+                                                                                        
+                                                                                        project.runhtml  = project.runhtml || '';
+                                                                                        
+                                                                                    
+                                                                                        this.runhtml  = this.runhtml || '';
+                                                                                        
+                                                                                        if (project.runhtml != this.runhtml) {
+                                                                                            // then we need to reload the browser using
+                                                                                            // load_html_string..
                                                                                             
+                                                                                            // then trigger a redraw once it's loaded..
+                                                                                            this.pendingRedraw = true;
+                                                                                     
+                                                                                            this.runhtml = project.runhtml;
                                                                                             
-                                                                                            dnd_success = true;
-                                                                                
+                                                                                            var html = imports.File.File.read(__script_path__ + '/../builder.html');
+                                                                                            html = html.replace('</head>', this.runhtml + '</head>');
+                                                                                            print("LOAD HTML " + html);
+                                                                                            this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
+                                                                                            // should trigger load_finished!
+                                                                                            return;
+                                                                                        
                                                                                         }
-                                                                                
-                                                                                        if (dnd_success == false)
-                                                                                        {
-                                                                                                Seed.print ("DnD data transfer failed!\n");
+                                                                                        
+                                                                                        this.pendingRedraw = false;    
+                                                                                         
+                                                                                        
+                                                                                        this.renderedData = data;
+                                                                                        var str = JSON.stringify(data) ;
+                                                                                        
+                                                                                        if (!this.ready) {
+                                                                                            console.log('not loaded yet');
                                                                                         }
+                                                                                        //Seed.print("RENDER:" + str);
+                                                                                        //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
+                                                                                     
+                                                                                        this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
+                                                                                    },
+                                                                                    listeners : {
+                                                                                        "load_finished":function (self, object) {
+                                                                                               // if (this.ready) { // dont do it twice!
+                                                                                                //   return; 
+                                                                                               //}
+                                                                                               this.ready = true;
+                                                                                                this.pendingRedraw = false;
+                                                                                                var js = this.get('/LeftTree.model').toJS();
+                                                                                                if (js && js[0]) {
+                                                                                                       this.renderJS(js[0]);
+                                                                                               }
+                                                                                        
+                                                                                        },
+                                                                                        "script_alert":function (self, object, p0) {
+                                                                                               print(p0);
+                                                                                                return false;
+                                                                                                return true; // do not display anything...
+                                                                                        },
+                                                                                        "console_message":function (self, object, p0, p1) {
+                                                                                           //  console.log(object);
+                                                                                                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);
                                                                                         
-                                                                                        Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
-                                                                                        return true;
+                                                                                                if (typeof(val['hover-node']) != 'undefined') {
+                                                                                                    this.activeNode = val['hover-node'];
+                                                                                                    console.log('active node: ' + this.activeNode);
+                                                                                                    return true;
+                                                                                                }
+                                                                                        
+                                                                                                 var ret = false;
+                                                                                                 if (typeof(val['id']) != 'undefined') {
+                                                                                                   // this.activeNode = val['id'];
+                                                                                                    var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); 
+                                                                                                    if (!tg) {
+                                                                                                        return false;
+                                                                                                    }
+                                                                                                    this.get('/LeftTree.view').selectNode(tg[0]);
+                                                                                                    ret  = true;
+                                                                                                    
+                                                                                                } 
+                                                                                                if (ret && typeof(val['set']) != 'undefined') {
+                                                                                                   this.get('/LeftPanel.model').add({
+                                                                                                        key : val['set'],
+                                                                                                        val : val['value']
+                                                                                                    });
+                                                                                                    //console.log('active node: ' + this.activeNode);
+                                                                                                    
+                                                                                                }
+                                                                                                //Seed.print('a:'+a);
+                                                                                                //Seed.print('b:'+b);
+                                                                                                //Seed.print('c:'+c);
+                                                                                                return ret;
+                                                                                        },
+                                                                                        "drag_motion":function (w, ctx,  x,   y,   time, ud) {
+                                                                                           // console.log('DRAG MOTION'); 
+                                                                                                // status:
+                                                                                                // if lastCurrentNode == this.currentNode.. -- don't change anything..
+                                                                                                this.targetData = [];
+                                                                                                this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
+                                                                                                
+                                                                                                // A) find out from drag all the places that node could be dropped.
+                                                                                                var src = Gtk.drag_get_source_widget(ctx);
+                                                                                                if (!src.dropList) {
+                                                                                                    Gdk.drag_status(ctx, 0, time);
+                                                                                                    return true;
+                                                                                                }
+                                                                                                // b) get what we are over.. (from activeNode)
+                                                                                                // tree is empty.. - list should be correct..
+                                                                                                if (!this.get('/LeftTree.model').currentTree) {
+                                                                                                    Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
+                                                                                                    return true;
+                                                                                                    
+                                                                                                }
+                                                                                                // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
+                                                                                                
+                                                                                                var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
+                                                                                                console.dump(tg);
+                                                                                                if (!tg.length) {
+                                                                                                    Gdk.drag_status(ctx, 0,time);
+                                                                                                    this.get('/LeftTree.view').highlight(false);
+                                                                                                    return true;
+                                                                                                }
+                                                                                                 
+                                                                                                // if we have a target..
+                                                                                                // -> highlight it! (in browser)
+                                                                                                // -> highlight it! (in tree)
+                                                                                                
+                                                                                                Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
+                                                                                                this.get('/LeftTree.view').highlight(tg);
+                                                                                                this.targetData = tg;
+                                                                                                // for tree we should handle this...
+                                                                                                return true;
+                                                                                        },
+                                                                                        "drag_drop":function (w, ctx, x, y,time, ud) {
+                                                                                               print("TARGET: drag-drop");
+                                                                                                var is_valid_drop_site = true;
+                                                                                                
+                                                                                                 
+                                                                                                Gtk.drag_get_data
+                                                                                                (
+                                                                                                        w,         /* will receive 'drag-data-received' signal */
+                                                                                                        ctx,        /* represents the current state of the DnD */
+                                                                                                        this.get('/Window').atoms["STRING"],    /* the target type we want */
+                                                                                                        time            /* time stamp */
+                                                                                                );
+                                                                                                                
+                                                                                                                
+                                                                                                                /* No target offered by source => error */
+                                                                                                               
+                                                                                        
+                                                                                               return  is_valid_drop_site;
+                                                                                        },
+                                                                                        "drag_data_received":function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
+                                                                                            {
+                                                                                                print("Browser: drag-data-received");
+                                                                                                var delete_selection_data = false;
+                                                                                                vardnd_success = false;
+                                                                                                /* Deal with what we are given from source */
+                                                                                                if( sel_data && sel_data.length ) {
+                                                                                                    
+                                                                                                    if (ctx.action == Gdk.DragAction.ASK)  {
+                                                                                                        /* Ask the user to move or copy, then set the ctx action. */
+                                                                                                    }
+                                                                                        
+                                                                                                    if (ctx.action == Gdk.DragAction.MOVE) {
+                                                                                                        delete_selection_data = true;
+                                                                                                    }
+                                                                                                    var source = Gtk.drag_get_source_widget(ctx);
+                                                                                        
+                                                                                                    print("Browser: source.DRAGDATA? " + source.dragData);
+                                                                                                    if (this.targetData) {
+                                                                                                        print(this.targetData);
+                                                                                                        this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
+                                                                                                    }
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    dnd_success = true;
+                                                                                        
+                                                                                                }
+                                                                                        
+                                                                                                if (dnd_success == false)
+                                                                                                {
+                                                                                                        Seed.print ("DnD data transfer failed!\n");
+                                                                                                }
+                                                                                                
+                                                                                                Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
+                                                                                                return true;
+                                                                                            }
                                                                                     }
-                                                                            }
+                                                                                }
+                                                                            ]
                                                                         }
                                                                     ]
-                                                                }
-                                                            ]
-                                                        },
-                                                        {
-                                                            xtype: Gtk.VBox,
-                                                            pack : "add",
-                                                            id : "RightGtkView",
-                                                            renderJS : function(data, withDebug)
-                                                            {
-                                                                 if (!data) {
-                                                                             return; 
-                                                                }
-                                                                this.withDebug = false;
-                                                                
-                                                                if (this.renderedEl) {
-                                                                    this.get('view').el.remove(this.renderedEl);
-                                                                    this.renderedEl.destroy();
-                                                                    this.renderedEl = false;
-                                                                }
-                                                                
-                                                                var tree =  this.get('/LeftTree.model').toJS(false,true)[0];
-                                                                // in theory tree is actually window..  
-                                                               try {
-                                                                this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
-                                                              } catch (e) {
-                                                                 print(e.message);
-                                                                return;
-                                                              }
-                                                                this.get('view').el.set_size_request(
-                                                                    tree.default_width * 1 || 400, tree.default_height * 1 || 400
-                                                                ) ;
-                                                                
-                                                                this.renderedEl.set_size_request(
-                                                                    tree.default_width || 600,
-                                                                    tree.default_height || 400
-                                                                );
-                                                                this.get('view').el.show_all();
-                                                                
-                                                                
-                                                                
-                                                            },
-                                                            showInWindow : function() {
-                                                              print("GET PROEJCT");
-                                                               var pr = this.get('/LeftProjectTree').getActiveProject();
-                                                              
-                                                               console.log(pr.paths);
-                                                                return;
-                                                            /*
-                                                                 var src= this.buildJS(
-                                                                       this.get('/LeftTree.model').toJS()[0], 
-                                                                       true);
-                                                                  // show term?? 
-                                                            
-                                                            
-                                                                //var x = new imports.sandbox.Context();
-                                                                //x.add_globals();
-                                                                //print(src);
-                                                                try {
-                                                                    Seed.check_syntax('var e = ' + src);
-                                                                    //x.eval(src);
-                                                                } catch( e) {
-                                                                    this.get('/Terminal').feed(e.message || e.toString() + "\n");
-                                                                    this.get('/Terminal').feed(console._dump(e)+"\n");
-                                                                    if (e.line) {
-                                                                        var lines = src.split("\n");
-                                                                        var start = Math.max(0, e.line - 10);
-                                                                        var end = Math.min(lines.length, e.line + 10);
-                                                                        for (var i =start ; i < end; i++) {
-                                                                            if (i == e.line) {
-                                                                                this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
-                                                                                continue;
+                                                                },
+                                                                {
+                                                                    xtype: Gtk.VBox,
+                                                                    pack : "add",
+                                                                    id : "RightGtkView",
+                                                                    renderJS : function(data, withDebug)
+                                                                    {
+                                                                          this.highlightWidget = false;
+                                                                         if (!data) {
+                                                                                     return; 
+                                                                        }
+                                                                        this.withDebug = false;
+                                                                        
+                                                                        if (this.renderedEl) {
+                                                                            this.get('view').el.remove(this.renderedEl);
+                                                                            this.renderedEl.destroy();
+                                                                            this.renderedEl = false;
+                                                                        }
+                                                                        
+                                                                        var tree =  this.get('/LeftTree.model').toJS(false,true)[0];
+                                                                        // in theory tree is actually window..  
+                                                                       try {
+                                                                        this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
+                                                                      } catch (e) {
+                                                                         print(e.message);
+                                                                        return;
+                                                                      }
+                                                                        this.get('view').el.set_size_request(
+                                                                            tree.default_width * 1 || 400, tree.default_height * 1 || 400
+                                                                        ) ;
+                                                                        
+                                                                        this.renderedEl.set_size_request(
+                                                                            tree.default_width || 600,
+                                                                            tree.default_height || 400
+                                                                        );
+                                                                        this.get('view').el.show_all();
+                                                                        
+                                                                        
+                                                                        
+                                                                    },
+                                                                    showInWindow : function() {
+                                                                      print("GET PROEJCT");
+                                                                       var pr = this.get('/LeftProjectTree').getActiveProject();
+                                                                      
+                                                                       console.log(pr.paths);
+                                                                        return;
+                                                                    /*
+                                                                         var src= this.buildJS(
+                                                                               this.get('/LeftTree.model').toJS()[0], 
+                                                                               true);
+                                                                          // show term?? 
+                                                                    
+                                                                    
+                                                                        //var x = new imports.sandbox.Context();
+                                                                        //x.add_globals();
+                                                                        //print(src);
+                                                                        try {
+                                                                            Seed.check_syntax('var e = ' + src);
+                                                                            //x.eval(src);
+                                                                        } catch( e) {
+                                                                            this.get('/Terminal').feed(e.message || e.toString() + "\n");
+                                                                            this.get('/Terminal').feed(console._dump(e)+"\n");
+                                                                            if (e.line) {
+                                                                                var lines = src.split("\n");
+                                                                                var start = Math.max(0, e.line - 10);
+                                                                                var end = Math.min(lines.length, e.line + 10);
+                                                                                for (var i =start ; i < end; i++) {
+                                                                                    if (i == e.line) {
+                                                                                        this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
+                                                                                        continue;
+                                                                                    }
+                                                                                    this.get('/Terminal').feed(lines[i] + "\n");
+                                                                                }
+                                                                                
                                                                             }
-                                                                            this.get('/Terminal').feed(lines[i] + "\n");
+                                                                            
+                                                                            return;
                                                                         }
+                                                                         this.get('/BottomPane').el.set_current_page(1);
+                                                                        this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); 
+                                                                        var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
+                                                                        this.get('/Terminal').el.feed_child(cmd, cmd.length);
+                                                                         /*
+                                                                        var _top = x.get_global_object()._top;
                                                                         
-                                                                    }
+                                                                        _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
+                                                                        _top.el.show_all();
+                                                                        if (_top.el.popup) {
+                                                                            _top.el.popup(null, null, null, null, 3, null);
+                                                                        }
+                                                                    */
+                                                                    },
+                                                                    viewAdd : function(item, par)
+                                                                            {
+                                                                        // does something similar to xobject..
+                                                                        item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;
+                                                                        
+                                                                        if (item.pack===false || item.pack === 'false') {  // no ;
+                                                                            return;
+                                                                        }
+                                                                        print("CREATE: " + item['|xns'] + '.' + item['xtype']);
+                                                                        var ns = imports.gi[item['|xns']];
+                                                                        var ctr = ns[item['xtype']];
+                                                                        var ctr_args = { };
+                                                                        for(var k in item) {
+                                                                            var kv = item[k];
+                                                                            if (typeof(kv) == 'object' || typeof(kv) == 'function') {
+                                                                                continue;
+                                                                            }
+                                                                            if ( 
+                                                                                k == 'pack' ||
+                                                                                k == 'items' ||
+                                                                                k == 'id' ||
+                                                                                k == 'xtype' ||
+                                                                                k == 'xdebug' ||
+                                                                                k == 'xns' ||
+                                                                                k == '|xns'
+                                                                            ) {
+                                                                                continue;
+                                                                            }
                                                                     
-                                                                    return;
-                                                                }
-                                                                 this.get('/BottomPane').el.set_current_page(1);
-                                                                this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); 
-                                                                var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
-                                                                this.get('/Terminal').el.feed_child(cmd, cmd.length);
-                                                                 /*
-                                                                var _top = x.get_global_object()._top;
-                                                                
-                                                                _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
-                                                                _top.el.show_all();
-                                                                if (_top.el.popup) {
-                                                                    _top.el.popup(null, null, null, null, 3, null);
-                                                                }
-                                                            */
-                                                            },
-                                                            viewAdd : function(item, par)
-                                                                    {
-                                                                // does something similar to xobject..
-                                                                item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;
-                                                                
-                                                                if (item.pack===false || item.pack === 'false') {  // no ;
-                                                                    return;
-                                                                }
-                                                                print("CREATE: " + item['|xns'] + '.' + item['xtype']);
-                                                                var ns = imports.gi[item['|xns']];
-                                                                var ctr = ns[item['xtype']];
-                                                                var ctr_args = { };
-                                                                for(var k in item) {
-                                                                    var kv = item[k];
-                                                                    if (typeof(kv) == 'object' || typeof(kv) == 'function') {
-                                                                        continue;
-                                                                    }
-                                                                    if ( 
-                                                                        k == 'pack' ||
-                                                                        k == 'items' ||
-                                                                        k == 'id' ||
-                                                                        k == 'xtype' ||
-                                                                        k == 'xdebug' ||
-                                                                        k == 'xns' ||
-                                                                        k == '|xns'
-                                                                    ) {
-                                                                        continue;
-                                                                    }
-                                                            
-                                                               if (k[0] == '|' && typeof(kv) == 'string') {
-                                                            
-                                                                       if (kv.match(new RegExp('function'))) {
-                                                                               continue;
+                                                                       if (k[0] == '|' && typeof(kv) == 'string') {
+                                                                    
+                                                                               if (kv.match(new RegExp('function'))) {
+                                                                                       continue;
+                                                                                    }
+                                                                                print("WASL " + k + '=' + kv);
+                                                                               try {
+                                                                                       eval( 'kv = ' + kv);
+                                                                               } catch(e) {    continue; }
+                                                                                    
+                                                                               k = k.substring(1);
+                                                                                 // print(k + '=' + kv);
+                                                                       }
+                                                                            if (k[0] == '|') { // should be boolean or number..
+                                                                               k = k.substring(1);
+                                                                               //print(k + '=' + kv);
                                                                             }
-                                                                        print("WASL " + k + '=' + kv);
-                                                                       try {
-                                                                               eval( 'kv = ' + kv);
-                                                                       } catch(e) {    continue; }
+                                                                             
+                                                                       if (k == 'show_tabs') { // force tab showing for notebooks.
+                                                                               kv = true;
+                                                                            }
+                                                                            print(k + '=' + typeof(kv) + " : " + kv);
+                                                                            ctr_args[k] = kv;
                                                                             
-                                                                       k = k.substring(1);
-                                                                          print(k + '=' + kv);
-                                                               }
-                                                                    if (k[0] == '|') { // should be boolean or number..
-                                                                       k = k.substring(1);
-                                                                    }
-                                                               if (k == 'show_tabs') { // force tab showing for notebooks.
-                                                                       kv = true;
-                                                                    }
-                                                                    ctr_args[k] = kv;
+                                                                        } 
+                                                                        
+                                                                        
+                                                                        var el = new ctr(ctr_args);
+                                                                        
+                                                                        //print("PACK");
+                                                                        //console.dump(item.pack);
+                                                                        
+                                                                        
+                                                                        
+                                                                        
+                                                                        var args = [];
+                                                                        var pack_m  = false;
+                                                                        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(","));
+                                                                            
+                                                                            pack_m = args.shift();
+                                                                        } else {
+                                                                            pack_m = item.pack.shift();
+                                                                            args = item.pack;
+                                                                        }
+                                                                        
+                                                                        // handle error.
+                                                                        if (pack_m && typeof(par[pack_m]) == 'undefined') {
+                                                                            throw {
+                                                                                    name: "ArgumentError", 
+                                                                                    message : 'pack method not available : ' + par.id + " : " + par + '.' +  pack_m +
+                                                                                            "ADDING : " + item.id + " " +  el
+                                                                                        
+                                                                           };
                                                                     
-                                                                } 
-                                                                
-                                                                
-                                                                var el = new ctr(ctr_args);
-                                                                
-                                                                //print("PACK");
-                                                                //console.dump(item.pack);
-                                                                
-                                                                
-                                                                
-                                                                
-                                                                var args = [];
-                                                                var pack_m  = false;
-                                                                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(","));
+                                                                            return;
+                                                                        }
+                                                                        
+                                                                        console.dump(args);
+                                                                        args.unshift(el);
+                                                                        //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
+                                                                        //Seed.print('args: ' + args.length);
+                                                                        if (pack_m) {
+                                                                            par[pack_m].apply(par, args);
+                                                                        }
+                                                                        
+                                                                        var _this = this;
+                                                                        item.items = item.items || [];
+                                                                        item.items.forEach(function(ch) {
+                                                                            _this.viewAdd(ch, el);
+                                                                        });
+                                                                        
+                                                                        
+                                                                        
+                                                                        // add the signal handlers.
+                                                                        // is it a widget!?!!?
+                                                                       
+                                                                        
+                                                                        try {
+                                                                             
+                                                                            
+                                                                            el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item  ], true));
+                                                                            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 ));
+                                                                        } catch(e) {
+                                                                            // ignore!
+                                                                           }
+                                                                        
+                                                                        
+                                                                        
+                                                                        return el;
+                                                                        
+                                                                    },
+                                                                    widgetExposeEvent : function(w, evt, ud, item) {
+                                                                        var widget = w;
+                                                                         if (this.inRender) {
+                                                                             return false;
+                                                                         }
+                                                                         
+                                                                         if ( this.highlightWidget) {
+                                                                              this.inRender = true;
+                                                                              if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
+                                                                                     Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
+                                                                                }
+                                                                               this.inRender = false;
+                                                                               return false;
+                                                                         }
+                                                                         
+                                                                         
+                                                                         if (this.activePath != item.xtreepath) {
+                                                                            return false;
+                                                                         }
+                                                                         
+                                                                       //  print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
+                                                                         // work out the coords of the window..
+                                                                         if (!this.gc) {
+                                                                          var dr = widget.window;
+                                                                          this.gc = (new Gdk.GC.c_new(dr));
+                                                                          this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
+                                                                          this.gc.set_line_attributes(4,  Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
+                                                                        }
                                                                     
-                                                                    pack_m = args.shift();
-                                                                } else {
-                                                                    pack_m = item.pack.shift();
-                                                                    args = item.pack;
-                                                                }
-                                                                
-                                                                // handle error.
-                                                                if (pack_m && typeof(par[pack_m]) == 'undefined') {
-                                                                    throw {
-                                                                            name: "ArgumentError", 
-                                                                            message : 'pack method not available : ' + par.id + " : " + par + '.' +  pack_m +
-                                                                                    "ADDING : " + item.id + " " +  el
-                                                                                
-                                                                   };
-                                                            
-                                                                    return;
-                                                                }
-                                                                
-                                                                console.dump(args);
-                                                                args.unshift(el);
-                                                                //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
-                                                                //Seed.print('args: ' + args.length);
-                                                                if (pack_m) {
-                                                                    par[pack_m].apply(par, args);
-                                                                }
-                                                                
-                                                                var _this = this;
-                                                                item.items = item.items || [];
-                                                                item.items.forEach(function(ch) {
-                                                                    _this.viewAdd(ch, el);
-                                                                });
-                                                                
-                                                                
-                                                                
-                                                                // add the signal handlers.
-                                                                // is it a widget!?!!?
-                                                               
-                                                                
-                                                                try {
+                                                                        
+                                                                         var r  = evt.expose.area;
+                                                                         // console.dump([r.x, r.y, r.width, r.height ] );
+                                                                         //return false;
+                                                                    //     print(widget.get_parent().toString().match(/GtkScrolledWindow/);
+                                                                         if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
+                                                                             // happens with gtkscrollview embedded stuff..
+                                                                             var np =this.activePath.split(':');
+                                                                             np.pop();
+                                                                             this.activePath = np.join(':');
+                                                                             this.renderedEl.queue_draw();
+                                                                             return true;
+                                                                    
+                                                                            
+                                                                         }
+                                                                    
+                                                                           
+                                                                         
+                                                                         
+                                                                          this.box = {
+                                                                            x : r.x - 2,
+                                                                            y : r.y - 2,
+                                                                            w: r.width + 4,
+                                                                            h: r.height + 4
+                                                                          }; 
+                                                                          // let's draw it..
+                                                                          this.inRender = true;
+                                                                    
+                                                                          
+                                                                          this.highlightWidget = widget;
+                                                                        
+                                                                        
                                                                      
                                                                     
-                                                                    el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item  ], true));
-                                                                    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 ));
-                                                                } catch(e) {
-                                                                    // ignore!
-                                                                   }
-                                                                
-                                                                
-                                                                
-                                                                return el;
-                                                                
-                                                            },
-                                                            widgetExposeEvent : function() {
-                                                               ///   print("WIDGET EXPOSE"); // draw highlight??
-                                                                        return false;
-                                                            },
-                                                            widgetDragMotionEvent : function() {
-                                                                 print("WIDGET DRAGMOTION"); 
-                                                                        return true;
-                                                            },
-                                                            widgetDragDropEvent : function() {
-                                                                  print("WIDGET DRAGDROP"); 
-                                                                        return true;
-                                                            },
-                                                            widgetPressEvent : function(w,e,u,d) {
-                                                                 if (this.get('view').pressed) {
-                                                                    return false;
-                                                                 }
-                                                            this.get('view').pressed = true;
-                                                                  print("WIDGET PRESS " + d.xtreepath );       
-                                                                      this.get('/LeftTree.view').selectNode(   d.xtreepath );        
-                                                                        return false;
-                                                            },
-                                                            widgetReleaseEvent : function() {
-                                                                this.get('view').pressed = false;
-                                                               return false;
-                                                            },
-                                                            items : [
-                                                                {
-                                                                    xtype: Gtk.HBox,
-                                                                    pack : "pack_start,false,true,0",
+                                                                        //  print("DRAW BOX");
+                                                                           //console.dump(this.box);
+                                                                          Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
+                                                                                this.inRender = false;
+                                                                                return false;
+                                                                    },
+                                                                    widgetDragMotionEvent : function() {
+                                                                         print("WIDGET DRAGMOTION"); 
+                                                                                return true;
+                                                                    },
+                                                                    widgetDragDropEvent : function() {
+                                                                          print("WIDGET DRAGDROP"); 
+                                                                                return true;
+                                                                    },
+                                                                    widgetPressEvent : function(w,e,u,d) {
+                                                                         if (this.get('view').pressed) {
+                                                                            return false;
+                                                                         }
+                                                                    this.get('view').pressed = true;
+                                                                          print("WIDGET PRESS " + d.xtreepath );       
+                                                                              this.get('/LeftTree.view').selectNode(   d.xtreepath );        
+                                                                                return false;
+                                                                    },
+                                                                    widgetReleaseEvent : function() {
+                                                                        this.get('view').pressed = false;
+                                                                       return false;
+                                                                    },
+                                                                    redraw : function() {
+                                                                       this.highlightWidget = false;
+                                                                        print("REDRAW CALLED");
+                                                                        this.activePath = this.get('/LeftTree').getActivePath();
+                                                                        if (this.renderedEl) {
+                                                                          print("QUEUE DRAW CALLING");
+                                                                          this.renderedEl.queue_draw();
+                                                                       }
+                                                                    },
                                                                     items : [
                                                                         {
-                                                                            xtype: Gtk.Button,
-                                                                            pack : "pack_start,false,false,0",
-                                                                            label : "Run The Application",
-                                                                            listeners : {
-                                                                                "button_press_event":function (self, event) {
-                                                                                  // call render on left tree - with special option!?!
-                                                                                 
-                                                                                
-                                                                                
-                                                                                       print("GET PROEJCT");
-                                                                                       var pr = this.get('/LeftProjectTree').getActiveProject();
-                                                                                  
-                                                                                var dir = '';
-                                                                                 for (var i in pr.paths) { 
-                                                                                      dir = i;
-                                                                                      break;
-                                                                                  }
-                                                                                   var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; 
-                                                                                   print ("RUN DIR:" + dir);
-                                                                                   
-                                                                                   this.get('/BottomPane').el.set_current_page(1);
-                                                                                    this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) 
-                                                                                       , false,false,false); 
-                                                                                    var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
-                                                                                    this.get('/Terminal').el.feed_child(cmd, cmd.length);
-                                                                                    return false;
-                                                                                  
-                                                                                
+                                                                            xtype: Gtk.HBox,
+                                                                            pack : "pack_start,false,true,0",
+                                                                            items : [
+                                                                                {
+                                                                                    xtype: Gtk.Button,
+                                                                                    pack : "pack_start,false,false,0",
+                                                                                    label : "Run The Application",
+                                                                                    listeners : {
+                                                                                        "button_press_event":function (self, event) {
+                                                                                            // call render on left tree - with special option!?!
+                                                                                         
+                                                                                            //print("GET PROEJCT");
+                                                                                            var pr = this.get('/LeftProjectTree').getActiveProject();
+                                                                                          
+                                                                                            var dir = '';
+                                                                                            for (var i in pr.paths) { 
+                                                                                                dir = i;
+                                                                                                break;
+                                                                                            }
+                                                                                            var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; 
+                                                                                            this.get('/Terminal').feed("RUN DIR:" + dir);
+                                                                                            
+                                                                                            this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) 
+                                                                                               , false,false,false); 
+                                                                                            var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
+                                                                                            this.get('/Terminal').el.feed_child(cmd, cmd.length);
+                                                                                            return false;
+                                                                                          
+                                                                                        
+                                                                                        }
+                                                                                    }
                                                                                 }
-                                                                            }
-                                                                        }
-                                                                    ]
-                                                                },
-                                                                {
-                                                                    xtype: Gtk.ScrolledWindow,
-                                                                    pack : "add",
-                                                                    id : "view-sw",
-                                                                    shadow_type : Gtk.ShadowType.IN,
-                                                                    init : function() {
-                                                                        XObject.prototype.init.call(this);
-                                                                     this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
-                                                                    },
-                                                                    items : [
+                                                                            ]
+                                                                        },
                                                                         {
-                                                                            xtype: Gtk.EventBox,
+                                                                            xtype: Gtk.ScrolledWindow,
                                                                             pack : "add",
+                                                                            id : "view-sw",
+                                                                            shadow_type : Gtk.ShadowType.IN,
                                                                             init : function() {
                                                                                 XObject.prototype.init.call(this);
-                                                                            this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
-                                                                                        red: 0x9F00, green: 0xB800 , blue : 0xA800
-                                                                                       }));
+                                                                             this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
                                                                             },
                                                                             items : [
                                                                                 {
-                                                                                    xtype: Gtk.Fixed,
-                                                                                    pack : "add",
+                                                                                    xtype: Gtk.EventBox,
+                                                                                    pack : "add_with_viewport",
                                                                                     init : function() {
-                                                                                       XObject.prototype.init.call(this);
-                                                                                       //this.el.set_hadjustment(this.parent.el.get_hadjustment());
-                                                                                       //this.el.set_vadjustment(this.parent.el.get_vadjustment());
-                                                                                     
+                                                                                        XObject.prototype.init.call(this);
+                                                                                    this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
+                                                                                                red: 0x9F00, green: 0xB800 , blue : 0xA800
+                                                                                               }));
                                                                                     },
                                                                                     items : [
                                                                                         {
-                                                                                            xtype: Gtk.EventBox,
-                                                                                            pack : "put,10,10",
+                                                                                            xtype: Gtk.Fixed,
+                                                                                            pack : "add",
                                                                                             init : function() {
-                                                                                               //this.el =     new Gtk.Image.from_stock (Gtk.STOCK_HOME,  Gtk.IconSize.MENU);
                                                                                                XObject.prototype.init.call(this);
-                                                                                            
-                                                                                                        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);
-                                                                                            },
-                                                                                            ready : false,
-                                                                                            getActiveNode : function(x,y)
-                                                                                            {
-                                                                                               // workout what node is here..
-                                                                                                return '0'; // top..
+                                                                                               //this.el.set_hadjustment(this.parent.el.get_hadjustment());
+                                                                                               //this.el.set_vadjustment(this.parent.el.get_vadjustment());
+                                                                                             
                                                                                             },
-                                                                                            id : "view",
-                                                                                            listeners : {
-                                                                                                "drag_motion":function (self, ctx, x, y, time) {
+                                                                                            items : [
+                                                                                                {
+                                                                                                    xtype: Gtk.EventBox,
+                                                                                                    pack : "put,10,10",
+                                                                                                    init : function() {
+                                                                                                       //this.el =     new Gtk.Image.from_stock (Gtk.STOCK_HOME,  Gtk.IconSize.MENU);
+                                                                                                       XObject.prototype.init.call(this);
                                                                                                     
-                                                                                                                // A) find out from drag all the places that node could be dropped.
-                                                                                                                var src = Gtk.drag_get_source_widget(ctx);
-                                                                                                                if (!src.dropList) {
-                                                                                                                    Gdk.drag_status(ctx, 0, time);
-                                                                                                                    return true;
-                                                                                                                }
-                                                                                                                // b) get what we are over.. (from activeNode)
-                                                                                                                // tree is empty.. - list should be correct..
-                                                                                                                if (!this.get('/LeftTree.model').currentTree) {
-                                                                                                                    Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
-                                                                                                                    return true;
-                                                                                                                    
-                                                                                                                }
-                                                                                                                // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
-                                                                                                                var activeNode = this.getActiveNode(x, y);
+                                                                                                                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);
+                                                                                                    },
+                                                                                                    ready : false,
+                                                                                                    getActiveNode : function(x,y)
+                                                                                                    {
+                                                                                                       // workout what node is here..
+                                                                                                        return '0'; // top..
+                                                                                                    },
+                                                                                                    id : "view",
+                                                                                                    listeners : {
+                                                                                                        "drag_motion":function (self, ctx, x, y, time) {
+                                                                                                            
+                                                                                                                        // A) find out from drag all the places that node could be dropped.
+                                                                                                                        var src = Gtk.drag_get_source_widget(ctx);
+                                                                                                                        if (!src.dropList) {
+                                                                                                                            Gdk.drag_status(ctx, 0, time);
+                                                                                                                            return true;
+                                                                                                                        }
+                                                                                                                        // b) get what we are over.. (from activeNode)
+                                                                                                                        // tree is empty.. - list should be correct..
+                                                                                                                        if (!this.get('/LeftTree.model').currentTree) {
+                                                                                                                            Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
+                                                                                                                            return true;
+                                                                                                                            
+                                                                                                                        }
+                                                                                                                        // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
+                                                                                                                        var activeNode = this.getActiveNode(x, y);
+                                                                                                                        
+                                                                                                                        
+                                                                                                                        var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
+                                                                                                                        console.dump(tg);
+                                                                                                                        if (!tg.length) {
+                                                                                                                            Gdk.drag_status(ctx, 0,time);
+                                                                                                                            this.get('/LeftTree.view').highlight(false);
+                                                                                                                            return true;
+                                                                                                                        }
+                                                                                                                         
+                                                                                                                        // if we have a target..
+                                                                                                                        // -> highlight it! (in browser)
+                                                                                                                        // -> highlight it! (in tree)
+                                                                                                                        
+                                                                                                                        Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
+                                                                                                                        this.get('/LeftTree.view').highlight(tg);
+                                                                                                                        this.targetData = tg;
+                                                                                                                        // for tree we should handle this...
+                                                                                                                        return true;
+                                                                                                        },
+                                                                                                        "drag_drop":function (self,ctx, x, y, time) {
+                                                                                                               Seed.print("TARGET: drag-drop");
+                                                                                                                var is_valid_drop_site = true;
                                                                                                                 
-                                                                                                                var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
-                                                                                                                console.dump(tg);
-                                                                                                                if (!tg.length) {
-                                                                                                                    Gdk.drag_status(ctx, 0,time);
-                                                                                                                    this.get('/LeftTree.view').highlight(false);
-                                                                                                                    return true;
-                                                                                                                }
                                                                                                                  
-                                                                                                                // if we have a target..
-                                                                                                                // -> highlight it! (in browser)
-                                                                                                                // -> highlight it! (in tree)
+                                                                                                                Gtk.drag_get_data
+                                                                                                                (
+                                                                                                                        self,         /* will receive 'drag-data-received' signal */
+                                                                                                                        ctx,        /* represents the current state of the this.gDnD */
+                                                                                                                        this.get('/Window').atoms["STRING"],    /* the target type we want */
+                                                                                                                        time            /* time stamp */
+                                                                                                                );
                                                                                                                 
-                                                                                                                Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
-                                                                                                                this.get('/LeftTree.view').highlight(tg);
-                                                                                                                this.targetData = tg;
-                                                                                                                // for tree we should handle this...
-                                                                                                                return true;
-                                                                                                },
-                                                                                                "drag_drop":function (self,ctx, x, y, time) {
-                                                                                                       Seed.print("TARGET: drag-drop");
-                                                                                                        var is_valid_drop_site = true;
+                                                                                                                
+                                                                                                                /* No target offered by source => error */
+                                                                                                               
                                                                                                         
-                                                                                                         
-                                                                                                        Gtk.drag_get_data
-                                                                                                        (
-                                                                                                                self,         /* will receive 'drag-data-received' signal */
-                                                                                                                ctx,        /* represents the current state of the this.gDnD */
-                                                                                                                this.get('/Window').atoms["STRING"],    /* the target type we want */
-                                                                                                                time            /* time stamp */
-                                                                                                        );
+                                                                                                                return  is_valid_drop_site;
+                                                                                                          
+                                                                                                        },
+                                                                                                        "drag_data_received":function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
+                                                                                                            {
+                                                                                                                Seed.print("GtkView: drag-data-received");
+                                                                                                                var delete_selection_data = false;
+                                                                                                                var dnd_success = false;
+                                                                                                                /* Deal with what we are given from source */
+                                                                                                                if( sel_data && sel_data.length ) {
+                                                                                                                    
+                                                                                                                    if (ctx.action == Gdk.DragAction.ASK)  {
+                                                                                                                        /* Ask the user to move or copy, then set the ctx action. */
+                                                                                                                    }
                                                                                                         
+                                                                                                                    if (ctx.action == Gdk.DragAction.MOVE) {
+                                                                                                                        delete_selection_data = true;
+                                                                                                                    }
+                                                                                                                    var source = Gtk.drag_get_source_widget(ctx);
                                                                                                         
-                                                                                                        /* No target offered by source => error */
-                                                                                                       
-                                                                                                
-                                                                                                        return  is_valid_drop_site;
-                                                                                                  
-                                                                                                },
-                                                                                                "drag_data_received":function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
-                                                                                                    {
-                                                                                                        Seed.print("GtkView: drag-data-received");
-                                                                                                        var delete_selection_data = false;
-                                                                                                        var dnd_success = false;
-                                                                                                        /* Deal with what we are given from source */
-                                                                                                        if( sel_data && sel_data.length ) {
-                                                                                                            
-                                                                                                            if (ctx.action == Gdk.DragAction.ASK)  {
-                                                                                                                /* Ask the user to move or copy, then set the ctx action. */
-                                                                                                            }
-                                                                                                
-                                                                                                            if (ctx.action == Gdk.DragAction.MOVE) {
-                                                                                                                delete_selection_data = true;
-                                                                                                            }
-                                                                                                            var source = Gtk.drag_get_source_widget(ctx);
-                                                                                                
-                                                                                                            Seed.print("Browser: source.DRAGDATA? " + source.dragData);
-                                                                                                            if (this.targetData) {
-                                                                                                                Seed.print(this.targetData);
-                                                                                                                this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
-                                                                                                            }
-                                                                                                            
-                                                                                                            
-                                                                                                            
-                                                                                                            dnd_success = true;
-                                                                                                
-                                                                                                        }
-                                                                                                
-                                                                                                        if (dnd_success == false)
-                                                                                                        {
-                                                                                                                Seed.print ("DnD data transfer failed!\n");
-                                                                                                        }
+                                                                                                                    Seed.print("Browser: source.DRAGDATA? " + source.dragData);
+                                                                                                                    if (this.targetData) {
+                                                                                                                        Seed.print(this.targetData);
+                                                                                                                        this.get('/LeftTree.model').dropNode(this.targetData,  source.dragData);
+                                                                                                                    }
+                                                                                                                    
+                                                                                                                    
+                                                                                                                    
+                                                                                                                    dnd_success = true;
                                                                                                         
-                                                                                                        Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
-                                                                                                        return true;
-                                                                                                    },
-                                                                                                "button_press_event":function (self, event) {
-                                                                                                  this.pressed = false;
-                                                                                                    return false;
+                                                                                                                }
+                                                                                                        
+                                                                                                                if (dnd_success == false)
+                                                                                                                {
+                                                                                                                        Seed.print ("DnD data transfer failed!\n");
+                                                                                                                }
+                                                                                                                
+                                                                                                                Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
+                                                                                                                return true;
+                                                                                                            },
+                                                                                                        "button_press_event":function (self, event) {
+                                                                                                          this.pressed = false;
+                                                                                                            return false;
+                                                                                                        }
+                                                                                                    }
                                                                                                 }
-                                                                                            }
+                                                                                            ]
                                                                                         }
                                                                                     ]
                                                                                 }
@@ -3052,6 +3351,44 @@ Window=new XObject({
                                                                     ]
                                                                 }
                                                             ]
+                                                        },
+                                                        {
+                                                            xtype: Gtk.ScrolledWindow,
+                                                            pack : "add",
+                                                            id : "Help",
+                                                            show : function() {
+                                                                
+                                                                var file = this.get('/LeftTree').getActiveFile();
+                                                                if (!file) {
+                                                                    return;
+                                                                }
+                                                                var activeEl = this.get('/LeftTree').getActiveElement();
+                                                                var xtype = file.guessName( activeEl )
+                                                                if (!xtype || !xtype.length) {
+                                                                    return;
+                                                                }
+                                                                this.get('/Window.view-help-nb').el.set_current_page(1);
+                                                                
+                                                                // get the active element being edited.
+                                                                var helpurl = file.getHelpUrl(xtype);       
+                                                                
+                                                                // now load the help info in the page..
+                                                                this.get('help-view').el.open(helpurl);
+                                                            },
+                                                            items : [
+                                                                {
+                                                                    xtype: WebKit.WebView,
+                                                                    pack : "add",
+                                                                    id : "help-view",
+                                                                    init : function() {
+                                                                        XObject.prototype.init.call(this);
+                                                                       this.get('/Window.help-view').el.open(
+                                                                         "http://devel.akbkhome.com/seed/");
+                                                                    
+                                                                    },
+                                                                    zoom_level : 0.8
+                                                                }
+                                                            ]
                                                         }
                                                     ]
                                                 }
@@ -3084,6 +3421,11 @@ Window=new XObject({
                                                             
                                                             },
                                                             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();
@@ -3107,6 +3449,10 @@ Window=new XObject({
                                                                  
                                                                 this.el.grab_focus();
                                                             },
+                                                            insert_spaces_instead_of_tabs : true,
+                                                            indent_width : 4,
+                                                            auto_indent : true,
+                                                            show_line_numbers : true,
                                                             items : [
                                                                 {
                                                                     xtype: GtkSource.Buffer,
@@ -3149,9 +3495,20 @@ Window=new XObject({
                                                             xtype: Vte.Terminal,
                                                             pack : "add",
                                                             id : "Terminal",
-                                                            feed : function(str) {
-                                                                this.el.feed(str,str.length);
-                                                            }
+                                                            feed : function(istr) {
+                                                                var str = istr.replace(/\n/g, "\r\n") + "\r\n";
+                                                                // we should make ourselves visable!!!
+                                                                this.get('/BottomPane').el.show();
+                                                                this.get('/BottomPane').el.set_current_page(1);
+                                                            
+                                                                this.el.feed(str ,str.length);
+                                                            },
+                                                            scroll_on_output : true,
+                                                            init : function() {
+                                                                XObject.prototype.init.call(this);
+                                                                this.el.set_size (80, 1000);
+                                                            },
+                                                            scrollback_lines : 1000
                                                         }
                                                     ]
                                                 }