From a25b6921e330ba47345df658f48162ed0e519621 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 1 Nov 2010 14:16:01 +0800 Subject: [PATCH] Sample/Window.bjs --- Sample/Window.bjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sample/Window.bjs b/Sample/Window.bjs index 9871653a6..9a3f7550d 100644 --- a/Sample/Window.bjs +++ b/Sample/Window.bjs @@ -666,7 +666,7 @@ "|getType": "function(treepath) {\n return this.getValue(treepath, 4);\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", + "|load": "function(ar) {\n// might casue problesm..\n this.get('/Editor.RightEditor').save();\n this.get('/Editor').el.hide();\n this.get('/Editor').activePath = false;\n\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 // 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 this.get('/Editor').activePath = false;\n this.get('/Editor').el.hide();\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 \n _this.get('/Editor').el.show_all();\n GLib.timeout_add(0, 1, function() {\n\n //_this.get('/BottomPane').el.show();\n //_this.get('/RightEditor').el.show();\n \n _this.get('/Editor.RightEditor.view').load( _this.getValue(path, 1) );\n \n _this.get('/Editor').activePath = path;\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", -- 2.39.2