dbgenerate.js
[app.Builder.js] / Sample / Window.bjs
index 588d844..cb877e8 100644 (file)
                                                     "items": [
                                                         {
                                                             "listeners": {
-                                                                "activate": "function (self) {\n    // this does not actually expand it..\n    // that is done by GTK..\n    \n    \n\n    if (!this.el.expanded) {\n        this.onExpand();\n    } else {\n        this.onCollapse();\n    }\n\t  \n}",
+                                                                "activate": "function (self) {\n    // this does not actually expand it..\n    // that is done by GTK..\n    \n    \n \tif (!this.get('/Editor').save()) {\n \t    // popup!! - click handled.. \n \t    return true;\n        }\n\n    if (!this.el.expanded) {\n        this.onExpand();\n    } else {\n        this.onCollapse();\n    }\n\t  \n}",
                                                                 "enter_notify_event": "function (self, event) {\nreturn;\n     this.el.expanded = !this.el.expanded;\n//if (this.el.expanded ) {\n    this.listeners.activate.call(this);\n//   }\n\nreturn true;\n}"
                                                             },
                                                             "id": "expander",
                                                             "label": "Select Project or File",
                                                             "pack": "pack_start,false,true",
                                                             "xtype": "Expander",
-                                                            "|onCollapse": "function() {\n    \n    var nb = this.get('/LeftTopPanel.notebook');\n    nb.el.set_current_page(0);\n}\n",
                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n   this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n",
+                                                            "|onCollapse": "function() {\n    \n    var nb = this.get('/LeftTopPanel.notebook');\n    nb.el.set_current_page(0);\n}\n",
                                                             "|onExpand": "function() {\n    var nb = this.get('/LeftTopPanel.notebook');            \n    var pm  = imports.Builder.Provider.ProjectManager.ProjectManager;\n    \n   \n    var model = this.get('/LeftProjectTree.combomodel');\n    //  print (\"loading Projects?\")\n    //console.dump(pm.projects);\n    model.loadData(pm.projects);\n     \n    \n    nb.el.set_current_page(1);\n    //pm.on('changed', function() {\n\t//console.log(\"CAUGHT project manager change\");\n    //    _combo.model.loadData(pm.projects);\n    //}\n    return;\n}\n",
                                                             "|xns": "Gtk"
                                                         },
                                                                             "pack": "pack_start,false,false",
                                                                             "items": [
                                                                                 {
-                                                                                    "|xns": "Gtk",
-                                                                                    "xtype": "ComboBox",
-                                                                                    "id": "combo",
-                                                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.get('render').el , 'markup', 1 );  \n}\n",
-                                                                                    "|getValue": "function() {\n    var ix = this.el.get_active();\n    if (ix < 0 ) {\n        return false;\n    }\n    var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n    if (typeof(data[ix]) == 'undefined') {\n \treturn false; \n    }\n    return data[ix].fn;\n}",
-                                                                                    "|setValue": "function(fn)\n{\n    var el = this.el;\n    el.set_active(-1);\n    var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n    data.forEach(function(n, ix) {\n        if (fn == n.fn) {\n            el.set_active(ix);\n            return false;\n        }\n    });\n}\n",
                                                                                     "listeners": {
                                                                                         "changed": "function (self) {\n\tvar fn = this.getValue();\n\tvar pm  = imports.Builder.Provider.ProjectManager.ProjectManager;\n\tthis.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))\n}"
                                                                                     },
+                                                                                    "id": "combo",
+                                                                                    "xtype": "ComboBox",
+                                                                                    "|getValue": "function() {\n    var ix = this.el.get_active();\n    if (ix < 0 ) {\n        return false;\n    }\n    var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n    if (typeof(data[ix]) == 'undefined') {\n \treturn false; \n    }\n    return data[ix].fn;\n}",
+                                                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.get('render').el , 'markup', 1 );  \n}\n",
+                                                                                    "|setValue": "function(fn)\n{\n    var el = this.el;\n    el.set_active(-1);\n    var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n    data.forEach(function(n, ix) {\n        if (fn == n.fn) {\n            el.set_active(ix);\n            return false;\n        }\n    });\n}\n",
+                                                                                    "|xns": "Gtk",
                                                                                     "items": [
                                                                                         {
                                                                                             "|xns": "Gtk",
                                                                                             "id": "render"
                                                                                         },
                                                                                         {
-                                                                                            "|xns": "Gtk",
-                                                                                            "xtype": "ListStore",
+                                                                                            "id": "combomodel",
                                                                                             "pack": "set_model",
-                                                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n  this.el.set_column_types ( 2, [\n        GObject.TYPE_STRING,  // real key\n        GObject.TYPE_STRING // real type\n        \n        \n    ] );\n   var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n   var _this = this;\n   pm.on('changed', function() {\n       print(\"caught changed hook on project manager - reloading data\");\n\t_this.loadData(pm.projects);\n\n   });\n}\n",
+                                                                                            "xtype": "ListStore",
+                                                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n  this.el.set_column_types ( 2, [\n        GObject.TYPE_STRING,  // real key\n        GObject.TYPE_STRING // real type\n        \n        \n    ] );\n   // this.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);\n   var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n   var _this = this;\n   pm.on('changed', function() {\n       print(\"caught changed hook on project manager - reloading data\");\n\t_this.loadData(pm.projects);\n\n   });\n}\n",
                                                                                             "|loadData": "function(data) {\n     var ov = this.get('/LeftProjectTree.combo').getValue();\n    this.el.clear();\n    var iter = new Gtk.TreeIter();\n    var el = this.el;\n    data.forEach(function(p) {\n        \n        el.append(iter);\n        \n         \n        el.set_value(iter, 0, p.fn);\n        el.set_value(iter, 1, p.name);\n        \n    });\n    \n    this.get('/LeftProjectTree.combo').setValue(ov);\n}\n",
-                                                                                            "id": "combomodel"
+                                                                                            "|xns": "Gtk"
                                                                                         }
                                                                                     ]
                                                                                 }
                                                                     ]
                                                                 },
                                                                 {
-                                                                    "|xns": "Gtk",
-                                                                    "xtype": "Button",
-                                                                    "pack": "add",
                                                                     "listeners": {
-                                                                        "button_press_event": "function (self, event) {\n    this.get('/MidPropTree.model').showData('events');\n    return false;\n}"
+                                                                        "button_press_event": "function (self, event) {\n    \n \tif (!this.get('/Editor').save()) {\n \t    // popup!! - click handled.. \n \t    return true;\n        }\n        this.get('/MidPropTree.model').showData('events');\n    return false;\n}"
                                                                     },
+                                                                    "pack": "add",
+                                                                    "xtype": "Button",
+                                                                    "|xns": "Gtk",
                                                                     "items": [
                                                                         {
                                                                             "|xns": "Gtk",
                                                                     ]
                                                                 },
                                                                 {
-                                                                    "|xns": "Gtk",
-                                                                    "xtype": "Button",
-                                                                    "pack": "add",
                                                                     "listeners": {
-                                                                        "button_press_event": "function (self, ev) {\n\tvar p = this.get('/AddPropertyPopup');\n\tif (!p.el) {\n\t\tp.init();\n\t}\n \tp.el.set_screen(Gdk.Screen.get_default());\n        p.el.show_all();\n         p.el.popup(null, null, null, null, 3, ev.button.time);\n    return true;\n}"
+                                                                        "button_press_event": "function (self, ev) {\n\n \tif (!this.get('/Editor').save()) {\n \t    // popup!! - click handled.. \n \t    return true;\n        }\n        \n\tvar p = this.get('/AddPropertyPopup');\n\tif (!p.el) {\n\t\tp.init();\n\t}\n \tp.el.set_screen(Gdk.Screen.get_default());\n        p.el.show_all();\n         p.el.popup(null, null, null, null, 3, ev.button.time);\n    return true;\n}"
                                                                     },
+                                                                    "pack": "add",
+                                                                    "xtype": "Button",
+                                                                    "|xns": "Gtk",
                                                                     "items": [
                                                                         {
                                                                             "|xns": "Gtk",
                                                             "items": [
                                                                 {
                                                                     "listeners": {
-                                                                        "button_press_event": "function (self, ev) {\n\n    \n    var res = { }; \n    \n    if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {\n        return false; //not on a element.\n    }\n    \n     // right click.\n     if (ev.type == Gdk.EventType.BUTTON_PRESS  && ev.button.button == 3) {    \n        // show popup!.   \n        if (res.column.title == 'value' && this.get('/LeftPanel').editing) {\n            return false;\n        }\n        //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();\n        var p = this.get('/LeftPanelPopup');\n        if (!p.el) {\n            p.init();\n        }\n\n        p.el.set_screen(Gdk.Screen.get_default());\n        p.el.show_all();\n        p.el.popup(null, null, null, null, 3, ev.button.time);\n        //Seed.print(\"click:\" + res.column.title);\n        \n        \n        return false;\n    }\n    \n     \n    if (res.column.title != 'value') {\n          //  XObject.error(\"column is not value?\");\n        return false; // ignore.. - key click.. ??? should we do this??\n    }\n    \n    // currently editing???\n//    if (  this.activePath) {\n        \n     //   this.activePath = false;\n       // stop editing!!!!\n        if (this.get('/Editor').dirty) {\n            //if (!this.get('/Editor.buffer').checkSyntax()) {\n            //   this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n            //   return true;\n            //    // error Dialog\n            //}\n            if (!this.get('/Editor.view').save()) {\n                return true;\n            }\n        }   \n        this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();\n        this.get('/LeftPanel').editing = false;\n    \n    //    XObject.error(\"Currently editing?\");\n     //   return false;\n   // }\n    \n    var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..\n    \n    var type = this.get('/LeftPanel.model').getType(res.path.to_string());\n        \n    // get options for this type -- this is to support option lists etc..\n    var provider = this.get('/LeftTree').getPaleteProvider();\n    var opts = provider.findOptions(type);\n    \n    if (opts === false) {\n        // it's text etnry\n         this.get('/LeftPanel').editableColumn.setOptions([]);\n        renderer.has_entry = true;\n    } else {\n         this.get('/LeftPanel').editableColumn.setOptions(opts);\n        renderer.has_entry = false;\n    }\n    this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1);\n        \n   //Seed.print(\"click\" + ev.type);\n    //console.dump(res);\n    return false;\n\n              \n   \n}"
+                                                                        "button_press_event": "function (self, ev) {\n\n    \n    if (!this.get('/Editor').save()) {\n        // popup!! - click handled.. \n        return true;\n    }\n    var res = { }; \n    \n    if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {\n        return false; //not on a element.\n    }\n    \n     // right click.\n     if (ev.type == Gdk.EventType.BUTTON_PRESS  && ev.button.button == 3) {    \n        // show popup!.   \n        if (res.column.title == 'value' && this.get('/LeftPanel').editing) {\n            return false;\n        }\n        //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();\n        var p = this.get('/LeftPanelPopup');\n        if (!p.el) {\n            p.init();\n        }\n\n        p.el.set_screen(Gdk.Screen.get_default());\n        p.el.show_all();\n        p.el.popup(null, null, null, null, 3, ev.button.time);\n        //Seed.print(\"click:\" + res.column.title);\n        \n        \n        return false;\n    }\n    \n     \n    if (res.column.title != 'value') {\n          //  XObject.error(\"column is not value?\");\n        return false; // ignore.. - key click.. ??? should we do this??\n    }\n    \n    // currently editing???\n//    if (  this.activePath) {\n        \n     //   this.activePath = false;\n       // stop editing!!!!\n        if (this.get('/Editor').dirty) {\n            //if (!this.get('/Editor.buffer').checkSyntax()) {\n            //   this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n            //   return true;\n            //    // error Dialog\n            //}\n            if (!this.get('/Editor.view').save()) {\n                return true;\n            }\n        }   \n        this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();\n        this.get('/LeftPanel').editing = false;\n    \n    //    XObject.error(\"Currently editing?\");\n     //   return false;\n   // }\n    \n    var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..\n    \n    var type = this.get('/LeftPanel.model').getType(res.path.to_string());\n        \n    // get options for this type -- this is to support option lists etc..\n    var provider = this.get('/LeftTree').getPaleteProvider();\n    var opts = provider.findOptions(type);\n    \n    if (opts === false) {\n        // it's text etnry\n         this.get('/LeftPanel').editableColumn.setOptions([]);\n        renderer.has_entry = true;\n    } else {\n         this.get('/LeftPanel').editableColumn.setOptions(opts);\n        renderer.has_entry = false;\n    }\n    this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1);\n        \n   //Seed.print(\"click\" + ev.type);\n    //console.dump(res);\n    return false;\n\n              \n   \n}"
                                                                     },
                                                                     "id": "view",
                                                                     "tooltip_column": 5,
                                                             "xtype": "ListStore",
                                                             "|getValue": "function(treepath, col)\n{\n    var tp = new Gtk.TreePath.from_string (treepath);\n    var iter = new Gtk.TreeIter();\n    this.el.get_iter (iter, tp);\n    var value = new GObject.Value('');\n    this.el.get_value(iter, col, value);\n    return value.value;\n    \n}",
                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n   this.el.set_column_types ( 6, [\n        GObject.TYPE_STRING,  // real key\n         GObject.TYPE_STRING, // real type\n         GObject.TYPE_STRING, // docs ?\n         GObject.TYPE_STRING, // visable desc\n         GObject.TYPE_STRING, // function desc\n         GObject.TYPE_STRING // element type (event|prop)\n        \n    ] );\n}\n",
-                                                            "|showData": "function(type) {\n    this.el.clear();\n            if (!this.get('/MidPropTree').activeElement || !type) {\n                return; // no active element\n            }\n\n            var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);\n            var palete = this.get('/LeftTree').getPaleteProvider();\n            \n             \n            \n            Seed.print('Showing right?');\n            if (!this.get('/MidPropTree').shown) {\n\n                this.get('/Window.left').el.position = this.get('/Window.left').el.position  + 150;\n                this.get('/MidPropTree').el.show();\n                this.get('/MidPropTree').shown = true;\n            }\n            \n            var elementList = palete.getPropertiesFor(fullpath, type).sort(function(a,b) { \n                return a.name >  b.name ? 1 : -1;\n            });\n            print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);\n           // console.dump(elementList);\n           \n            \n            var iter = new Gtk.TreeIter();\n            for(var i =0 ; i < elementList.length; i++) {\n                var p=elementList[i];\n                this.el.append(iter);\n              //  console.log( '<b>' + p.name +'</b> ['+p.type+']');\n                    //GObject.TYPE_STRING,  // real key\n                    // GObject.TYPE_STRING, // real type\n                    // GObject.TYPE_STRING, // docs ?\n                    // GObject.TYPE_STRING // func def?\n                    \n                \n                this.el.set_value(iter, 0, p.name);\n                this.el.set_value(iter, 1, p.type);\n                this.el.set_value(iter, 2, '<span size=\"small\"><b>' + p.name +'</b> ['+p.type+']</span>' + \"\\n\" + p.desc);\n                this.el.set_value(iter, 3, p.sig ? p.sig  : '');\n                this.el.set_value(iter, 4, '<span size=\"small\"><b>' + p.name +'</b> ['+p.type+']</span>');\n                this.el.set_value(iter, 5, type);\n                \n            }\n                             \n}\n",
+                                                            "|showData": "function(type) {\n    this.el.clear();\n            if (!this.get('/MidPropTree').activeElement || !type) {\n                return; // no active element\n            }\n\n            var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);\n            var palete = this.get('/LeftTree').getPaleteProvider();\n            \n             \n            \n            Seed.print('Showing right?');\n            if (!this.get('/MidPropTree').shown) {\n\n                this.get('/Window.left').el.position = this.get('/Window.left').el.position  + 150;\n                this.get('/MidPropTree').el.show();\n                this.get('/MidPropTree').shown = true;\n            }\n            \n            var elementList = palete.getPropertiesFor(fullpath, type).sort(function(a,b) { \n                return a.name >  b.name ? 1 : -1;\n            });\n            print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);\n           // console.dump(elementList);\n           \n            \n            var iter = new Gtk.TreeIter();\n            for(var i =0 ; i < elementList.length; i++) {\n                var p=elementList[i];\n                this.el.append(iter);\n              //  console.log( '<b>' + p.name +'</b> ['+p.type+']');\n                    //GObject.TYPE_STRING,  // real key\n                    // GObject.TYPE_STRING, // real type\n                    // GObject.TYPE_STRING, // docs ?this.el.set_value(iter, 0, p.name);et_value(iter, 0, p.name);\n                    // GObject.TYPE_STRING // func def?\n                    \n                \n                this.el.set_value(iter, 0, p.name);\n                this.el.set_value(iter, 1, p.type);\n                this.el.set_value(iter, 2, '<span size=\"small\"><b>' + p.name +'</b> ['+p.type+']</span>' + \"\\n\" + p.desc);\n                this.el.set_value(iter, 3, p.sig ? p.sig  : '');\n                this.el.set_value(iter, 4, '<span size=\"small\"><b>' + p.name +'</b> ['+p.type+']</span>');\n                this.el.set_value(iter, 5, type);\n                \n            }\n                             \n}\n",
                                                             "|xns": "Gtk"
                                                         },
                                                         {
-                                                            "|xns": "Gtk",
+                                                            "pack": false,
                                                             "xtype": "TreeViewColumn",
                                                             "|init": "function() {\n    this.el = new Gtk.TreeViewColumn();\n    this.parent.el.append_column(this.el);\n    \n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 4  );\n}\n",
-                                                            "pack": false,
+                                                            "|xns": "Gtk",
                                                             "items": [
                                                                 {
                                                                     "|xns": "Gtk",
                                                                                             "pack": "pack_start,false,false,0",
                                                                                             "xtype": "CheckButton",
                                                                                             "|xns": "Gtk"
+                                                                                        },
+                                                                                        {
+                                                                                            "listeners": {
+                                                                                                "clicked": "function (self) {\n  this.get('/RightBrowser.view').redraws = 99;\n  this.get('/RightBrowser.view').renderJS(null,true);\n}"
+                                                                                            },
+                                                                                            "label": "Full Redraw",
+                                                                                            "pack": "pack_start,false,false,0",
+                                                                                            "xtype": "Button",
+                                                                                            "|xns": "Gtk"
                                                                                         }
                                                                                     ]
                                                                                 },
                                                                             "|redraw": "function() {\n   this.highlightWidget = false;\n    print(\"REDRAW CALLED\");\n    this.activePath = this.get('/LeftTree').getActivePath();\n    if (this.renderedEl) {\n      print(\"QUEUE DRAW CALLING\");\n      this.renderedEl.queue_draw();\n   }\n}\n",
                                                                             "|renderJS": "function(data, withDebug)\n{\n      this.highlightWidget = false;\n   \n    this.withDebug = false;\n    while (this.get('view').el.get_children().length) {\n        var c = this.get('view').el.get_children()[0];\n        this.get('view').el.remove(c);        \n        c.destroy();\n    }\n     if (!data) {\n         return; \n    }\n    \n    var tree =  this.get('/LeftTree.model').toJS(false,true)[0];\n    // in theory tree is actually window..  \n   try {\n  \n        this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);\n      \n  } catch (e) {\n     print(e.message);\n    return;\n  }\n    this.get('view').el.set_size_request(\n        tree.default_width * 1 || 400, tree.default_height * 1 || 400\n    ) ;\n    if (this.renderedEl) {\n        this.renderedEl.set_size_request(\n            tree.default_width || 600,\n            tree.default_height || 400\n        );\n    }\n    this.get('view').el.show_all();\n    \n    \n    \n}",
                                                                             "|showInWindow": "function() {\n  print(\"GET PROEJCT\");\n\tvar pr = this.get('/LeftProjectTree').getActiveProject();\n  \n\tconsole.log(pr.paths);\n    return;\n/*\n     var src= this.buildJS(\n\t\tthis.get('/LeftTree.model').toJS()[0], \n\t\ttrue);\n      // show term?? \n\n\n    //var x = new imports.sandbox.Context();\n    //x.add_globals();\n    //print(src);\n    try {\n        Seed.check_syntax('var e = ' + src);\n        //x.eval(src);\n    } catch( e) {\n        this.get('/Terminal').feed(e.message || e.toString() + \"\\n\");\n        this.get('/Terminal').feed(console._dump(e)+\"\\n\");\n        if (e.line) {\n            var lines = src.split(\"\\n\");\n            var start = Math.max(0, e.line - 10);\n            var end = Math.min(lines.length, e.line + 10);\n            for (var i =start ; i < end; i++) {\n                if (i == e.line) {\n                    this.get('/Terminal').feed(\">>>>>\" + lines[i] + \"\\n\");\n                    continue;\n                }\n                this.get('/Terminal').feed(lines[i] + \"\\n\");\n            }\n            \n        }\n        \n        return;\n    }\n     this.get('/BottomPane').el.set_current_page(1);\n    this.get('/Terminal').el.fork_command( null , [], [], \"/tmp\", false,false,false); \n    var cmd = \"/usr/bin/seed /tmp/BuilderGtkView.js\\n\";\n    this.get('/Terminal').el.feed_child(cmd, cmd.length);\n     /*\n    var _top = x.get_global_object()._top;\n    \n    _top.el.set_screen(Gdk.Screen.get_default()); // just in case..\n    _top.el.show_all();\n    if (_top.el.popup) {\n        _top.el.popup(null, null, null, null, 3, null);\n    }\n*/\n}\n",
-                                                                            "|viewAdd": "function(item, par)\n        {\n    // does something similar to xobject..\n    item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;\n    \n    if (item.pack===false || item.pack === 'false') {  // no ;\n        return;\n    }\n    print(\"CREATE: \" + item['|xns'] + '.' + item['xtype']);\n    var type = item['|xns'] + '.' + item['xtype'];\n    \n    if (item['|xns'] == 'GtkClutter') { // we can not add this yet!\n        return false;\n    }\n    var ns = imports.gi[item['|xns']];\n    var ctr = ns[item['xtype']];\n    var ctr_args = { };\n    for(var k in item) {\n        var kv = item[k];\n        if (typeof(kv) == 'object' || typeof(kv) == 'function') {\n            continue;\n        }\n        if ( \n            k == 'pack' ||\n            k == 'items' ||\n            k == 'id' ||\n            k == 'xtype' ||\n            k == 'xdebug' ||\n            k == 'xns' ||\n            k == '|xns'\n        ) {\n            continue;\n        }\n\n\tif (k[0] == '|' && typeof(kv) == 'string') {\n\n\t\tif (kv.match(new RegExp('function'))) {\n\t\t\tcontinue;\n                }\n\t\t print(\"WASL \" + k + '=' + kv);\n\t\ttry {\n\t\t\teval( 'kv = ' + kv);\n\t\t} catch(e) {    continue; }\n                \n\t\tk = k.substring(1);\n             // print(k + '=' + kv);\n\t}\n        if (k[0] == '|') { // should be boolean or number..\n\t\tk = k.substring(1);\n\t\t//print(k + '=' + kv);\n        }\n         \n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n           kv = true;\n        }\n        print(k + '=' + typeof(kv) + \" : \" + kv);\n        ctr_args[k] = kv;\n        \n    } \n    \n    \n    var el = new ctr(ctr_args);\n    \n    print(\"PACK\" + item.pack);\n    //console.dump(item.pack);\n    \n    \n    \n    \n    var args = [];\n    var pack_m  = false;\n    if (typeof(item.pack) == 'string') {\n         \n        item.pack.split(',').forEach(function(e, i) {\n            \n            if (e == 'false') { args.push( false); return; }\n            if (e == 'true') {  args.push( true);  return; }\n            if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }\n            args.push(e);\n        });\n        //print(args.join(\",\"));\n        \n        pack_m = args.shift();\n    } else {\n        pack_m = item.pack.shift();\n        args = item.pack;\n    }\n    \n    // handle error.\n    if (pack_m && typeof(par[pack_m]) == 'undefined') {\n        throw {\n                name: \"ArgumentError\", \n                message : 'pack method not available : ' + par.id + \" : \" + par + '.' +  pack_m +\n                        \"ADDING : \" + item.id + \" \" +  el\n                    \n\t    };\n\n        return;\n    }\n    \n    console.dump(args);\n    args.unshift(el);\n    //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');\n    //Seed.print('args: ' + args.length);\n    if (pack_m) {\n        par[pack_m].apply(par, args);\n    }\n    \n    var _this = this;\n    item.items = item.items || [];\n    item.items.forEach(function(ch,n) {\n\n          print (\"type:\" + type);\n          \n           print (\"ch.pack:\" + ch.pack);\n         if (type == 'Gtk.Table' && ch.pack == 'add') {\n            var c = n % item.n_columns;\n            var r = Math.floor(n/item.n_columns);\n            ch.pack = [ 'attach', c, c+1, r, r+1, \n                     typeof(ch.x_options) == 'undefined' ?  5 : ch.x_options,\n                        typeof(ch.y_options) == 'undefined' ?  5 : ch.y_options,\n                        typeof(ch.x_padding) == 'undefined' ?  0 : ch.x_padding,\n                        typeof(ch.x_padding) == 'undefined' ?  0 : ch.x_padding\n            ].join(',');\n        }\n    \n        _this.viewAdd(ch, el);\n    });\n    \n    \n    \n    // add the signal handlers.\n    // is it a widget!?!!?\n   \n    \n    try {\n         \n        \n        el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item  ], true));\n        el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item  ], true));\n        el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item  ], true));\n        el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item  ], true ));\n  el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item  ], true ));\n    } catch(e) {\n        // ignore!\n       }\n    \n    \n    \n    return el;\n    \n}",
+                                                                            "|viewAdd": "function(item, par)\n{\n\n    // does something similar to xobject..\n    //item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;\n    \n    // pack is forced to 'false'\n    if (item.pack===false || item.pack === 'false') {  // no ;\n        return;\n    }\n    \n    print(\"CREATE: \" + item['|xns'] + '.' + item['xtype']);\n    \n    \n    var type = item['|xns'] + '.' + item['xtype'];\n    \n    if (item['|xns'] == 'GtkClutter') { // we can not add this yet!\n        return false;\n    }\n    \n    var ns = imports.gi[item['|xns']];\n    var ctr = ns[item['xtype']]; // why are we using array here..?\n    \n\n    \n    var ctr_args = { };\n    for(var k in item) {\n        var kv = item[k];\n        if (typeof(kv) == 'object' || typeof(kv) == 'function') {\n            continue;\n        }\n        if ( \n            k == 'pack' ||\n            k == 'items' ||\n            k == 'id' ||\n            k == 'xtype' ||\n            k == 'xdebug' ||\n            k == 'xns' ||\n            k == '|xns'\n        ) {\n            continue;\n        }\n        // value is a function..\n\tif (k[0] == '|' && typeof(kv) == 'string') {\n\n\t\tif (kv.match(new RegExp('function'))) {\n\t\t\tcontinue;\n                }\n\t\tprint(\"WASL \" + k + '=' + kv);\n\t\ttry {\n\t\t\teval( 'kv = ' + kv);\n\t\t} catch(e) {    continue; }\n                \n\t\tk = k.substring(1);\n             // print(k + '=' + kv);\n\t}\n        if (k[0] == '|') { // should be boolean or number..\n\t\tk = k.substring(1);\n\t\t//print(k + '=' + kv);\n        }\n         \n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n           kv = true;\n        }\n        print(k + '=' + typeof(kv) + \" : \" + kv);\n        ctr_args[k] = kv;\n        \n    } \n    var altctr =  XObject.baseXObject({ xtype:  ctr} );\n    var pack_m  = false;\n    if (!item.pack && altctr) {\n        // try XObject.\n        print(\"SETTING PACK TO XObjectBase method\");\n        pack_m = altctr.prototype.pack;\n        \n        \n    }\n    \n    var el = new ctr(ctr_args);\n    item.el = el;\n    print(\"PACK\" + item.pack);\n    //console.dump(item.pack);\n    \n    \n    \n    \n    var args = [];\n    if (!pack_m) {\n        item.pack = (typeof(item.pack) == 'undefined') ?  'add' : item.pack;\n        if (typeof(item.pack) == 'string') {\n             \n            item.pack.split(',').forEach(function(e, i) {\n                \n                if (e == 'false') { args.push( false); return; }\n                if (e == 'true') {  args.push( true);  return; }\n                if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }\n                args.push(e);\n            });\n            //print(args.join(\",\"));\n            \n            pack_m = args.shift();\n        } else {\n            pack_m = item.pack.shift();\n            args = item.pack;\n        }\n    }\n    // handle error.\n    if (typeof(pack_m) == 'string' && typeof(par[pack_m]) == 'undefined') {\n        throw {\n                name: \"ArgumentError\", \n                message : 'pack method not available : ' + par.id + \" : \" + par + '.' +  pack_m +\n                        \"ADDING : \" + item.id + \" \" +  el\n                    \n\t    };\n\n        return;\n    }\n    \n    console.dump(args);\n    args.unshift(el);\n    //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');\n    //Seed.print('args: ' + args.length);\n    if (typeof(pack_m) == 'string') {\n        par[pack_m].apply(par, args);\n    } else if (pack_m) {\n        pack_m.call(item, par, item);\n    }\n    \n    var _this = this;\n    item.items = item.items || [];\n    item.items.forEach(function(ch,n) {\n\n         print (\"type:\" + type);\n          \n         print (\"ch.pack:\" + ch.pack);\n           \n           \n         if (type == 'Gtk.Table' && ch.pack == 'add') {\n            var c = n % item.n_columns;\n            var r = Math.floor(n/item.n_columns);\n            ch.pack = [ 'attach', c, c+1, r, r+1, \n                     typeof(ch.x_options) == 'undefined' ?  5 : ch.x_options,\n                        typeof(ch.y_options) == 'undefined' ?  5 : ch.y_options,\n                        typeof(ch.x_padding) == 'undefined' ?  0 : ch.x_padding,\n                        typeof(ch.x_padding) == 'undefined' ?  0 : ch.x_padding\n            ].join(',');\n        }\n    \n        _this.viewAdd(ch, el);\n    });\n    \n    \n    \n    // add the signal handlers.\n    // is it a widget!?!!?\n   \n    \n    try {\n         \n        \n        el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item  ], true));\n        el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item  ], true));\n        el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item  ], true));\n        el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item  ], true ));\n        el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item  ], true ));\n    } catch(e) {\n        // ignore!\n       }\n    \n    \n    \n    return el;\n    \n}",
                                                                             "|widgetDragDropEvent": "function() {\n      print(\"WIDGET DRAGDROP\"); \n            return true;\n}\n",
                                                                             "|widgetDragMotionEvent": "function() {\n     print(\"WIDGET DRAGMOTION\"); \n            return true;\n}\n",
                                                                             "|widgetExposeEvent": "function(w, evt, ud, item) {\n    var widget = w;\n     if (this.inRender) {\n         return false;\n     }\n     \n     if ( this.highlightWidget) {\n          this.inRender = true;\n          if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {\n                 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);\n            }\n           this.inRender = false;\n           return false;\n     }\n     \n     \n     if (this.activePath != item.xtreepath) {\n        return false;\n     }\n     \n   //  print(\"HIGHLIGHT: \" + item.xtreepath ); // draw highlight??\n     // work out the coords of the window..\n     if (!this.gc) {\n      var dr = widget.window;\n      this.gc = (new Gdk.GC.c_new(dr));\n      this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));\n      this.gc.set_line_attributes(4,  Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);\n    }\n\n    \n     var r  = evt.expose.area;\n     // console.dump([r.x, r.y, r.width, r.height ] );\n     //return false;\n//     print(widget.get_parent().toString().match(/GtkScrolledWindow/);\n     if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak\n         // happens with gtkscrollview embedded stuff..\n         var np =this.activePath.split(':');\n         np.pop();\n         this.activePath = np.join(':');\n         this.renderedEl.queue_draw();\n         return true;\n\n        \n     }\n\n       \n     \n     \n      this.box = {\n        x : r.x - 2,\n        y : r.y - 2,\n        w: r.width + 4,\n        h: r.height + 4\n      }; \n      // let's draw it..\n      this.inRender = true;\n\n      \n      this.highlightWidget = widget;\n    \n    \n \n\n    //  print(\"DRAW BOX\");\n       //console.dump(this.box);\n      Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);\n            this.inRender = false;\n            return false;\n}\n",
                                                             "|shadow_type": "Gtk.ShadowType.IN",
                                                             "items": [
                                                                 {
-                                                                    "|xns": "Gtk",
-                                                                    "xtype": "TreeView",
-                                                                    "pack": "add",
-                                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n  this.el.set_size_request(150,-1);\n                          //  set_reorderable: [1]\n                                  \n            var description = new Pango.FontDescription.c_new();\n    description.set_size(8000);\n    this.el.modify_font(description);\n    \n    this.selection = this.el.get_selection();\n    this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n   // this.selection.signal['changed'].connect(function() {\n    //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);\n    //});\n    // see: http://live.gnome.org/GnomeLove/DragNDropTutorial\n     \n    Gtk.drag_source_set (\n            this.el,            /* widget will be drag-able */\n            Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */\n            null,            /* lists of target to support */\n            0,              /* size of list */\n            Gdk.DragAction.COPY         /* what to do with data after dropped */\n    );\n    //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);\n   \n    Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n    Gtk.drag_source_add_text_targets(this.el); \n    /*\n    print(\"RP: TARGET:\" + LeftTree.atoms[\"STRING\"]);\n    targets = new Gtk.TargetList();\n    targets.add( LeftTree.atoms[\"STRING\"], 0, 0);\n    targets.add_text_targets( 1 );\n    Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);\n    \n    //if you want to allow text to be output elsewhere..\n    //Gtk.drag_source_add_text_targets(this.el);\n    */\n    return true; \n}\n",
-                                                                    "|headers_visible": false,
-                                                                    "|enable_tree_lines": true,
                                                                     "listeners": {
                                                                         "drag_begin": "function (self, ctx) {\n    // we could fill this in now...\n        Seed.print('SOURCE: drag-begin');\n        \n        \n        \n        var iter = new Gtk.TreeIter();\n        var s = this.selection;\n        s.get_selected(this.get('/RightPalete.model').el, iter);\n        var path = this.get('/RightPalete.model').el.get_path(iter);\n        \n        var pix = this.el.create_row_drag_icon ( path);\n            \n                \n        Gtk.drag_set_icon_pixmap (ctx,\n            pix.get_colormap(),\n            pix,\n            null,\n            -10,\n            -10);\n        \n        var value = new GObject.Value('');\n        this.get('/RightPalete.model').el.get_value(iter, 0, value);\n        if (!this.get('/RightPalete').provider) {\n            return false;\n        }\n        this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);\n        this.el.dragData = value.value;\n        \n        \n        \n        \n        return true;\n}",
                                                                         "drag_data_get": "function (self, drag_context, selection_data, info, time) {\n \t//Seed.print('Palete: drag-data-get: ' + target_type);\n        if (this.el.dragData && this.el.dragData.length ) {\n            selection_data.set_text(this.el.dragData ,this.el.dragData.length);\n        }\n        \n        \n        //this.el.dragData = \"TEST from source widget\";\n        \n        \n}",
-                                                                        "drag_end": "function (self, drag_context) {\n \tSeed.print('SOURCE: drag-end');\n\tthis.el.dragData = false;\n\tthis.el.dropList = false;\n\tthis.get('/LeftTree.view').highlight(false);\n\treturn true;\n}"
+                                                                        "drag_end": "function (self, drag_context) {\n \tSeed.print('SOURCE: drag-end');\n\tthis.el.dragData = false;\n\tthis.el.dropList = false;\n\tthis.get('/LeftTree.view').highlight(false);\n\treturn true;\n}",
+                                                                        "button_press_event": "function (self, event) {\n\n \tif (!this.get('/Editor').save()) {\n \t    // popup!! - click handled.. \n \t    return true;\n        }\n    return false;\n}"
                                                                     },
+                                                                    "pack": "add",
+                                                                    "xtype": "TreeView",
+                                                                    "|enable_tree_lines": true,
+                                                                    "|headers_visible": false,
+                                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n  this.el.set_size_request(150,-1);\n                          //  set_reorderable: [1]\n                                  \n            var description = new Pango.FontDescription.c_new();\n    description.set_size(8000);\n    this.el.modify_font(description);\n    \n    this.selection = this.el.get_selection();\n    this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n   // this.selection.signal['changed'].connect(function() {\n    //    _view.listeners['cursor-changed'].apply(_view, [ _view, '']);\n    //});\n    // see: http://live.gnome.org/GnomeLove/DragNDropTutorial\n     \n    Gtk.drag_source_set (\n            this.el,            /* widget will be drag-able */\n            Gdk.ModifierType.BUTTON1_MASK,       /* modifier that will start a drag */\n            null,            /* lists of target to support */\n            0,              /* size of list */\n            Gdk.DragAction.COPY         /* what to do with data after dropped */\n    );\n    //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);\n   \n    Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n    Gtk.drag_source_add_text_targets(this.el); \n    /*\n    print(\"RP: TARGET:\" + LeftTree.atoms[\"STRING\"]);\n    targets = new Gtk.TargetList();\n    targets.add( LeftTree.atoms[\"STRING\"], 0, 0);\n    targets.add_text_targets( 1 );\n    Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);\n    \n    //if you want to allow text to be output elsewhere..\n    //Gtk.drag_source_add_text_targets(this.el);\n    */\n    return true; \n}\n",
+                                                                    "|xns": "Gtk",
                                                                     "items": [
                                                                         {
                                                                             "|xns": "Gtk",