sync
authorAlan Knowles <alan@akbkhome.com>
Thu, 12 Aug 2010 04:40:35 +0000 (12:40 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 12 Aug 2010 04:40:35 +0000 (12:40 +0800)
21 files changed:
Options.js [new file with mode: 0644]
dbgenerate.js [new file with mode: 0644]
oldbuilder/AddPropertyPopup.js [new file with mode: 0644]
oldbuilder/DialogNewComponent.js [new file with mode: 0755]
oldbuilder/EditProject.js [new file with mode: 0755]
oldbuilder/LeftPanel.js [new file with mode: 0755]
oldbuilder/LeftPanelPopup.js [new file with mode: 0755]
oldbuilder/LeftProjectTree.js [new file with mode: 0755]
oldbuilder/LeftProps.js [new file with mode: 0755]
oldbuilder/LeftTopPanel.js [new file with mode: 0755]
oldbuilder/LeftTree.js [new file with mode: 0755]
oldbuilder/LeftTreeMenu.js [new file with mode: 0755]
oldbuilder/MidPropTree.js [new file with mode: 0755]
oldbuilder/RightBrowser.js [new file with mode: 0755]
oldbuilder/RightEditor.js [new file with mode: 0755]
oldbuilder/RightGtkView.js [new file with mode: 0755]
oldbuilder/RightPalete.js [new file with mode: 0755]
oldbuilder/StandardErrorDialog.js [new file with mode: 0755]
oldbuilder/TopMenu.js [new file with mode: 0755]
oldbuilder/Window.js [new file with mode: 0755]
tests/options.js [new file with mode: 0644]

diff --git a/Options.js b/Options.js
new file mode 100644 (file)
index 0000000..1c7d5d7
--- /dev/null
@@ -0,0 +1,193 @@
+//<script type="text/javascript">
+
+XObject = imports.XObject.XObject
+/**
+ * Options parsing is needed as GLib's built in GOptionGroup is not feasible to use in an introspected way at present.
+ * 
+ * usage :
+ * 
+ * o = new Options(
+ *    help_desription : 'Help about this',
+ *    options : [
+ *        { arg_short : 'a', arg_long: 'test', description : 'a test', flag_array: true , flag_boolean : false, arg_default: 'fred'}
+ *    ]
+ * );
+ * cfg = o.parse(Seed.argv);
+ * 
+ * Currently only supports simple parsing
+ * eg. --longarg test -b test
+ * 
+ * Does not support --aaaaa=bbbb
+ */
+Options  = XObject.define(
+    function (cfg) {
+        options = []; // default.
+        XObject.extend(this,cfg);
+        if (this.help_description.length) {
+            this.options.push({ arg_short : 'h', arg_long: 'help', description : 'Show Help', flag_boolean : true});
+            
+        }
+    },
+    Object,
+    {
+        /**
+         * @cfg {String} help_description what appears at the start of the help message.
+         */
+        help_description: '',
+        /**
+         * @cfg {Boolean} If extra arguments are allowed.
+         */
+        allow_extra : false,
+        /**
+         * @param {Object} Resulting key/value of data.
+         */
+        result : false,
+        /**
+         * @prop {Array} the arguments
+         */
+        args: false,
+        /**
+         * @prop {Array} extra the arguments that are not accounted for.
+         */
+        extra: false,
+        /**
+         * parse the argv
+         * usage: options.parse(Seed.argv)
+         */
+        parse: function (argv)
+        {
+            var _this = this;
+            this.result = {};
+            this.options.forEach(function(a) {
+                
+                if (typeof(a.arg_default) != 'undefined') {
+                    _this.result[a.arg_long] = a.arg_default;
+                    return;
+                }
+                
+                if (a.flag_boolean) {
+                    _this.result[a.arg_long] = false;
+                    return;
+                }
+                if (a.flag_array) {
+                    _this.result[a.arg_long] = [];
+                    return;
+                }
+                
+            })
+            
+            this.extra = {};
+            var args = Array.prototype.slice.call(Seed.argv);
+            args.shift(); //seed
+            args.shift(); //script..
+        
+            for(var i =0; i < args.length;i++) {
+                
+                var a= this.findArg(args[i]);
+                
+                if (!a) {
+                    if (!this.allow_extra) {
+                        throw {
+                            name: "ArgumentError", 
+                            message: "Unknown argument: " + args[i] 
+                        };
+                    }
+                    this.extra.push(args[i]);
+                }
+                
+                if (a.arg_long == 'help' ) {
+                    print("Help Message Requested");
+                    this.showHelp();
+                    Seed.quit();
+                    return;
+                }
+                
+                if (a.flag_boolean) {
+                    this.result[a.arg_long] = true;
+                    continue;
+                }
+                var next = args[i+1];
+                if (this.findArg(next)) {
+                    throw {
+                        name: "ArgumentError", 
+                        message: "Invalid argument sequence: " + args[i] + ' ' + next
+                    };
+                }
+                // type juggling -- fixme...
+                
+                if (a.flag_array) {
+                    this.result[a.arg_long].push(next);
+                    i++;
+                    continue;
+                }
+            
+                if (typeof(this.result[a.arg_long]) != 'undefined') {
+                    throw {
+                        name: "ArgumentError", 
+                        message: "Invalid argument duplicate: " + args[i] + ' ' + next
+                    };
+                }
+                
+                this.result[a.arg_long] = next;
+                i++;
+            }
+            // validate results..
+            this.options.forEach(function(a) {
+                if (typeof(a.arg_default) != 'undefined') {
+                    return;
+                }
+                if (a.flag_boolean) {
+                    return; 
+                }
+                if (typeof(_this.result[a.arg_long]) != 'undefined') {
+                    return;
+                }
+                _this.showHelp();
+                throw {
+                    name: "ArgumentError", 
+                    message: "Missing Argument: --" + a.arg_long
+                };
+            });
+            
+            
+            return this.result;
+        },
+            
+             
+        findArg : function(str)
+        {
+            var ret = false;
+            var type = str.substring(0,1) == '-' ? 'arg_short' : '';
+            type = str.substring(0,2) == '--' ? 'arg_long' : type;
+            if (type == '') {
+                return false; // not an arg..
+            }
+            var match = str.substring(type =='arg_long' ? 2 : 1);
+            
+            this.options.forEach(function(o) {
+                if (ret) {
+                    return; // no more parsing.
+                }
+                if (o[type] == match) {
+                    ret = o;
+                }
+                
+            });
+            return ret;
+            
+        },
+        
+        
+        showHelp: function()
+        {
+            print(this.help_description);
+            this.options.forEach(function(o) {
+                // fixme needs tidying up..
+                print('  --' + o.arg_long + '   (-' + o.arg_short + ')  ' + o.description);
+            });
+            
+                
+        }
+    }
+);
\ No newline at end of file
diff --git a/dbgenerate.js b/dbgenerate.js
new file mode 100644 (file)
index 0000000..e4fbe08
--- /dev/null
@@ -0,0 +1,708 @@
+//<script type="text/javascript">
+
+/**
+ * This is a hacky generator to generate element definitions for the Roo version from the database
+ * 
+ * Let's see if libgda can be used to generate our Readers for roo...
+ * 
+ * Concept - conect to database..
+ * 
+ * list tables
+ * 
+ * extra schemas..
+ * 
+ * write readers..
+ * 
+ * usage: seed generate.js  
+ * 
+ */
+Gda  = imports.gi.Gda;
+GObject = imports.gi.GObject;
+
+GLib = imports.gi.GLib;
+
+console = imports.console;
+File = imports.File.File;
+Options = imports.Options.Options;
+
+Gda.init();
+
+var prov = Gda.Config.list_providers ();
+//print(prov.dump_as_string());
+
+var o = new Options({
+    help_description : 'Element builder for App Builder based on database schema',
+    
+    options:  [
+        { arg_long : 'DBNAME' , arg_short : 'd', description : 'Database Name' },
+        { arg_long : 'USERNAME' , arg_short : 'u', description : 'Username'},
+        { arg_long : 'PASSWORD' , arg_short : 'p', description : '' , arg_default :'' },
+        { arg_long : 'INI' , arg_short : 'I', description : 'Either base directory which has Pman/***/DataObjects/***.ini or location of ini file.' },
+    ]
+           
+})
+
+
+
+var cfg = o.parse(Seed.argv);
+print(JSON.stringify(cfg, null,4));
+
+var   cnc = Gda.Connection.open_from_string ("MySQL", "DB_NAME=" + cfg.DBNAME, 
+                                              "USERNAME=" + cfg.USERNAME + ';PASSWORD=' + cfg.PASSWORD,
+                                              Gda.ConnectionOptions.NONE, null);
+
+
+
+                                              
+
+Gda.DataSelect.prototype.fetchAll = function()
+{
+    var cols = [];
+    
+    for (var i =0;i < this.get_n_columns(); i++) {
+        cols.push(this.get_column_name(i));
+    }
+    //print(JSON.stringify(cols, null,4));
+    var iter = this.create_iter();
+    var res = [];
+    //print(this.get_n_rows());
+    var _this = this;
+    for (var r = 0; r < this.get_n_rows(); r++) {
+        
+        // single clo..
+        //print("GOT ROW");
+        if (cols.length == 1) {
+            res.push(this.get_value_at(0,r).get_string());
+            continue;
+        }
+        var add = { };
+        
+        cols.forEach(function(n,i) {
+            var val = _this.get_value_at(i,r);
+            var type = GObject.type_name(val.g_type) ;
+            var vs = ['GdaBinary', 'GdaBlob' ].indexOf(type) > -1 ? val.value.to_string(1024) : val.value;
+            //print(n + " : TYPE: " + GObject.type_name(val.g_type) + " : " + vs);
+            //print (n + '=' + iter.get_value_at(i).value);
+            add[n] = vs;
+        });
+        
+        res.push(add);
+        
+    }
+    return res;
+
+}
+
+var map = {
+    'date' : 'date',
+    'datetime' : 'string',
+    'int' : 'int',
+    'bigint' : 'int',
+    'char' : 'int',
+    'tinyint' : 'int',
+    'decimal' : 'float',
+    'float' : 'float',
+    'varchar' : 'string',
+    'text' : 'string',
+    'longtext' : 'string',
+    'tinytext' : 'string',
+    'mediumtext' : 'string',
+    'enum' : 'string',
+    'timestamp' : 'number',
+    'blob' : 'text'
+    
+}
+
+var ini = { }
+
+function readIni(fn)
+{
+    var key_file = new GLib.KeyFile.c_new();
+    if (!key_file.load_from_file (fn , GLib.KeyFileFlags.NONE )) {
+        return;
+    }
+   
+    var groups = key_file.get_groups();
+    groups.forEach(function(g) {
+        ini[g] = {}
+           
+        var keys = key_file.get_keys(g);
+        keys.forEach(function(k) {
+            ini[g][k] = key_file.get_value(g,k);
+        })
+    })
+    
+}
+if (File.isFile(cfg.INI)) {
+    if (cfg.INI.match(/links\.ini$/)) {
+        readIni(cfg.INI);
+    } else {
+        readIni(cfg.INI.replace(/\.ini$/, ".links.ini"));
+    }
+}
+
+if (File.isDirectory(cfg.INI)) {
+        
+
+    //--- load ini files..
+    // this is very specific.
+    
+    var dirs = File.list( cfg.INI + '/Pman').filter( 
+        function(e) { 
+            if (!File.isDirectory(cfg.INI + '/Pman/' + e + '/DataObjects')) {
+                return false;
+            }
+            return true;
+        }
+    );
+    
+     
+    dirs.forEach(function(d) {
+        // this currently misses the web.*/Pman/XXXX/DataObjects..
+        var path = cfg.INI + '/Pman/' + d + '/DataObjects';
+         
+        if (!File.isDirectory(path)) {
+            return; //skip
+        }
+        var inis = File.list(path).filter(
+            function(e) { return e.match(/\.links\.ini$/); }
+        );
+        if (!inis.length) {
+            return;
+        }
+        
+        inis.forEach(function(i) {
+            readIni(path + '/' + i); 
+            
+        })
+    });
+    // look at web.XXXX/Pman/XXX/DataObjects/*.ini
+    var inis = File.list(cfg.INI).filter(
+        function(e) { return e.match(/\.links\.ini$/); }
+    )
+    
+     inis.forEach(function(i) {
+        readIni(path + '/' + i); 
+        
+    })
+    
+    
+}
+print(JSON.stringify(ini, null,4));
+ //console.dump(ini);
+
+
+ //Seed.quit();
+
+//GLib.key_file_load_from_file (key_file, String file, KeyFileFlags flags) : Boolean
+
+
+
+
+var tables = Gda.execute_select_command(cnc, "SHOW TABLES").fetchAll();
+var readers = [];
+tables.forEach(function(table) {
+    //print(table);
+    var schema = Gda.execute_select_command(cnc, "DESCRIBE `" + table+'`').fetchAll();
+    var reader = []; 
+    var colmodel = []; 
+    var combofields= [ { name : 'id', type: 'int' } ]; // technically the primary key..
+         
+    var form = {}
+       
+    var firstTxtCol = '';
+    
+    print(JSON.stringify(schema, null,4));
+    
+    schema.forEach(function(e)  {
+        var type = e.Type.match(/([^(]+)\(([^\)]+)\)/);
+        var row  = { }; 
+        if (type) {
+            e.Type = type[1];
+            e.Size = type[2];
+        }
+        
+        
+        
+        row.name = e.Field;
+        
+        
+        if (typeof(map[e.Type]) == 'undefined') {
+           console.dump(e);
+           throw {
+                name: "ArgumentError", 
+                message: "Unknown mapping for type : " + e.Type
+            };
+        }
+        row.type = map[e.Type];
+        
+        if (row.type == 'string' && !firstTxtCol.length) {
+            firstTxtCol = row.name;
+        }
+        
+        if (row.type == 'date') {
+            row.dateFormat = 'Y-m-d';
+        }
+        reader.push(row);
+        
+        if (combofields.length == 1 && row.type == 'string') {
+            combofields.push(row);
+        }
+        
+        
+        var title = row.name.replace(/_id/, '').replace(/_/g, ' ');
+        title  = title[0].toUpperCase() + title.substring(1);
+        
+        colmodel.push({
+            "xtype": "ColumnModel",
+            "header": title,
+            "width":  row.type == 'string' ? 200 : 75,
+            "dataIndex": row.name,
+            "|renderer": row.type != 'date' ? 
+                    "function(v) { return String.format('{0}', v); }" :
+                    "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
+            "|xns": "Roo.grid",
+            "*prop": "colModel[]"
+        });
+        var xtype = 'TextField';
+        if (row.type == 'number') {
+            xtype = 'NumberField';
+        }
+        if (row.type == 'date') {
+            xtype = 'DateField';
+        }
+        if (e.Type == 'text') {
+            xtype = 'TextArea';
+        }
+        if (e.name == 'id') {
+            xtype = 'Hidden';
+        }
+        // what about booleans.. -> checkboxes..
+        
+        
+        
+        form[row.name] = {
+            fieldLabel : title,
+            name : row.name,
+            width : row.type == 'string' ? 200 : 75,
+            '|xns' : 'Roo.form',
+            xtype : xtype
+        }
+        if (xtype == 'TextArea') {
+            form[row.name].height = 100;
+        }
+        
+        
+    });
+    
+    var combo = {
+        '|xns' : 'Roo.form',
+        xtype: 'ComboBox',
+        allowBlank : 'false',
+        editable : 'false',
+        emptyText : 'Select ' + table,
+        forceSelection : true,
+        listWidth : 400,
+        loadingText: 'Searching...',
+        minChars : 2,
+        pageSize : 20,
+        qtip: 'Select ' + table,
+        selectOnFocus: true,
+        triggerAction : 'all',
+        typeAhead: true,
+        
+        width: 300,
+        
+        
+        
+        tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>', // SET WHEN USED
+        queryParam : '',// SET WHEN USED
+        fieldLabel : table,  // SET WHEN USED
+        valueField : 'id',
+        displayField : '', // SET WHEN USED eg. project_id_name
+        hiddenName : '', // SET WHEN USED eg. project_id
+        name : '', // SET WHEN USED eg. project_id_name
+        items : [
+            {
+                    
+                '*prop' : 'store',
+                'xtype' : 'Store',
+                '|xns' : 'Roo.data',
+                'remoteSort' : true,
+                '|sortInfo' : '{ direction : \'ASC\', field: \'id\' }',
+                listeners : {
+                    '|beforeload' : 'function (_self, o)' +
+                    "{\n" +
+                    "    o.params = o.params || {};\n" +
+                    "    // set more here\n" +
+                    "}\n"
+                },
+                items : [
+                    {
+                        '*prop' : 'proxy',
+                        'xtype' : 'HttpProxy',
+                        'method' : 'GET',
+                        '|xns' : 'Roo.data',
+                        '|url' : "baseURL + '/Roo/" + table + ".php'",
+                    },
+                    
+                    {
+                        '*prop' : 'reader',
+                        'xtype' : 'JsonReader',
+                        '|xns' : 'Roo.data',
+                        'id' : 'id',
+                        'root' : 'data',
+                        'totalProperty' : 'total',
+                        '|fields' : JSON.stringify(combofields)
+                        
+                    }
+                ]
+            }
+        ]
+    }
+    
+    
+    
+    
+    //print(JSON.stringify(reader,null,4));
+    readers.push({
+        table : table ,
+        combo : combo,
+        combofields : combofields,
+        reader :  reader,
+        oreader : JSON.parse(JSON.stringify(reader)), // dupe it..
+        colmodel : colmodel,
+        firstTxtCol : firstTxtCol,
+        form : form
+    });
+    
+    //console.dump(schema );
+    
+     
+});
+
+
+
+// merge in the linked tables..
+readers.forEach(function(reader) {
+    if (typeof(ini[reader.table]) == 'undefined') {
+     
+        return;
+    }
+    print("OVERLAY - " + reader.table);
+    // we have a map..
+    for (var col in ini[reader.table]) {
+        var kv = ini[reader.table][col].split(':');
+        
+        
+        var add = readers.filter(function(r) { return r.table == kv[0] })[0];
+        if (!add) {
+            continue;
+        }
+        // merge in data (eg. project_id => project_id_*****
+     
+        add.oreader.forEach(function(or) {
+            reader.reader.push({
+                name : col + '_' + or.name,
+                type : or.type
+            });
+        });
+        
+        // col is mapped to something..
+        var combofields = add.combofields;
+        if (add.combofields.length < 2) {
+            continue;
+        }
+        if (typeof(reader.form[col]) == 'undefined') {
+            print("missing linked column " + col);
+            continue;
+        }
+        
+        var combofields_name = add.combofields[1].name;
+        var old =   reader.form[col];
+        reader.form[col] = JSON.parse(JSON.stringify(add.combo)); // clone
+        reader.form[col].queryParam  = 'query[' + combofields_name + ']';// SET WHEN USED
+        reader.form[col].fieldLabel = old.fieldLabel;  // SET WHEN USED
+        reader.form[col].hiddenName = old.name; // SET WHEN USED eg. project_id
+        reader.form[col].displayField = combofields_name; // SET WHEN USED eg. project_id
+        reader.form[col].name  = old.name + '_' + combofields_name; // SET WHEN USED eg. project_id_name
+        reader.form[col].tpl = '<div class="x-grid-cell-text x-btn button"><b>{' + combofields_name +'}</b> </div>'; // SET WHEN USED
+        
+             
+    };
+    
+    
+});
+
+//readers.forEach(function(reader) {
+//    delete reader.oreader;
+//});
+
+
+
+
+//print(JSON.stringify(readers, null, 4));
+
+readers.forEach(function(reader) {
+    
+
+    var dir = GLib.get_home_dir() + '/.Builder/Roo.data.JsonReader'; 
+    if (!File.isDirectory(dir)) {
+        File.mkdir(dir);
+    }
+    
+    // READERS
+    print("WRITE: " +  dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json');
+    
+                
+    var jreader = {
+        '|xns' : 'Roo.data',
+        xtype : "JsonReader",
+        totalProperty : "total",
+        root : "data",
+        '*prop' : "reader",
+        id : 'id', // maybe no..
+        '|fields' :  JSON.stringify(reader.reader, null,4).replace(/"/g,"'")
+    };
+    
+    File.write(
+        dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json',
+        JSON.stringify(jreader, null, 4)
+    )
+    
+    
+    // GRIDS
+    dir = GLib.get_home_dir() + '/.Builder/Roo.GridPanel'; 
+    if (!File.isDirectory(dir)) {
+        File.mkdir(dir);
+    }
+    
+
+    print("WRITE: " +  dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json');
+    
+    File.write(
+        dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json',
+            
+       
+        JSON.stringify({
+            '|xns' : 'Roo',
+            xtype : "GridPanel",
+            "title": reader.table,
+            "fitToframe": true,
+            "fitContainer": true,
+            "tableName": reader.table,
+            "background": true,
+            "listeners": {
+                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
+            },
+            "items": [
+                {
+                    "*prop": "grid",
+                    "xtype": "Grid",
+                    "autoExpandColumn": reader.firstTxtCol,
+                    "loadMask": true,
+                    "listeners": {
+                        "|render": "function() \n" +
+                            "{\n" +
+                            "   _this.grid = this; \n" +
+                            "    //_this.dialog = Pman.Dialog.FILL_IN\n" +
+                            "    if (_this.panel.active) {\n" +
+                            "       this.footer.onClick('first');\n" +
+                            "    }\n" +
+                            "}"
+                    },
+                    "|xns": "Roo.grid",
+
+                    "items": [
+                        {
+                            "*prop": "dataSource",
+                            "xtype": "Store",
+                            
+                            "|xns": "Roo.data",
+                            "items": [
+                                
+                                {
+                                    "*prop": "proxy",
+                                    "xtype": "HttpProxy",
+                                    "method": "GET",
+                                    "|url": "baseURL + '/Roo/" + reader.table + ".php'",
+                                    "|xns": "Roo.data"
+                                },
+                                jreader
+                            ]
+                        },
+                        {
+                            "*prop": "footer",
+                            "xtype": "PagingToolbar",
+                            "pageSize": 25,
+                            "displayInfo": true,
+                            "displayMsg": "Displaying " + reader.table + "{0} - {1} of {2}",
+                            "emptyMsg": "No " + reader.table + " found",
+                            "|xns": "Roo"
+                        },
+                        {
+                            "*prop": "toolbar",
+                            "xtype": "Toolbar",
+                            "|xns": "Roo",
+                            "items": [
+                                {
+                                    "text": "Add",
+                                    "xtype": "Button",
+                                    "cls": "x-btn-text-icon",
+                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
+                                    "listeners": {
+                                        "|click": "function()\n"+
+                                            "{\n"+
+                                            "   //yourdialog.show( { id : 0 } , function() {\n"+
+                                            "   //  _this.grid.footer.onClick('first');\n"+
+                                            "   //}); \n"+
+                                            "}\n"
+                                    },
+                                    "|xns": "Roo.Toolbar"
+                                },
+                                {
+                                    "text": "Edit",
+                                    "xtype": "Button",
+                                    "cls": "x-btn-text-icon",
+                                    "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
+                                    "listeners": {
+                                        "|click": "function()\n"+
+                                            "{\n"+
+                                            "    var s = _this.grid.getSelectionModel().getSelections();\n"+
+                                            "    if (!s.length || (s.length > 1))  {\n"+
+                                            "        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n"+
+                                            "        return;\n"+
+                                            "    }\n"+
+                                            "    \n"+
+                                            "    //_this.dialog.show(s[0].data, function() {\n"+
+                                            "    //    _this.grid.footer.onClick('first');\n"+
+                                            "    //   }); \n"+
+                                            "    \n"+
+                                            "}\n" 
+                                        
+                                    },
+                                    "|xns": "Roo.Toolbar"
+                                },
+                                {
+                                    "text": "Delete",
+                                    "cls": "x-btn-text-icon",
+                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
+                                    "xtype": "Button",
+                                    "listeners": {
+                                        "|click": "function()\n"+
+                                            "{\n"+
+                                            "   //Pman.genericDelete(_this, _this.grid.tableName); \n"+
+                                            "}\n"+
+                                            "        "
+                                    },
+                                    "|xns": "Roo.Toolbar"
+                                }
+                            ]
+                        }, // end toolbar
+                    ].concat( reader.colmodel)
+                }
+            ]
+            
+            
+        }, null, 4)
+    )
+    
+    /// FORMS..
+    
+    dir = GLib.get_home_dir() + '/.Builder/Roo.form.Form'; 
+    if (!File.isDirectory(dir)) {
+        File.mkdir(dir);
+    }
+    var formElements = [];
+    for (var k in reader.form) {
+        if (k == 'id') { // should really do primary key testing..
+            continue;
+        }
+        formElements.push(reader.form[k]);
+    }
+    formElements.push(reader.form['id']);
+
+    print("WRITE: " +  dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json');
+    
+    File.write(
+        dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json',
+            
+       
+        JSON.stringify({
+            '|xns' : 'Roo.form',
+            xtype : "Form",
+            listeners : {
+                "|actioncomplete" : "function(_self,action)\n"+
+                    "{\n"+
+                    "    if (action.type == 'setdata') {\n"+
+                    "       //_this.dialog.el.mask(\"Loading\");\n"+
+                    "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
+                    "       return;\n"+
+                    "    }\n"+
+                    "    if (action.type == 'load') {\n"+
+                    "        _this.dialog.el.unmask();\n"+
+                    "        return;\n"+
+                    "    }\n"+
+                    "    if (action.type =='submit') {\n"+
+                    "    \n"+
+                    "        _this.dialog.el.unmask();\n"+
+                    "        _this.dialog.hide();\n"+
+                    "    \n"+
+                    "         if (_this.callback) {\n"+
+                    "            _this.callback.call(_this, _this.form.getValues());\n"+
+                    "         }\n"+
+                    "         _this.form.reset();\n"+
+                    "         return;\n"+
+                    "    }\n"+
+                    "}\n",
+                
+                "|rendered" : "function (form)\n"+
+                    "{\n"+
+                    "    _this.form= form;\n"+
+                    "}\n"
+            },
+            method : "POST",
+            style : "margin:10px;",
+            "|url" : "baseURL + '/Roo/" + reader.table + ".php'",
+            items : formElements
+        }, null, 4)
+    );
+            
+            
+   
+   
+   
+     /// COMBO..
+    
+    dir = GLib.get_home_dir() + '/.Builder/Roo.form.ComboBox'; 
+    if (!File.isDirectory(dir)) {
+        File.mkdir(dir);
+    }
+   
+    print("WRITE: " +  dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json');
+    
+    File.write(
+        dir + '/' + cfg.DB_NAME + '_' + reader.table + '.json',
+            
+       
+        JSON.stringify(reader.combo, null, 4)
+    );
+            
+   
+   
+   
+   
+   
+   
+   
+   
+   
+});              
+
+
+
+
diff --git a/oldbuilder/AddPropertyPopup.js b/oldbuilder/AddPropertyPopup.js
new file mode 100644 (file)
index 0000000..871406f
--- /dev/null
@@ -0,0 +1,148 @@
+//<Script type="text/javascript">
+Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+
+AddPropertyPopup = new XObject({
+    
+        
+    xtype : Gtk.Menu,
+    
+     
+    items :  [
+        {
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Add "id"',
+            tooltip_markup : "Using this.get('*someid') will find any id in an application.",
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : 'id', 
+                        type : 'string',
+                        val : '',
+                        //skel  : skel,
+                        etype : 'props'
+                    }) //, skel);
+                }
+            }
+        },
+        {
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Gtk - Add "pack"',
+            tooltip_markup : "Set what type of packing is to be used.",
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : 'pack', 
+                        type : 'string',
+                        val : 'add',
+                        //skel  : skel,
+                        etype : 'props'
+                    }) //, skel);
+                }
+            }
+        },
+        {
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Gtk - Add "init"',
+            tooltip_markup : "Set what type of packing is to be used.",
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : '|init', 
+                        type : 'function',
+                        val  : "function() {\n    XObject.prototype.init.call(this);\n}\n",
+                        etype : 'props'
+                    }) //, skel);
+                }
+            }
+        },
+    
+       
+        {
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Add String Property (User defined)',
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : '', 
+                        type : 'string',
+                        val  : "",
+                        etype : 'props'
+                    });
+                   
+                }
+            }
+            
+        },
+        {
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Add Number Property (User defined)',
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : '', 
+                        type : 'number',
+                        val  : 0,
+                        etype : 'props'
+                    });
+                   
+                }
+            }
+            
+        },
+        {
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Add Boolean Property (User defined)',
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : '', 
+                        type : 'boolean',
+                        val  : false,
+                        etype : 'props'
+                    });
+                   
+                }
+            }
+            
+        },
+        {
+            
+            
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Add Function (User defined)',
+            listeners : {
+                activate : function () {
+                    var LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+                    LeftPanel.get('model').add( {
+                        key : '|', 
+                        type : 'function',
+                        val  : "function() {\n    \n}\n",
+                        etype : 'props'
+                    }) //, skel);
+                }
+            }
+            
+        },
+    ]
+});
diff --git a/oldbuilder/DialogNewComponent.js b/oldbuilder/DialogNewComponent.js
new file mode 100755 (executable)
index 0000000..c9cd979
--- /dev/null
@@ -0,0 +1,422 @@
+//<Script type="text/javascript">
+
+Gtk = imports.gi.Gtk;
+GObject = imports.gi.GObject;
+Gio = imports.gi.Gio;
+GLib = imports.gi.GLib;
+
+console = imports.console;
+XObject = imports.XObject.XObject;
+
+
+StandardErrorDialog = imports.Builder.StandardErrorDialog.StandardErrorDialog;
+/**
+ * add a component
+ * 
+ * basically uses a standard template ? pulled from the web?
+ * 
+ * you have to pick which template, and give it a name..
+ * 
+ * and pick which directory to put it in?
+ * 
+ */
+
+DialogNewComponent = new XObject({
+        
+        xtype : Gtk.Dialog,
+      //  type: Gtk.WindowType.TOPLEVEL,
+        deletable : false,
+        modal : true,
+        title  : "New Component",
+        border_width : 0,
+        project : false,
+        init : function()
+        {
+            XObject.debug = true;
+            XObject.prototype.init.call(this); 
+            this.el.add_button("OK",1 );
+            this.el.add_button("Cancel",0 );
+            
+            this.el.set_default_size (600, 400);
+            console.log('shown all');
+            //show_all : []
+        },
+       
+        show : function (c) 
+        {
+            if (!this.el) {
+                this.init();
+            }
+            c = c || { name : '' , xtype : '' };
+            // check whic project we are adding to..
+            XObject.extend(this, c);
+            // causes problems.. get_screen?? not transfer ownership?
+           /// var Window                = imports.Builder.Window.Window;
+            //this.el.set_screen(Window.el.get_screen());
+            
+            var paths = [];
+            for (var i in this.project.paths) {
+                paths.push({
+                    id : i,
+                    desc : i
+                });
+            }
+             console.log('load paths');
+             
+            // load the paths.
+            this.get('directory_model').loadData(paths);
+                
+            
+            console.log('show all');
+            this.el.show_all();
+            this.success = c.success;
+            /*
+            var tm = this.get('template_model');
+            if (tm.templates) {
+                return;
+            }
+            tm.templates = [];
+            var dir = __script_path__ + '/templates/';
+            
+            var f = Gio.file_new_for_path(dir);
+            f.enumerate_children_async ("*",  Gio.FileQueryInfoFlags.NONE, 
+                    GLib.PRIORITY_DEFAULT, null, function(o,ar) {
+                // enum completed..
+                var fe = f.enumerate_children_finish(ar);
+                var ch = '';
+                while (ch = fe.next_file(null)) {
+                    var add = dir + '/' + ch.get_name();
+                    if (!add.match(/\.js$/)) {
+                        continue;
+                    }
+                    tm.templates.push(add);
+                    
+                }
+                tm.loadData();
+                
+            }, null);
+            */
+            
+        },
+        
+        listeners : 
+        {
+            'delete-event' : function (widget, event) {
+                this.el.hide();
+                return true;
+            },
+            
+            response : function (w, id) 
+            {
+                if (id < 1) { // cancel!
+                    this.el.hide();
+                    return;
+                }
+                
+                
+                    
+                   
+            
+                if (!DialogNewComponent.get('xnsid').el.get_text().length || 
+               //    DialogNewComponent.get('template').getValue().length ||
+                   !DialogNewComponent.get('directory').getValue().length 
+                ) {
+                    StandardErrorDialog.show(
+                        "You have to set Project name ,template and directory"
+                    );
+                     
+                    return;
+                }
+                
+                var dir = DialogNewComponent.get('directory').getValue();
+                var xidns = DialogNewComponent.get('xnsid').el.get_text();
+                
+                
+                 if (GLib.file_test (GLib.dir + '/' + xidns + '.bjs', GLib.FileTest.EXISTS)) {
+                    StandardErrorDialog.show(
+                        "That file already exists"
+                    ); 
+                    return;
+                }
+                this.el.hide();
+                
+                
+                //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
+                
+                var _this = this;
+                var nf = _this.project.create(dir + '/' + xidns + '.bjs');
+                if (DialogNewComponent.success) {
+                    DialogNewComponent.success(_this.project, nf);
+                }
+                
+                //tmpl.copyTo(dir + '/' + xidns + '.bjs', function() {
+                //    tmpl.setNSID(xidns);
+                ///    _this.project.addFile(tmpl);
+                //    this.success(_this.project, tmpl);
+                //});
+                
+                
+                
+                
+            }
+            
+            
+            
+        },
+        
+       
+     
+        items : [
+            {
+                
+                xtype : Gtk.VBox,
+                
+                pack: function(p,e) {
+                    p.el.get_content_area().add(e.el)
+                },
+                items : [
+                    {
+                        xtype : Gtk.HBox,
+                        pack : [ 'pack_start', false, true , 0 ],
+                        
+                        items : [
+                            {
+                                xtype : Gtk.Label,
+                                label : "Component Name:",
+                                pack : [ 'pack_start', false, true , 0 ]
+                                
+                            },
+                            
+                            {
+                                id : 'xnsid',
+                                xtype : Gtk.Entry,
+                                pack : [ 'pack_end', true, true , 0 ],
+                                setValue : function(v) 
+                                {
+                                    this.el.set_text(v);
+                                },
+                                getValue : function()
+                                {
+                                    return this.el.get_text();
+                                }
+                            }
+                         
+                        ]
+                        
+                    },
+                    {
+                        xtype : Gtk.HBox,
+                        pack : [ 'pack_start', false, true , 0 ],
+                        
+                        items : [
+                            {
+                                xtype : Gtk.Label,
+                                label : "Using Template:",
+                                pack : [ 'pack_start', false, true , 0 ],
+                                
+                            },
+                            
+                            
+                            {
+                                id : 'template',
+                                xtype : Gtk.ComboBox,
+                                pack : [ 'pack_end', true, true , 0 ],
+                                init : function()
+                                {
+                                    XObject.prototype.init.call(this); 
+                                    this.el.add_attribute(this.items[0].el , 'markup', 1 );  
+                                       
+                                },
+                            
+                                setValue : function(v)
+                                {
+                                    var el = this.el;
+                                    el.set_active(-1);
+                                    DialogNewComponent.get('template_model').templates.forEach(
+                                        function(n, ix) {
+                                            if (v == n ) {
+                                                el.set_active(ix);
+                                                return false;
+                                            }
+                                        }
+                                    );
+                                },
+                                getValue : function() 
+                                {
+                                    var ix = this.el.get_active();
+                                    if (ix < 0 ) {
+                                        return '';
+                                    }
+                                    return DialogNewComponent.get('template_model').templates[ix];
+                                  
+                                },
+                                
+                                 
+                                items : [
+                                    {
+                                        
+                                        xtype : Gtk.CellRendererText,
+                                        pack : ['pack_start'],
+                                        
+                                    },
+                                    {
+                                        id : 'template_model',
+                                        pack : [ 'set_model' ],
+                                        xtype : Gtk.ListStore,
+                                        
+                                        init :   function ()
+                                        {
+                                            XObject.prototype.init.call(this); 
+                                            this.el.set_column_types ( 2, [
+                                                    GObject.TYPE_STRING,  // real key
+                                                    GObject.TYPE_STRING // real type
+                                            ] );
+                                             
+                                            
+                                        
+                                        },
+                                       
+                                        templates : false,
+                                        
+                                        loadData : function () {
+                                            this.el.clear();
+                                            var iter = new Gtk.TreeIter();
+                                            var el = this.el;
+                                            this.templates.forEach(function(p) {
+                                                
+                                                el.append(iter);
+                                                
+                                                el.set_value(iter, 0, p);
+                                                el.set_value(iter, 1, p);
+                                                
+                                            });
+                                             
+                                            
+                                            
+                                        }
+                                         
+                                    }
+                                  
+                                         
+                                ]
+                            }
+                 
+                                
+                        ]
+                    },
+                    {
+                        xtype : Gtk.HBox,
+                        
+                        pack : [ 'pack_start', false, true , 0 ],
+                        
+                        items : [
+                            {
+                                xtype : Gtk.Label,
+                                pack : [ 'pack_start', false, true , 0 ],
+                                label : "In Directory:"
+                            },
+                            
+                            {
+                                id : 'directory',
+                                
+                                xtype : Gtk.ComboBox,
+                                pack : [ 'pack_end', true, true , 0 ],
+                            
+                                 init : function()
+                                {
+                                    XObject.prototype.init.call(this); 
+                                   this.el.add_attribute(this.items[0].el , 'markup', 1 );  
+                                       
+                                },
+                            
+                                setValue : function(v)
+                                {
+                                    var el = this.el;
+                                    el.set_active(-1);
+                                    this.get('directory_model').data.forEach(
+                                        function(n,ix) {
+                                            if (v == n.xtype) {
+                                                el.set_active(ix);
+                                                return false;
+                                            }
+                                        }
+                                    );
+                                },
+                                getValue : function() 
+                                {
+                                    var ix = this.el.get_active();
+                                    if (ix < 0 ) {
+                                        return '';
+                                    }
+                                    var data = this.get('directory_model').data;
+                                    
+                                    return  data[ix].desc;
+                                    
+                                },
+                                
+                                 
+                                items : [
+                                    {
+                                        xtype : Gtk.CellRendererText,
+                                        pack : ['pack_start'],
+                                    },
+                                    {
+                                        
+                                        xtype : Gtk.ListStore,
+                                        pack : [ 'set_model' ],
+                                        id: 'directory_model',
+                                        init : function()
+                                        {
+                                            XObject.prototype.init.call(this); 
+                                            this.el.set_column_types ( 2, [
+                                                GObject.TYPE_STRING,  // real key
+                                                GObject.TYPE_STRING // real type
+                                            ]); 
+                                        },
+                                     
+                                       
+                                       
+                                        
+                                        loadData : function (data) {
+                                            this.el.clear();
+                                            this.data   = data;
+                                            var iter = new Gtk.TreeIter();
+                                            var el = this.el;
+                                            data.forEach( function(p) {
+                                                
+                                                el.append(iter);
+                                                
+                                                 
+                                                el.set_value(iter, 0, p.id);
+                                                el.set_value(iter, 1, p.desc);
+                                                
+                                            });
+                                             
+                                        }
+                                         
+                                    }
+                                  
+                                         
+                                ]
+                            }
+                 
+                                
+                        ]
+                    },
+                    {
+                        xtype : Gtk.Label,
+                        pack : [ 'pack_end', true, true , 0 ],
+                        label : ""
+                    }
+                    
+                    
+                ]
+            }
+        ]
+    }
+);
+    
+
+
+//XN.xnew(create());
+//_win = XN.xnew(create());
\ No newline at end of file
diff --git a/oldbuilder/EditProject.js b/oldbuilder/EditProject.js
new file mode 100755 (executable)
index 0000000..5c8c58e
--- /dev/null
@@ -0,0 +1,263 @@
+//<Script type="text/javascript">
+
+Gtk = imports.gi.Gtk;
+GObject = imports.gi.GObject;
+console = imports.console;
+XObject = imports.XObject.XObject;
+
+StandardErrorDialog = imports.Builder.StandardErrorDialog.StandardErrorDialog;
+ProjectManager =      imports.Builder.Provider.ProjectManager.ProjectManager;
+/**
+ * add/edit project
+ * 
+ * project type: gtk or roo..
+ * 
+ * directory.
+ * 
+ * 
+ * 
+ */
+
+EditProject = new XObject({
+    
+        
+        xtype : function () {
+            return new Gtk.Dialog({type: Gtk.WindowType.TOPLEVEL});
+        },
+        deletable : false,
+        modal : true,
+        border_width : 0,
+        title : "Project Properties",
+        project : {},
+        init : function()
+        {
+            XObject.prototype.init.call(this); 
+            this.el.add_button("OK",1 );
+            this.el.add_button("Cancel",0 );
+             
+            this.el.set_default_size(600, 400);
+        },
+        show : function (c) 
+        {
+            
+            c = c || { name : '' , xtype : '' };
+            this.project  = c;
+            if (!this.el) {
+                this.init();
+            }
+            var _this = this;
+            [ 'xtype' , 'name' ].forEach(function(k) {
+                _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
+            });
+            
+            this.el.show_all();
+            this.success = c.success;
+            
+            
+        },
+        
+        listeners :  {
+            
+            'delete-event' : function (widget, event) {
+                this.el.hide();
+                return true;
+            },
+            
+            response : function (w, id) 
+            {
+                
+                if (id < 1) {
+                    this.el.hide();
+                    return;
+                }
+                if (!this.get('xtype').getValue().length) {
+                    StandardErrorDialog.show("You have to set Project type");
+                     
+                    return;
+                }
+                this.el.hide();
+                
+                
+                
+                
+                this.project.name  = this.get('name').getValue();
+                this.project.xtype  = this.get('xtype').getValue();
+                
+                
+                
+                
+                var pr = ProjectManager.update(this.project);
+                
+                this.success(pr);
+                Seed.print(id);
+            },
+            
+        
+            
+        },
+        
+      
+        items : [
+            {
+                
+                xtype : Gtk.VBox,
+                pack : function(p,e) {
+                    p.el.get_content_area().add(e.el)
+                },
+                items : [
+                    {
+                        xtype : Gtk.HBox,
+                        pack : [ 'pack_start', false, true , 0 ],
+                        items : [
+                            {
+                                xtype : Gtk.Label,
+                                pack : [ 'pack_start', false, true , 0 ],
+                                label : "Project Name:"
+                            },
+                            
+                            {
+                                xtype : Gtk.Entry,
+                                id : 'name',
+                                pack : [ 'pack_end', true, true , 0 ],
+                                
+                                setValue : function(v) 
+                                {
+                                    this.el.set_text(v);
+                                },
+                                getValue : function()
+                                {
+                                    return this.el.get_text();
+                                }
+                            }
+                         
+                        ]
+                        
+                    },
+                    {
+                        xtype : Gtk.HBox,
+                        pack : [ 'pack_start', false, true , 0 ],
+                        items : [
+                            {
+                                xtype : Gtk.Label,
+                                pack : [ 'pack_start', false, true , 0 ],
+                                label : "Project Type:"
+                            },
+                            {
+                                xtype : Gtk.ComboBox,
+                                id : 'xtype',
+                                pack : [ 'pack_end', true, true , 0 ],
+                                init : function() {
+                                    XObject.prototype.init.call(this); 
+                                    this.el.add_attribute(this.items[0].el , 'markup', 1 );  
+                                },
+                                setValue : function(v)
+                                {
+                                    var el = this.el;
+                                    el.set_active(-1);
+                                    this.get('model').data.forEach(function(n, ix) {
+                                        if (v == n.xtype) {
+                                            el.set_active(ix);
+                                            return false;
+                                        }
+                                    });
+                                },
+                                getValue : function() 
+                                {
+                                    var ix = this.el.get_active();
+                                    if (ix < 0 ) {
+                                        return '';
+                                    }
+                                    return this.get('model').data[ix].xtype;
+                                    /*
+                                    var iter = new Gtk.TreeIter();
+                                    if (this.el.get_active_iter(iter)) {
+                                        return '';
+                                    }
+                                    var value = new GObject.Value('');
+                                    this.model.el.get_value(iter, 0, value);
+                                    return value.value;
+                                    */
+                                },
+                                
+                                
+                                items : [
+                                    {
+                                        xtype : Gtk.CellRendererText,
+                                        pack : ['pack_start']
+                                    },
+                                    {
+                                        id : 'model',
+                                        pack : [ 'set_model' ],
+                                        xtype : Gtk.ListStore,
+                                        init : function ()
+                                        {
+                                            XObject.prototype.init.call(this); 
+                             
+                                     
+                                            this.el.set_column_types ( 2, [
+                                                GObject.TYPE_STRING,  // real key
+                                                GObject.TYPE_STRING // real type
+                                                
+                                                
+                                            ] );
+                                            
+                                            this.data = [
+                                                { xtype: 'Roo', desc : "Roo Project" },
+                                                { xtype: 'Gtk', desc : "Gtk Project" },    
+                                                //{ xtype: 'JS', desc : "Javascript Class" }
+                                            ]
+                                            
+                                            this.loadData(this.data);
+                                                
+                                            
+                                            
+                                        },
+                                       
+                                       
+                                        
+                                        loadData : function (data) {
+                                            
+                                            var iter = new Gtk.TreeIter();
+                                            var el = this.el;
+                                            data.forEach(function(p) {
+                                                
+                                                el.append(iter);
+                                                
+                                                 
+                                                el.set_value(iter, 0, p.xtype);
+                                                el.set_value(iter, 1, p.desc);
+                                                
+                                            });
+                                             
+                                            
+                                            
+                                        }
+                                         
+                                    }
+                                  
+                                         
+                                ]
+                            }
+                 
+                                
+                        ]
+                    },
+                    {
+                        xtype : Gtk.Label,
+                        pack : [ 'pack_end', true, true , 0 ],
+                        
+                        label : ""
+                    }
+                    
+                    
+                    
+                    
+                ]
+            }
+        ]
+    }
+    
+)
+//_win = XN.xnew(create());
\ No newline at end of file
diff --git a/oldbuilder/LeftPanel.js b/oldbuilder/LeftPanel.js
new file mode 100755 (executable)
index 0000000..0ac5283
--- /dev/null
@@ -0,0 +1,656 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+LeftPanelPopup  = imports.Builder.LeftPanelPopup.LeftPanelPopup;
+RightEditor     = imports.Builder.RightEditor.RightEditor;
+/**
+ * 
+ * really the properties..
+ */
+
+
+LeftPanel = new XObject({
+        
+        xtype: Gtk.ScrolledWindow,
+        smooth_scroll : true,
+        pack : [ 'pack_end', true, true, 0 ],
+        shadow_type : Gtk.ShadowType.IN,
+        
+        editing : false,
+        
+        init : function () {
+            XObject.prototype.init.call(this); 
+            this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+        },
+        
+          
+    
+        
+        items : [
+            {
+                id : 'view',
+                
+                xtype : Gtk.TreeView,
+                
+                tooltip_column : 1,
+                headers_visible :   false ,
+                enable_tree_lines :  true ,
+                     
+                init : function () {
+                    XObject.prototype.init.call(this); 
+                       
+                    this.selection = this.el.get_selection();
+                    this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                 
+                    
+                    var description = new Pango.FontDescription.c_new();
+                    description.set_size(8000);
+                    this.el.modify_font(description);
+                },     
+                listeners : {
+                    
+                  
+                    'button-press-event' : function(tv, ev) {
+                        
+                        
+                        
+                        
+                        var res = { }; 
+                        if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
+                            return false; //not on a element.
+                        }
+                        
+                        
+                        if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
+                            
+                            if (res.column.title != 'value') {
+                                return false; // ignore..
+                            }
+                            if (  LeftPanel.editing) {
+                                return false;
+                            }
+                            var renderer = LeftPanel.editableColumn.items[0].el; // set has_entry..
+                            LeftPanel.editableColumn.items[0].el.stop_editing();
+                            var type = LeftPanel.get('model').getType(res.path.to_string());
+                            
+                             
+                            var LeftTree = imports.Builder.LeftTree.LeftTree;
+                            var provider = LeftTree.getPaleteProvider();
+                            
+                            var opts = provider.findOptions(type);
+                            
+                            if (opts === false) {
+                                LeftPanel.editableColumn.setOptions([]);
+                                renderer.has_entry = true;
+                            } else {
+                                LeftPanel.editableColumn.setOptions(opts);
+                                renderer.has_entry = false;
+                            }
+                            
+                            
+                            Seed.print("click" + ev.type);
+                            //console.dump(res);
+                            return false;
+                        }
+                      
+                    
+                       
+                        if (res.column.title == 'value') {
+                            return false;
+                        }
+                        if (!LeftPanelPopup.el) LeftPanelPopup.init();
+                        LeftPanelPopup.el.set_screen(Gdk.Screen.get_default());
+                        LeftPanelPopup.el.show_all();
+                        LeftPanelPopup.el.popup(null, null, null, null, 3, ev.button.time);
+                        Seed.print("click:" + res.column.title);
+                        
+                        
+                        return false;
+                        
+                    },
+                    'row-activated' : function() 
+                    {
+                        console.print('row activated');  
+                          // always set the cmobo entry to not ediable..
+                        
+                      
+                    }
+
+                    
+                    
+                },
+                items : [
+                
+                    {
+                        id : 'model',
+                        pack : [ 'set_model' ],
+                        xtype : Gtk.ListStore,
+                        
+                        init : function ()
+                        {
+                            XObject.prototype.init.call(this); 
+                            this.el.set_column_types ( 5, [
+                                GObject.TYPE_STRING,  // 0 real key
+                                GObject.TYPE_STRING, // 1 real value 
+                                 GObject.TYPE_STRING,  // 2 visable key
+                                 GObject.TYPE_STRING, // 3 visable value
+                                 GObject.TYPE_STRING, // 4 need to store type of!!!
+                              
+                            ]);
+                                    
+                            
+                         
+                        },
+                        toShort: function(str) {
+                            var a = typeof(str) == 'string' ? str.split("\n") : [];
+                            return a.length > 1 ? a[0] + '....' : '' + str;
+                        },
+                        load : function (ar)
+                        {
+                            this.el.clear();
+                            
+                            RightEditor.el.hide();
+                            if (ar === false) {
+                                return ;
+                            }
+                            var ret = {}; 
+                            
+                            var LeftTree = imports.Builder.LeftTree.LeftTree;
+                            var provider = LeftTree.getPaleteProvider();
+                            
+                            // sort!!!?
+                            var iter = new Gtk.TreeIter();
+                            for (var i in ar) {
+                                if (typeof(ar[i]) == 'object') {
+                                    continue;
+                                }
+                                
+                                var type = provider.findType(ar, i, ar[i]);
+                                
+                                this.el.append(iter);
+                                var p = this.el.get_path(iter).to_string();
+                                ret[i] = p;
+                                this.el.set_value(iter, 0, i);
+                                this.el.set_value(iter, 1, '' + ar[i]);
+                                this.el.set_value(iter, 2, i);
+                                this.el.set_value(iter, 3, this.toShort(ar[i]));
+                                this.el.set_value(iter, 4, type);
+                            }
+                            ar.listeners = ar.listeners || {};
+                            for (var i in ar.listeners ) {
+                                this.el.append(iter);
+                                var p = this.el.get_path(iter).to_string();
+                                ret['!' + i] = p;
+                                
+                                this.el.set_value(iter, 0, '!'+  i  );
+                                this.el.set_value(iter, 1, '' + ar.listeners[i]);
+                                this.el.set_value(iter, 2, '<b>'+ i + '</b>');
+                                
+                                this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
+                                this.el.set_value(iter, 4, 'function');
+                            }
+                            return ret;
+                        },
+                        
+                        
+                        
+                        add : function( info ) {
+                            // info includes key, val, skel, etype..
+                             console.dump(info);
+                            type = info.type.toLowerCase();
+                            var data = this.toJS();
+                            
+                            if (info.etype == 'events') {
+                                data.listeners = data.listeners || { };
+                                if (typeof(data.listeners[info.key]) != 'undefined') {
+                                    return; //already set!
+                                }
+                            } else {
+                                if (typeof(data[info.key]) != 'undefined') {
+                                    return;
+                                }
+                            }
+                            
+                            if (typeof(info.val) == 'undefined') {
+                                    
+                                info.val = '';
+                                if (info.type == 'boolean') {
+                                    info.val = true;
+                                }
+                                if (type == 'number') {
+                                    info.val = 0;
+                                }
+                                // utf8 == string..
+                                
+                                
+                            }
+                            var k = info.key;
+                            if (info.etype == 'events') {
+                             
+                                data.listeners[info.key] = info.val;
+                                k = '!' + info.key;
+                            } else {
+                                data[info.key] = info.val;
+                            }
+                            
+                            
+                            var map = this.load(data);
+                            
+                            // flag it as changed to the interface..
+                            var LeftTree        = imports.Builder.LeftTree.LeftTree;
+                            LeftTree.get('model').changed(data, true); 
+                            
+                            
+                            this.startEditing(map[k]);
+                             
+                            /*
+                            LeftPanel.get('view').el.row_activated(
+                                new Gtk.TreePath.from_string(map[k]), 
+                                LeftPanel.editableColumn.el
+                            );
+                            */
+                            
+                            
+                        },
+                        /**
+                         * start editing path (or selected if not set..)
+                         * @param {String|false} path  (optional) treepath to edit - selected tree gets
+                         *     edited by default.
+                         * @param {Number} 0 or 1 (optional)- column to edit. 
+                         */
+                        startEditing : function(path, col)
+                        {
+                            // fix tp (treepath) and path string..
+                            var tp;
+                            if (typeof(path) == 'string') {
+                                tp = new Gtk.TreePath.from_string(path);
+                            } else {
+                                var iter = new Gtk.TreeIter();
+                                var s = LeftPanel.get('view').selection;
+                                s.get_selected(this.el, iter);
+                                tp = this.el.get_path(iter);
+                                path = tp.to_string();
+                            }
+                            
+                           
+                            // which colum is to be edited..
+                            var colObj = false;
+                            if (typeof(col) == 'undefined') {
+                                var k = this.getValue(path, 0);
+                                colObj = (!k.length || k == '|') ? 
+                                    LeftPanel.propertyColumn : LeftPanel.editableColumn;
+                            } else {
+                                colObj = col ? LeftPanel.editableColumn : LeftPanel.propertyColumn;
+                            }
+                            
+                            // make sure the pulldown is set correctly..
+                            // not really needed for second col...
+                            var LeftTree = imports.Builder.LeftTree.LeftTree;
+                            var provider = LeftTree.getPaleteProvider();
+                           
+                            var type = LeftPanel.get('model').getType(path);
+                            var opts = provider.findOptions(type);
+                            var renderer = LeftPanel.editableColumn.items[0].el;
+                            
+                            if (opts === false) {
+                                LeftPanel.editableColumn.setOptions([]);
+                                renderer.has_entry = true; /// probably does not have any effect.
+                            } else {
+                                LeftPanel.editableColumn.setOptions(opts);
+                                renderer.has_entry = false;
+                            }
+                            
+                            
+                            // iter now has row...
+                            GLib.timeout_add(0, 100, function() {
+                                
+                                colObj.items[0].el.editable = true; // esp. need for col 0..
+                                LeftPanel.get('view').el.set_cursor_on_cell(
+                                    tp,
+                                    colObj.el,
+                                    colObj.items[0].el,
+                                    true
+                                );
+                            });
+                            
+                          
+                          
+                        },
+                        deleteSelected : function()
+                        {
+                            var data = this.toJS();
+                            var iter = new Gtk.TreeIter();
+                            var s = LeftPanel.get('view').selection;
+                            s.get_selected(this.el, iter);
+                                 
+                               
+                            var gval = new GObject.Value('');
+                            LeftPanel.get('model').el.get_value(iter, 0 ,gval);
+                            
+                            var val = gval.value;
+                            if (val[0] == '!') {
+                                // listener..
+                                if (!data.listeners || typeof(data.listeners[  val.substring(1)]) == 'undefined') {
+                                    return;
+                                }
+                                delete data.listeners[  val.substring(1)];
+                                if (!XObject.keys(data.listeners).length) {
+                                    delete data.listeners;
+                                }
+                                
+                            } else {
+                                if (typeof(data[val]) == 'undefined') {
+                                    return;
+                                }
+                                delete data[val];
+                            }
+                            
+                            
+                            this.load(data);
+                            var LeftTree        = imports.Builder.LeftTree.LeftTree;
+                            LeftTree.get('model').changed(data, true);
+                            
+                        },
+                        
+                        
+                        
+                        activePath : false,
+                        changed : function(str, doRefresh)
+                        {
+                            if (!this.activePath) {
+                                return;
+                            }
+                            var iter = new Gtk.TreeIter();
+                            this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
+                            
+                            this.el.set_value(iter, 1, '' +str);
+                            this.el.set_value(iter, 3, '' + this.toShort(str));
+                            // update the tree...
+                            var LeftTree        = imports.Builder.LeftTree.LeftTree;
+                            LeftTree.get('model').changed(this.toJS(), doRefresh); 
+                        },
+                        toJS: function()
+                        {
+                            var iter = new Gtk.TreeIter();
+                            LeftPanel.get('model').el.get_iter_first(iter);
+                            var ar = {};
+                               
+                            while (true) {
+                                
+                                var k = this.getValue(this.el.get_path(iter).to_string(), 0);
+                               // Seed.print(k);
+                                if (k[0] == '!') {
+                                    ar.listeners = ar.listeners || {};
+                                    ar.listeners[  k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
+                                    
+                                } else {
+                                    ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
+                                }
+                                
+                                if (! LeftPanel.get('model').el.iter_next(iter)) {
+                                    break;
+                                }
+                            }
+                            
+                            
+                            Seed.print(JSON.stringify(ar));
+                            return ar;
+                            // convert the list into a json string..
+                        
+                            
+                        },
+                        getType :function(treepath_str)
+                        {
+                            return this.getValue(treepath_str, 4);
+                        },
+                        
+                        /** get's a value, and tries to use type column to work out what type */
+                        getValue: function (treepath_str, col) {
+                            
+                            var iter = new Gtk.TreeIter();
+                            this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
+                            
+                            var gval = new GObject.Value('');
+                            LeftPanel.get('model').el.get_value(iter, col ,gval);
+                            var val = '' + gval.value;
+                            if (col != 1) {
+                                return val;
+                            }
+                            var type = this.getType(this.el.get_path(iter).to_string());
+                            //print("TYPE: " +type + " -  val:" + val);
+                            switch(type.toLowerCase()) {
+                                case 'double':
+                                case 'float':
+                                case 'number':
+                                case 'uint':
+                                case 'int':
+                                    return parseFloat(val); // Nan ?? invalid!!?
+                                case 'boolean':
+                                    return val == 'true' ? true : false;
+                                default: 
+                                    return val;
+                            }
+                            
+                        },
+                        
+                        editSelected: function( e)
+                        {
+                            print("EDIT SELECTED?");
+                            var iter = new Gtk.TreeIter();
+                            var s = LeftPanel.get('view').selection;
+                            s.get_selected(LeftPanel.get('model').el, iter);
+                            var m = LeftPanel.get('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();
+                                    RightEditor.el.show();
+                                    RightEditor.get('view').load( rval );
+                                    
+                                    e.editing_done();
+                                    e.remove_widget();
+                                    _this.activePath = activePath ;
+                                    
+                             //       Gdk.threads_leave();
+                                    return false;
+                                });
+                                return;
+                            }
+                             
+                            RightEditor.el.hide();
+
+                            var type = this.getValue(this.el.get_path(iter).to_string(),4);
+                            print("type = " + type);
+                            // toggle boolean
+                            if (type == 'boolean') {
+                                // let's show a pulldown..
+                                //LeftPanel.editableColumn.setOptions([ 'true' , 'false']);
+                                
+                                return;
+                                val = ! this.getValue(this.el.get_path(iter).to_string(),1);
+                                
+                                this.activePath = false;
+                                var _this = this;
+                                GLib.timeout_add(0, 1, function() {
+                                    //   Gdk.threads_enter();
+                                     
+                                    e.editing_done();
+                                    e.remove_widget();
+                                    _this.activePath = activePath ;
+                                    _this.changed(''+val,true);
+                                    
+                             
+                                    return false;
+                                });
+                            }
+                            //LeftPanel.editableColumn.el.has_entry = true; // alwo editing?
+                             // otherwise we are going to show the text editor..   
+                             
+                            
+                            
+                       
+                        }
+                          
+                        
+                    },
+
+                    {
+                        
+                        xtype: Gtk.TreeViewColumn,
+                        pack : ['append_column'],
+                        title : 'key',
+                        init : function ()
+                        {
+                            XObject.prototype.init.call(this); 
+                            this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                            LeftPanel.propertyColumn= this;
+                        },
+                        items : [
+                            {
+                                xtype : Gtk.CellRendererText,
+                                editable : false,
+                                pack : ['pack_start'],
+                            
+                                listeners : {
+                                    'editing-started' : function(r, e, p) {
+                                        LeftPanel.get('model').activePath  = p;
+                                        this.editEvent = e;
+                                    },
+                                    edited : function(r,p, t) {
+
+                                        // since our visiable col is differnt from the editable one..
+                                        var model = LeftPanel.get('model');
+                                        var path = LeftPanel.get('model').activePath;
+                                        var iter = new Gtk.TreeIter();
+                                        model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
+                                        model.el.set_value(iter, 0, t);
+                                        model.el.set_value(iter, 2, t);
+                                        
+                                        LeftPanel.get('model').activePath = false;
+                                        var LeftTree        = imports.Builder.LeftTree.LeftTree;
+                                        LeftTree.get('model').changed(LeftPanel.get('model').toJS(), true); 
+                                        this.el.editable = false;
+                                        
+                                            //this.el.has_entry = false;
+                                    }
+                                }
+                            }
+                        ]
+                    },
+                            
+                    {
+                        
+                        xtype: Gtk.TreeViewColumn,
+                        pack : ['append_column'],
+                        title : 'value',
+                        init : function ()
+                        {
+                            XObject.prototype.init.call(this); 
+                            this.el.add_attribute(this.items[0].el , 'text', 3 );
+                            this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
+                            this.el.add_attribute(this.items[0].el , 'editable', 3 );
+                           // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
+
+                            LeftPanel.editableColumn= this;
+                        },
+                        setOptions : function(ar)
+                        {
+                            //this.items[0].el.has_entry = false; // stop editable.
+                           //this.items[0].el.editable = false;
+                            var m = this.items[0].el.model;
+                            m.clear();
+                            var iter = new Gtk.TreeIter();
+                            ar.forEach(function(i) {
+                                   // sort!!!?
+                                m.append(iter);
+                                m.set_value(iter, 0, i);
+                            });
+                            
+                            
+                          
+                        },
+                        
+                        items : [
+                         
+                            {
+                                
+                                xtype : function() {
+                                    var  ret = new Gtk.CellRendererCombo();
+                                    ret.model = new Gtk.ListStore();
+                                    ret.model.set_column_types ( 1, [
+                                        GObject.TYPE_STRING,  // 0 real key
+                                        
+                                    ]);
+                                    
+                                    return  ret;
+                                },
+                                pack : ['pack_start'],
+                                editable : true,
+                                has_entry : false,
+                                text_column : 0,
+                                listeners : {
+                                    edited : function(r,p, t) {
+                                        LeftPanel.editing = false;
+                                        print("EDITED? p:" + p + " t:" + t);
+                                        LeftPanel.get('model').changed(t, true);
+                                        LeftPanel.get('model').activePath = false;
+                                        //this.el.has_entry = false;
+                                    },
+                                    
+                                    'editing-started' : function(r, e, p) {
+                                        LeftPanel.editing  = true;
+                                      //  console.log('editing started');
+                                       // r.has_entry = false;
+                                        LeftPanel.get('model').editSelected(e);
+                                    }    
+                                },
+                                
+                                
+                            }
+                        ]
+                    }
+                
+                ]
+            }
+        ]    
+            
+    }
+);
+    
+     
+    
diff --git a/oldbuilder/LeftPanelPopup.js b/oldbuilder/LeftPanelPopup.js
new file mode 100755 (executable)
index 0000000..c0a932f
--- /dev/null
@@ -0,0 +1,69 @@
+//<Script type="text/javascript">
+Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+
+LeftPanelPopup = new XObject({
+    
+        
+    xtype : Gtk.Menu,
+    
+     
+    items :  [
+        {
+            
+            
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Delete Property / Event',
+            listeners : {
+                activate : function () {
+                    imports.Builder.LeftPanel.LeftPanel.get('model').deleteSelected();
+                }
+            }
+        },
+        {
+            
+            
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Edit Property / Method Name',
+            listeners : {
+                activate : function () {
+                   imports.Builder.LeftPanel.LeftPanel.get('model').startEditing(false, 0);
+                }
+            }
+        },
+        {
+            
+            
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Change Property to Javascript Value',
+            listeners : {
+                activate : function () {
+                   imports.Builder.LeftPanel.LeftPanel.get('model').setSelectedToJS();
+                }
+            }
+        },
+        {
+            
+            
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Change Property to String (or native) Value',
+            listeners : {
+                activate : function () {
+                    imports.Builder.LeftPanel.LeftPanel.get('model').setSelectedToNoJS();
+                }
+            }
+            
+        },
+    ]
+});
diff --git a/oldbuilder/LeftProjectTree.js b/oldbuilder/LeftProjectTree.js
new file mode 100755 (executable)
index 0000000..fe644f9
--- /dev/null
@@ -0,0 +1,513 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+ProjectManager      = imports.Builder.Provider.ProjectManager.ProjectManager;
+EditProject         = imports.Builder.EditProject.EditProject;
+DialogNewComponent  = imports.Builder.DialogNewComponent.DialogNewComponent;
+LeftTree            = imports.Builder.LeftTree.LeftTree;
+
+// http://www.google.com/codesearch/p?hl=en#EKZaOgYQHwo/unstable/sources/sylpheed-2.2.9.tar.bz2%7C1erxr_ilM1o/sylpheed-2.2.9/src/folderview.c&q=gtk_tree_view_get_drag_dest_row
+
+
+Gtk.rc_parse_string(
+            "style \"gtkcombobox-style\" {\n" + 
+            "    GtkComboBox::appears-as-list = 1\n" +
+            "}\n"+
+            "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
+
+
+LeftProjectTree = new XObject({
+        
+        xtype : Gtk.VBox,
+        
+        showNoProjectSelected : function()
+        {
+           imports.Builder.StandardErrorDialog.StandardErrorDialog.show("Select a Project first.");
+        },
+        
+        
+        
+        items : [
+            {
+                
+                xtype: Gtk.Toolbar,
+                pack : ['pack_start', false , true ], // expand // fill.
+                listeners : {
+                    'size-allocate': function(w,a) {
+                    
+                        
+                        //LeftProjectTree.get('combo').el.set_size_request( 
+                        //        Gtk.allocation_get_width(a)-50,-1);
+                        
+                        
+                    }
+                },
+                items : [
+                    {
+                        
+                        xtype: Gtk.ToolItem,
+                        pack : [ 'insert', 0],
+                        expand: true,
+                        
+                        items : [
+                        
+                            {
+                                id : 'combo',
+                                
+                                xtype : Gtk.ComboBox,
+                                //pack : [ 'insert', 1],
+                                expand: true,
+                                
+                                init : function () 
+                                {
+                                    XObject.prototype.init.call(this); 
+                                    this.el.add_attribute(this.items[0].el , 'markup', 1 );  
+                                },
+                            
+                                setValue : function(fn)
+                                {
+                                    var el = this.el;
+                                    el.set_active(-1);
+                                    var data = ProjectManager.projects;
+                                    data.forEach(function(n, ix) {
+                                        if (fn == n.fn) {
+                                            el.set_active(ix);
+                                            return false;
+                                        }
+                                    });
+                                },
+                                getValue : function() 
+                                {
+                                    var ix = this.el.get_active();
+                                    if (ix < 0 ) {
+                                        return false;
+                                    }
+                                    var data =  ProjectManager.projects;
+                                    return data[ix].fn;
+                                    
+                                },
+                                
+                                
+                                listeners : {
+                                      
+                                    changed : function() {
+                                        var fn = this.getValue();
+                                        var pm  = ProjectManager;
+                                        LeftProjectTree.get('model').loadProject(pm.getByFn(fn))
+                                    }
+                                },
+                                items : [
+                                   {
+                                          
+                                        xtype : Gtk.CellRendererText,
+                                        pack : ['pack_start']
+                                        
+                                    },
+                                    {
+                                        id : 'combomodel',
+                                        pack : [ 'set_model' ],
+                                        xtype : Gtk.ListStore,
+                                        
+                                        init :  function ()
+                                        {
+                                            XObject.prototype.init.call(this); 
+                          
+                                            this.el.set_column_types ( 2, [
+                                                GObject.TYPE_STRING,  // real key
+                                                GObject.TYPE_STRING // real type
+                                                
+                                                
+                                            ] );
+                                                
+                                             
+                                        },
+                                       
+                                       
+                                        
+                                        loadData : function (data) {
+                                            
+                                            var ov = LeftProjectTree.get('combo').getValue();
+                                            this.el.clear();
+                                            var iter = new Gtk.TreeIter();
+                                            var el = this.el;
+                                            data.forEach(function(p) {
+                                                
+                                                el.append(iter);
+                                                
+                                                 
+                                                el.set_value(iter, 0, p.fn);
+                                                el.set_value(iter, 1, p.name);
+                                                
+                                            });
+                                            
+                                            LeftProjectTree.get('combo').setValue(ov);
+                                            
+                                        }
+                                         
+                                    }
+                                  
+                                         
+                                ]
+                        
+                            }
+                        ]
+                         
+                        
+                        
+                    },
+                    {
+                        
+                        
+                        xtype: Gtk.ToolButton,
+                        pack : [ 'insert', 1],
+                        label : "Manage",
+                        'stock-id' :  Gtk.STOCK_EDIT,
+                        listeners : {
+                            clicked: function() {
+                                this.get('menu').el.show_all();
+                                this.get('menu').el.popup(null, null, null, 
+                                    null, 1, Gtk.get_current_event_time());
+                                
+                            }
+                        },
+                        
+                        items : [
+                            {
+                                id : 'menu',
+                                xtype : Gtk.Menu,
+                                pack : [ false ],
+                                
+                                
+                                items :  [
+                                    {
+                                        xtype : Gtk.MenuItem,
+                                        pack : [ 'append' ],
+                                        label : "New Project",
+                                        listeners : {
+                                            activate : function () {
+                                                
+                                                
+                                                EditProject.show({
+                                                    success : function(pr) {
+                                                        LeftProjectTree.get('combo').setValue(pr.fn);
+                                                    }
+                                                });
+                                            }
+                                        }
+                                    },
+                                    {
+                                        
+                                        
+                                        xtype : Gtk.MenuItem,
+                                        pack : [ 'append' ],
+                                        label : "Add Directory To Current Project",
+                                        listeners : {
+                                            activate : function () {
+                                                
+                                                var fn = LeftProjectTree.get('combo').getValue();
+                                                if (!fn) {
+                                                    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;
+                                                }
+                                                    
+                                                //Seed.print(dc.get_filename());
+                                                var pm  = ProjectManager;
+                                                pm.getByFn(fn).add(dc.get_filename(), 'dir');
+                                                dc.destroy();
+                                                
+                                                 
+                                            }
+                                        }
+                                    },
+                                    {
+                                        
+                                        
+                                        xtype : Gtk.MenuItem,
+                                        pack : [ 'append' ],
+                                        label : "Add File To Current Project",
+                                        listeners : {
+                                            activate : function () {
+                                                var fn = LeftProjectTree.get('combo').getValue();
+                                                if (!fn) {
+                                                    LeftProjectTree.showNoProjectSelected();
+                                                    return true;
+                                                }
+                                                
+                                                
+                                                var dc = new Gtk.FileChooserDialog({
+                                                    action : Gtk.FileChooserAction.OPEN,
+                                                    modal: true,
+                                                    'select-multiple' : false, // later..
+                                                    "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;
+                                                }
+                                                    
+                                                //Seed.print(dc.get_filename());
+                                                
+                                                ProjectManager.getByFn(fn).add(dc.get_filename(), 'file');
+                                                dc.destroy();
+                                                
+                                                 
+                                            }
+                                        }
+                                    },
+                                    
+                                    {
+                                         
+                                        
+                                        xtype : Gtk.MenuItem,
+                                        pack : [ 'append' ],
+                                        label : 'Add Component',
+                                        listeners : {
+                                            activate : function () {
+                                                var fn = LeftProjectTree.get('combo').getValue();
+                                                if (!fn) {
+                                                    LeftProjectTree.showNoProjectSelected();
+                                                    return true;
+                                                }
+                                                
+                                                DialogNewComponent.show({
+                                                    project : ProjectManager.getByFn(fn)
+                                                });
+                                                
+                                                 
+                                            }
+                                        }
+                                    }
+                                    
+                                 
+                                ]
+                            }
+                        ]
+                        
+                        
+                    }
+                
+                ]
+                
+                
+        
+            },
+
+            {
+                
+                
+                xtype: Gtk.ScrolledWindow,
+                smooth_scroll : true,
+                shadow_type : Gtk.ShadowType.IN,
+                 init :  function ()
+                {
+                    XObject.prototype.init.call(this); 
+              
+                    this.el.set_policy  (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
+                    //set_size_request : [-1,400]
+                },
+                items : [        
+                    {
+                        
+                        id : 'view',  
+                        
+                        xtype : Gtk.TreeView,
+                        headers_visible :  false,
+                        enable_tree_lines :  true ,
+                        tooltip_column : 1,
+                          //  set_reorderable: [1]
+                        
+                        init :  function ()
+                        {
+                            XObject.prototype.init.call(this); 
+                            var description = new Pango.FontDescription.c_new();
+                            description.set_size(8000);
+                            this.el.modify_font(description);
+                            
+                            this.selection = this.el.get_selection();
+                            this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                        },
+                        listeners : {
+                            
+                            'cursor-changed'  : function(tv, a) { 
+                                //select -- should save existing...
+                                var iter = new Gtk.TreeIter();
+                                
+                                if (this.selection.count_selected_rows() < 1) {
+                                    //XN.get('Builder.LeftTree.model').
+                                    LeftTree.get('model').load( false);
+                                    
+                                    return;
+                                }
+                                var model = LeftProjectTree.get('model');
+                                //console.log('changed');
+                                var s = this.selection;
+                                s.get_selected(model, iter);
+                                value = new GObject.Value('');
+                                model.el.get_value(iter, 2, value);
+                                
+                                console.log(value.value);// id..
+                                
+                                var file = LeftProjectTree.project.getById(value.value);
+                                
+                                
+                                console.log(file);
+                                
+                                var LeftTopPanel        = imports.Builder.LeftTopPanel.LeftTopPanel;
+
+                                var nb = LeftTopPanel.get('expander');
+                                nb.el.expanded = false;
+                                nb.listeners.activate.call(nb);
+                                //_expander.el.set_expanded(false);
+
+                                var ltm = LeftTree.get('model');
+                                ltm.loadFile(file);
+                                
+                                return true;
+                                
+                                
+                            
+                            }
+                        },
+                        
+                        items  : [
+                            {
+                                pack : ['set_model'],
+                                
+                                xtype : Gtk.TreeStore,
+                                id : 'model',
+                                init :  function ()
+                                {
+                                    XObject.prototype.init.call(this);    
+                                    this.el.set_column_types ( 3, [
+                                            GObject.TYPE_STRING, // title 
+                                            GObject.TYPE_STRING, // tip
+                                            GObject.TYPE_STRING // id..
+                                            ] );
+                           
+                                    
+                                },
+                                activeIter : false, // fixme - should not use iters..
+                                
+                                
+                                 
+                                
+                                loadProject : function (pr)
+                                {
+                                    
+                                    
+                                    this.el.clear();
+                                    if (!pr) {
+                                        return;
+                                    }
+                                    LeftProjectTree.project = pr;
+                                    this.load(pr.toTree());
+                                    LeftProjectTree.get('view').el.expand_all();
+                                    // needs more thought!!??
+                                  
+                                    
+                                    
+                                },
+                                
+                                load : function(tr,iter)
+                                {
+                                    console.dump(tr);
+                                    console.log('Project tree load: ' + tr.length);
+                                    var citer = new Gtk.TreeIter();
+                                    //this.insert(citer,iter,0);
+                                    
+                                    var _this = this;
+                                    tr.forEach(function (r) {
+                                        if (!iter) {
+                                            _this.el.append(citer);   
+                                        } else {
+                                            _this.el.insert(citer,iter,-1);
+                                        }
+                                        _this.el.set_value(citer, 0,  '' + r.getTitle() ); // title 
+                                        _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
+                                        _this.el.set_value(citer, 2, '' + r.id ); //id
+                                        if (r.cn && r.cn.length) {
+                                            _this.load(r.cn, citer);
+                                        }
+                                        
+                                    });
+                                    
+                                },
+                                
+                                
+                                
+                                
+                                getValue: function (iter, col) {
+                                    var gval = new GObject.Value('');
+                                    this.el.get_value(iter, col ,gval);
+                                    return  gval.value;
+                                    
+                                    
+                                }
+                                
+                                
+                                
+                              //  this.expand_all();
+                            },
+                            
+                              
+                            {
+                                pack : ['append_column'],
+                                
+                                xtype : Gtk.TreeViewColumn,
+                                items : [
+                                    {
+                                        
+                                        xtype : Gtk.CellRendererText,
+                                        pack: [ 'pack_start']
+                                          
+                                    } 
+                                ],
+                                     init :  function ()
+                                {
+                                    XObject.prototype.init.call(this);    
+                            
+                                    this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                    
+                                }
+                              
+                            }
+                            
+                       ]
+                    }
+                ]
+                        
+            }
+        ]
+                     
+    }
+);
diff --git a/oldbuilder/LeftProps.js b/oldbuilder/LeftProps.js
new file mode 100755 (executable)
index 0000000..070e6f2
--- /dev/null
@@ -0,0 +1,177 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+MidPropTree = imports.Builder.MidPropTree.MidPropTree;
+AddPropertyPopup = imports.Builder.AddPropertyPopup.AddPropertyPopup; 
+
+
+/**
+ * 
+ * Properties and events pulldowns..
+ * 
+ */
+
+LeftProps = new XObject({
+        
+        xtype: Gtk.HBox,
+        pack : [ 'pack_start', false, true, 0 ],
+        items : [       
+            {
+                
+                
+                xtype: Gtk.Button,
+                 
+                listeners : {
+                    // pressed...
+                    'button-press-event' : function(w, ev ){
+                        console.log('pressed');
+                        MidPropTree.get('model').showData('props');
+                        return true;
+                        // show the MidPropTree..
+                    }
+                  
+                },
+                items : [
+                    {
+                        
+                        xtype: Gtk.HBox,
+                        pack : ['add'],
+                        items : [
+                            {
+                                
+                                xtype: Gtk.Image,
+                                'stock' : Gtk.STOCK_ADD,
+                                'icon-size' : Gtk.IconSize.MENU,
+                                
+                                pack : ['add']
+                                
+                            },
+                            {
+                                
+                                xtype: Gtk.Label,
+                                pack : ['add'],
+                                label: "Property"
+                                
+                            }
+                        
+                        ]
+                    }
+                         
+                ]
+            },
+             {
+                
+                
+                xtype: Gtk.Button,
+                 
+                
+                
+                listeners : {
+                    // pressed...
+                    'button-press-event' : function(w, ev ){
+                        console.log('pressed');
+                        MidPropTree.get('model').showData('events');
+                        return true;
+                        // show the MidPropTree..
+                    }
+                  
+                },
+                items : [
+                    {
+                        
+                        xtype: Gtk.HBox,
+                        pack : ['add'],
+                        items : [
+                            {
+                                
+                                xtype: Gtk.Image,
+                                'stock' : Gtk.STOCK_ADD,
+                                'icon-size' : Gtk.IconSize.MENU,
+                                
+                                pack : ['add']
+                                
+                            },
+                            {
+                                
+                                xtype: Gtk.Label,
+                                pack : ['add'],
+                                label: 'Handler'
+                                
+                            }
+                        
+                        ]
+                    }
+                         
+                ]
+            },
+              {
+                
+                
+                xtype: Gtk.Button,
+                 
+                
+                
+                listeners : {
+                    // pressed...
+                    'button-press-event' : function(w, ev ){
+                        // show the menu..
+                        if (!AddPropertyPopup.el) {
+                            AddPropertyPopup.init();
+                        }
+                        AddPropertyPopup.el.set_screen(Gdk.Screen.get_default());
+                        AddPropertyPopup.el.show_all();
+                        AddPropertyPopup.el.popup(null, null, null, null, 3, ev.button.time);
+                        //console.log('pressed');
+                        //Builder.MidPropTree._model.showData('events');
+                        return true;
+                        // show the MidPropTree..
+                    }
+                  
+                },
+                items : [
+                    {
+                        
+                        xtype: Gtk.HBox,
+                        pack : ['add'],
+                        items : [
+                            {
+                                
+                                xtype: Gtk.Image,
+                                'stock' : Gtk.STOCK_ADD,
+                                'icon-size' : Gtk.IconSize.MENU,
+                                
+                                pack : ['add']
+                                
+                            },
+                            {
+                                
+                                xtype: Gtk.Label,
+                                pack : ['add'],
+                                label: 'Other'
+                                
+                            }
+                        
+                        ]
+                    } 
+             
+                         
+                ]
+            }
+        ]
+        
+             
+    }
+
+
+)
+    
diff --git a/oldbuilder/LeftTopPanel.js b/oldbuilder/LeftTopPanel.js
new file mode 100755 (executable)
index 0000000..5a575ff
--- /dev/null
@@ -0,0 +1,111 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango ;
+GObject = imports.gi.GObject;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+ProjectManager      = imports.Builder.Provider.ProjectManager.ProjectManager; 
+LeftProjectTree     = imports.Builder.LeftProjectTree.LeftProjectTree;
+LeftTree            = imports.Builder.LeftTree.LeftTree;
+
+// vbox
+
+
+// expander
+// notebook
+
+LeftTopPanel = new XObject({
+        
+        xtype : Gtk.VBox,
+        
+        items : [
+            
+            {
+                id : 'expander',
+                xtype : Gtk.Expander,
+                
+                label : 'Project Tree',
+                pack : ['pack_start', false , true ], // expand // fill.
+                init : function(){
+                    XObject.prototype.init.call(this); 
+                    this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
+                },
+                listeners : {
+                    
+                    activate : function () 
+                    {
+                        var nb = LeftTopPanel.get('notebook');
+                        if (this.el.expanded) {
+                            // now expanded..
+                            var pm  = ProjectManager;
+                            
+                           
+                            var model = LeftProjectTree.get('combomodel');
+                            
+                            model.loadData(ProjectManager.projects);
+                             
+                            
+                            nb.el.set_current_page(1);
+                            //pm.on('changed', function() {
+                                //console.log("CAUGHT project manager change");
+                            //    _combo.model.loadData(pm.projects);
+                            //}
+                            return;
+                        }
+                        nb.el.set_current_page(0);
+                        
+                       //Seed.print("ACTIVATE?");
+                       // var pm  = Builder.Provider.ProjectManager;
+                       // _combo.model.loadData(pm.projects);
+                       // pm.on('changed', function() {
+                       //     console.log("CAUGHT project manager change");
+                       //    _combo.model.loadData(pm.projects);
+                        //});
+                       // this.items[0].el[this.get_expanded() ? 'hide' : 'show']();
+                    },
+                    'enter-notify-event' : function (w,e)
+                    {
+                        
+                        //console.log("enter!");
+                        this.el.expanded = !this.el.expanded;
+                        //if (this.el.expanded ) {
+                            this.listeners.activate.call(this);
+                        //   }
+                        
+                       return true;
+                    }
+                    
+                },
+            },
+            {
+                    
+                xtype : Gtk.Notebook,
+                id: 'notebook',
+                label : 'Project Tree',
+                'show-border' : false,
+                'show-tabs' : false,
+                pack : ['pack_start', true , true ], // expand // fill.
+                
+                init : function()
+                {
+                    XObject.prototype.init.call(this); 
+                    this.el.set_current_page(0);
+                },
+                
+                items :  [
+                    LeftTree,
+                    LeftProjectTree
+                    
+                ]
+            }
+            
+        ]
+    }
+);
+            
+            
+            
\ No newline at end of file
diff --git a/oldbuilder/LeftTree.js b/oldbuilder/LeftTree.js
new file mode 100755 (executable)
index 0000000..554bf0e
--- /dev/null
@@ -0,0 +1,1043 @@
+//<Script type="text/javascript">
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+// recursive imports here break!!?
+Roo             = imports.Builder.Provider.Palete.Roo.Roo;
+LeftTreeMenu    = imports.Builder.LeftTreeMenu.LeftTreeMenu;
+LeftPanel       = imports.Builder.LeftPanel.LeftPanel;
+MidPropTree     = imports.Builder.MidPropTree.MidPropTree;
+
+RightEditor     = imports.Builder.RightEditor.RightEditor;
+// http://www.google.com/codesearch/p?hl=en#EKZaOgYQHwo/unstable/sources/sylpheed-2.2.9.tar.bz2%7C1erxr_ilM1o/sylpheed-2.2.9/src/folderview.c&q=gtk_tree_view_get_drag_dest_row
+
+var idSeed = 0;
+function id(el, prefix){
+    prefix = prefix || "left-tree";
+    //el = Roo.getDom(el);
+    var ret = prefix + (++idSeed);
+    return ret;
+    //return el ? (el.id ? el.id : (el.id = id)) : id;
+}
+
+LeftTree = new XObject(
+{
+        id : 'LeftTree',
+        xtype: Gtk.ScrolledWindow,
+        smooth_scroll : true,
+        
+        shadow_type :  Gtk.ShadowType.IN,
+        init : function() {
+            this.targetList.add( this.atoms["STRING"], 0 , 1);
+            // will not work without changes to gir..
+           // var ta_ar = Gtk.target_table_new_from_list(this.targetList,r);
+            
+            XObject.prototype.init.call(this); 
+            this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+            
+             
+        },
+        
+        getPaleteProvider: function ()
+        {
+            var model = this.get('model');
+            var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+            return pm.getPalete(model.file.getType());
+            
+        },
+        
+        renderView: function() // renders into the preview pane..
+        {
+            var model = this.get('model');
+            print("RENDER VIEW?" + model.file.getType());
+            switch( model.file.getType()) {
+                case 'Roo':
+                    var RightBrowser    = imports.Builder.RightBrowser.RightBrowser;
+                    RightBrowser.get('view').renderJS(model.toJS(false,true)[0]);
+                case 'Gtk':
+                    var RightGtkView = imports.Builder.RightGtkView.RightGtkView ;
+                    RightGtkView.renderJS(model.toJS(false,true)[0]);
+            }
+            
+        },
+        
+        atoms : {
+           "STRING" : Gdk.atom_intern("STRING")
+        },
+                        
+        targetList :  new Gtk.TargetList(),
+        
+        items : [        
+            {
+                id : 'view',
+                xtype: Gtk.TreeView,
+                headers_visible :  false,
+                enable_tree_lines :  true,
+                tooltip_column : 0,
+                // selection  -- set by init..
+                init : function() {
+                    XObject.prototype.init.call(this); 
+                    
+                    var description = new Pango.FontDescription.c_new();
+                    description.set_size(8000);
+                    this.el.modify_font(description);
+                    
+                    this.selection = this.el.get_selection();
+                    this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                    this.selection.signal['changed'].connect(function() {
+                        LeftTree.get('view').listeners['cursor-changed'].apply(
+                            LeftTree.get('view'), [ LeftTree.get('view'), '']
+                        );
+                    });
+                    
+                    Gtk.drag_source_set (
+                        this.el,            /* widget will be drag-able */
+                        Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
+                        null,            /* lists of target to support */
+                        0,              /* size of list */
+                        Gdk.DragAction.COPY   | Gdk.DragAction.MOVE           /* what to do with data after dropped */
+                    );
+                    var targets = new Gtk.TargetList();
+                    targets.add( LeftTree.atoms["STRING"], 0, 0);
+                    Gtk.drag_source_set_target_list(this.el, targets);
+
+                    Gtk.drag_source_add_text_targets(this.el); 
+                    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   | Gdk.DragAction.MOVE       /* what to do with data after dropped */
+                    );
+                     
+                    Gtk.drag_dest_set_target_list(this.el, targets);
+                    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( 
+                            new  Gtk.TreePath.from_string( treepath_ar[0] ),  treepath_ar[1]);
+                    } else {
+                        this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
+                    }
+                     
+                },
+                
+                selectNode : function(treepath_str) 
+                {
+                    
+                   this.selection.select_path(new  Gtk.TreePath.from_string( treepath_str));
+                },
+                
+                listeners : {
+                    
+                    
+                    
+                    'button-press-event' : function(tv, ev) {
+                        console.log("button press?");
+                        if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button.button != 3) {
+                            Seed.print("click" + ev.type);
+                            return false;
+                        }
+                      
+                    
+                        var res = {}; 
+                        LeftTree.get('view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
+                        
+                        if (!LeftTreeMenu.el)  LeftTreeMenu.init();
+                        
+                        LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());
+                        LeftTreeMenu.el.show_all();
+                        LeftTreeMenu.el.popup(null, null, null, null, 3, ev.button.time);
+                        Seed.print("click:" + res.path.to_string());
+                        return false;
+                        
+                    },
+                    
+                     'drag-begin' : function (w, ctx, ud) 
+                    {
+                           // we could fill this in now...
+                        Seed.print('SOURCE: drag-begin');
+                         this.targetData = false;
+                        // find what is selected in our tree...
+                        var iter = new Gtk.TreeIter();
+                        var s = this.selection;
+                        s.get_selected(LeftTree.get('model').el, iter);
+
+                        // set some properties of the tree for use by the dropped element.
+                        var value = new GObject.Value('');
+                        LeftTree.get('model').el.get_value(iter, 2, value);
+                        var data = JSON.parse(value.value);
+                        var xname = LeftTree.get('model').file.guessName(data);
+                        
+                        this.el.dragData = xname;
+                        this.el.dropList = LeftTree.getPaleteProvider().getDropList(xname);
+                        
+
+                        // make the drag icon a picture of the node that was selected
+                        var path = LeftTree.get('model').el.get_path(iter);
+                        this.el.treepath = path.to_string();
+                        
+                        var pix = this.el.create_row_drag_icon ( path);
+                        
+                        Gtk.drag_set_icon_pixmap (ctx,
+                            pix.get_colormap(),
+                            pix,
+                            null,
+                            -10,
+                            -10);
+                        
+                        return true;
+                      
+                        
+                    },
+                    
+                    'drag-end' : function ( w,  drag_context, x, y, time, user_data)   
+                    {
+                        // i'm not sure if this would work, without implementing the whole kaboodle.
+                        Seed.print('LEFT-TREE: drag-end');
+                        this.el.dragData = false;
+                        this.el.dropList = false;
+                        this.targetData = false;
+                        LeftTree.get('view').highlight(false);
+                        return true;
+                      
+                      
+                    },
+                    'drag-motion' : function (w, ctx,  x,   y,   time, ud) 
+                    {
+                        
+                        console.log("LEFT-TREE: drag-motion - " + ctx.actions);
+                        var src = Gtk.drag_get_source_widget(ctx);
+                        
+                        // a drag from  elsewhere...- prevent drop..
+                        if (!src.dragData) {
+                            print("no drag data!");
+                            Gdk.drag_status(ctx, 0, time);
+                            this.targetData = false;
+                            return true;
+                        }
+                        var action = Gdk.DragAction.COPY;
+                        if (src == this.el) {
+                             
+                            // unless we are copying!!! ctl button..
+                            action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
+                        }
+                        var data = {};
+                        print("GETTING POS");
+                        var isOver = LeftTree.get('view').el.get_dest_row_at_pos(x,y, data);
+                        print("ISOVER? " + isOver);
+                        if (!isOver) {
+                            Gdk.drag_status(ctx, 0 ,time);
+                            return false; // not over apoint!?!
+                        }
+                        // drag node is parent of child..
+                        console.log("SRC TREEPATH: " + src.treepath);
+                        console.log("TARGET TREEPATH: " + data.path.to_string());
+                        
+                        // nned to check a  few here..
+                        //Gtk.TreeViewDropPosition.INTO_OR_AFTER
+                        //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
+                        //Gtk.TreeViewDropPosition.AFTER
+                        //Gtk.TreeViewDropPosition.BEFORE
+                        
+                        if (typeof(src.treepath) != 'undefined'  && 
+                            src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
+                            print("subpath drag");
+                             Gdk.drag_status(ctx, 0 ,time);
+                            return false;
+                        }
+                        
+                        // check that 
+                        //print("DUMPING DATA");
+                        //console.dump(data);
+                        // path, pos
+                        
+                        Seed.print(data.path.to_string() +' => '+  data.pos);
+                        var tg = LeftTree.get('model').findDropNodeByPath(
+                            data.path.to_string(), src.dropList, data.pos);
+                            
+                        LeftTree.get('view').highlight(tg);
+                        if (!tg.length) {
+                            print("Can not find drop node path");
+                            this.targetData = false;
+                            Gdk.drag_status(ctx, 0, time);
+                            return true;
+                        }
+                        //console.dump(tg);
+                        this.targetData = tg;    
+                        
+                        
+                        Gdk.drag_status(ctx, action ,time);
+                         
+                        return true;
+                    },
+                    
+                    'drag-drop'  : function (w, ctx, x, y,time, ud) 
+                    {
+                                
+                        Seed.print("TARGET: drag-drop");
+                       
+                        Gtk.drag_get_data
+                        (
+                                w,         /* will receive 'drag-data-received' signal */
+                                ctx,        /* represents the current state of the DnD */
+                                LeftTree.atoms["STRING"],    /* the target type we want */
+                                time            /* time stamp */
+                        );
+                        
+                         
+                        /* No target offered by source => error */
+                       
+
+                        return  true;
+                        
+
+                    },
+                   'drag-data-received' : function (w, ctx,  x,  y, sel_data,  target_type,  time, ud) 
+                    {
+                        Seed.print("Tree: drag-data-received");
+                        delete_selection_data = false;
+                        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);
+                            if (this.targetData) {
+                                if (source != this.el) {
+                                    LeftTree.get('model').dropNode(this.targetData,  source.dragData);
+                                } else {
+                                    // drag around.. - reorder..
+                                    LeftTree.get('model').moveNode(this.targetData, ctx.action);
+                                    
+                                    
+                                }
+                                //Seed.print(this.targetData);
+                              
+                            }
+                            
+                            
+                            
+                            // we can send stuff to souce here...
+
+                            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;
+                    },
+                    
+                    'cursor-changed'  : function(tv, a) {
+                        var iter = new Gtk.TreeIter();
+                        
+                        if (this.selection.count_selected_rows() < 1) {
+                            LeftPanel.get('model').load( false);
+                            MidPropTree.activeElement =  false;
+                            MidPropTree.hideWin();
+                            var RightPalete     = imports.Builder.RightPalete.RightPalete;
+                            var pm = RightPalete.get('model');
+                            if (!LeftTree.getPaleteProvider()) {
+                                // it may not be loaded yet..
+                                return  true;
+                            }
+                            pm.load( LeftTree.getPaleteProvider().gatherList(
+                                LeftTree.get('model').listAllTypes()));
+                           
+                            return true;
+                        }
+                        
+                        //console.log('changed');
+                        var s = this.selection;
+                        s.get_selected(LeftTree.get('model').el, iter);
+                        
+                        
+                        // var val = "";
+                        value = new GObject.Value('');
+                        LeftTree.get('model').el.get_value(iter, 2, value);
+                        LeftTree.get('model').activeIter = iter;
+                        
+                        var data = JSON.parse(value.value);
+                        MidPropTree.activeElement =  data;
+                        MidPropTree.hideWin();
+                        LeftPanel.get('model').load( data);
+                        
+                        console.log(value.value);
+                       // _g.button.set_label(''+value.get_string());
+                        var RightPalete     = imports.Builder.RightPalete.RightPalete;
+                        var pm = RightPalete.get('model');
+                        pm.load( RightPalete.provider.gatherList(
+                            LeftTree.get('model').listAllTypes()));
+                       
+                        
+                       
+                       
+                        //Seed.print( value.get_string());
+                        return true;
+                        
+                        
+                    
+                    }
+                },
+                
+                items  : [
+                    {
+                        id : 'model',
+                        pack : ['set_model'],
+                        
+                        
+                        xtype: Gtk.TreeStore,
+                         
+                        init : function() {
+                            XObject.prototype.init.call(this); 
+                 
+                            
+                            this.el.set_column_types ( 3, [
+                                                    GObject.TYPE_STRING, // title 
+                                                    GObject.TYPE_STRING, // tip
+                                                    GObject.TYPE_STRING // source..
+                                                    ] );
+                            
+                            //if (LeftProjectTree.project).getProvider()
+                            
+                           
+                        },
+                        activeIter : false,
+                        
+                        
+                        changed : function( n, refresh) 
+                        {
+                            print("MODEL CHANGED CALLED" + this.activeIter);
+                            if (this.activeIter) {
+                                    
+                                this.el.set_value(this.activeIter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
+                                this.el.set_value(this.activeIter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
+                                
+                                this.el.set_value(this.activeIter, 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?!");
+                                LeftTree.renderView();
+                                
+                                var RightPalete     = imports.Builder.RightPalete.RightPalete;
+                                var pm = RightPalete.get('model');
+                                if (!RightPalete.provider) {
+                                    pm.load([]);
+                                    return;
+                                }
+                                
+                                
+                                pm.load( RightPalete.provider.gatherList(this.listAllTypes()));
+                                //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
+                            }
+                             
+                        },
+                        
+                        
+                        loadFile : function(f)
+                        {
+                            //console.dump(f);
+                            this.el.clear();
+                            this.file = f;
+                            
+                            if (!f) {
+                                console.log('missing file');
+                                return;
+                            }
+                            
+                            // load the file if not loaded..
+                            if (f.items === false) {
+                                var _this = this;
+                                f.loadItems(function() {
+                                    _this.loadFile(f);
+                                });
+                                return;
+                                
+                            }
+                            if (f.items.length && typeof(f.items[0]) == 'string') {
+                            
+                                RightEditor.el.show();
+                                RightEditor.get('view').load( f.items[0]);
+                                return;
+                            }
+                            print("LOAD");
+                            //console.dump(f.items);
+                            this.load(f.items);
+                            LeftTree.get('view').el.expand_all();
+                            var Window = imports.Builder.Window.Window;
+                            if (!f.items.length) {
+                                // single item..
+                                
+                                Window.get('leftvpaned').el.set_position(80);
+                                // select first...
+                                LeftTree.get('view').el.set_cursor( 
+                                    new  Gtk.TreePath.from_string('0'), null, false);
+                                
+                                
+                            } else {
+                                  Window.get('leftvpaned').el.set_position(200);
+                            }
+                            
+                            
+                            print("hide right editior");
+                            RightEditor.el.hide();
+                            print("set current tree");
+                            this.currentTree = this.toJS(false, false)[0];
+                            //console.dump(this.currentTree);
+                            this.currentTree = this.currentTree || { items: [] };
+                            LeftTree.renderView();
+                            //console.dump(this.map);
+                            var RightPalete     = imports.Builder.RightPalete.RightPalete;
+                            var pm = RightPalete.get('model');
+                            // set up provider..
+                            
+                            RightPalete.provider = LeftTree.getPaleteProvider();
+                            
+                            if (!RightPalete.provider) {
+                                print ("********* PALETE PROVIDER MISSING?!!");
+                            }
+                            LeftTree.renderView();
+                            
+                            pm.load( LeftTree.getPaleteProvider().gatherList(this.listAllTypes()));
+                            
+                            
+                                    
+                            Window.get('view-notebook').el.set_current_page(
+                                LeftTree.get('model').file.getType()== 'Roo' ? 0 : -1);
+                                    
+                            
+                            
+                        },
+                        
+                        findDropNode : function (treepath_str, targets)
+                        {
+                            
+                            
+                            var path = treepath_str.replace(/^builder-/, '');
+                            
+                            if (!XObject.keys(this.treemap).length) {
+                                print("NO KEYS");
+                                return [ '',  Gtk.TreeViewDropPosition.INTO_OR_AFTER];
+                            }
+                            print("FIND treepath: " + path);
+                            //console.dump(this.treemap);
+                            
+                            if (!treepath_str.match(/^builder-/)) {
+                                return []; // nothing!
+                            }
+                            if (targets === true) {
+                                return [ path ];
+                            }
+                            return this.findDropNodeByPath(path,targets) 
+                        },
+                        findDropNodeByPath : function (treepath_str, targets, pref)
+                        {
+                            
+                            var path = treepath_str + ''; // dupe it..
+                            pref = typeof(pref) == 'undefined' ?  Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
+                            var last = false;
+                            //console.dump(this.treemap);
+                            while (path.length) {
+                                print("LOOKING FOR PATH: " + path);
+                                var node_data = this.singleNodeToJS(path);
+                                if (node_data === false) {
+                                    print("node not found");
+                                    return [];
+                                }
+                                
+                                var xname = LeftTree.get('model').file.guessName(node_data);
+                                var match = false;
+                                var prop = '';
+                                targets.forEach(function(tg) {
+                                    if (match) {
+                                        return;;
+                                    }
+                                    if ((tg == xname)  ) {
+                                        match = tg;
+                                    }
+                                    if (tg.indexOf(xname +':') === 0) {
+                                        match = tg;
+                                        prop = tg.split(':').pop();
+                                    }
+                                });
+                                
+                                if (match) {
+                                    if (last) { // pref is after/before..
+                                        // then it's after last
+                                        if (pref > 1) {
+                                            return []; // do not allow..
+                                        }
+                                        return [ last, pref , prop];
+                                        
+                                    }
+                                    return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
+                                }
+                                var par = path.split(':');
+                                last = path;
+                                par.pop();
+                                path = par.join(':');
+                            }
+                            
+                            return [];
+                            
+                            
+                        },
+                        /** 
+                        * drop a node.. - tecncially add node..
+                        * 
+                        * @param {Array} target_data - [ treepath_string,  before/after/ , property (to add as)]
+                        * @param {Object} node with data..
+                        */
+                        
+                        dropNode: function(target_data, node) {
+                            
+                            console.dump(target_data);
+                            var tp = target_data[0].length ? new  Gtk.TreePath.from_string( target_data[0] ) : false;
+                            
+                            print("add where: " + target_data[1]  );
+                            var parent = tp;
+                            var after = false;
+                            if (target_data[1]  < 2) { // before or after..
+                                var ar = target_data[0].split(':');
+                                ar.pop();
+                                parent  = new  Gtk.TreePath.from_string( ar.join(':') );
+                                after = tp;
+                            }
+                            var n_iter = new Gtk.TreeIter();
+                            var iter_par = new Gtk.TreeIter();
+                            var iter_after = after ? new Gtk.TreeIter() : false;
+                            
+                            
+                            
+                            if (parent !== false) {
+                                this.el.get_iter(iter_par, parent);
+                            } else {
+                                iter_par = null;
+                            }
+                            
+                            
+                            if (after) {
+                                Seed.print(target_data[1]  > 0 ? 'insert_after' : 'insert_before');
+                                this.el.get_iter(iter_after, after);
+                                this.el[ target_data[1]  > 0 ? 'insert_after' : 'insert_before'](
+                                        n_iter, iter_par, iter_after);
+                                
+                            } else {
+                                this.el.append(n_iter, iter_par);
+                                
+                            }
+                            
+                            if (typeof(node) == 'string') {
+                                var ar = node.split('.');
+                                var xtype = ar.pop();
+                                
+                                node = {
+                                    '|xns' : ar.join('.'),
+                                    'xtype' : xtype
+                                };
+                                if (target_data.length == 3 && target_data[2].length) {
+                                    node['*prop'] = target_data[2];
+                                }
+                                
+                            }
+                            // work out what kind of packing to use..
+                            if (typeof(node.pack) == 'undefined'  && parent !== false) {
+                                var pal = this.get('/LeftTree').getPaleteProvider();
+                                
+                                var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
+                                print ("PNAME : "  + pname);
+                                var cname = pal.guessName(node);
+                                print ("CNAME : "  + cname);
+                                node.pack = pal.getDefaultPack(pname, cname);
+                                
+                                
+                            }
+                            
+                            
+                            var xitems = [];
+                            if (node.items) {
+                                xitems = node.items;
+                                delete node.items;
+                            }
+                            if (xitems) {
+                                this.load(xitems, n_iter);
+                            }
+                            if (xitems || after) {
+                                LeftTree.get('view').el.expand_row(this.el.get_path(iter_par), true);
+                            }
+                            // wee need to get the empty proptypes from somewhere..
+                            
+                            //var olditer = this.activeIter;
+                            this.activeIter = n_iter;
+                            this.changed(node, true);
+                            
+                            
+                            
+                            LeftTree.get('view').el.set_cursor(this.el.get_path(n_iter), null, false);
+                            
+                            //Builder.MidPropTree._model.load(node);
+                            //Builder.MidPropTree._win.hideWin();
+                            //Builder.LeftPanel._model.load( node);
+                            
+                            
+                            
+                            
+                        },
+                        moveNode: function(target_data , action) {
+                            
+                            //print("MOVE NODE");
+                           // console.dump(target_data);
+                            var old_iter = new Gtk.TreeIter();
+                            var s = LeftTree.get('view').selection;
+                            s.get_selected(this.el, old_iter);
+                            var node = this.nodeToJS(old_iter,false);
+                            //console.dump(node);
+                            
+                            
+                            // needs to drop first, otherwise the target_data 
+                            // treepath will be invalid.
+                            
+                            this.dropNode(target_data, node);
+                            
+                            print("MOVENODE ACTION: " + action);
+                            
+                            if (action & Gdk.DragAction.MOVE) {
+                                print("REMOVING OLD NODE");
+                                this.el.remove(old_iter);
+                                
+                            }
+                            
+                            this.activeIter = false;
+                            this.changed(false,true);
+                            return; // do not remove.
+                            
+                           
+                            
+                            
+                        },
+                        
+                        deleteSelected: function() {
+                            
+                            
+                            
+                            var old_iter = new Gtk.TreeIter();
+                            var s = LeftTree.get('view').selection;
+                            s.get_selected(this.el, old_iter);
+                            s.unselect_all();
+                            
+                            this.el.remove(old_iter);
+                            
+                            // rebuild treemap.
+                            this.map = {};
+                            this.treemap = { };
+                            //this.toJS(null, true) // does not do anything?
+                            this.activeIter = false;
+                            this.changed(false,true);
+                            
+                            
+                            
+                        },    
+                        
+                        
+                        currentTree  : false,
+                         
+                        treemap: false, // map of treepath to nodes.
+                        
+                        listAllTypes : function()
+                        {
+                            
+                            
+                            var s = LeftTree.get('view').selection;
+                            print ("LIST ALL TYPES: " + s.count_selected_rows() );
+                            
+                            if (s.count_selected_rows() > 0) {
+                                var iter = new Gtk.TreeIter();    
+                                s.get_selected(LeftTree.get('model').el, iter);
+
+                                // set some properties of the tree for use by the dropped element.
+                                var value = new GObject.Value('');
+                                LeftTree.get('model').el.get_value(iter, 2, value);
+                                var data = JSON.parse(value.value);
+                                
+                                
+                                var xname = LeftTree.get('model').file.guessName(data);
+                                console.log('selected:' + xname);
+                                if (xname.length) {
+                                    return [ xname ];
+                                }
+                                return []; // could not find it..
+                            }
+                            
+                            var ret = [ ];
+                            
+                            function addall(li)
+                            {
+                                li.forEach(function(el) {
+                                    // this is specific to roo!!!?
+                                    
+                                    var fullpath =  LeftTree.get('model').file.guessName(el);
+                                    if (fullpath.length && ret.indexOf(fullpath) < 0) {
+                                        ret.push(fullpath);
+                                    }
+                                    
+                                    
+                                    if (el.items && el.items.length) {
+                                        addall(el.items);
+                                    }
+                                    
+                                })
+                                
+                                
+                            }
+                            
+                            addall([this.currentTree]);
+                            
+                            // only if we have nothing, should we add '*top'
+                            if (!ret.length) {
+                                ret = [ '*top' ];
+                            }
+                            console.log('all types in tree');
+                            console.dump(ret);
+                            
+                            return ret;
+                            
+                            
+                        },
+                        singleNodeToJS: function (treepath) 
+                        {
+                            var iter = new Gtk.TreeIter(); 
+                            if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
+                                return false;
+                            }
+                            
+                            var iv = this.getValue(iter, 2);
+                           
+                            return JSON.parse(iv);
+                            
+                        },
+                        
+                        /**
+                         * convert tree into a javascript array
+                         * 
+                         */
+                        nodeToJS: function (iter, with_id) 
+                        {
+                            var par = new Gtk.TreeIter(); 
+                            var iv = this.getValue(iter, 2);
+                           // print("IV" + iv);
+                            var k = JSON.parse(iv);
+                            if (k.json && !this.el.iter_parent( par, iter  )) {
+                                delete k.json;
+                            }
+                            
+                            if (with_id) {
+                                var treepath_str = this.el.get_path(iter).to_string();
+                                // not sure how we can handle mixed id stuff..
+                                if (typeof(k.id) == 'undefined')  {
+                                    k.id =  'builder-'+ treepath_str ;
+                                }
+                                
+                               
+                                this.treemap[  treepath_str ] = k;
+                                k.xtreepath = treepath_str ;
+                                
+                            }
+                            if (this.el.iter_has_child(iter)) {
+                                citer = new Gtk.TreeIter();
+                                this.el.iter_children(citer, iter);
+                                k.items = this.toJS(citer,with_id);
+                            }
+                            return k;
+                        },
+                         /**
+                          * iterates through child nodes (or top..)
+                          * 
+                          */
+                        toJS: function(iter, with_id)
+                        {
+                            //Seed.print("WITHID: "+ with_id);
+                            
+                            var first = false;
+                            if (!iter) {
+                                
+                                this.treemap = { }; 
+                                
+                                iter = new Gtk.TreeIter();
+                                if (!this.el.get_iter_first(iter)) {
+                                    return [];
+                                }
+                                first = true;
+                            } 
+                            
+                            var ar = [];
+                               
+                            while (true) {
+                                
+                                var k = this.nodeToJS(iter, with_id); 
+                                ar.push(k);
+                                
+                                
+                                if (!this.el.iter_next(iter)) {
+                                    break;
+                                }
+                            }
+                            
+                            return ar;
+                            // convert the list into a json string..
+                        
+                            
+                        },
+                        getValue: function (iter, col) {
+                            var gval = new GObject.Value('');
+                            this.el.get_value(iter, col ,gval);
+                            return  gval.value;
+                            
+                            
+                        },
+                        
+                        nodeTitle: function(c)
+                        {
+                              
+                            var txt = [];
+                            c = c || {};
+                            var sr = (typeof(c['+buildershow']) != 'undefined') &&  !c['+buildershow'] ? true : false;
+                            if (sr) txt.push('<s>');
+                            if (typeof(c['*prop']) != 'undefined')   { txt.push(c['*prop']+ ':'); }
+                            if (c.xtype)      { txt.push(c.xtype); }
+                            if (c.id)      { txt.push('<b>[id=' + c.id + ']</b>'); }
+                            if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
+                            if (c.boxLabel)   { txt.push('[' + c.boxLabel + ']'); }
+                            
+                            
+                            if (c.layout)     { txt.push('<i>' + c.layout + '</i>'); }
+                            if (c.title)      { txt.push('<b>' + c.title + '</b>'); }
+                            if (c.label)      { txt.push('<b>' + c.label+ '</b>'); }
+                            if (c.header)    { txt.push('<b>' + c.header + '</b>'); }
+                            if (c.legend)      { txt.push('<b>' + c.legend + '</b>'); }
+                            if (c.text)       { txt.push('<b>' + c.text + '</b>'); }
+                            if (c.name)       { txt.push('<b>' + c.name+ '</b>'); }
+                            if (c.region)     { txt.push('<i>(' + c.region + ')</i>'); }
+                            if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
+                            
+                            // for flat classes...
+                            if (typeof(c['*class']) != 'undefined')  { txt.push('<b>' +  c['*class']+  '</b>'); }
+                            if (typeof(c['*extends']) != 'undefined')  { txt.push(': <i>' +  c['*extends']+  '</i>'); }
+                            
+                            
+                            if (sr) txt.push('</s>');
+                            return (txt.length == 0 ? "Element" : txt.join(" "));
+                        
+                      //console.log(n.xtype);
+                           // return n.xtype;
+                        },
+                        
+                        nodeToJSON : function(c) {
+                            var o  = {}
+                            for (var i in c) {
+                                if (i == 'items') {
+                                     continue;
+                                }
+                                o[i] = c[i];
+                            }
+                            return JSON.stringify(o);
+                        },
+                        /**
+                         * load javascript array onto an iter..
+                         * @param tr = array of elements
+                         * @param iter = iter of parent (or null if not..)
+                         */
+                        
+                        
+                         
+                        
+                        load : function(tr,iter)
+                        {
+                            var citer = new Gtk.TreeIter();
+                            //this.insert(citer,iter,0);
+                            for(var i =0 ; i < tr.length; i++) {
+                                if (iter) {
+                                    this.el.insert(citer,iter,-1);
+                                } else {
+                                    this.el.append(citer);
+                                }
+                                
+                                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, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
+                                if (tr[i].items && tr[i].items.length) {
+                                    this.load(tr[i].items, citer);
+                                }
+                            }
+                            
+                            
+                            
+                            
+                        },
+                        
+                        
+                        
+                      //  this.expand_all();
+                    },
+                    
+                      
+                    {
+                        xtype: Gtk.TreeViewColumn,
+                        pack : ['append_column'],
+                        init : function(){
+                            XObject.prototype.init.call(this); 
+                            this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                           
+                        },
+                        items : [
+                            {
+                                
+                                xtype: Gtk.CellRendererText,
+                                pack: [ 'pack_start']
+                                  
+                            } 
+                        ],
+                     
+                      
+                    }
+                    
+               ]
+            }
+        ]
+                
+         
+    }
+);
+    
diff --git a/oldbuilder/LeftTreeMenu.js b/oldbuilder/LeftTreeMenu.js
new file mode 100755 (executable)
index 0000000..1723e6c
--- /dev/null
@@ -0,0 +1,37 @@
+//<Script type="text/javascript">
+Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+LeftTreeMenu = new XObject( 
+    {
+  
+        xtype : Gtk.Menu,
+        
+        
+        items :  [
+            {
+                
+                xtype : Gtk.MenuItem,
+                pack : [ 'append' ],
+                label : "Delete Element",
+                listeners : {
+                    activate : function () {
+                        imports.Builder.LeftTree.LeftTree.get('model').deleteSelected();
+                    }
+                }
+            }
+            // on our web version, a pulldown with the list of potential items appears...
+            // our palete should handle this.. really.
+         
+        ]
+    
+    
+    }
+);
\ No newline at end of file
diff --git a/oldbuilder/MidPropTree.js b/oldbuilder/MidPropTree.js
new file mode 100755 (executable)
index 0000000..9c93633
--- /dev/null
@@ -0,0 +1,273 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+
+
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+Roo             = imports.Builder.Provider.Palete.Roo.Roo;
+
+
+
+/**
+ * 
+ * Properties and events tree - that hides and shows when you press buttons on the left....
+ * 
+ */
+MidPropTree = new XObject({
+         
+        
+        xtype: Gtk.ScrolledWindow,
+        smooth_scroll : true,
+        pack : [ 'pack_end', false, true, 0 ],
+        
+        activeElement : false, // used by left tree to set what list to show.  
+        shadow_type :  Gtk.ShadowType.IN,
+        init : function() {
+            XObject.prototype.init.call(this); 
+            this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+            this.el.set_size_request ( 150, -1 );
+            this.shown = true;
+        },
+        
+        hideWin : function() {
+            
+            if (!this.shown) {
+                return;
+            }
+            
+            var Window          = imports.Builder.Window.Window;            
+            if (Window.get('left').el.position < 160) {
+                return;
+            }
+            Window.get('left').el.position = Window.get('left').el.position  - 150;
+                
+            this.el.hide();
+            this.shown = false;
+        },
+        items : [
+            {
+                   
+                
+                xtype : Gtk.TreeView,
+                
+                enable_tree_lines :  true,
+                tooltip_column : 2,
+                headers_visible : false,
+                // selection  -- set by init..
+                init : function() {
+                    XObject.prototype.init.call(this); 
+                    
+           
+                    
+                    this.selection = this.el.get_selection();
+                    this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                 
+                
+                    
+                    var description = new Pango.FontDescription.c_new();
+                    description.set_size(8000);
+                    this.el.modify_font(description);
+                    
+                       // this.column.add_attribute(this.column.items[1], "text", 1);
+                        
+                         
+                     
+                  //  this.expand_all();
+                },
+                listeners : {
+                    
+                    'cursor-changed' : function () {
+                        var iter = new Gtk.TreeIter();
+                        
+                        //console.log('changed');
+                        var m = this.get('model');
+                        var s = this.selection;
+                        s.get_selected(m.el, iter);
+                        var tp = m.el.get_path(iter).to_string();
+                        
+                        
+                        // var val = "";
+                        
+                        var key = m.getValue(tp, 0);
+                        
+                        var type = m.getValue(tp, 1);
+                        var skel = m.getValue(tp, 3);
+                        var etype = m.getValue(tp, 5);
+                        
+                        
+                        MidPropTree.hideWin();
+                        var LeftPanel       = imports.Builder.LeftPanel.LeftPanel;
+                        if (type == 'function') {
+                            
+                            if (etype != 'events') {
+                                key = '|' + key;
+                            }
+                            
+                            LeftPanel.get('model').add({
+                                key :  key, 
+                                type : type,
+                                val  : skel,
+                                etype : etype
+                            })  
+                            return;
+                        }
+                        
+                        if (type.indexOf('.') > -1 || 
+                                type == 'boolean') {
+                             key = '|' + key;
+                        }
+                        
+                        LeftPanel.get('model').add( {
+                            key : key, 
+                            type : type,
+                            //skel  : skel,
+                            etype : etype
+                           }) //, skel);
+                        
+                        
+                    }
+                },
+                items : [
+                
+                    {
+                        id : 'model',
+                        pack : [ 'set_model' ],
+                        xtype : Gtk.ListStore,
+                        currentData : false,
+                        init : function() {
+                            XObject.prototype.init.call(this); 
+                            this.el.set_column_types ( 6, [
+                                GObject.TYPE_STRING,  // real key
+                                 GObject.TYPE_STRING, // real type
+                                 GObject.TYPE_STRING, // docs ?
+                                 GObject.TYPE_STRING, // visable desc
+                                 GObject.TYPE_STRING, // function desc
+                                 GObject.TYPE_STRING // element type (event|prop)
+                                
+                            ] );
+                                
+                        },
+                        getValue : function(treepath, col)
+                        {
+                            var tp = new Gtk.TreePath.from_string (treepath);
+                            var iter = new Gtk.TreeIter();
+                            this.el.get_iter (iter, tp);
+                            var value = new GObject.Value('');
+                            this.el.get_value(iter, col, value);
+                            return value.value;
+                            
+                        },
+                        /*
+                        load : function (ar)
+                        {
+                            this.el.clear();
+                            // roo specific..
+                            var LeftTree       = imports.Builder.LeftTree.LeftTree;
+                            var fullpath = LeftTree.get('model').file.guessName(ar);
+                            var palete = LeftTree.getPaleteProvider();
+                            
+                            
+                            this.currentData  = false;
+                            if (!fullpath.length) {
+                                return;
+                            }
+                            palete.getProperties()
+                            
+                            this.currentData = Roo.proplist[fullpath];
+                            
+                             
+                             
+                            
+                        },
+                        
+                        */
+                        
+                        
+                        showData : function (type) 
+                        {
+                            this.el.clear();
+                            if (!MidPropTree.activeElement || !type) {
+                                return; // no active element
+                            }
+                            var LeftTree       = imports.Builder.LeftTree.LeftTree;
+                            var fullpath = LeftTree.get('model').file.guessName(MidPropTree.activeElement);
+                            var palete = LeftTree.getPaleteProvider();
+                            
+                             
+                            
+                            Seed.print('Showing right?');
+                            if (!MidPropTree.shown) {
+                                var Window          = imports.Builder.Window.Window;
+                                Window.get('left').el.position = Window.get('left').el.position  + 150;
+                                MidPropTree.el.show();
+                                MidPropTree.shown = true;
+                            }
+                            
+                            var elementList = palete.getPropertiesFor(fullpath, type);
+                            print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
+                            console.dump(elementList);
+                           
+                            
+                            var iter = new Gtk.TreeIter();
+                            for(var i =0 ; i < elementList.length; i++) {
+                                var p=elementList[i];
+                                this.el.append(iter);
+                              //  console.log( '<b>' + p.name +'</b> ['+p.type+']');
+                                    //GObject.TYPE_STRING,  // real key
+                                    // GObject.TYPE_STRING, // real type
+                                    // GObject.TYPE_STRING, // docs ?
+                                    // GObject.TYPE_STRING // func def?
+                                    
+                                
+                                this.el.set_value(iter, 0, p.name);
+                                this.el.set_value(iter, 1, p.type);
+                                this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
+                                this.el.set_value(iter, 3, p.sig ? p.sig  : '');
+                                this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
+                                this.el.set_value(iter, 5, type);
+                                
+                            }
+                             
+                          
+                            
+                        }
+                         
+                        
+                    },
+                  
+                    
+
+                    {
+                        
+                        xtype: Gtk.TreeViewColumn,
+                        pack : ['append_column'],
+                        init : function() {
+                            XObject.prototype.init.call(this); 
+                 
+                        
+                            this.el.add_attribute(this.items[0].el , 'markup', 4  );
+                        },
+                        items : [
+                            {
+                                xtype : Gtk.CellRendererText,
+                                pack : ['pack_start'],
+                                
+                            }
+                        ]
+                    }
+                ]   
+            }
+        ]    
+            
+    }
+
+);
+    
diff --git a/oldbuilder/RightBrowser.js b/oldbuilder/RightBrowser.js
new file mode 100755 (executable)
index 0000000..0c91972
--- /dev/null
@@ -0,0 +1,300 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+WebKit= imports.gi.WebKit;
+
+/**
+ * The based browser component - draws html/js lib based elements.
+ * 
+ * the API for the rendered HTML goes like this:
+ * 
+ * Builder.render(.... json string ...)
+ * Builder.overPos(" + x +','+ y + ");");  // mouse hovering over this pos.. 
+ * 
+ * 
+ * callbacks are done with.. console.log(
+ *   .. { id : 'xxx' } - highlights an elements
+ *      { width : xx }  = sets the width of the selected element (with id)
+ *      { height: xx }  = sets the width of the selected element (with id)
+ * .. { hover-node : 'xxx' } - response to overPos
+ * 
+ * basic dumping is done with alert();
+ * 
+ * 
+ */
+
+
+XObject = imports.XObject.XObject;
+File = imports.File.File;
+console = imports.console;
+
+LeftTree = imports.Builder.LeftTree.LeftTree ;
+LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+ //console.dump(imports.Builder.LeftTree);
+ //Seed.quit();
+
+RightBrowser = new XObject({
+        xtype : Gtk.VBox,
+       pack : [ 'append_page', new Gtk.Label({ label : "Roo View" })  ],
+        items : [
+        
+            {
+                xtype: Gtk.HBox,
+                pack : [ 'pack_start', false, true, 0 ],
+                items : [       
+                    {
+                        
+                        
+                        xtype: Gtk.Button,
+                        label : 'Dump HTML',
+                         pack : [ 'pack_start', false, false, 0 ],
+                        listeners : {
+                            // pressed...
+                            'button-press-event' : function(w, ev ){
+                                /// dump..
+                                RightBrowser.get('view').el.execute_script(
+                                    "console.log(document.body.innerHTML);");
+                                RightBrowser.get('view').el.execute_script(
+                                    "console.log(Builder.dump(Builder));");   
+                                return true;
+                                // show the MidPropTree..
+                            }
+                          
+                        }
+                    }
+                ]
+            }, 
+            {
+            
+                     
+                renderedData : false, 
+                xtype: Gtk.ScrolledWindow,
+               
+                smooth_scroll : true,
+                shadow_type : Gtk.ShadowType.IN ,
+                init : function() {
+                    XObject.prototype.init.call(this); 
+                     
+                    this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+                },
+                
+                items : [
+                
+                
+                    {
+                        id : 'view',
+                        xtype : WebKit.WebView,
+                        packing : ['add' ],
+                        ready : false,
+                        init : function() {
+                            XObject.prototype.init.call(this); 
+                            // fixme!
+                            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, LeftTree.targetList);
+                            //Gtk.drag_dest_add_text_targets(this.el);
+                        },   
+                        listeners : {
+                            
+                             
+                           
+                            'load-finished' : function() {
+                                if (this.ready) { // dont do it twice!
+                                    return; 
+                                }
+                                this.ready = true;
+                                
+                                this.renderJS(LeftTree.get('model').toJS()[0]);
+                               // this.el.execute_script("alert(document.documentElement.innerHTML);");
+                            },
+                            // we should really use console...
+                            'script-alert' : function(w,s,r) {
+                                Seed.print(r);
+                                return false;
+                                return true;
+                            },
+                            'console-message' : function (a,b,c) {
+                                console.log(b);
+                                if (!b.match(/^\{/)) {
+                                    return false; // do not handle!!! -> later maybe in console..
+                                }
+                                console.log(b);
+                                var val =  JSON.parse(b);
+                                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 = LeftTree.get('model').findDropNode(val['id'], true); 
+                                    if (!tg) {
+                                        return false;
+                                    }
+                                    LeftTree.get('view').selectNode(tg[0]);
+                                    ret  = true;
+                                    
+                                } 
+                                if (ret && typeof(val['set']) != 'undefined') {
+                                    LeftPanel.get('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-leave" : function () {
+                                Seed.print("TARGET: drag-leave");
+                                // stop monitoring of mouse montion in rendering..
+                                return true;
+                            },
+                            '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 (!LeftTree.get('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 = LeftTree.get('model').findDropNode(this.activeNode, src.dropList);
+                                console.dump(tg);
+                                if (!tg.length) {
+                                    Gdk.drag_status(ctx, 0,time);
+                                    LeftTree.get('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);
+                                LeftTree.get('view').highlight(tg);
+                                this.targetData = tg;
+                                // for tree we should handle this...
+                                return true;
+                            },
+                            "drag-drop"  : function (w, ctx,x,y,time, ud) 
+                            {
+                                        
+                                Seed.print("TARGET: drag-drop");
+                                is_valid_drop_site = true;
+                                
+                                 
+                                Gtk.drag_get_data
+                                (
+                                        w,         /* will receive 'drag-data-received' signal */
+                                        ctx,        /* represents the current state of the DnD */
+                                        LeftTree.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) 
+                            {
+                                Seed.print("Browser: drag-data-received");
+                                delete_selection_data = false;
+                                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);
+                                        LeftTree.get('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;
+                            }
+                            
+                           //'line-mark-activated' : line_mark_activated,
+                           
+                            
+                        },
+                        renderJS: function(data) {
+                            this.renderedData = data;
+                            var str = JSON.stringify(data) ;
+                            
+                            if (!this.ready) {
+                                console.log('not loaded yet');
+                            }
+                            Seed.print("RENDER:" + str);
+                            File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
+                            this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
+                        }
+                      
+                    }
+                ]
+            }
+                
+        ]
+    }
+    
+    
+);
+    
diff --git a/oldbuilder/RightEditor.js b/oldbuilder/RightEditor.js
new file mode 100755 (executable)
index 0000000..ff787ae
--- /dev/null
@@ -0,0 +1,107 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GObject = imports.gi.GObject;
+
+Pango = imports.gi.Pango ;
+
+GtkSource = imports.gi.GtkSource;
+
+if (!GtkSource) {
+    Seed.die("Failed to load SourceView");
+}
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+
+RightEditor = new XObject({
+         
+        xtype: Gtk.ScrolledWindow,
+        
+        shadow_type :  Gtk.ShadowType.IN  ,
+        
+        items : [
+            { 
+                id : 'view',
+                xtype : GtkSource.View,
+                
+                init : function() {
+                    XObject.prototype.init.call(this); 
+                    var _this = this;
+                    this.el.set_buffer (new GtkSource.Buffer());
+                    this.el.get_buffer().signal.changed.connect(function() {
+                            var s = new Gtk.TextIter();
+                            var e = new Gtk.TextIter();
+                            _this.el.get_buffer().get_start_iter(s);
+                            _this.el.get_buffer().get_end_iter(e);
+                            var str = _this.el.get_buffer().get_text(s,e,true);
+                            try {
+                                Seed.check_syntax('var e = ' + str);
+                            } catch (e) {
+                                _this.el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
+                                    red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
+                                   }));
+                                print("SYNTAX ERROR IN EDITOR");   
+                                print(e);
+                                console.dump(e);
+                                return;
+                            }
+                            _this.el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
+                                    red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
+                                   }));
+                            
+                            imports.Builder.LeftPanel.LeftPanel.get('model').changed(  str , false);
+                    });
+                   
+                    var description = Pango.Font.description_from_string("monospace")
+                    description.set_size(8000);
+                    this.el.modify_font(description);
+            
+                    
+                      
+                   
+                },
+                
+                load : function(str) {
+                    this.get('/BottomPane').el.set_current_page(0);
+                    this.el.get_buffer().set_text(str, str.length);
+                    var lm = GtkSource.LanguageManager.get_default();
+                    
+                    this.el.get_buffer().set_language(lm.get_language('js'));
+                    var buf = this.el.get_buffer();
+                    var cursor = buf.get_mark("insert");
+                    var iter= new Gtk.TextIter;
+                    buf.get_iter_at_mark(iter, cursor);
+                    iter.set_line(1);
+                    iter.set_line_offset(4);
+                    buf.move_mark(cursor, iter);
+                    
+                    
+                    cursor = buf.get_mark("selection_bound");
+                    iter= new Gtk.TextIter;
+                    buf.get_iter_at_mark(iter, cursor);
+                    iter.set_line(1);
+                    iter.set_line_offset(4);
+                    buf.move_mark(cursor, iter);
+                    
+                    
+                    
+                    this.el.grab_focus();
+                },
+                // neeed???
+                
+                
+                
+            }
+        ]
+    }
+        
+        
+    
+    
+    
+);
+    
diff --git a/oldbuilder/RightGtkView.js b/oldbuilder/RightGtkView.js
new file mode 100755 (executable)
index 0000000..fdd9128
--- /dev/null
@@ -0,0 +1,648 @@
+//<script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GObject = imports.gi.GObject;
+ GLib= imports.gi.GLib;
+
+/**
+* we use a hidden window to render the created dialog...
+* then use snapshot to render it to an image...
+* 
+*/
+
+XObject = imports.XObject.XObject;
+File = imports.File.File;
+console = imports.console;
+
+LeftTree = imports.Builder.LeftTree.LeftTree ;
+LeftPanel = imports.Builder.LeftPanel.LeftPanel;
+ //console.dump(imports.Builder.LeftTree);
+ //Seed.quit();
+
+RightGtkView = new XObject({
+        xtype : Gtk.VBox,
+        lastSrc : '',
+        pack : [ 'append_page', new Gtk.Label({ label : "Gtk View" })  ],
+        items : [
+        
+            {
+                xtype: Gtk.HBox,
+                pack : [ 'pack_start', false, true, 0 ],
+                items : [       
+                    {
+                        
+                        
+                        xtype: Gtk.Button,
+                        label : 'Show in New Window',
+                        pack : [ 'pack_start', false, false, 0 ],
+                        listeners : {
+                            // pressed...
+                            'button-press-event' : function(w, ev ){
+                                /// dump..
+                                RightGtkView.showInWindow();
+                                return true;
+                                // show the MidPropTree..
+                            }
+                          
+                        }
+                    }
+                ]
+            }, 
+            {
+            
+                     
+                renderedData : false, 
+                xtype: Gtk.ScrolledWindow,
+                id: 'view-sw',
+                smooth_scroll : true,
+                shadow_type : Gtk.ShadowType.IN ,
+                init : function() {
+                    XObject.prototype.init.call(this); 
+                     
+                    this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+                },
+                
+                items : [
+                    {
+                        
+                        id : 'view-vbox',
+                        xtype : Gtk.Fixed,
+                        init : function () {
+                            XObject.prototype.init.call(this); 
+                        },
+                        pack  : 'add_with_viewport' ,
+                        items: [
+                            {
+                                id : 'view',
+                                xtype : Gtk.VBox,
+                                /*
+                                xtype : function() {
+                                    return new Gtk.Image.from_stock (Gtk.STOCK_HOME, 100) 
+
+                                },
+                                */
+                                pack : 'put,10,10',
+                                ready : false,
+                                init : function() {
+                                    XObject.prototype.init.call(this); 
+                                    // fixme!
+                                   
+                                    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, LeftTree.targetList);
+                                    //Gtk.drag_dest_add_text_targets(this.el);
+                                },   
+                                listeners : {
+                                    
+                                      
+                                    
+                                    "drag-leave" : function () {
+                                        Seed.print("TARGET: drag-leave");
+                                        // stop monitoring of mouse montion in rendering..
+                                        return true;
+                                    },
+                                    'drag-motion' : function (w, ctx,  x,   y,   time, ud) 
+                                    {
+                                        
+                                    
+                                       // console.log('DRAG MOTION'); 
+                                        // status:
+                                        // if lastCurrentNode == this.currentNode.. -- don't change anything..
+                                         
+                                        
+                                        // 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 (!LeftTree.get('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 = LeftTree.get('model').findDropNode(activeNode, src.dropList);
+                                        console.dump(tg);
+                                        if (!tg.length) {
+                                            Gdk.drag_status(ctx, 0,time);
+                                            LeftTree.get('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);
+                                        LeftTree.get('view').highlight(tg);
+                                        this.targetData = tg;
+                                        // for tree we should handle this...
+                                        return true;
+                                        
+                                    },
+                                    "drag-drop"  : function (w, ctx,x,y,time, ud) 
+                                    {
+                                                
+                                        Seed.print("TARGET: drag-drop");
+                                        is_valid_drop_site = true;
+                                        
+                                         
+                                        Gtk.drag_get_data
+                                        (
+                                                w,         /* will receive 'drag-data-received' signal */
+                                                ctx,        /* represents the current state of the DnD */
+                                                LeftTree.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) 
+                                    {
+                                        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);
+                                                LeftTree.get('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;
+                                    }
+                                    
+                                   //'line-mark-activated' : line_mark_activated,
+                                   
+                                    
+                                },
+                                 
+                                getActiveNode : function(x,y)
+                                {
+                                   // workout what node is here..
+                                    return '0'; // top..
+                                }
+                            }
+                        ]
+                    }
+                ]
+            }
+                
+        ],
+        
+        showInWindow: function ()
+        {
+            
+            
+            var src= this.buildJS(this.get('/LeftTree.model').toJS()[0], true);
+            
+            
+            this.get('/Terminal').feed("Running\n");
+            
+            //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");
+                    }
+                    
+                }
+                
+                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);
+            //'/usr/bin/seed',  [ '/tmp/BuilderGtkView.js'], [], "/tmp", false,false,false);
+            /*
+            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);
+            }
+            */
+        },
+        
+        buildJS: function(data,withDebug) 
+        {
+            var i = [ 'Gtk', 'Gdk', 'Pango', 'GLib', 'Gio', 'GObject', 'GtkSource', 'WebKit', 'Vte' ];
+            var src = "";
+            i.forEach(function(e) {
+                src += e+" = imports.gi." + e +";\n";
+            });
+            
+            if (withDebug) {
+               src+= "imports.searchPath.push(" + JSON.stringify(GLib.path_get_dirname(__script_path__)) + ");\n";
+            }
+            
+            src += "console = imports.console;\n"; // path?!!?
+            src += "XObject = imports.XObject.XObject;\n"; // path?!!?
+            src += "XObject.cache = {};\n"; // reset cache!
+            if (withDebug) {
+                
+                
+                
+                src += "Gtk.init(null,null);\n"; 
+            }
+            if (withDebug) {
+                src += "XObject.debug=true;\n"; 
+            }
+            
+            this.withDebug = withDebug;
+            src += '_top=new XObject('+ this.mungeToString(data) + ')\n;';
+            src += '_top.init();\n';
+            if (withDebug) {
+                src += "_top.el.show_all();\n"; 
+                src += "Gtk.main();\n"; 
+            }
+            File.write('/tmp/BuilderGtkView.js', src);
+            print("Test code  in /tmp/BuilderGtkView.js");
+            this.lastSrc = src;
+            return src;
+        },
+        
+        renderJS : function(data, withDebug)
+        {
+            // can we mess with data?!?!?
+            
+            /**
+             * first effort..
+             * sandbox it? - nope then will have dificulting passing. stuff aruond..
+             * 
+             */
+            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..
+            this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
+            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();
+            
+            return;
+            
+            
+            var src = this.buildJS(data,withDebug);
+            var x = new imports.sandbox.Context();
+            x.add_globals();
+            //x.get_global_object().a = "hello world";
+            
+            try {
+                Seed.check_syntax('var e = ' + src);
+                x.eval(src);
+            } catch( e) {
+                //if (!withDebug) {
+                //   return this.renderJS(data,true);
+               // }
+                print(e.message || e.toString());
+                console.dump(e);
+                return;
+            }
+            
+            var r = new Gdk.Rectangle();
+            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);
+            }
+            
+            
+            
+            var pb = _top.items[0].el.get_snapshot(r);
+            _top.el.hide();
+            if (!pb) {
+                return;
+            }
+            
+            _top.el.destroy();
+            x._top = false;
+            var Window = imports.Builder.Window.Window;
+            var gc = new Gdk.GC.c_new(Window.el.window);
+                
+                // 10 points all round..
+            var full = new Gdk.Pixmap.c_new (Window.el.window, r.width+20, r.height+20, pb.get_depth());
+            // draw a white background..
+           // gc.set_rgb_fg_color({ red: 0, white: 0, black : 0 });
+            Gdk.draw_rectangle(full, gc, true, 0, 0, r.width+20, r.height+20);
+            // paint image..
+            Gdk.draw_drawable (full, gc, pb, 0, 0, 10, 10, r.width, r.height);
+            // boxes..
+            //gc.set_rgb_fg_color({ red: 255, white: 255, black : 255 });
+            Gdk.draw_rectangle(full, gc, true, 0, 0, 10, 10);
+            this.get('view').el.set_from_pixmap(full, null);
+            //this.get('view-vbox').el.set_size_request( r.width+20, r.height+20);
+            //var img = new Gtk.Image.from_file("/home/alan/solarpanels.jpeg");
+            
+            
+            
+        },
+        mungeToString:  function(obj, isListener, pad)
+        {
+            pad = pad || '';
+            var keys = [];
+            var isArray = false;
+            isListener = isListener || false;
+             
+            // am I munging a object or array...
+            if (obj.constructor.toString() === Array.toString()) {
+                for (var i= 0; i < obj.length; i++) {
+                    keys.push(i);
+                }
+                isArray = true;
+            } else {
+                for (var i in obj) {
+                    keys.push(i);
+                }
+            }
+            
+            
+            var els = []; 
+            var skip = [];
+            if (!isArray && 
+                    typeof(obj['|xns']) != 'undefined' &&
+                    typeof(obj['xtype']) != 'undefined'
+                ) {
+                    els.push('xtype: '+ obj['|xns'] + '.' + obj['xtype']);
+                    skip.push('|xns','xtype');
+                }
+            
+            var _this = this;
+            
+            
+            
+            keys.forEach(function(i) {
+                var el = obj[i];
+                if (!isArray && skip.indexOf(i) > -1) {
+                    return;
+                }
+                if (isListener) {
+                    if (!_this.withDebug) {
+                        // do not write listeners unless we are debug mode.
+                        return;
+                    }
+                    //if (obj[i].match(new RegExp("Gtk.main" + "_quit"))) { // we can not handle this very well..
+                    //    return;
+                   // }
+                    var str= ('' + obj[i]).replace(/^\s+|\s+$/g,"");
+                    var lines = str.split("\n");
+                    if (lines.length > 1) {
+                        str = lines.join("\n" + pad);
+                    }
+                    els.push(JSON.stringify(i) + ":" + str);
+                    return;
+                }
+                if (i[0] == '|') {
+                    // does not hapepnd with arrays..
+                    if (typeof(el) == 'string' && !obj[i].length) { //skip empty.
+                        return;
+                    }
+                    // this needs to go...
+                    //if (typeof(el) == 'string'  && obj[i].match(new RegExp("Gtk.main" + "_quit"))) { // we can not handle this very well..
+                    //    return;
+                    //}
+                    
+                    var str= ('' + obj[i]).replace(/^\s+|\s+$/g,"");;
+                    var lines = str.split("\n");
+                    if (lines.length > 1) {
+                        str = lines.join("\n" + pad);
+                    }
+                    
+                    els.push(JSON.stringify(i.substring(1)) + ":" + str);
+                    return;
+                }
+                var left = isArray ? '' : (JSON.stringify(i) + " : " )
+                if (typeof(el) == 'object') {
+                    els.push(left + _this.mungeToString(el, i == 'listeners', pad + '    '));
+                    return;
+                }
+                els.push(JSON.stringify(i) + ":" + JSON.stringify(obj[i]));
+            });
+            var spad = pad.substring(0, pad.length-4);
+            return (isArray ? '[' : '{') + "\n" +
+                pad  + els.join(",\n" + pad ) + 
+                "\n" + spad + (isArray ? ']' : '}');
+               
+            
+            
+        },
+        
+        buildView : function()
+        {
+            
+            
+        },
+        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;
+                }
+                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') {
+                Seed.print('pack method not available : ' + item.xtype + '.' +  pack_m);
+                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 ));
+            } 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)
+        {
+            print("WIDGET PRESs" + d.xtreepath ); 
+            
+            return false;
+        }
+        
+        
+        
+    } 
+    
+    
+);
+    
diff --git a/oldbuilder/RightPalete.js b/oldbuilder/RightPalete.js
new file mode 100755 (executable)
index 0000000..726e08b
--- /dev/null
@@ -0,0 +1,410 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+GObject = imports.gi.GObject;
+Pango = imports.gi.Pango ;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+LeftTree =   imports.Builder.LeftTree.LeftTree;
+Roo = imports.Builder.Provider.Palete.Roo.Roo;
+// normally appears as a vbox with a expander button,
+// when you put your mouse over though, it expands.
+
+RightPalete = new XObject({
+         
+        
+        xtype: Gtk.VBox,
+        pack : [ 'pack_start', false, false ],
+        
+        hide : function() {
+            this.get('hidden').el.show();
+            this.get('visible').el.hide();
+        },
+        show : function() {
+            this.get('hidden').el.hide();
+            this.get('visible').el.show();
+            this.get('model').expanded();
+            
+        },
+        provider : false,
+        
+        items : [
+            {
+                    
+                id : 'hidden',
+                xtype: Gtk.VBox,
+                 
+                items : [
+                
+                
+                    {
+                        
+                        xtype: Gtk.Button,
+                        pack : [ 'pack_start', false, true ],
+                        listeners : {
+                            clicked : function() {
+                                RightPalete.show();
+                            }
+                        },
+                        items : [
+                            {
+                                
+                                xtype: Gtk.Image,
+                                
+                                stock : Gtk.STOCK_GOTO_FIRST,
+                                'icon-size' : Gtk.IconSize.MENU,
+                                pack : ['add']
+                            }
+                        ]
+                    },
+                    {
+                        pack : [ 'pack_start', true, true ],
+                        
+                        xtype: Gtk.Label,
+                        label: 'Palete',
+                        angle : 270,
+                        init : function() {
+                            XObject.prototype.init.call(this);  
+                            this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
+                        },
+                        listeners : {
+                            'enter-notify-event' : function (w,e)
+                            {
+                                RightPalete.show();
+                                //console.log("enter!");
+                                //this.el.expanded = !this.el.expanded;
+                                //this.listeners.activate.call(this);
+                                return true;
+                            }
+                        }
+                    }
+                ]
+            },
+            
+            {
+                    
+                id : 'visible',
+                xtype: Gtk.VBox,
+                
+                items : [         
+                    {
+                        
+                        
+                        xtype: Gtk.HBox,
+                        pack : [ 'pack_start', false, true ],
+                        items : [
+                            {
+                                 
+                                
+                                xtype: Gtk.Label,
+                                label: "Palete"
+                             
+                            },
+                            {
+                                
+                                xtype: Gtk.Button,
+                                pack : [ 'pack_start', false, true ],
+                                listeners : {
+                                    clicked : function() {
+                                        RightPalete.hide();
+                                    }
+                                },
+                                items : [
+                                    {
+                                        
+                                        xtype: Gtk.Image,
+                                        stock : Gtk.STOCK_GOTO_LAST,
+                                        'icon-size' : Gtk.IconSize.MENU,
+                                
+                                        // open arrow...
+                                    }
+                                ]
+                            }
+                        ]
+                    },
+                    
+                    // expandable here...( show all.. )
+                    
+                                // our pallete goes here...
+            // two trees technically...
+            
+                    
+                    {
+                
+                        
+                        xtype: Gtk.ScrolledWindow,
+                        smooth_scroll : true,
+                        shadow_type :  Gtk.ShadowType.IN ,
+                        
+                        init : function() {
+                            XObject.prototype.init.call(this);  
+                       
+                            this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+                            this.el.set_size_request(-1,200);
+                        },
+                        items : [        
+                            {
+                                
+                                    
+                                id : 'view',
+                                xtype : Gtk.TreeView,
+                                headers_visible :  false,
+                                enable_tree_lines :  true ,
+                                tooltip_column : 1,
+                                init : function() {
+                                    XObject.prototype.init.call(this);  
+                                    this.el.set_size_request(150,-1);
+                                  //  set_reorderable: [1]
+                                  
+                                    var description = new Pango.FontDescription.c_new();
+                                    description.set_size(8000);
+                                    this.el.modify_font(description);
+                                    
+                                    this.selection = this.el.get_selection();
+                                    this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                                   // this.selection.signal['changed'].connect(function() {
+                                    //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
+                                    //});
+                                    // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
+                                     
+                                    Gtk.drag_source_set (
+                                            this.el,            /* widget will be drag-able */
+                                            Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */
+                                            null,            /* lists of target to support */
+                                            0,              /* size of list */
+                                            Gdk.DragAction.COPY         /* what to do with data after dropped */
+                                    );
+                                    Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
+                                    /*
+                                    print("RP: TARGET:" + LeftTree.atoms["STRING"]);
+                                    targets = new Gtk.TargetList();
+                                    targets.add( LeftTree.atoms["STRING"], 0, 0);
+                                    targets.add_text_targets( 1 );
+                                    Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
+                                    
+                                    //if you want to allow text to be output elsewhere..
+                                    //Gtk.drag_source_add_text_targets(this.el);
+                                    */
+                                    return true; 
+                                },  
+                                listeners : {
+                                    
+                              
+                                    'drag-data-get' : function (w, ctx, selection_data, target_type,  time, ud) 
+                                    {
+                                        
+                                        Seed.print('Palete: drag-data-get: ' + target_type);
+                                        if (this.el.dragData && this.el.dragData.length ) {
+                                            selection_data.set_text(this.el.dragData ,this.el.dragData.length);
+                                        }
+                                        
+                                        
+                                        //this.el.dragData = "TEST from source widget";
+                                        
+                                        
+                                        
+                                        return true;
+                                    },
+                                   
+                                    'drag-begin' : function (w, ctx, ud) 
+                                    {
+                                        // we could fill this in now...
+                                        Seed.print('SOURCE: drag-begin');
+                                        
+                                        
+                                        
+                                        var iter = new Gtk.TreeIter();
+                                        var s = this.selection;
+                                        s.get_selected(RightPalete.get('model').el, iter);
+                                        var path = RightPalete.get('model').el.get_path(iter);
+                                        
+                                        var pix = this.el.create_row_drag_icon ( path);
+                                            
+                                                
+                                        Gtk.drag_set_icon_pixmap (ctx,
+                                            pix.get_colormap(),
+                                            pix,
+                                            null,
+                                            -10,
+                                            -10);
+                                        
+                                        var value = new GObject.Value('');
+                                        RightPalete.get('model').el.get_value(iter, 0, value);
+                                        if (!RightPalete.provider) {
+                                            return false;
+                                        }
+                                        this.el.dropList = RightPalete.provider.getDropList(value.value);
+                                        this.el.dragData = value.value;
+                                        
+                                        
+                                        
+                                        
+                                        return true;
+                                    },
+                                    'drag-end' : function () 
+                                    {
+                                        Seed.print('SOURCE: drag-end');
+                                        this.el.dragData = false;
+                                        this.el.dropList = false;
+                                        LeftTree.get('view').highlight(false);
+                                        return true;
+                                    },
+                                    
+                                    /*
+                                    'cursor-changed'  : function(tv, a) { 
+                                        //select -- should save existing...
+                                        var iter = new Gtk.TreeIter();
+                                        
+                                        if (this.selection.count_selected_rows() < 1) {
+                                            
+                                            Builder.LeftTree._model.load( false);
+                                            
+                                            return;
+                                        }
+                                        
+                                        //console.log('changed');
+                                        var s = this.selection;
+                                        s.get_selected(_model, iter);
+                                        value = new GObject.Value('');
+                                        _model.el.get_value(iter, 2, value);
+                                        
+                                        console.log(value.value);
+                                        var file = _model.project.get(value.value);
+                                        
+                                        
+                                        console.log(file);
+                                        _expander.el.set_expanded(false);
+
+                                        Builder.LeftTree._model.loadFile(file);
+                                        
+                                        return true;
+                                        
+                                        
+                                    
+                                    }
+                                    */
+                                },
+                                
+                                items  : [
+                                    {
+                                        pack : ['set_model'],
+                                        
+                                        id : 'model',
+                                        xtype : Gtk.ListStore,
+                                         
+                                        init  :  function()
+                                        {
+                                           
+                                           XObject.prototype.init.call(this);  
+                                 
+                                            
+                                            
+                                            
+                                            this.el.set_column_types ( 2, [
+                                                    GObject.TYPE_STRING, // title 
+                                                    GObject.TYPE_STRING // tip
+                                                    
+                                                    ] );
+                                             
+                                              
+                                            
+                                        },
+                                        expanded : function() // event handler realy.
+                                        {
+                                            // should ask tree for list of current compeents.
+                                            
+                                            //console.dump(this.provider);
+                                            //var li = this.provider.gatherList([]);
+                                            //console.dump(li);
+                                            //this.load( this.provider.gatherList([]));
+                                            
+                                            
+                                            
+                                            
+                                        },
+                                        
+                                        load : function(tr,iter)
+                                        {
+                                            if (!iter) {
+                                                this.el.clear();
+                                            }
+                                            //console.log('Project tree load: ' + tr.length);
+                                            var citer = new Gtk.TreeIter();
+                                            //this.insert(citer,iter,0);
+                                            for(var i =0 ; i < tr.length; i++) {
+                                                if (!iter) {
+                                                    
+                                                    this.el.append(citer);   
+                                                } else {
+                                                    this.el.insert(citer,iter,-1);
+                                                }
+                                                
+                                                var r = tr[i];
+                                                //Seed.print(r);
+                                                this.el.set_value(citer, 0,  '' +  r ); // title 
+                                                
+                                                //this.el.set_value(citer, 1,  new GObject.Value( r)); //id
+                                                //if (r.cn && r.cn.length) {
+                                                //    this.load(r.cn, citer);
+                                                //}
+                                            }
+                                            
+                                            
+                                        },
+                                        
+                                        
+                                        
+                                        
+                                        getValue: function (iter, col) {
+                                            var gval = new GObject.Value('');
+                                             this.el.get_value(iter, col ,gval);
+                                            return  gval.value;
+                                            
+                                            
+                                        }
+                                        
+                                        
+                                        
+                                      //  this.expand_all();
+                                    },
+                                    
+                                      
+                                    {
+                                        pack : ['append_column'],
+                                        
+                                        xtype : Gtk.TreeViewColumn,
+                                        init  :  function()
+                                        {
+                                           
+                                            XObject.prototype.init.call(this);  
+                                            this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                        },
+
+                                        items : [
+                                            {
+                                                
+                                                xtype : Gtk.CellRendererText,
+                                                pack: [ 'pack_start']
+                                                  
+                                            } 
+                                        ]
+                                        
+                                    
+                                      
+                                    }
+                                    
+                               ]
+                            }
+                        ]
+                    }
+                ]
+
+            }
+        ]
+            
+    }
+)
\ No newline at end of file
diff --git a/oldbuilder/StandardErrorDialog.js b/oldbuilder/StandardErrorDialog.js
new file mode 100755 (executable)
index 0000000..5dccb46
--- /dev/null
@@ -0,0 +1,60 @@
+//<Script type="text/javascript">
+
+Gtk = imports.gi.Gtk;
+GObject = imports.gi.GObject;
+Gio = imports.gi.Gio;
+GLib = imports.gi.GLib;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+
+
+/**
+ * add a component
+ * 
+ * basically uses a standard template ? pulled from the web?
+ * 
+ * you have to pick which template, and give it a name..
+ * 
+ * and pick which directory to put it in?
+ * 
+ */
+
+
+StandardErrorDialog = new XObject({
+    
+    
+    
+    xtype : function () {
+        return new Gtk.MessageDialog({ buttons : Gtk.ButtonsType.OK });
+            
+    },
+    modal : true,
+    
+    'message-type' : Gtk.MessageType.ERROR,
+    //"secondary-text"           gchar*                : Read / Write
+    //"secondary-use-markup"     gboolean              : Read / Write
+    text   : "FIXME",
+    "use-markup"     : true,
+    
+    show : function(msg)
+    {
+        if (!this.el) {
+            this.init();
+        }
+        this.el.text =  msg;
+        this.el.show_all();
+    },
+    
+    listeners :  {
+        'delete-event' : function (widget, event) {
+            this.el.hide();
+            return true;
+        },
+        
+        response : function () {
+            this.el.hide();
+        }
+    }
+});
\ No newline at end of file
diff --git a/oldbuilder/TopMenu.js b/oldbuilder/TopMenu.js
new file mode 100755 (executable)
index 0000000..0746596
--- /dev/null
@@ -0,0 +1,127 @@
+//<Script type="text/javascript">
+Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+
+XObject = imports.XObject.XObject;
+console = imports.console;
+TopMenu = new XObject({
+    id : 'TopMenu',
+    xtype : Gtk.MenuBar,
+    pack : [ 'pack_start', false,false ],
+    id : 'menu', 
+    items :  [
+        {
+            
+            xtype: Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'File',
+            
+            items : [
+                {
+                    
+                    xtype : Gtk.Menu,
+                    pack : [ 'set_submenu' ],
+                    items : [
+                      {
+            
+                            
+                            xtype : Gtk.MenuItem,
+                            pack : [ 'append' ],
+                            label : "New Project (from directory)",
+                            listeners : {
+                                activate : function () {
+                                    
+                                }
+                            }
+                        },
+                        {
+            
+                            
+                            xtype : Gtk.MenuItem,
+                            pack : [ 'append' ],
+                            label : 'Open Project File',
+                            listeners : {
+                                activate : function () {
+                                    
+                                }
+                            }
+                        },
+                        {
+            
+                            
+                            xtype : Gtk.MenuItem,
+                            pack : [ 'append' ],
+                            label : 'Recent (with submenu)',
+                            listeners : {
+                                activate : function () {
+                                    
+                                }
+                            }
+                        },
+                        
+                          {
+        
+                            
+                            xtype : Gtk.SeparatorMenuItem,
+                            pack : [ 'append' ] 
+                             
+                        },
+                        
+                        {
+            
+                            
+                            xtype : Gtk.MenuItem,
+                            pack : [ 'append' ],
+                            label : "Test Loader",
+                            listeners : {
+                                activate : function () {
+                                    
+                                    
+                                    
+                                    
+                                }
+                            }
+                        },
+                        
+                          {
+        
+                            
+                            xtype : Gtk.SeparatorMenuItem,
+                            pack : [ 'append' ] 
+                             
+                        },
+                        {
+            
+                            
+                            xtype : Gtk.MenuItem,
+                            pack : [ 'append' ],
+                            label : 'Quit',
+                            listeners : {
+                                activate : function () {
+                                    Seed.quit();
+                                }
+                            }
+                        },
+                    ]
+                }
+            ]
+        },
+    
+        {
+            
+            
+            xtype : Gtk.MenuItem,
+            pack : [ 'append' ],
+            label : 'Settings',
+            listeners : {
+                activate : function () {
+                    
+                }
+            }
+        } 
+    ]
+});
\ No newline at end of file
diff --git a/oldbuilder/Window.js b/oldbuilder/Window.js
new file mode 100755 (executable)
index 0000000..c1bdd40
--- /dev/null
@@ -0,0 +1,197 @@
+//<Script type="text/javascript">
+
+Gtk = imports.gi.Gtk;
+Vte = imports.gi.Vte;
+// core libs
+XObject = imports.XObject.XObject;
+console = imports.console;
+
+// components.
+TopMenu         = imports.Builder.TopMenu.TopMenu;
+LeftTopPanel    = imports.Builder.LeftTopPanel.LeftTopPanel;
+LeftProps       = imports.Builder.LeftProps.LeftProps;
+LeftPanel       = imports.Builder.LeftPanel.LeftPanel;
+MidPropTree     = imports.Builder.MidPropTree.MidPropTree;
+RightBrowser    = imports.Builder.RightBrowser.RightBrowser;
+RightGtkView    = imports.Builder.RightGtkView.RightGtkView;
+RightEditor     = imports.Builder.RightEditor.RightEditor;
+RightPalete     = imports.Builder.RightPalete.RightPalete;
+// concept:
+/**
+ * 
+ * left - tree + props
+ * right - top = preview - webkit?
+ * right - bottom = soruceview
+ * 
+ * Palete... as toolbar??? - changes depending on what you pick?
+ * 
+ * Not sure how to do Gtk version.. - our preview might be fun... = probably have to do a gtkhbox.. or something..
+ * 
+ */
+  
+//print('window loaded');
+
+Window = new XObject({
+    
+    id: 'Builder.Window',
+    
+    xtype : function() {
+        return new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
+    },
+    
+    //type: Gtk.WindowType.TOPLEVEL,
+    title : "Application Builder",
+    border_width : 0,
+    
+    init : function()
+    {
+        XObject.prototype.init.call(this); 
+        
+        this.el.show_all();
+        MidPropTree.hideWin();
+        RightPalete.hide();
+        
+        this.el.set_default_size(900, 600);
+        
+    },
+    
+    listeners : {
+        'delete-event' : function (widget, event) {
+            return false;
+        },
+        destroy  : function (widget) {
+            Gtk.main_quit();
+        },
+         
+    },
+    
+        
+    items : [
+        {
+            xtype : Gtk.VBox,
+            id: 'w-vbox',
+            items : [
+                TopMenu,
+                {
+                    id : 'left',
+                    xtype : Gtk.HPaned,
+                    position : 400,
+                    items : [
+                        {
+                            xtype : Gtk.HBox,
+                            items : [
+                                {
+                                    id : 'leftvpaned',
+                                    xtype : Gtk.VPaned,
+                                    position : 300,
+                                    items : [
+                                        LeftTopPanel,
+                                        {
+                                            xtype: Gtk.VBox,
+                                            items : [
+                                                {
+                            
+                                                    xtype : Gtk.HBox,
+                                                    pack : [ 'pack_start', false, true, 0 ],
+                                                    items : [  
+                                                        LeftProps 
+                                                    ]
+                                                },
+                                                LeftPanel
+                                                
+                                            ]
+                                        }
+                                        
+                                    ]
+                                },
+                                MidPropTree
+                                
+                            ]
+                        },
+                                
+                        {
+                            xtype : Gtk.HBox,
+                            items : [
+                                {
+                                    xtype : Gtk.VPaned,
+                                    position :  300,
+                                    items : [
+                                        {
+                                            xtype : Gtk.VBox,
+                                            items : [
+                                            
+                                                {
+                                                    id : 'view-notebook',
+                                                    xtype : Gtk.Notebook,
+                                                    show_tabs : false,
+                                                    tab_border : 0,
+                                                    pack : ['pack_start', true,true],
+                                                    init : function()
+                                                    {
+                                                        XObject.prototype.init.call(this); 
+                                                        this.el.set_current_page(0);
+                                                    },
+                                                    items : [
+                                                       RightBrowser,
+                                                       RightGtkView,
+                                                    ]
+                                                } 
+                                            
+                                            
+                                                
+                                            ]
+                                        },
+                                        
+                                        
+                                        {
+                                            xtype: Gtk.Notebook,
+                                            "pack":"add",
+                                            "id" : "BottomPane",
+                                            "init":function() {
+                                                XObject.prototype.init.call(this);
+                                                this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
+                                                this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
+                                            },
+                                            items : [
+                                                RightEditor,
+                                                {
+                                                    xtype: Gtk.ScrolledWindow,
+                                                    "pack":"add",
+                                                    "items" : [
+                                                        {
+                                                            xtype: Vte.Terminal,
+                                                            "pack":"add",
+                                                            "id":"Terminal",
+                                                            "feed":function(str) {
+                                                                this.el.feed(str,str.length);
+                                                            },
+                                                    
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        }
+                                         
+                                         
+                                    ]
+                                },
+                                RightPalete
+                                 
+                                
+                            ]
+                        }
+                    ]
+                }
+                
+            ]
+       }
+                
+    ]
+}); 
+    
+  
\ No newline at end of file
diff --git a/tests/options.js b/tests/options.js
new file mode 100644 (file)
index 0000000..5472d3f
--- /dev/null
@@ -0,0 +1,160 @@
+//<script type="text/javascript">
+
+XObject = import XObject.XObject
+/**
+ * Options parsing is needed as GLib's built in GOptionGroup is not feasible to use in an introspected way at present.
+ * 
+ * usage :
+ * 
+ * o = new Options(
+ *    help_desription : 'Help about this',
+ *    options : [
+ *        { short : 'a', long: 'test', description : 'a test', flag_array: true , flag_boolean : false}
+ *    ]
+ * );
+ * cfg = o.parse(Seed.argv);
+ * 
+ * Currently only supports simple parsing
+ * eg. --longarg test -b test
+ * 
+ * Does not support --aaaaa=bbbb
+ */
+Options  = XObject.define(
+    function (cfg) {
+        options = []; // default.
+        XObject.extend(this,cfg);
+    },
+    Object,
+    {
+        /**
+         * @cfg {String} help_description what appears at the start of the help message.
+         */
+        help_description: '',
+        /**
+         * @cfg {Boolean} If extra arguments are allowed.
+         */
+        allow_extra : false,
+        /**
+         * @param {Object} Resulting key/value of data.
+         */
+        result : false,
+        /**
+         * @prop {Array} the arguments
+         */
+        args: false,
+        /**
+         * @prop {Array} extra the arguments that are not accounted for.
+         */
+        extra: false,
+        /**
+         * parse the argv
+         * usage: options.parse(Seed.argv)
+         */
+        parse: function (argv)
+        {
+            var _this = this;
+            this.options.forEach(function(a) {
+                if (a.flag_boolean) {
+                    _this.result[a.name] = false;
+                    return;
+                }
+                if (a.flag_array) {
+                    _this.result[a.name] = [];
+                    return;
+                }
+            })
+            this.result = {};
+            this.extra = {};
+            var args = Array.prototype.slice.call(Seed.argv);
+            args.shift(); //seed
+            args.shift(); //script..
+        
+            for(var i =0; i < args.length;i++) {
+                
+                var a= this.findArg(args[i]);
+                
+                if (!a) {
+                    if (!this.allow_extra) {
+                        throw {
+                            name: "ArgumentError", 
+                            message: "Unknown argument: " + args[i] 
+                        };
+                    }
+                    this.extra.push(args[i]);
+                }
+                
+                if (a.long == 'help' ) {
+                    this.showHelp();
+                    return;
+                }
+                
+                if (a.flag_boolean) {
+                    this.result[a.long] = true;
+                    continue;
+                }
+                var next = args[i+1];
+                if (this.findArg(next)) {
+                    throw {
+                        name: "ArgumentError", 
+                        message: "Invalid argument sequence: " + args[i] + ' ' + next;
+                    };
+                }
+                // type juggling -- fixme...
+                
+                if (a.flag_array) {
+                    this.result[a.long].push(next);
+                    i++;
+                    continue;
+                }
+            
+                if (typeof(this.result[a.long]) != 'undefined') {
+                    throw {
+                        name: "ArgumentError", 
+                        message: "Invalid argument duplicate: " + args[i] + ' ' + next;
+                    };
+                }
+                
+                this.result[a.long] = next;
+                i++;
+            }
+            return this.result;
+        }
+        
+        
+    },
+    
+    findArg : function(str)
+    {
+        var ret = false;
+        var type = str.substring(0,1) == '-' ? 'short' : '';
+        type = str.substring(0,2) == '--' ? 'long' : type;
+        if (type == '') {
+            return false; // not an arg..
+        }
+        var match = str.substring(type =='long' ? 2 , 1);
+        this.options.forEach(function(o)) {
+            if (ret) {
+                return; // no more parsing.
+            }
+            if (o[type] == 'match') {
+                ret = o;
+            }
+            
+        }
+        return ret;
+        
+    },
+    
+    
+    showHelp: function()
+    {
+        print(this.help_description);
+        this.options.forEach(function(o) {
+            // fixme needs tidying up..
+            print('  --' + o.long + '   (-' + o.short + ')  ' + o.description);
+        }
+        Seed.quit();
+            
+    }
+}
\ No newline at end of file