"|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",
]
},
{
- "|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,
"|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, '<b>'+ i + '</b>');\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"
]
},
{
- "|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"
}
]
}
{
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,
},
{
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);
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,
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('');
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;
}
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 {
// 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 {
// 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,
{
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;
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
+ ]);
}
}
]