From f356ef4b7c6902290ed96c6b22b9cb407f0a4d7c Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Sun, 24 Oct 2010 11:14:51 +0800 Subject: [PATCH] back to using builder as the core directory --- Builder/Window.bjs | 96 ++++++---- Builder/Window.js | 425 ++++++++++++++++++++++++++------------------- builder.sh | 2 +- gir-1.1 | 2 +- roojs1 | 2 +- 5 files changed, 311 insertions(+), 216 deletions(-) diff --git a/Builder/Window.bjs b/Builder/Window.bjs index 146394d4e..998ebf8f6 100644 --- a/Builder/Window.bjs +++ b/Builder/Window.bjs @@ -146,7 +146,7 @@ "items": [ { "listeners": { - "activate": "function (self, event) {\n var js = this.get('/LeftTree.model').toJS();\n if (js && js[0]) {\n this.get('/RightBrowser.view').renderJS(js[0]);\n } \n return false;\n}" + "activate": "function (self, event) {\n var js = this.get('/LeftTree.model').toJS();\n if (js && js[0]) {\n this.get('/RightBrowser.view').renderJS(js[0], true);\n } \n return false;\n}" }, "label": "_Redraw (Roo)", "pack": "add", @@ -221,24 +221,26 @@ "items": [ { "listeners": { - "activate": "function (self) {\n\tvar nb = this.get('/LeftTopPanel.notebook');\n\tif (this.el.expanded) {\n\t // now expanded..\n \n\t var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n\t \n\t \n\t var model = this.get('/LeftProjectTree.combomodel');\n\t // print (\"loading Projects?\")\n\t//console.dump(pm.projects);\n\t model.loadData(pm.projects);\n\t \n\t \n\t nb.el.set_current_page(1);\n\t //pm.on('changed', function() {\n\t\t//console.log(\"CAUGHT project manager change\");\n\t // _combo.model.loadData(pm.projects);\n\t //}\n\t return;\n\t}\n\tnb.el.set_current_page(0);\n}", - "enter_notify_event": "function (self, event) {\n this.el.expanded = !this.el.expanded;\n//if (this.el.expanded ) {\n this.listeners.activate.call(this);\n// }\n\nreturn true;\n}" + "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}", + "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", + "|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" }, { - "|xns": "Gtk", - "xtype": "Notebook", "id": "notebook", - "|show_border": false, - "|show_tabs": false, "pack": "pack_start,true,true", + "xtype": "Notebook", "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_current_page(0);\n\n}\n", + "|show_border": false, + "|show_tabs": false, + "|xns": "Gtk", "items": [ { "id": "LeftTree", @@ -397,7 +399,7 @@ "items": [ { "listeners": { - "cursor_changed": "function (self) {\n \tvar iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n //XN.get('Builder.LeftTree.model').\n this.get('/LeftTree.model').load( false);\n \n return;\n }\n var model = this.get('/LeftProjectTree.model');\n //console.log('changed');\n var s = this.selection;\n s.get_selected(model, iter);\n value = new GObject.Value('');\n model.el.get_value(iter, 2, value);\n \n console.log(value.value);// id..\n \n var file = this.get('/LeftProjectTree').project.getById(value.value);\n \n file.items = false;\n console.log(file);\n \n\n\n var nb = this.get('/LeftTopPanel.expander');\n nb.el.expanded = false;\n nb.listeners.activate.call(nb);\n //_expander.el.set_expanded(false);\n\n var ltm = this.get('/LeftTree.model');\n ltm.loadFile(file);\n \n return true;\n}" + "cursor_changed": "function (self) {\n \tvar iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n //XN.get('Builder.LeftTree.model').\n this.get('/LeftTree.model').load( false);\n \n return;\n }\n var model = this.get('/LeftProjectTree.model');\n //console.log('changed');\n var s = this.selection;\n s.get_selected(model, iter);\n value = new GObject.Value('');\n model.el.get_value(iter, 2, value);\n \n console.log(value.value);// id..\n \n var file = this.get('/LeftProjectTree').project.getById(value.value);\n \n file.items = false;\n console.log(file);\n \n\n\n var nb = this.get('/LeftTopPanel.expander');\n nb.el.expanded = false;\n nb.onCollapse();\n //nb.listeners.activate.call(nb);\n //_expander.el.set_expanded(false);\n\n var ltm = this.get('/LeftTree.model');\n ltm.loadFile(file);\n \n return true;\n}" }, "id": "view", "tooltip_column": 1, @@ -632,25 +634,25 @@ ] }, { - "|xns": "Gtk", - "xtype": "ScrolledWindow", + "editing": false, "id": "LeftPanel", "pack": "add", - "|shadow_type": "Gtk.ShadowType.IN", - "editing": false, + "xtype": "ScrolledWindow", "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", + "|shadow_type": "Gtk.ShadowType.IN", + "|xns": "Gtk", "items": [ { - "|xns": "Gtk", - "xtype": "TreeView", + "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 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, - "|headers_visible": false, + "xtype": "TreeView", "|enable_tree_lines": true, + "|headers_visible": false, "|init": "function() {\n XObject.prototype.init.call(this); \n \n this.selection = this.el.get_selection();\n this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n \n \n var description = new Pango.FontDescription.c_new();\n description.set_size(8000);\n this.el.modify_font(description);\n}\n", - "listeners": { - "button_press_event": "function (self, ev) {\n \n \n var res = { }; \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 \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {\n \n if (res.column.title != 'value') {\n return false; // ignore..\n }\n if ( this.get('/LeftPanel').editing) {\n return false;\n }\n var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..\n this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();\n var type = this.get('/LeftPanel.model').getType(res.path.to_string());\n \n \n\n var provider = this.get('/LeftTree').getPaleteProvider();\n \n var opts = provider.findOptions(type);\n \n if (opts === false) {\n this.get('/LeftPanel').editableColumn.setOptions([]);\n renderer.has_entry = true;\n } else {\n LeftPanel.editableColumn.setOptions(opts);\n renderer.has_entry = false;\n }\n \n \n //Seed.print(\"click\" + ev.type);\n //console.dump(res);\n return false;\n }\n \n \n \n if (res.column.title == 'value') {\n return false;\n }\n //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();\n\t\tvar p = this.get('/LeftPanelPopup');\n\t\tif (!p.el) {\n\t\t\tp.init();\n\t\t}\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}" - }, + "|xns": "Gtk", "items": [ { "activePath": false, @@ -660,13 +662,12 @@ "|add": "function(info) {\n // info includes key, val, skel, etype..\n console.dump(info);\n type = info.type.toLowerCase();\n var data = this.toJS();\n \n if (info.etype == 'events') {\n data.listeners = data.listeners || { };\n if (typeof(data.listeners[info.key]) != 'undefined') {\n return; //already set!\n }\n } else {\n if (typeof(data[info.key]) != 'undefined') {\n return;\n }\n }\n \n if (typeof(info.val) == 'undefined') {\n \n info.val = '';\n if (info.type.toLowerCase() == 'boolean') {\n info.val = true;\n }\n if (type == 'number') {\n info.val = 0;\n }\n // utf8 == string..\n \n \n }\n var k = info.key;\n if (info.etype == 'events') {\n \n data.listeners[info.key] = info.val;\n k = '!' + info.key;\n } else {\n data[info.key] = info.val;\n }\n \n \n var map = this.load(data);\n \n // flag it as changed to the interface..\n\n this.get('/LeftTree.model').changed(data, true); \n \n \n this.startEditing(map[k]);\n \n /*\n LeftPanel.get('view').el.row_activated(\n new Gtk.TreePath.from_string(map[k]), \n LeftPanel.editableColumn.el\n );\n */\n}\n", "|changed": "function(str, doRefresh) {\n if (!this.activePath) {\n return;\n }\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));\n \n this.el.set_value(iter, 1, '' +str);\n this.el.set_value(iter, 3, '' + this.toShort(str));\n var type = this.getIterValue(iter, 4);\n\n this.el.set_value(iter, 5, type + ' : ' + str);\n // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \n}\n", "|deleteSelected": "function() {\n var data = this.toJS();\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.el, iter);\n \n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);\n \n var val = gval.value;\n if (val[0] == '!') {\n // listener..\n if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {\n return;\n }\n delete data.listeners[ val.substring(1)];\n if (!XObject.keys(data.listeners).length) {\n delete data.listeners;\n }\n \n } else {\n if (typeof(data[val]) == 'undefined') {\n return;\n }\n delete data[val];\n }\n \n \n this.load(data);\n this.get('/LeftTree.model').changed(data, true);\n \n}\n", - "|editSelected": "function(e) {\n print(\"EDIT SELECTED?\");\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.get('/LeftPanel.model').el, iter);\n var m = this.get('/LeftPanel.model')\n \n var gval = new GObject.Value('');\n this.el.get_value(iter, 0 ,gval);\n var val = '' + gval.value;\n \n gval = new GObject.Value('');\n this.el.get_value(iter, 1 ,gval);\n var rval = gval.value;\n var activePath = this.el.get_path(iter).to_string(); \n this.activePath = activePath ;\n // was activeIter...\n // not listener...\n\n var showEditor = false;\n \n if (val[0] == '!') {\n showEditor = true;\n }\n if (val[0] == '|') {\n if (rval.match(/function/g) || rval.match(/\\n/g) || rval.length > 20) {\n showEditor = true;\n }\n }\n \n if (showEditor) {\n var _this = this;\n this.activePath = false;\n GLib.timeout_add(0, 1, function() {\n // Gdk.threads_enter();\n _this.get('/BottomPane').el.show();\n _this.get('/RightEditor').el.show();\n _this.get('/RightEditor.view').load( rval );\n \n e.editing_done();\n e.remove_widget();\n _this.activePath = activePath ;\n \n // Gdk.threads_leave();\n return false;\n });\n return;\n }\n this.get('/BottomPane').el.hide();\n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n", "|getIterValue": "function(iter, col) {\n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n", "|getType": "function(treepath) {\n return this.getValue(treepath, 4);\n}\n", - "|getValue": "function(treepath_str, col) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));\n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n var val = '' + gval.value;\n if (col != 1) {\n return val;\n }\n var type = this.getType(this.el.get_path(iter).to_string());\n //print(\"TYPE: \" +type + \" - val:\" + val);\n switch(type.toLowerCase()) {\n case 'number':\n case 'uint':\n case 'int':\n return parseFloat(val); // Nan ?? invalid!!? \n case 'float':\n case 'gfloat':\n return 1.0 * parseFloat(val); // Nan ?? invalid!!?\n case 'boolean':\n return val == 'true' ? true : false;\n default: \n var nv = parseFloat(val);\n if (!isNaN(nv) && (val == ''+nv)) {\n return nv;\n }\n return val;\n }\n \n}\n", + "|getValue": "function(treepath_str, col) \n{\n // get's the value in a row.. - keys - returns string, values - formats it..\n\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));\n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n var val = '' + gval.value;\n \n if (col != 1) {\n return val;\n }\n var type = this.getType(this.el.get_path(iter).to_string());\n //print(\"TYPE: \" +type + \" - val:\" + val);\n switch(type.toLowerCase()) {\n case 'number':\n case 'uint':\n case 'int':\n return parseFloat(val); // Nan ?? invalid!!? \n case 'float':\n case 'gfloat':\n return 1.0 * parseFloat(val); // Nan ?? invalid!!?\n case 'boolean':\n return val == 'true' ? true : false;\n default: \n var nv = parseFloat(val);\n if (!isNaN(nv) && (val == ''+nv)) {\n return nv;\n }\n return val;\n }\n \n}\n", "|init": "function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 6, [\n GObject.TYPE_STRING, // 0 real key\n GObject.TYPE_STRING, // 1 real value \n GObject.TYPE_STRING, // 2 visable key\n GObject.TYPE_STRING, // 3 visable value\n GObject.TYPE_STRING, // 4 need to store type of!!!\n GObject.TYPE_STRING // 5 tooltip\n \n ]);\n}\n", "|load": "function(ar) {\n this.el.clear();\n \n this.get('/RightEditor').el.hide();\n if (ar === false) {\n return ;\n }\n var ret = {}; \n \n\n var provider = this.get('/LeftTree').getPaleteProvider();\n var iter = new Gtk.TreeIter();\n \n // sort!!!?\n var keys = XObject.keys(ar);\n keys.sort();\n ar.listeners = ar.listeners || {};\n \n for (var i in ar.listeners ) {\n this.el.append(iter);\n var p = this.el.get_path(iter).to_string();\n ret['!' + i] = p;\n \n this.el.set_value(iter, 0, '!'+ i );\n this.el.set_value(iter, 1, '' + ar.listeners[i]);\n this.el.set_value(iter, 2, ''+ i + '');\n \n this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));\n this.el.set_value(iter, 4, 'function');\n this.el.set_value(iter, 5, i + ' : ' + ar.listeners[i]);\n }\n \n \n \n var _this = this;\n keys.forEach(function(i) {\n if (typeof(ar[i]) == 'object') {\n return;\n }\n \n var type = provider.findType(ar, i, ar[i]);\n \n _this.el.append(iter);\n var p = _this.el.get_path(iter).to_string();\n ret[i] = p;\n _this.el.set_value(iter, 0, ''+i);\n _this.el.set_value(iter, 1, '' + ar[i]); \n _this.el.set_value(iter, 2, ''+i);\n _this.el.set_value(iter, 3, ''+ _this.toShort(ar[i]));\n _this.el.set_value(iter, 4, ''+type);\n _this.el.set_value(iter, 5, type + ' : ' + ar[i]);\n })\n return ret;\n}\n", - "|startEditing": "function(path,col) {\n /**\n * start editing path (or selected if not set..)\n * @param {String|false} path (optional) treepath to edit - selected tree gets\n * edited by default.\n * @param {Number} 0 or 1 (optional)- column to edit. \n */\n var tp;\n if (typeof(path) == 'string') {\n tp = new Gtk.TreePath.from_string(path);\n } else {\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.el, iter);\n tp = this.el.get_path(iter);\n path = tp.to_string();\n }\n \n \n // which colum is to be edited..\n var colObj = false;\n if (typeof(col) == 'undefined') {\n var k = this.getValue(path, 0);\n colObj = (!k.length || k == '|') ? \n this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;\n } else {\n colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;\n }\n \n // make sure the pulldown is set correctly..\n // not really needed for second col...\n\n var provider = this.get('/LeftTree').getPaleteProvider();\n \n var type = this.get('/LeftPanel.model').getType(path);\n var opts = provider.findOptions(type);\n var renderer = this.get('/LeftPanel').editableColumn.items[0].el;\n \n if (opts === false) {\n this.get('/LeftPanel').editableColumn.setOptions([]);\n renderer.has_entry = true; /// probably does not have any effect.\n } else {\n this.get('/LeftPanel').editableColumn.setOptions(opts);\n renderer.has_entry = false;\n }\n \n var _this=this;\n // iter now has row...\n GLib.timeout_add(0, 100, function() {\n \n colObj.items[0].el.editable = true; // esp. need for col 0..\n _this.get('/LeftPanel.view').el.set_cursor_on_cell(\n tp,\n colObj.el,\n colObj.items[0].el,\n true\n );\n });\n \n}\n", + "|startEditing": "function(path,col) {\n// alled by menu 'edit' currently..\n /**\n * start editing path (or selected if not set..)\n * @param {String|false} path (optional) treepath to edit - selected tree gets\n * edited by default.\n * @param {Number} 0 or 1 (optional)- column to edit. \n */\n // fix tp to be the 'treepath' string (eg. 0/1/2...)\n var tp;\n if (typeof(path) == 'string') {\n tp = new Gtk.TreePath.from_string(path);\n } else {\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.el, iter);\n tp = this.el.get_path(iter);\n path = tp.to_string();\n }\n \n \n // which colum is to be edited..\n var colObj = false;\n \n // not sure what this does..\n \n if (typeof(col) == 'undefined') {\n var k = this.getValue(path, 0);\n col = 1;\n colObj = (!k.length || k == '|') ? \n this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;\n } else {\n colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;\n }\n \n // make sure the pulldown is set correctly..\n // not really needed for second col...\n var showEditor = false;\n \n if (col) {\n var provider = this.get('/LeftTree').getPaleteProvider();\n var type = this.get('/LeftPanel.model').getType(path);\n var opts = provider.findOptions(type);\n var renderer = this.get('/LeftPanel').editableColumn.items[0].el;\n \n if (opts === false) {\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;/// - pulldowns do not have entries\n }\n // determine if we should use the Text editor...\n var keyname = this.getValue(path, 0);\n var data_value = this.getValue(path, 1);\n \n if ((keyname[0] == '|') || \n ( \n (typeof(data_value) == 'string' ) && \n ( data_value.match(/function/g) || data_value.match(/\\n/g)) // || (data_value.length > 20))\n )) {\n showEditor = true;\n }\n print(\"SHOW EDITOR\" + showEditor ? 'YES' :'no');\n \n }\n var _this = this; \n // end editing..\n this.get('/BottomPane').el.hide();\n this.get('/RightEditor').el.hide();\n \n \n if (showEditor) {\n\n this.activePath = false;\n GLib.timeout_add(0, 1, function() {\n\n _this.get('/BottomPane').el.show();\n _this.get('/RightEditor').el.show();\n _this.get('/RightEditor.view').load( _this.getValue(path, 1) );\n \n //e.editing_done();\n //e.remove_widget();\n _this.activePath = path ;\n \n return false;\n });\n return;\n }\n \n \n \n\n // iter now has row...\n GLib.timeout_add(0, 100, function() {\n _this.activePath = path;\n colObj.items[0].el.editable = true; // esp. need for col 0..\n _this.get('/LeftPanel.view').el.set_cursor_on_cell(\n tp,\n colObj.el,\n colObj.items[0].el,\n true\n );\n });\n \n}\n", "|toJS": "function() {\n var iter = new Gtk.TreeIter();\n this.get('/LeftPanel.model').el.get_iter_first(iter);\n var ar = {};\n \n while (true) {\n \n var k = this.getValue(this.el.get_path(iter).to_string(), 0);\n // Seed.print(k);\n if (k[0] == '!') {\n ar.listeners = ar.listeners || {};\n ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);\n \n } else {\n ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);\n }\n \n if (! this.get('/LeftPanel.model').el.iter_next(iter)) {\n break;\n }\n }\n \n \n //print(JSON.stringify(ar));\n return ar;\n // convert the l\n}\n", "|toShort": "function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\n}\n", "|xns": "Gtk" @@ -690,24 +691,25 @@ ] }, { - "|xns": "Gtk", - "xtype": "TreeViewColumn", "pack": "append_column", - "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'text', 3 );\n\tthis.el.add_attribute(this.items[0].el , 'sensitive', 3 );\n\tthis.el.add_attribute(this.items[0].el , 'editable', 3 );\n // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);\n\n \tthis.get('/LeftPanel').editableColumn= this;\n}\n", + "title": "value", + "xtype": "TreeViewColumn", + "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'text', 3 );\n\tthis.el.add_attribute(this.items[0].el , 'sensitive', 3 );\n\t//this.el.add_attribute(this.items[0].el , 'editable', 3 );\n // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);\n\n \tthis.get('/LeftPanel').editableColumn= this;\n}\n", "|setOptions": "function(ar) {\n var m = this.items[0].el.model;\n m.clear();\n var iter = new Gtk.TreeIter();\n ar.forEach(function(i) {\n // sort!!!?\n m.append(iter);\n m.set_value(iter, 0, i);\n });\n \n}\n", + "|xns": "Gtk", "items": [ { - "|xns": "Gtk", - "xtype": "CellRendererCombo", + "listeners": { + "edited": "function (self, object, p0) {\n \tthis.get('/LeftPanel').editing = false;\n \tvar ap = this.get('/LeftPanel.model').activePath\n\tprint(\"EDITED? \" + ap + \" - p:\" + p0 + \" t:\" + p0);\n this.get('/LeftPanel.model').changed(p0, true);\n this.get('/LeftPanel.model').activePath = false;\n this.el.editable = false;\n}", + "editing_started": "function (self, editable, path) {\n this.get('/LeftPanel').editing = true;\n\t// console.log('editing started');\n // r.has_entry = false;\n\n this.el.editable = false; // make sure it's not editor...\n \n}" + }, "pack": "pack_start", + "text_column": 0, + "xtype": "CellRendererCombo", "|editable": true, "|has_entry": true, - "text_column": 0, "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.model = new Gtk.ListStore();\n this.el.model.set_column_types ( 1, [\n GObject.TYPE_STRING // 0 real key\n ]);\n}\n", - "listeners": { - "edited": "function (self, object, p0) {\n \tthis.get('/LeftPanel').editing = false;\n\tprint(\"EDITED? p:\" + p0 + \" t:\" + p0);\n this.get('/LeftPanel.model').changed(p0, true);\n this.get('/LeftPanel.model').activePath = false;\n}", - "editing_started": "function (self, editable, path) {\n this.get('/LeftPanel').editing = true;\n\t// console.log('editing started');\n // r.has_entry = false;\n this.get('/LeftPanel.model').editSelected(editable);\n}" - } + "|xns": "Gtk" } ] } @@ -833,6 +835,33 @@ "xtype": "VBox", "|xns": "Gtk", "items": [ + { + "pack": "pack_start,false,true,0", + "xtype": "HBox", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "clicked": "function (self) {\n this.get('/RightBrowser.view').renderJS(null,true);\n}" + }, + "label": "Redraw", + "pack": "pack_start,false,false,0", + "xtype": "Button", + "|xns": "Gtk" + }, + { + "listeners": { + "toggled": "function (self, state) {\n this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");\n}" + }, + "active": true, + "id": "AutoRedraw", + "label": "Auto Redraw On", + "pack": "pack_start,false,false,0", + "xtype": "CheckButton", + "|xns": "Gtk" + } + ] + }, { "pack": "add", "xtype": "ScrolledWindow", @@ -850,12 +879,13 @@ "drag_data_received": "function (w, ctx, x, y, sel_data, target_type, time, ud) \n {\n print(\"Browser: drag-data-received\");\n var delete_selection_data = false;\n vardnd_success = false;\n /* Deal with what we are given from source */\n if( sel_data && sel_data.length ) {\n \n if (ctx.action == Gdk.DragAction.ASK) {\n /* Ask the user to move or copy, then set the ctx action. */\n }\n\n if (ctx.action == Gdk.DragAction.MOVE) {\n delete_selection_data = true;\n }\n var source = Gtk.drag_get_source_widget(ctx);\n\n print(\"Browser: source.DRAGDATA? \" + source.dragData);\n if (this.targetData) {\n print(this.targetData);\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n }\n \n \n \n dnd_success = true;\n\n }\n\n if (dnd_success == false)\n {\n Seed.print (\"DnD data transfer failed!\\n\");\n }\n \n Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);\n return true;\n }", "create_web_view": "function (self, object) {\n print(\"CREATE WEB VIEW\");\n return null; //new WebKit.WebView();\n}" }, + "redraws": 0, "id": "view", "pack": "add", "xtype": "WebView", "|init": "function() {\n XObject.prototype.init.call(this);\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_developer_extras = true;\n \n // this was an attempt to change the url perms.. did not work..\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n var _this = this;\n \n // init inspector..\n this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {\n _this.get('/BottomPane.inspector').el.show();\n return _this.get('/BottomPane.inspector').el;\n \n });\n \n // FIXME - base url of script..\n // we need it so some of the database features work.\n this.el.load_html_string( \"Render not ready\" , \n //fixme - should be a config option!\n // or should we catch stuff and fix it up..\n 'http://localhost/app.Builder/'\n );\n \n \n //this.el.open('file:///' + __script_path__ + '/../builder.html');\n \n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\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 \n // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n \n GLib.timeout_add_seconds(0, 1, function() {\n // print(\"run refresh?\");\n _this.runRefresh(); \n return true;\n });\n \n \n}\n", - "|renderJS": "function(data) {\n this.refreshRequired = true;\n}\n", - "|runRefresh": "function() \n{\n // this is run every 2 seconds from the init..\n\n \n \n if (!this.refreshRequired) {\n // print(\"no refresh required\");\n return;\n }\n\n if (this.lastRedraw) {\n // do not redraw if last redraw was less that 5 seconds ago.\n if (((new Date()) - this.lastRedraw) < 5000) {\n return;\n }\n }\n \n \n \n \n if (!this.get('/Window.LeftTree').getActiveFile()) {\n return;\n }\n this.refreshRequired = false;\n // print(\"HTML RENDERING\");\n \n this.get('/BottomPane').el.show();\n this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n\n \n var js = this.get('/LeftTree.model').toJS();\n if (!js || !js.length) {\n print(\"no data\");\n return;\n }\n var data = js[0];\n \n \n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n // set it to non-empty.\n project.runhtml = project.runhtml || '';\n project.runhtml = project.runhtml.length ? project.runhtml : ''; \n \n\n this.runhtml = this.runhtml || '';\n \n if (project.runhtml != this.runhtml) {\n // then we need to reload the browser using\n // load_html_string..\n \n // then trigger a redraw once it's loaded..\n this.pendingRedraw = true;\n var runhtml = ''+ \"\\n\" ;\n \n this.runhtml = project.runhtml;\n // need to modify paths\n \n \n \n var html = imports.File.File.read(__script_path__ + '/../builder.html');\n html = html.replace('', runhtml + this.runhtml + '');\n print(\"LOAD HTML \" + html);\n this.el.load_html_string( html , \n //fixme - should be a config option!\n 'http://localhost/app.Builder/'\n );\n \n // should trigger load_finished! - which in truns shoudl set refresh Required;\n return;\n \n }\n \n \n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n this.lastRedraw = new Date();\n\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n print( \"before render\" + this.lastRedraw);\n print( \"after render\" + (new Date()));\n \n}\n", + "|renderJS": "function(data, force) {\n\n // this is the public redraw call..\n // we refresh in a loop privately..\n var autodraw = this.get('/RightBrowser.AutoRedraw').el.active;\n if (!autodraw && !force) {\n print(\"Skipping redraw - no force, and autodraw off\");\n return;\n }\n this.refreshRequired = true;\n}\n", + "|runRefresh": "function() \n{\n // this is run every 2 seconds from the init..\n\n \n \n if (!this.refreshRequired) {\n // print(\"no refresh required\");\n return;\n }\n\n if (this.lastRedraw) {\n // do not redraw if last redraw was less that 5 seconds ago.\n if (((new Date()) - this.lastRedraw) < 5000) {\n return;\n }\n }\n \n \n \n \n if (!this.get('/Window.LeftTree').getActiveFile()) {\n return;\n }\n this.refreshRequired = false;\n // print(\"HTML RENDERING\");\n \n this.get('/BottomPane').el.show();\n this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n\n \n var js = this.get('/LeftTree.model').toJS();\n if (!js || !js.length) {\n print(\"no data\");\n return;\n }\n var data = js[0];\n this.redraws++;\n \n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n // set it to non-empty.\n project.runhtml = project.runhtml || '';\n project.runhtml = project.runhtml.length ? project.runhtml : ''; \n \n\n this.runhtml = this.runhtml || '';\n \n if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {\n // then we need to reload the browser using\n // load_html_string..\n \n // then trigger a redraw once it's loaded..\n this.pendingRedraw = true;\n var runhtml = ''+ \"\\n\" ;\n \n this.runhtml = project.runhtml;\n // need to modify paths\n \n \n \n var html = imports.File.File.read(__script_path__ + '/../builder.html');\n html = html.replace('', runhtml + this.runhtml + '');\n print(\"LOAD HTML \" + html);\n this.el.load_html_string( html , \n //fixme - should be a config option!\n 'http://localhost/app.Builder/'\n );\n this.redraws = 0;\n // should trigger load_finished! - which in truns shoudl set refresh Required;\n return;\n \n }\n \n \n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n this.lastRedraw = new Date();\n\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n print( \"before render\" + this.lastRedraw);\n print( \"after render\" + (new Date()));\n \n}\n", "|xns": "WebKit" } ] diff --git a/Builder/Window.js b/Builder/Window.js index 9c9d09688..7e0d14085 100644 --- a/Builder/Window.js +++ b/Builder/Window.js @@ -213,7 +213,7 @@ Window=new XObject({ activate : function (self, event) { var js = this.get('/LeftTree.model').toJS(); if (js && js[0]) { - this.get('/RightBrowser.view').renderJS(js[0]); + this.get('/RightBrowser.view').renderJS(js[0], true); } return false; } @@ -338,29 +338,20 @@ Window=new XObject({ xtype: Gtk.Expander, listeners : { activate : function (self) { - var nb = this.get('/LeftTopPanel.notebook'); - if (this.el.expanded) { - // now expanded.. - - var pm = imports.Builder.Provider.ProjectManager.ProjectManager; - - - var model = this.get('/LeftProjectTree.combomodel'); - // print ("loading Projects?") - //console.dump(pm.projects); - model.loadData(pm.projects); - - - nb.el.set_current_page(1); - //pm.on('changed', function() { - //console.log("CAUGHT project manager change"); - // _combo.model.loadData(pm.projects); - //} - return; - } - nb.el.set_current_page(0); + // this does not actually expand it.. + // that is done by GTK.. + + + + if (!this.el.expanded) { + this.onExpand(); + } else { + this.onCollapse(); + } + }, enter_notify_event : function (self, event) { + return; this.el.expanded = !this.el.expanded; //if (this.el.expanded ) { this.listeners.activate.call(this); @@ -372,22 +363,45 @@ Window=new XObject({ id : "expander", label : "Select Project or File", pack : "pack_start,false,true", + onCollapse : function() { + + var nb = this.get('/LeftTopPanel.notebook'); + nb.el.set_current_page(0); + }, init : function() { XObject.prototype.init.call(this); this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK ); + }, + onExpand : function() { + var nb = this.get('/LeftTopPanel.notebook'); + var pm = imports.Builder.Provider.ProjectManager.ProjectManager; + + + var model = this.get('/LeftProjectTree.combomodel'); + // print ("loading Projects?") + //console.dump(pm.projects); + model.loadData(pm.projects); + + + nb.el.set_current_page(1); + //pm.on('changed', function() { + //console.log("CAUGHT project manager change"); + // _combo.model.loadData(pm.projects); + //} + return; } }, { xtype: Gtk.Notebook, id : "notebook", - show_border : false, - show_tabs : false, pack : "pack_start,true,true", init : function() { XObject.prototype.init.call(this); this.el.set_current_page(0); }, + show_border : false, + show_tabs : false, items : [ { xtype: Gtk.ScrolledWindow, @@ -1561,7 +1575,8 @@ Window=new XObject({ var nb = this.get('/LeftTopPanel.expander'); nb.el.expanded = false; - nb.listeners.activate.call(nb); + nb.onCollapse(); + //nb.listeners.activate.call(nb); //_expander.el.set_expanded(false); var ltm = this.get('/LeftTree.model'); @@ -1900,21 +1915,96 @@ Window=new XObject({ }, { xtype: Gtk.ScrolledWindow, + editing : false, id : "LeftPanel", pack : "add", - shadow_type : Gtk.ShadowType.IN, - editing : false, init : function() { XObject.prototype.init.call(this); this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }, + shadow_type : Gtk.ShadowType.IN, items : [ { xtype: Gtk.TreeView, + listeners : { + button_press_event : function (self, ev) { + + + var res = { }; + + if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) { + return false; //not on a element. + } + + // right click. + if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button.button == 3) { + // show popup!. + if (res.column.title == 'value' && this.get('/LeftPanel').editing) { + return false; + } + //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init(); + var p = this.get('/LeftPanelPopup'); + if (!p.el) { + p.init(); + } + + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, null, 3, ev.button.time); + //Seed.print("click:" + res.column.title); + + + return false; + } + + + if (res.column.title != 'value') { + // XObject.error("column is not value?"); + return false; // ignore.. - key click.. ??? should we do this?? + } + + // currently editing??? + // if ( this.activePath) { + + // this.activePath = false; + // stop editing!!!! + this.get('/LeftPanel').editableColumn.items[0].el.stop_editing(); + this.get('/LeftPanel').editing = false; + + // XObject.error("Currently editing?"); + // return false; + // } + + var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry.. + + var type = this.get('/LeftPanel.model').getType(res.path.to_string()); + + // get options for this type -- this is to support option lists etc.. + var provider = this.get('/LeftTree').getPaleteProvider(); + var opts = provider.findOptions(type); + + if (opts === false) { + // it's text etnry + this.get('/LeftPanel').editableColumn.setOptions([]); + renderer.has_entry = true; + } else { + this.get('/LeftPanel').editableColumn.setOptions(opts); + renderer.has_entry = false; + } + this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1); + + //Seed.print("click" + ev.type); + //console.dump(res); + return false; + + + + } + }, id : "view", tooltip_column : 5, - headers_visible : false, enable_tree_lines : true, + headers_visible : false, init : function() { XObject.prototype.init.call(this); @@ -1926,68 +2016,6 @@ Window=new XObject({ description.set_size(8000); this.el.modify_font(description); }, - listeners : { - button_press_event : function (self, ev) { - - - var res = { }; - if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) { - return false; //not on a element. - } - - - if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) { - - if (res.column.title != 'value') { - return false; // ignore.. - } - if ( this.get('/LeftPanel').editing) { - return false; - } - var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry.. - this.get('/LeftPanel').editableColumn.items[0].el.stop_editing(); - var type = this.get('/LeftPanel.model').getType(res.path.to_string()); - - - - var provider = this.get('/LeftTree').getPaleteProvider(); - - var opts = provider.findOptions(type); - - if (opts === false) { - this.get('/LeftPanel').editableColumn.setOptions([]); - renderer.has_entry = true; - } else { - LeftPanel.editableColumn.setOptions(opts); - renderer.has_entry = false; - } - - - //Seed.print("click" + ev.type); - //console.dump(res); - return false; - } - - - - if (res.column.title == 'value') { - return false; - } - //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init(); - var p = this.get('/LeftPanelPopup'); - if (!p.el) { - p.init(); - } - - p.el.set_screen(Gdk.Screen.get_default()); - p.el.show_all(); - p.el.popup(null, null, null, null, 3, ev.button.time); - //Seed.print("click:" + res.column.title); - - - return false; - } - }, items : [ { xtype: Gtk.TreeStore, @@ -2098,61 +2126,6 @@ Window=new XObject({ this.load(data); this.get('/LeftTree.model').changed(data, true); - }, - editSelected : function(e) { - print("EDIT SELECTED?"); - var iter = new Gtk.TreeIter(); - var s = this.get('/LeftPanel.view').selection; - s.get_selected(this.get('/LeftPanel.model').el, iter); - var m = this.get('/LeftPanel.model') - - var gval = new GObject.Value(''); - this.el.get_value(iter, 0 ,gval); - var val = '' + gval.value; - - gval = new GObject.Value(''); - this.el.get_value(iter, 1 ,gval); - var rval = gval.value; - var activePath = this.el.get_path(iter).to_string(); - this.activePath = activePath ; - // was activeIter... - // not listener... - - var showEditor = false; - - if (val[0] == '!') { - showEditor = true; - } - if (val[0] == '|') { - if (rval.match(/function/g) || rval.match(/\n/g) || rval.length > 20) { - showEditor = true; - } - } - - if (showEditor) { - var _this = this; - this.activePath = false; - GLib.timeout_add(0, 1, function() { - // Gdk.threads_enter(); - _this.get('/BottomPane').el.show(); - _this.get('/RightEditor').el.show(); - _this.get('/RightEditor.view').load( rval ); - - e.editing_done(); - e.remove_widget(); - _this.activePath = activePath ; - - // Gdk.threads_leave(); - return false; - }); - return; - } - this.get('/BottomPane').el.hide(); - this.get('/RightEditor').el.hide(); - - //var type = this.getValue(this.el.get_path(iter).to_string(),4); - - }, getIterValue : function(iter, col) { var gval = new GObject.Value(''); @@ -2162,13 +2135,17 @@ Window=new XObject({ getType : function(treepath) { return this.getValue(treepath, 4); }, - getValue : function(treepath_str, col) { - var iter = new Gtk.TreeIter(); + getValue : function(treepath_str, col) + { + // get's the value in a row.. - keys - returns string, values - formats it.. + + var iter = new Gtk.TreeIter(); this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str)); var gval = new GObject.Value(''); this.get('/LeftPanel.model').el.get_value(iter, col ,gval); var val = '' + gval.value; + if (col != 1) { return val; } @@ -2260,13 +2237,15 @@ Window=new XObject({ return ret; }, startEditing : function(path,col) { + // alled by menu 'edit' currently.. /** * start editing path (or selected if not set..) * @param {String|false} path (optional) treepath to edit - selected tree gets * edited by default. * @param {Number} 0 or 1 (optional)- column to edit. */ - var tp; + // fix tp to be the 'treepath' string (eg. 0/1/2...) + var tp; if (typeof(path) == 'string') { tp = new Gtk.TreePath.from_string(path); } else { @@ -2280,8 +2259,12 @@ Window=new XObject({ // which colum is to be edited.. var colObj = false; + + // not sure what this does.. + if (typeof(col) == 'undefined') { var k = this.getValue(path, 0); + col = 1; colObj = (!k.length || k == '|') ? this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn; } else { @@ -2290,25 +2273,65 @@ Window=new XObject({ // make sure the pulldown is set correctly.. // not really needed for second col... - - var provider = this.get('/LeftTree').getPaleteProvider(); - - var type = this.get('/LeftPanel.model').getType(path); - var opts = provider.findOptions(type); - var renderer = this.get('/LeftPanel').editableColumn.items[0].el; + var showEditor = false; - if (opts === false) { - this.get('/LeftPanel').editableColumn.setOptions([]); - renderer.has_entry = true; /// probably does not have any effect. - } else { - this.get('/LeftPanel').editableColumn.setOptions(opts); - renderer.has_entry = false; + if (col) { + var provider = this.get('/LeftTree').getPaleteProvider(); + var type = this.get('/LeftPanel.model').getType(path); + var opts = provider.findOptions(type); + var renderer = this.get('/LeftPanel').editableColumn.items[0].el; + + if (opts === false) { + this.get('/LeftPanel').editableColumn.setOptions([]); + renderer.has_entry = true; + } else { + this.get('/LeftPanel').editableColumn.setOptions(opts); + renderer.has_entry = false;/// - pulldowns do not have entries + } + // determine if we should use the Text editor... + var keyname = this.getValue(path, 0); + var data_value = this.getValue(path, 1); + + if ((keyname[0] == '|') || + ( + (typeof(data_value) == 'string' ) && + ( data_value.match(/function/g) || data_value.match(/\n/g)) // || (data_value.length > 20)) + )) { + showEditor = true; + } + print("SHOW EDITOR" + showEditor ? 'YES' :'no'); + } + var _this = this; + // end editing.. + this.get('/BottomPane').el.hide(); + this.get('/RightEditor').el.hide(); + + + if (showEditor) { + + this.activePath = false; + GLib.timeout_add(0, 1, function() { + + _this.get('/BottomPane').el.show(); + _this.get('/RightEditor').el.show(); + _this.get('/RightEditor.view').load( _this.getValue(path, 1) ); + + //e.editing_done(); + //e.remove_widget(); + _this.activePath = path ; + + return false; + }); + return; + } + - var _this=this; + + // iter now has row... GLib.timeout_add(0, 100, function() { - + _this.activePath = path; colObj.items[0].el.editable = true; // esp. need for col 0.. _this.get('/LeftPanel.view').el.set_cursor_on_cell( tp, @@ -2391,11 +2414,12 @@ Window=new XObject({ { xtype: Gtk.TreeViewColumn, pack : "append_column", + title : "value", init : function() { XObject.prototype.init.call(this); this.el.add_attribute(this.items[0].el , 'text', 3 ); this.el.add_attribute(this.items[0].el , 'sensitive', 3 ); - this.el.add_attribute(this.items[0].el , 'editable', 3 ); + //this.el.add_attribute(this.items[0].el , 'editable', 3 ); // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL); this.get('/LeftPanel').editableColumn= this; @@ -2414,30 +2438,34 @@ Window=new XObject({ items : [ { xtype: Gtk.CellRendererCombo, - pack : "pack_start", - editable : true, - has_entry : true, - text_column : 0, - init : function() { - XObject.prototype.init.call(this); - this.el.model = new Gtk.ListStore(); - this.el.model.set_column_types ( 1, [ - GObject.TYPE_STRING // 0 real key - ]); - }, listeners : { edited : function (self, object, p0) { this.get('/LeftPanel').editing = false; - print("EDITED? p:" + p0 + " t:" + p0); + var ap = this.get('/LeftPanel.model').activePath + print("EDITED? " + ap + " - p:" + p0 + " t:" + p0); this.get('/LeftPanel.model').changed(p0, true); this.get('/LeftPanel.model').activePath = false; + this.el.editable = false; }, editing_started : function (self, editable, path) { this.get('/LeftPanel').editing = true; // console.log('editing started'); // r.has_entry = false; - this.get('/LeftPanel.model').editSelected(editable); + + this.el.editable = false; // make sure it's not editor... + } + }, + pack : "pack_start", + text_column : 0, + editable : true, + has_entry : true, + init : function() { + XObject.prototype.init.call(this); + this.el.model = new Gtk.ListStore(); + this.el.model.set_column_types ( 1, [ + GObject.TYPE_STRING // 0 real key + ]); } } ] @@ -2722,6 +2750,34 @@ Window=new XObject({ id : "RightBrowser", pack : "add", items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + listeners : { + clicked : function (self) { + this.get('/RightBrowser.view').renderJS(null,true); + } + }, + label : "Redraw", + pack : "pack_start,false,false,0" + }, + { + xtype: Gtk.CheckButton, + listeners : { + toggled : function (self, state) { + this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off"); + } + }, + active : true, + id : "AutoRedraw", + label : "Auto Redraw On", + pack : "pack_start,false,false,0" + } + ] + }, { xtype: Gtk.ScrolledWindow, pack : "add", @@ -2906,6 +2962,7 @@ Window=new XObject({ return null; //new WebKit.WebView(); } }, + redraws : 0, id : "view", pack : "add", init : function() { @@ -2958,7 +3015,15 @@ Window=new XObject({ }, - renderJS : function(data) { + renderJS : function(data, force) { + + // this is the public redraw call.. + // we refresh in a loop privately.. + var autodraw = this.get('/RightBrowser.AutoRedraw').el.active; + if (!autodraw && !force) { + print("Skipping redraw - no force, and autodraw off"); + return; + } this.refreshRequired = true; }, runRefresh : function() @@ -2998,7 +3063,7 @@ Window=new XObject({ return; } var data = js[0]; - + this.redraws++; var project = this.get('/Window.LeftTree').getActiveFile().project; //print (project.fn); @@ -3009,7 +3074,7 @@ Window=new XObject({ this.runhtml = this.runhtml || ''; - if (project.runhtml != this.runhtml) { + if ((project.runhtml != this.runhtml) || (this.redraws > 10)) { // then we need to reload the browser using // load_html_string.. @@ -3031,7 +3096,7 @@ Window=new XObject({ //fixme - should be a config option! 'http://localhost/app.Builder/' ); - + this.redraws = 0; // should trigger load_finished! - which in truns shoudl set refresh Required; return; diff --git a/builder.sh b/builder.sh index ff739f07b..8fa6a00a0 100755 --- a/builder.sh +++ b/builder.sh @@ -3,4 +3,4 @@ export GI_TYPELIB_PATH=~/.Builder/girepository-1.1 # run theapplication. -seed gtkrun.js Sample \ No newline at end of file +seed gtkrun.js Builder diff --git a/gir-1.1 b/gir-1.1 index 41e741c79..6167de400 160000 --- a/gir-1.1 +++ b/gir-1.1 @@ -1 +1 @@ -Subproject commit 41e741c79921d77fe46fc2778899d6553b8b6a11 +Subproject commit 6167de400f7cc2594b574657de7b042a6a4a2ddb diff --git a/roojs1 b/roojs1 index cbdd15997..024aa1e05 160000 --- a/roojs1 +++ b/roojs1 @@ -1 +1 @@ -Subproject commit cbdd15997f956a85ddd189d244fe489d0459ab61 +Subproject commit 024aa1e059e89298284f5c4daf2d4b3ecf02eecf -- 2.39.2