From e37d8b7ac343d45c94dec04dd26ecc34ab0fcbc6 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 25 May 2010 09:23:39 +0800 Subject: [PATCH] sync --- Builder/Window.bjs | 2 +- Builder/Window.js | 1260 +++++++++++++++++++++++--------------------- Sample/Window.bjs | 2 +- Sample/Window.js | 1260 +++++++++++++++++++++++--------------------- roojs1 | 2 +- 5 files changed, 1305 insertions(+), 1221 deletions(-) diff --git a/Builder/Window.bjs b/Builder/Window.bjs index 6f31eb83f..ef12f6aed 100644 --- a/Builder/Window.bjs +++ b/Builder/Window.bjs @@ -1 +1 @@ -{"id":"file-gtk-4","name":"Window","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/Window.bjs","items":[{"|xns":"Gtk","xtype":"Window","|type":"Gtk.WindowType.TOPLEVEL","title":"Application Builder","border_width":0,"|init":"function() {\n this.atoms = {\n \"STRING\" : Gdk.atom_intern(\"STRING\")\n\t};\n\tthis.targetList = new Gtk.TargetList();\n\tthis.targetList.add( this.atoms[\"STRING\"], 0, 0);\n\t//imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\nGtk.rc_parse_string(\n \"style \\\"gtkcombobox-style\\\" {\\n\" + \n \" GtkComboBox::appears-as-list = 1\\n\" +\n \"}\\n\"+\n \"class \\\"GtkComboBox\\\" style \\\"gtkcombobox-style\\\"\\n\");\n XObject.prototype.init.call(this);\n this.el.show_all();\n \n \n \n}\n","default_width":800,"default_height":500,"id":"Window","listeners":{"delete_event":"function (self, event) {\n return false;\n}","destroy":"function (self) {\n Gtk.main_quit();\n}","show":"function (self) {\n print(\"WINDOW SHOWING - trying to hide\");\nimports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\n \tthis.get('/MidPropTree').hideWin();\n this.get('/RightPalete').hide();\n\n}"},"items":[{"|xns":"Gtk","xtype":"VBox","id":"w-vbox","items":[{"|xns":"Gtk","xtype":"MenuBar","pack":"pack_start,false,false","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"_File","items":[{"|xns":"Gtk","xtype":"Menu","pack":"set_submenu","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"New _Project","listeners":{"activate":"function (self) {\n\tthis.get('/EditProject').show({\n\t success : function(pr) {\n\t\t this.get('/LeftProjectTree').get('combo').setValue(pr.fn);\n\t }\n\t});\n}"}},{"|xns":"Gtk","xtype":"MenuItem","label":"_New File","|use_underline":true,"listeners":{"activate":"function (self) {\n \tvar fn = this.get('/LeftProjectTree.combo').getValue();\n if (!fn) {\n this.get('/LeftProjectTree').showNoProjectSelected();\n return true;\n }\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n this.get('/DialogNewComponent').show({\n project : pm.getByFn(fn)\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"_Quit","|use_underline":true,"listeners":{"activate":"function (self) {\n Gtk.main_quit();\n} "}}]}]},{"|xns":"Gtk","xtype":"MenuItem","label":"Help"}]},{"|xns":"Gtk","xtype":"HPaned","id":"left","position":400,"items":[{"|xns":"Gtk","xtype":"HBox","items":[{"|xns":"Gtk","xtype":"VPaned","position":300,"id":"leftvpaned","items":[{"|xns":"Gtk","xtype":"VBox","id":"LeftTopPanel","items":[{"|xns":"Gtk","xtype":"Expander","label":"Select Project","id":"expander","pack":"pack_start,false,true","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","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}"}},{"|xns":"Gtk","xtype":"Notebook","id":"notebook","|show_border":false,"|show_tabs":false,"pack":"pack_start,true,true","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_current_page(0);\n\n}\n","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n","id":"LeftTree","|getPaleteProvider":"function() {\n var model = this.get('model');\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n return pm.getPalete(model.file.getType());\n}\n","|renderView":"function() {\n \t var model = this.get('model');\n\tprint(\"RENDER VIEW?\" + model.file.getType());\n\tswitch( model.file.getType()) {\n\t\tcase 'Roo':\n\t\t this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);\n\t\tcase 'Gtk':\n\t\t this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);\n\t}\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","pack":"add","id":"view","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":0,"|init":"function() {\n \tXObject.prototype.init.call(this);\n\tvar description = new Pango.FontDescription.c_new();\n\tdescription.set_size(8000);\n\tthis.el.modify_font(description);\n\n\tthis.selection = this.el.get_selection();\n\tthis.selection.set_mode( Gtk.SelectionMode.SINGLE);\n\tvar _this = this;\n\tthis.selection.signal['changed'].connect(function() {\n\t\t_this.get('/LeftTree.view').listeners.cursor_changed.apply(\n\t\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n\t\t);\n\t});\n\n\tGtk.drag_source_set (\n\t\tthis.el, /* widget will be drag-able */\n\t\tGdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n\t\tnull, /* lists of target to support */\n\t\t0, /* size of list */\n\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n\n\tGtk.drag_source_add_text_targets(this.el); \n\tGtk.drag_dest_set\n\t(\n\t this.el, /* widget that will accept a drop */\n\t Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n\t null, /* lists of target to support */\n\t 0, /* size of list */\n\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n\tGtk.drag_dest_add_text_targets(this.el);\n}\n","|highlight":"function(treepath_ar) {\n if (treepath_ar.length && treepath_ar[0].length ) {\n this.el.set_drag_dest_row( \n new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n }","|selectNode":"function(treepath_str) {\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n","listeners":{"button_press_event":"function (self, ev) {\n \tconsole.log(\"button press?\");\n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {\n print(\"click\" + ev.type);\n return false;\n }\n \n \n var res = {}; \n this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);\n \n if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();\n \n this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());\n this.get('/LeftTreeMenu').el.show_all();\n this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);\n print(\"click:\" + res.path.to_string());\n return false;\n}","drag_begin":"function (self, drag_context) {\n\tprint('SOURCE: drag-begin');\n this.targetData = false;\n // find what is selected in our tree...\n var iter = new Gtk.TreeIter();\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n var xname = this.get('/LeftTree.model').file.guessName(data);\n \n this.el.dragData = xname;\n this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);\n \n\n // make the drag icon a picture of the node that was selected\n var path = this.get('/LeftTree.model').el.get_path(iter);\n this.el.treepath = path.to_string();\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_pixmap (ctx,\n pix.get_colormap(),\n pix,\n null,\n -10,\n -10);\n \n return true;\n}","drag_end":"function (self, drag_context) {\n\tSeed.print('LEFT-TREE: drag-end');\n this.el.dragData = false;\n this.el.dropList = false;\n this.targetData = false;\n this.get('/LeftTree.view').highlight(false);\n return true;\n}","drag_motion":"function (self, ctx, x, y, time) {\n console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n\n // a drag from elsewhere...- prevent drop..\n if (!src.dragData) {\n print(\"no drag data!\");\n Gdk.drag_status(ctx, 0, time);\n this.targetData = false;\n return true;\n }\n var action = Gdk.DragAction.COPY;\n if (src == this.el) {\n // unless we are copying!!! ctl button..\n action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n }\n var data = {};\n\n\t\tif (!this.get('/LeftTree.model').el.iter_n_children(null)) {\n\t\t\t// no children.. -- asume it's ok..\n\t\t\tthis.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];\n\t\t\tGdk.drag_status(ctx, action ,time);\n\t\t\treturn true;\n\t\t}\n\n print(\"GETTING POS\");\n var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);\n print(\"ISOVER? \" + isOver);\n if (!isOver) {\n Gdk.drag_status(ctx, 0 ,time);\n return false; // not over apoint!?!\n }\n // drag node is parent of child..\n console.log(\"SRC TREEPATH: \" + src.treepath);\n console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n if (typeof(src.treepath) != 'undefined' && \n src.treepath == data.path.to_string().substring(0,src.treepath.length)) {\n print(\"subpath drag\");\n Gdk.drag_status(ctx, 0 ,time);\n return false;\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n print(data.path.to_string() +' => '+ data.pos);\n var tg = this.get('/LeftTree.model').findDropNodeByPath(\n data.path.to_string(), src.dropList, data.pos);\n \n this.get('/LeftTree.view').highlight(tg);\n if (!tg.length) {\n print(\"Can not find drop node path\");\n this.targetData = false;\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n //console.dump(tg);\n this.targetData = tg; \n \n \n Gdk.drag_status(ctx, action ,time);\n \n return true;\n}","drag_drop":"function (w, ctx, x, y, time) {\n Seed.print(\"TARGET: drag-drop\");\n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return true;\n}","drag_data_received":"function (self, ctx, x, y, sel_data, info, time) {\n\t print(\"Tree: drag-data-received\");\n\n var delete_selection_data = false;\n var dnd_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 \n var source = Gtk.drag_get_source_widget(ctx);\n\n if (this.targetData) {\n if (source != this.el) {\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n } else {\n // drag around.. - reorder..\n this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);\n \n \n }\n //Seed.print(this.targetData);\n \n }\n \n \n \n // we can send stuff to souce here...\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}","cursor_changed":"function (self) {\n if (this.blockChanges) {\n return true;\n }\n var iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n this.get('/LeftPanel.model').load( false);\n this.get('/MidPropTree').activeElement = false;\n this.get('/MidPropTree').hideWin();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/LeftTree').getPaleteProvider()) {\n // it may not be loaded yet..\n return true;\n }\n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n return true;\n }\n \n //console.log('changed');\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n \n \n // var val = \"\";\n value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();\n \n var data = JSON.parse(value.value);\n this.get('/MidPropTree').activeElement = data;\n this.get('/MidPropTree').hideWin();\n this.get('/LeftPanel.model').load( data);\n \n console.log(value.value);\n // _g.button.set_label(''+value.get_string());\n\n var pm =this.get('/RightPalete.model');\n pm.load( this.get('/RightPalete').provider.gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n \n \n \n //Seed.print( value.get_string());\n return true;\n \n}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // source..\n ] );\n}\n","activePath":false,"|changed":"function(n, refresh) {\n print(\"MODEL CHANGED CALLED\" + this.activePath);\n if (this.activePath) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))\n this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n \n this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);\n }\n //this.currentTree = this.toJS(false, true)[0];\n this.file.items = this.toJS(false, false);\n print(\"AFTER CHANGED\");\n //console.dump(this.file.items);\n this.file.save();\n this.currentTree = this.file.items[0];\n //console.log(this.file.toSource());\n \n if (refresh) {\n print(\"REDNER BROWSER?!\");\n this.get('/LeftTree').renderView();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/RightPalete').provider) {\n pm.load([]);\n return;\n }\n \n \n pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));\n //imports['Builder/RightBrowser.js'].renderJS(this.toJS());\n }\n\t \n}\n","|loadFile":"function(f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n if (!f) {\n console.log('missing file');\n return;\n }\n \n // load the file if not loaded..\n if (f.items === false) {\n var _this = this;\n f.loadItems(function() {\n _this.loadFile(f);\n });\n return;\n \n }\n if (f.items.length && typeof(f.items[0]) == 'string') {\n \n this.get('/RightEditor').el.show();\n this.get('/RightEditor.view').load( f.items[0]);\n return;\n }\n print(\"LOAD\");\n //console.dump(f.items);\n this.load(f.items);\n this.get('/LeftTree.view').el.expand_all();\n\n if (!f.items.length) {\n // single item..\n \n this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n this.get('/LeftTree.view').el.set_cursor( \n new Gtk.TreePath.from_string('0'), null, false);\n \n \n } else {\n this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n \n //print(\"hide right editior\");\n this.get('/RightEditor').el.hide();\n //print(\"set current tree\");\n this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n this.currentTree = this.currentTree || { items: [] };\n this.get('/LeftTree').renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n \n}\n","|findDropNode":"function(treepath_str, targets) {\n\n// this is used by the dragdrop code in the roo version AFAIR..\n\n \t\tvar path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (!this.el.iter_n_children(null)) {\n print(\"NO KEYS\");\n return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];\n }\n print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n if (!treepath_str.match(/^builder-/)) {\n return []; // nothing!\n }\n if (targets === true) {\n return [ path ];\n }\n return this.findDropNodeByPath(path,targets) \n}\n","|findDropNodeByPath":"function(treepath_str, targets, pref) {\n var path = treepath_str + ''; // dupe it..\n pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;\n var last = false;\n //console.dump(this.treemap);\n while (path.length) {\n print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.singleNodeToJS(path);\n if (node_data === false) {\n print(\"node not found\");\n return [];\n }\n \n var xname = this.get('/LeftTree.model').file.guessName(node_data);\n var match = false;\n var prop = '';\n targets.forEach(function(tg) {\n if (match) {\n return;;\n }\n if ((tg == xname) ) {\n match = tg;\n }\n if (tg.indexOf(xname +':') === 0) {\n match = tg;\n prop = tg.split(':').pop();\n }\n });\n \n if (match) {\n if (last) { // pref is after/before..\n // then it's after last\n if (pref > 1) {\n return []; // do not allow..\n }\n return [ last, pref , prop];\n \n }\n return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];\n }\n var par = path.split(':');\n last = path;\n par.pop();\n path = par.join(':');\n }\n \n return [];\n \n}\n","|dropNode":"function(target_data, node) {\n print(\"drop Node\");\n \t console.dump(node);\n \t console.dump(target_data);\n var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;\n \n print(\"add \" + tp + \"@\" + target_data[1] );\n var parent = tp;\n var after = false;\n if (tp && target_data[1] < 2) { // before or after..\n var ar = target_data[0].split(':');\n ar.pop();\n parent = new Gtk.TreePath.from_string( ar.join(':') );\n after = tp;\n }\n var n_iter = new Gtk.TreeIter();\n var iter_par = new Gtk.TreeIter();\n var iter_after = after ? new Gtk.TreeIter() : false;\n \n \n \n if (parent !== false) {\n this.el.get_iter(iter_par, parent);\n } else {\n iter_par = null;\n }\n \n \n if (tp && after) {\n print(target_data[1] > 0 ? 'insert_after' : 'insert_before');\n this.el.get_iter(iter_after, after);\n this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](\n n_iter, iter_par, iter_after);\n \n } else {\n this.el.append(n_iter, iter_par);\n \n }\n \n if (typeof(node) == 'string') {\n var ar = node.split('.');\n var xtype = ar.pop();\n \n node = {\n '|xns' : ar.join('.'),\n 'xtype' : xtype\n };\n if (target_data.length == 3 && target_data[2].length) {\n node['*prop'] = target_data[2];\n }\n \n }\n // work out what kind of packing to use..\n if (typeof(node.pack) == 'undefined' && parent !== false) {\n var pal = this.get('/LeftTree').getPaleteProvider();\n \n var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));\n print (\"PNAME : \" + pname);\n var cname = pal.guessName(node);\n print (\"CNAME : \" + cname);\n node.pack = pal.getDefaultPack(pname, cname);\n \n \n }\n \n \n var xitems = [];\n if (node.items) {\n xitems = node.items;\n delete node.items;\n }\n// load children - if it has any..\n\n if (xitems) {\n this.load(xitems, n_iter);\n }\n if (tp && (xitems || after)) {\n this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);\n }\n // wee need to get the empty proptypes from somewhere..\n \n //var olditer = this.activeIter;\n this.activePath = this.el.get_path(n_iter).to_string();\n\n\t // changed actually set's the node data..\n this.changed(node, true);\n \n \n \n this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);\n \n //Builder.MidPropTree._model.load(node);\n //Builder.MidPropTree._win.hideWin();\n //Builder.LeftPanel._model.load( node);\n \n \n}\n","|moveNode":"function(target_data, action) {\n //print(\"MOVE NODE\");\n // console.dump(target_data);\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var node = this.nodeToJS(old_iter,false);\n //console.dump(node);\n \n \n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n \n this.dropNode(target_data, node);\n\t if (action & Gdk.DragAction.MOVE) {\n // print(\"REMOVING OLD NODE\");\n this.el.remove(old_iter);\n \n }\n \n this.activePath= false;\n this.changed(false,true);\n}\n","|deleteSelected":"function() {\n this.get('/LeftTree.view').blockChanges = true;\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var path = this.el.get_path(old_iter).to_string();\n\n this.activePath= false; \n s.unselect_all();\n\n this.activePath= false; \n\t var iter = new Gtk.TreeIter();\n this.el.get_iter_from_string(iter, path);\n this.el.remove(iter);\n \n // rebuild treemap. -- depreciated.!!\n this.map = {};\n this.treemap = { };\n //this.toJS(null, true) // does not do anything?\n this.activePath= false; \n this.changed(false,true);\n this.get('/LeftTree.view').blockChanges = false;\n}\n","currentTree":false,"|listAllTypes":"function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n \n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n","|singleNodeToJS":"function (treepath) \n {\n var iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n \n var iv = this.getIterValue(iter, 2);\n \n return JSON.parse(iv);\n \n }","|nodeToJS":"function (iter, with_id) \n{\n var par = new Gtk.TreeIter(); \n var iv = this.getIterValue(iter, 2);\n // print(\"IV\" + iv);\n var k = JSON.parse(iv);\n if (k.json && !this.el.iter_parent( par, iter )) {\n delete k.json;\n }\n \n if (with_id) {\n var treepath_str = this.el.get_path(iter).to_string();\n // not sure how we can handle mixed id stuff..\n if (typeof(k.id) == 'undefined') {\n k.id = 'builder-'+ treepath_str ;\n }\n \n // needed??\n this.treemap[ treepath_str ] = k;\n k.xtreepath = treepath_str ;\n \n }\n if (this.el.iter_has_child(iter)) {\n citer = new Gtk.TreeIter();\n this.el.iter_children(citer, iter);\n k.items = this.toJS(citer,with_id);\n }\n return k;\n}\n","|toJS":"function(iter, with_id)\n {\n //Seed.print(\"WITHID: \"+ with_id);\n \n var first = false;\n if (!iter) {\n \n this.treemap = { }; \n \n iter = new Gtk.TreeIter();\n if (!this.el.get_iter_first(iter)) {\n return [];\n }\n first = true;\n } \n \n var ar = [];\n \n while (true) {\n \n var k = this.nodeToJS(iter, with_id); \n ar.push(k);\n \n \n if (!this.el.iter_next(iter)) {\n break;\n }\n }\n \n return ar;\n // convert the list into a json string..\n \n \n }","|getIterValue":" function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}","|nodeTitle":"function(c) {\n var txt = [];\n c = c || {};\n var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;\n if (sr) txt.push('');\n if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }\n if (c.xtype) { txt.push(c.xtype); }\n if (c.id) { txt.push('[id=' + c.id + ']'); }\n if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }\n if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }\n \n \n if (c.layout) { txt.push('' + c.layout + ''); }\n if (c.title) { txt.push('' + c.title + ''); }\n if (c.label) { txt.push('' + c.label+ ''); }\n if (c.header) { txt.push('' + c.header + ''); }\n if (c.legend) { txt.push('' + c.legend + ''); }\n if (c.text) { txt.push('' + c.text + ''); }\n if (c.name) { txt.push('' + c.name+ ''); }\n if (c.region) { txt.push('(' + c.region + ')'); }\n if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }\n \n // for flat classes...\n if (typeof(c['*class']) != 'undefined') { txt.push('' + c['*class']+ ''); }\n if (typeof(c['*extends']) != 'undefined') { txt.push(': ' + c['*extends']+ ''); }\n \n \n if (sr) txt.push('');\n return (txt.length == 0 ? \"Element\" : txt.join(\" \"));\n}\n","|nodeToJSON":"function(c) {\n var o = {}\n for (var i in c) {\n if (i == 'items') {\n continue;\n }\n o[i] = c[i];\n }\n return JSON.stringify(o);\n}\n","|load":"function(tr,iter)\n {\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (iter) {\n this.el.insert(citer,iter,-1);\n } else {\n this.el.append(citer);\n }\n \n this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);\n if (tr[i].items && tr[i].items.length) {\n this.load(tr[i].items, citer);\n }\n } \n }"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"LeftTreeMenu","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"Delete Element","listeners":{"activate":"function (self) {\n\n this.get('/LeftTree.model').deleteSelected();\n}"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"LeftProjectTree","|showNoProjectSelected":"function() {\n this.get('/StandardErrorDialog').show(\"Select a Project first.\"); \n}\n","|getActiveProject":"function() {\n return this.project;\n}\n","listeners":{"leave_notify_event":"function (self, event) {\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","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 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}"},"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true","id":"render"},{"|xns":"Gtk","xtype":"ListStore","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 \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","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":1,"|init":"function() {\n XObject.prototype.init.call(this);\nvar 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}\n","id":"view","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 \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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // id..\n ] );\n \n}\n","|loadProject":"function(pr) {\n this.el.clear();\n if (!pr) {\n return;\n }\n this.get('/LeftProjectTree').project = pr;\n this.load(pr.toTree());\n this.get('/LeftProjectTree.view').el.expand_all();\n}\n","|load":"function(tr,iter) {\n console.dump(tr);\n console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n \n var _this = this;\n tr.forEach(function (r) {\n if (!iter) {\n _this.el.append(citer); \n } else {\n _this.el.insert(citer,iter,-1);\n }\n _this.el.set_value(citer, 0, '' + r.getTitle() ); // title \n _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip\n _this.el.set_value(citer, 2, '' + r.id ); //id\n if (r.cn && r.cn.length) {\n _this.load(r.cn, citer);\n }\n \n });\n}\n","|getValue":"function(iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]},{"|xns":"Gtk","xtype":"VBox","listeners":{},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","id":"LeftProps","items":[{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('props');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Property"}]}]},{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('events');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Handler"}]}]},{"|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}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Other"}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"AddPropertyPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Using this.get('*someid') will find any id in an application.","label":"ID","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : 'id', \n type : 'string',\n val : '',\n //skel : skel,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add what type of packing is to be used","label":"PACK","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : 'pack', \n \t type : 'string',\n \t val : 'add',\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Override the init method","label":"INIT","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : '|init', \n type : 'function',\n val : \"function() {\\n XObject.prototype.init.call(this);\\n}\\n\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined string property","label":"String","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'string',\n val : \"\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined number property","label":"Number","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'number',\n val : 0,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined boolean property","label":"Boolean","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'boolean',\n val : false,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user function boolean property","label":"Function","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : '|', \n type : 'function',\n val : \"function() {\\n \\n}\\n\",\n etype : 'props'\n });\n}"}}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","id":"LeftPanel","pack":"add","|shadow_type":"Gtk.ShadowType.IN","editing":false,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","id":"view","tooltip_column":1,"|headers_visible":false,"|enable_tree_lines":true,"|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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 5, [\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 \n ]);\n}\n","|toShort":"function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\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 \n // sort!!!?\n var iter = new Gtk.TreeIter();\n for (var i in ar) {\n if (typeof(ar[i]) == 'object') {\n continue;\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 }\n ar.listeners = ar.listeners || {};\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 }\n return ret;\n}\n","|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 == '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","|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","|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","activePath":false,"|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 // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \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","|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 'boolean':\n return val == 'true' ? true : false;\n default: \n return val;\n }\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)) {\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('/RightEditor').el.show();\n\t\t _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 \n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\n this.el.add_attribute(this.items[0].el , 'markup', 2 );\n this.get('/LeftPanel').propertyColumn = this;\n}\n","title":"key","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start","listeners":{"editing_started":"function (self, editable, path) {\n\n this.get('/LeftPanel.model').activePath = path;\n\n}","edited":"function (self, object, p0) {\n\tvar model = this.get('/LeftPanel.model');\n var path = model.activePath;\n var iter = new Gtk.TreeIter();\n model.el.get_iter(iter, new Gtk.TreePath.from_string(path));\n model.el.set_value(iter, 0, p0);\n model.el.set_value(iter, 2, p0);\n \n\tmodel.activePath = false;\n\n\tthis.get('/LeftTree.model').changed(model.toJS(), true); \n this.el.editable = false;\n}"}}]},{"|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","|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","items":[{"|xns":"Gtk","xtype":"CellRendererCombo","pack":"pack_start","|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":"Menu","pack":false,"id":"LeftPanelPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Delete","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').deleteSelected();\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Edit","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').startEditing(false, 0);\n}"}}]}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"pack_end,false,true,0","id":"MidPropTree","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n XObject.prototype.init.call(this); \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n this.el.set_size_request ( 150, -1 );\n this.shown = true;\n}\n","activeElement":false,"|hideWin":"function() {\n \n if (!this.shown) {\n return;\n }\n \n \n if (this.get('/Window.left').el.position < 160) {\n return;\n }\n this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;\n \n this.el.hide();\n this.shown = false;\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|enable_tree_lines":true,"|headers_visible":false,"tooltip_column":2,"|init":"function() {\n\tXObject.prototype.init.call(this); \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 \n\n \n \n \n}\n","pack":"add","listeners":{"cursor_changed":"function (self) {\n var iter = new Gtk.TreeIter();\n \n //console.log('changed');\n var m = this.get('model');\n\tif (!this.selection){\n\t\tthis.selection = this.el.get_selection();\n\t}\n\n var s = this.selection;\n if (!s.get_selected(m.el, iter)) {\n\t\treturn; \n\t}\n var tp = m.el.get_path(iter).to_string();\n \n \n // var val = \"\";\n \n var key = m.getValue(tp, 0);\n \n var type = m.getValue(tp, 1);\n var skel = m.getValue(tp, 3);\n var etype = m.getValue(tp, 5);\n \n \n this.get('/MidPropTree').hideWin();\n\n if (type == 'function') {\n \n if (etype != 'events') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add({\n key : key, \n type : type,\n val : skel,\n etype : etype\n }) \n return;\n }\n \n if (type.indexOf('.') > -1 || \n type == 'boolean') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add( {\n key : key, \n type : type,\n //skel : skel,\n etype : etype\n }) //, \n}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|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","|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}","|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);\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( '' + p.name +' ['+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, '' + p.name +' ['+p.type+']' + \"\\n\" + p.desc);\n this.el.set_value(iter, 3, p.sig ? p.sig : '');\n this.el.set_value(iter, 4, '' + p.name +' ['+p.type+']');\n this.el.set_value(iter, 5, type);\n \n }\n \n}\n","id":"model"},{"|xns":"Gtk","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,"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true"}]}]}]}]},{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"VPaned","pack":"add","position":300,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Notebook","pack":"pack_start,true,true","id":"view-notebook","tab_border":0,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_current_page(0);\n print(\"SET LABEL?\")\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Roo View\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Gtk View\" }));\n}\n","|show_tabs":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightBrowser","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Dump HTML to console","listeners":{"activate":"function (self) {\n \tthis.get('/RightBrowser.view').el.execute_script(\n \"console.log(document.body.innerHTML);\");\n this.get('/RightBrowser.view').el.execute_script(\n\t \"console.log(Builder.dump(Builder));\"); \n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"WebKit","xtype":"WebView","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n // this may not work!?\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","|renderJS":"function(data) {\n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n Seed.print(\"RENDER:\" + str);\n imports.File.File.write('/tmp/builder.debug.js', \"Builder.render(\" + JSON.stringify(data) + \");\");\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n}\n","listeners":{"load_finished":"function (self, object) {\n\t if (this.ready) { // dont do it twice!\n\t return; \n\t}\n\tthis.ready = true;\n\n\tthis.renderJS(this.get('/LeftTree.model').toJS()[0]);\n}","script_alert":"function (self, object, p0) {\n \tprint(p0);\n return false;\n return true; // do not display anything...\n}","console_message":"function (self, object, p0, p1) {\n console.log(object);\n if (!object.match(/^\\{/)) {\n return false; // do not handle!!! -> later maybe in console..\n }\n console.log(object);\n var val = JSON.parse(object);\n\n if (typeof(val['hover-node']) != 'undefined') {\n this.activeNode = val['hover-node'];\n console.log('active node: ' + this.activeNode);\n return true;\n }\n\n var ret = false;\n if (typeof(val['id']) != 'undefined') {\n // this.activeNode = val['id'];\n var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); \n if (!tg) {\n return false;\n }\n this.get('/LeftTree.view').selectNode(tg[0]);\n ret = true;\n \n } \n if (ret && typeof(val['set']) != 'undefined') {\n this.get('/LeftPanel.model').add({\n key : val['set'],\n val : val['value']\n });\n //console.log('active node: ' + this.activeNode);\n \n }\n //Seed.print('a:'+a);\n //Seed.print('b:'+b);\n //Seed.print('c:'+c);\n return ret;\n}","drag_motion":"function (w, ctx, x, y, time, ud) {\n // console.log('DRAG MOTION'); \n // status:\n // if lastCurrentNode == this.currentNode.. -- don't change anything..\n this.targetData = [];\n this.el.execute_script(\"Builder.overPos(\" + x +','+ y + \");\");\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n \n var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (w, ctx, x, y,time, ud) {\n\tprint(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n\treturn is_valid_drop_site;\n}","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 }"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightGtkView","|renderJS":"function(data, withDebug)\n{\n if (!data) {\n return; \n }\n this.withDebug = false;\n \n if (this.renderedEl) {\n this.get('view').el.remove(this.renderedEl);\n this.renderedEl.destroy();\n this.renderedEl = false;\n }\n \n var tree = this.get('/LeftTree.model').toJS(false,true)[0];\n // in theory tree is actually window.. \n try {\n this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);\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 \n this.renderedEl.set_size_request(\n tree.default_width || 600,\n tree.default_height || 400\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 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 }\n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n kv = true;\n }\n ctr_args[k] = kv;\n \n } \n \n \n var el = new ctr(ctr_args);\n \n //print(\"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 _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}","|widgetExposeEvent":"function() {\n /// print(\"WIDGET EXPOSE\"); // draw highlight??\n return false;\n}\n","|widgetDragMotionEvent":"function() {\n print(\"WIDGET DRAGMOTION\"); \n return true;\n}\n","|widgetDragDropEvent":"function() {\n print(\"WIDGET DRAGDROP\"); \n return true;\n}\n","|widgetPressEvent":"function(w,e,u,d) {\n if (this.get('view').pressed) {\n return false;\n }\nthis.get('view').pressed = true;\n print(\"WIDGET PRESS \" + d.xtreepath ); \n this.get('/LeftTree.view').selectNode( d.xtreepath ); \n return false;\n}\n","|widgetReleaseEvent":"function() {\n this.get('view').pressed = false;\n return false;\n}\n","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Run The Application","listeners":{"button_press_event":"function (self, event) {\n // call render on left tree - with special option!?!\n \n\n\n\tprint(\"GET PROEJCT\");\n\tvar pr = this.get('/LeftProjectTree').getActiveProject();\n \nvar dir = '';\n for (var i in pr.paths) { \n dir = i;\n break;\n }\n var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; \n print (\"RUN DIR:\" + dir);\n \n this.get('/BottomPane').el.set_current_page(1);\n this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) \n\t, false,false,false); \n var cmd = \"/usr/bin/seed \" + runner + \" \" + dir + \"\\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n return false;\n \n\n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"view-sw","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0x9F00, green: 0xB800 , blue : 0xA800\n }));\n} \n","items":[{"|xns":"Gtk","xtype":"Fixed","pack":"add","|init":"function() {\n\tXObject.prototype.init.call(this);\n\t//this.el.set_hadjustment(this.parent.el.get_hadjustment());\n\t//this.el.set_vadjustment(this.parent.el.get_vadjustment());\n \n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"put,10,10","|init":"function() {\n\t//this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);\n\tXObject.prototype.init.call(this);\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","ready":false,"|getActiveNode":"function(x,y)\n{\n // workout what node is here..\n return '0'; // top..\n}","id":"view","listeners":{"drag_motion":"function (self, ctx, x, y, time) {\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n var activeNode = this.getActiveNode(x, y);\n \n \n var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (self,ctx, x, y, time) {\n\tSeed.print(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n self, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the this.gDnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return is_valid_drop_site;\n \n}","drag_data_received":"function (w, ctx, x, y, sel_data, target_type, time, ud) \n {\n Seed.print(\"GtkView: drag-data-received\");\n var delete_selection_data = false;\n var dnd_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 Seed.print(\"Browser: source.DRAGDATA? \" + source.dragData);\n if (this.targetData) {\n Seed.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 }","button_press_event":"function (self, event) {\n this.pressed = false;\n return false;\n}"}}]}]}]}]}]}]},{"|xns":"Gtk","xtype":"Notebook","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Code Editor\" }));\n \tthis.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Console\" }));\n}\n","id":"BottomPane","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"RightEditor","items":[{"|xns":"GtkSource","xtype":"View","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n var description = Pango.Font.description_from_string(\"monospace\")\n description.set_size(8000);\n this.el.modify_font(description);\n\n}\n","|load":"function(str) {\n this.get('/BottomPane').el.set_current_page(0);\n this.el.get_buffer().set_text(str, str.length);\n var lm = GtkSource.LanguageManager.get_default();\n \n this.el.get_buffer().set_language(lm.get_language('js'));\n var buf = this.el.get_buffer();\n var cursor = buf.get_mark(\"insert\");\n var iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n \n cursor = buf.get_mark(\"selection_bound\");\n iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n this.el.grab_focus();\n}","items":[{"|xns":"GtkSource","xtype":"Buffer","pack":"set_buffer","listeners":{"changed":"function (self) {\n var s = new Gtk.TextIter();\n var e = new Gtk.TextIter();\n this.el.get_start_iter(s);\n this.el.get_end_iter(e);\n var str = this.el.get_text(s,e,true);\n try {\n Seed.check_syntax('var e = ' + str);\n } catch (e) {\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n }));\n print(\"SYNTAX ERROR IN EDITOR\"); \n print(e);\n console.dump(e);\n return;\n }\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n }));\n \n this.get('/LeftPanel.model').changed( str , false);\n}"}}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","items":[{"|xns":"Vte","xtype":"Terminal","pack":"add","id":"Terminal","|feed":"function(str) {\n this.el.feed(str,str.length);\n}\n"}]}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"pack_start,false,false","id":"RightPalete","|hide":"function() {\n \n this.get('buttonbar').el.show();\n this.get('viewbox').el.hide();\n print(\"TRIED TO HIDE\");\n}\n","|show":"function() {\n this.get('buttonbar').el.hide();\n this.get('viewbox').el.show();\n // this.get('model').expanded();\n \n}\n","provider":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"buttonbar","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').show();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_FIRST","|icon_size":"Gtk.IconSize.MENU"}]},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete","angle":270,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","listeners":{"enter_notify_event":"function (self, event) {\n this.get('/RightPalete').show();\n return false;\n}"}}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"viewbox","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true","items":[{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete"},{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').hide();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_LAST","|icon_size":"Gtk.IconSize.MENU"}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\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}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING // tip\n \n ] );\n}\n","id":"model","|load":"function(tr,iter)\n{\n if (!iter) {\n this.el.clear();\n }\n //console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (!iter) {\n \n this.el.append(citer); \n } else {\n this.el.insert(citer,iter,-1);\n }\n \n var r = tr[i];\n //Seed.print(r);\n this.el.set_value(citer, 0, '' + r ); // title \n \n //this.el.set_value(citer, 1, new GObject.Value( r)); //id\n //if (r.cn && r.cn.length) {\n // this.load(r.cn, citer);\n //}\n }\n \n \n}","|getValue":"function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]}]}]}]}]} \ No newline at end of file +{"id":"file-gtk-5","name":"Window","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/Window.bjs","items":[{"|xns":"Gtk","xtype":"Window","|type":"Gtk.WindowType.TOPLEVEL","title":"Application Builder","border_width":0,"|init":"function() {\n this.atoms = {\n \"STRING\" : Gdk.atom_intern(\"STRING\")\n\t};\n\tthis.targetList = new Gtk.TargetList();\n\tthis.targetList.add( this.atoms[\"STRING\"], 0, 0);\n\t//imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\nGtk.rc_parse_string(\n \"style \\\"gtkcombobox-style\\\" {\\n\" + \n \" GtkComboBox::appears-as-list = 1\\n\" +\n \"}\\n\"+\n \"class \\\"GtkComboBox\\\" style \\\"gtkcombobox-style\\\"\\n\");\n XObject.prototype.init.call(this);\n this.el.show_all();\n \n \n \n}\n","default_width":800,"default_height":500,"id":"Window","listeners":{"delete_event":"function (self, event) {\n return false;\n}","destroy":"function (self) {\n Gtk.main_quit();\n}","show":"function (self) {\n print(\"WINDOW SHOWING - trying to hide\");\nimports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\n \tthis.get('/MidPropTree').hideWin();\n this.get('/RightPalete').hide();\n\n}"},"items":[{"|xns":"Gtk","xtype":"VBox","id":"w-vbox","items":[{"|xns":"Gtk","xtype":"MenuBar","pack":"pack_start,false,false","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"_File","items":[{"|xns":"Gtk","xtype":"Menu","pack":"set_submenu","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"New _Project","listeners":{"activate":"function (self) {\n\tthis.get('/EditProject').show({\n\t success : function(pr) {\n\t\t this.get('/LeftProjectTree').get('combo').setValue(pr.fn);\n\t }\n\t});\n}"}},{"|xns":"Gtk","xtype":"MenuItem","label":"_New File","|use_underline":true,"listeners":{"activate":"function (self) {\n \tvar fn = this.get('/LeftProjectTree.combo').getValue();\n if (!fn) {\n this.get('/LeftProjectTree').showNoProjectSelected();\n return true;\n }\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n this.get('/DialogNewComponent').show({\n project : pm.getByFn(fn)\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"_Quit","|use_underline":true,"listeners":{"activate":"function (self) {\n Gtk.main_quit();\n} "}}]}]},{"|xns":"Gtk","xtype":"MenuItem","label":"Help"}]},{"|xns":"Gtk","xtype":"HPaned","id":"left","position":400,"items":[{"|xns":"Gtk","xtype":"HBox","items":[{"|xns":"Gtk","xtype":"VPaned","position":300,"id":"leftvpaned","items":[{"|xns":"Gtk","xtype":"VBox","id":"LeftTopPanel","items":[{"|xns":"Gtk","xtype":"Expander","label":"Select Project","id":"expander","pack":"pack_start,false,true","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","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}"}},{"|xns":"Gtk","xtype":"Notebook","id":"notebook","|show_border":false,"|show_tabs":false,"pack":"pack_start,true,true","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_current_page(0);\n\n}\n","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n","id":"LeftTree","|getPaleteProvider":"function() {\n var model = this.get('model');\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n return pm.getPalete(model.file.getType());\n}\n","|renderView":"function() {\n \t var model = this.get('model');\n\tprint(\"RENDER VIEW?\" + model.file.getType());\n\tswitch( model.file.getType()) {\n\t\tcase 'Roo':\n\t\t this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);\n\t\tcase 'Gtk':\n\t\t this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);\n\t}\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","pack":"add","id":"view","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":0,"|init":"function() {\n \tXObject.prototype.init.call(this);\n\tvar description = new Pango.FontDescription.c_new();\n\tdescription.set_size(8000);\n\tthis.el.modify_font(description);\n\n\tthis.selection = this.el.get_selection();\n\tthis.selection.set_mode( Gtk.SelectionMode.SINGLE);\n\tvar _this = this;\n\tthis.selection.signal['changed'].connect(function() {\n\t\t_this.get('/LeftTree.view').listeners.cursor_changed.apply(\n\t\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n\t\t);\n\t});\n\n\tGtk.drag_source_set (\n\t\tthis.el, /* widget will be drag-able */\n\t\tGdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n\t\tnull, /* lists of target to support */\n\t\t0, /* size of list */\n\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n\n\tGtk.drag_source_add_text_targets(this.el); \n\tGtk.drag_dest_set\n\t(\n\t this.el, /* widget that will accept a drop */\n\t Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n\t null, /* lists of target to support */\n\t 0, /* size of list */\n\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n\tGtk.drag_dest_add_text_targets(this.el);\n}\n","|highlight":"function(treepath_ar) {\n if (treepath_ar.length && treepath_ar[0].length ) {\n this.el.set_drag_dest_row( \n new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n }","|selectNode":"function(treepath_str) {\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n","listeners":{"button_press_event":"function (self, ev) {\n \tconsole.log(\"button press?\");\n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {\n print(\"click\" + ev.type);\n return false;\n }\n \n \n var res = {}; \n this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);\n \n if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();\n \n this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());\n this.get('/LeftTreeMenu').el.show_all();\n this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);\n print(\"click:\" + res.path.to_string());\n return false;\n}","drag_begin":"function (self, drag_context) {\n\tprint('SOURCE: drag-begin');\n this.targetData = false;\n // find what is selected in our tree...\n var iter = new Gtk.TreeIter();\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n var xname = this.get('/LeftTree.model').file.guessName(data);\n \n this.el.dragData = xname;\n this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);\n \n\n // make the drag icon a picture of the node that was selected\n var path = this.get('/LeftTree.model').el.get_path(iter);\n this.el.treepath = path.to_string();\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_pixmap (ctx,\n pix.get_colormap(),\n pix,\n null,\n -10,\n -10);\n \n return true;\n}","drag_end":"function (self, drag_context) {\n\tSeed.print('LEFT-TREE: drag-end');\n this.el.dragData = false;\n this.el.dropList = false;\n this.targetData = false;\n this.get('/LeftTree.view').highlight(false);\n return true;\n}","drag_motion":"function (self, ctx, x, y, time) {\n console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n\n // a drag from elsewhere...- prevent drop..\n if (!src.dragData) {\n print(\"no drag data!\");\n Gdk.drag_status(ctx, 0, time);\n this.targetData = false;\n return true;\n }\n var action = Gdk.DragAction.COPY;\n if (src == this.el) {\n // unless we are copying!!! ctl button..\n action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n }\n var data = {};\n\n\t\tif (!this.get('/LeftTree.model').el.iter_n_children(null)) {\n\t\t\t// no children.. -- asume it's ok..\n\t\t\tthis.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];\n\t\t\tGdk.drag_status(ctx, action ,time);\n\t\t\treturn true;\n\t\t}\n\n print(\"GETTING POS\");\n var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);\n print(\"ISOVER? \" + isOver);\n if (!isOver) {\n Gdk.drag_status(ctx, 0 ,time);\n return false; // not over apoint!?!\n }\n // drag node is parent of child..\n console.log(\"SRC TREEPATH: \" + src.treepath);\n console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n if (typeof(src.treepath) != 'undefined' && \n src.treepath == data.path.to_string().substring(0,src.treepath.length)) {\n print(\"subpath drag\");\n Gdk.drag_status(ctx, 0 ,time);\n return false;\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n print(data.path.to_string() +' => '+ data.pos);\n var tg = this.get('/LeftTree.model').findDropNodeByPath(\n data.path.to_string(), src.dropList, data.pos);\n \n this.get('/LeftTree.view').highlight(tg);\n if (!tg.length) {\n print(\"Can not find drop node path\");\n this.targetData = false;\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n //console.dump(tg);\n this.targetData = tg; \n \n \n Gdk.drag_status(ctx, action ,time);\n \n return true;\n}","drag_drop":"function (w, ctx, x, y, time) {\n Seed.print(\"TARGET: drag-drop\");\n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return true;\n}","drag_data_received":"function (self, ctx, x, y, sel_data, info, time) {\n\t print(\"Tree: drag-data-received\");\n\n var delete_selection_data = false;\n var dnd_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 \n var source = Gtk.drag_get_source_widget(ctx);\n\n if (this.targetData) {\n if (source != this.el) {\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n } else {\n // drag around.. - reorder..\n this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);\n \n \n }\n //Seed.print(this.targetData);\n \n }\n \n \n \n // we can send stuff to souce here...\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}","cursor_changed":"function (self) {\n if (this.blockChanges) {\n return true;\n }\n var iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n this.get('/LeftPanel.model').load( false);\n this.get('/MidPropTree').activeElement = false;\n this.get('/MidPropTree').hideWin();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/LeftTree').getPaleteProvider()) {\n // it may not be loaded yet..\n return true;\n }\n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n return true;\n }\n \n //console.log('changed');\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n \n \n // var val = \"\";\n value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();\n \n var data = JSON.parse(value.value);\n this.get('/MidPropTree').activeElement = data;\n this.get('/MidPropTree').hideWin();\n this.get('/LeftPanel.model').load( data);\n \n console.log(value.value);\n // _g.button.set_label(''+value.get_string());\n\n var pm =this.get('/RightPalete.model');\n pm.load( this.get('/RightPalete').provider.gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n \n \n \n //Seed.print( value.get_string());\n return true;\n \n}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // source..\n ] );\n}\n","activePath":false,"|changed":"function(n, refresh) {\n print(\"MODEL CHANGED CALLED\" + this.activePath);\n if (this.activePath) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))\n this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n \n this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);\n }\n //this.currentTree = this.toJS(false, true)[0];\n this.file.items = this.toJS(false, false);\n print(\"AFTER CHANGED\");\n //console.dump(this.file.items);\n this.file.save();\n this.currentTree = this.file.items[0];\n //console.log(this.file.toSource());\n \n if (refresh) {\n print(\"REDNER BROWSER?!\");\n this.get('/LeftTree').renderView();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/RightPalete').provider) {\n pm.load([]);\n return;\n }\n \n \n pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));\n //imports['Builder/RightBrowser.js'].renderJS(this.toJS());\n }\n\t \n}\n","|loadFile":"function(f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n if (!f) {\n console.log('missing file');\n return;\n }\n \n // load the file if not loaded..\n if (f.items === false) {\n var _this = this;\n f.loadItems(function() {\n _this.loadFile(f);\n });\n return;\n \n }\n if (f.items.length && typeof(f.items[0]) == 'string') {\n \n this.get('/RightEditor').el.show();\n this.get('/RightEditor.view').load( f.items[0]);\n return;\n }\n print(\"LOAD\");\n //console.dump(f.items);\n this.load(f.items);\n this.get('/LeftTree.view').el.expand_all();\n\n if (!f.items.length) {\n // single item..\n \n this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n this.get('/LeftTree.view').el.set_cursor( \n new Gtk.TreePath.from_string('0'), null, false);\n \n \n } else {\n this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n \n //print(\"hide right editior\");\n this.get('/RightEditor').el.hide();\n //print(\"set current tree\");\n this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n this.currentTree = this.currentTree || { items: [] };\n this.get('/LeftTree').renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n \n}\n","|findDropNode":"function(treepath_str, targets) {\n\n// this is used by the dragdrop code in the roo version AFAIR..\n\n \t\tvar path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (!this.el.iter_n_children(null)) {\n print(\"NO KEYS\");\n return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];\n }\n print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n if (!treepath_str.match(/^builder-/)) {\n return []; // nothing!\n }\n if (targets === true) {\n return [ path ];\n }\n return this.findDropNodeByPath(path,targets) \n}\n","|findDropNodeByPath":"function(treepath_str, targets, pref) {\n var path = treepath_str + ''; // dupe it..\n pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;\n var last = false;\n //console.dump(this.treemap);\n while (path.length) {\n print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.singleNodeToJS(path);\n if (node_data === false) {\n print(\"node not found\");\n return [];\n }\n \n var xname = this.get('/LeftTree.model').file.guessName(node_data);\n var match = false;\n var prop = '';\n targets.forEach(function(tg) {\n if (match) {\n return;;\n }\n if ((tg == xname) ) {\n match = tg;\n }\n if (tg.indexOf(xname +':') === 0) {\n match = tg;\n prop = tg.split(':').pop();\n }\n });\n \n if (match) {\n if (last) { // pref is after/before..\n // then it's after last\n if (pref > 1) {\n return []; // do not allow..\n }\n return [ last, pref , prop];\n \n }\n return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];\n }\n var par = path.split(':');\n last = path;\n par.pop();\n path = par.join(':');\n }\n \n return [];\n \n}\n","|dropNode":"function(target_data, node) {\n print(\"drop Node\");\n \t console.dump(node);\n \t console.dump(target_data);\n var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;\n \n print(\"add \" + tp + \"@\" + target_data[1] );\n var parent = tp;\n var after = false;\n if (tp && target_data[1] < 2) { // before or after..\n var ar = target_data[0].split(':');\n ar.pop();\n parent = new Gtk.TreePath.from_string( ar.join(':') );\n after = tp;\n }\n var n_iter = new Gtk.TreeIter();\n var iter_par = new Gtk.TreeIter();\n var iter_after = after ? new Gtk.TreeIter() : false;\n \n \n \n if (parent !== false) {\n this.el.get_iter(iter_par, parent);\n } else {\n iter_par = null;\n }\n \n \n if (tp && after) {\n print(target_data[1] > 0 ? 'insert_after' : 'insert_before');\n this.el.get_iter(iter_after, after);\n this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](\n n_iter, iter_par, iter_after);\n \n } else {\n this.el.append(n_iter, iter_par);\n \n }\n \n if (typeof(node) == 'string') {\n var ar = node.split('.');\n var xtype = ar.pop();\n \n node = {\n '|xns' : ar.join('.'),\n 'xtype' : xtype\n };\n if (target_data.length == 3 && target_data[2].length) {\n node['*prop'] = target_data[2];\n }\n \n }\n // work out what kind of packing to use..\n if (typeof(node.pack) == 'undefined' && parent !== false) {\n var pal = this.get('/LeftTree').getPaleteProvider();\n \n var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));\n print (\"PNAME : \" + pname);\n var cname = pal.guessName(node);\n print (\"CNAME : \" + cname);\n node.pack = pal.getDefaultPack(pname, cname);\n \n \n }\n \n \n var xitems = [];\n if (node.items) {\n xitems = node.items;\n delete node.items;\n }\n// load children - if it has any..\n\n if (xitems) {\n this.load(xitems, n_iter);\n }\n if (tp && (xitems || after)) {\n this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);\n }\n // wee need to get the empty proptypes from somewhere..\n \n //var olditer = this.activeIter;\n this.activePath = this.el.get_path(n_iter).to_string();\n\n\t // changed actually set's the node data..\n this.changed(node, true);\n \n \n \n this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);\n \n //Builder.MidPropTree._model.load(node);\n //Builder.MidPropTree._win.hideWin();\n //Builder.LeftPanel._model.load( node);\n \n \n}\n","|moveNode":"function(target_data, action) {\n //print(\"MOVE NODE\");\n // console.dump(target_data);\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var node = this.nodeToJS(old_iter,false);\n //console.dump(node);\n \n \n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n \n this.dropNode(target_data, node);\n\t if (action & Gdk.DragAction.MOVE) {\n // print(\"REMOVING OLD NODE\");\n this.el.remove(old_iter);\n \n }\n \n this.activePath= false;\n this.changed(false,true);\n}\n","|deleteSelected":"function() {\n this.get('/LeftTree.view').blockChanges = true;\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var path = this.el.get_path(old_iter).to_string();\n\n this.activePath= false; \n s.unselect_all();\n\n this.activePath= false; \n\t var iter = new Gtk.TreeIter();\n this.el.get_iter_from_string(iter, path);\n this.el.remove(iter);\n \n // rebuild treemap. -- depreciated.!!\n this.map = {};\n this.treemap = { };\n //this.toJS(null, true) // does not do anything?\n this.activePath= false; \n this.changed(false,true);\n this.get('/LeftTree.view').blockChanges = false;\n}\n","currentTree":false,"|listAllTypes":"function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n \n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n","|singleNodeToJS":"function (treepath) \n {\n var iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n \n var iv = this.getIterValue(iter, 2);\n \n return JSON.parse(iv);\n \n }","|nodeToJS":"function (iter, with_id) \n{\n var par = new Gtk.TreeIter(); \n var iv = this.getIterValue(iter, 2);\n // print(\"IV\" + iv);\n var k = JSON.parse(iv);\n if (k.json && !this.el.iter_parent( par, iter )) {\n delete k.json;\n }\n \n if (with_id) {\n var treepath_str = this.el.get_path(iter).to_string();\n // not sure how we can handle mixed id stuff..\n if (typeof(k.id) == 'undefined') {\n k.id = 'builder-'+ treepath_str ;\n }\n \n // needed??\n this.treemap[ treepath_str ] = k;\n k.xtreepath = treepath_str ;\n \n }\n if (this.el.iter_has_child(iter)) {\n citer = new Gtk.TreeIter();\n this.el.iter_children(citer, iter);\n k.items = this.toJS(citer,with_id);\n }\n return k;\n}\n","|toJS":"function(iter, with_id)\n {\n //Seed.print(\"WITHID: \"+ with_id);\n \n var first = false;\n if (!iter) {\n \n this.treemap = { }; \n \n iter = new Gtk.TreeIter();\n if (!this.el.get_iter_first(iter)) {\n return [];\n }\n first = true;\n } \n \n var ar = [];\n \n while (true) {\n \n var k = this.nodeToJS(iter, with_id); \n ar.push(k);\n \n \n if (!this.el.iter_next(iter)) {\n break;\n }\n }\n \n return ar;\n // convert the list into a json string..\n \n \n }","|getIterValue":" function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}","|nodeTitle":"function(c) {\n var txt = [];\n c = c || {};\n var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;\n if (sr) txt.push('');\n if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }\n if (c.xtype) { txt.push(c.xtype); }\n if (c.id) { txt.push('[id=' + c.id + ']'); }\n if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }\n if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }\n \n \n if (c.layout) { txt.push('' + c.layout + ''); }\n if (c.title) { txt.push('' + c.title + ''); }\n if (c.label) { txt.push('' + c.label+ ''); }\n if (c.header) { txt.push('' + c.header + ''); }\n if (c.legend) { txt.push('' + c.legend + ''); }\n if (c.text) { txt.push('' + c.text + ''); }\n if (c.name) { txt.push('' + c.name+ ''); }\n if (c.region) { txt.push('(' + c.region + ')'); }\n if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }\n \n // for flat classes...\n if (typeof(c['*class']) != 'undefined') { txt.push('' + c['*class']+ ''); }\n if (typeof(c['*extends']) != 'undefined') { txt.push(': ' + c['*extends']+ ''); }\n \n \n if (sr) txt.push('');\n return (txt.length == 0 ? \"Element\" : txt.join(\" \"));\n}\n","|nodeToJSON":"function(c) {\n var o = {}\n for (var i in c) {\n if (i == 'items') {\n continue;\n }\n o[i] = c[i];\n }\n return JSON.stringify(o);\n}\n","|load":"function(tr,iter)\n {\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (iter) {\n this.el.insert(citer,iter,-1);\n } else {\n this.el.append(citer);\n }\n \n this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);\n if (tr[i].items && tr[i].items.length) {\n this.load(tr[i].items, citer);\n }\n } \n }"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"LeftTreeMenu","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"Delete Element","listeners":{"activate":"function (self) {\n\n this.get('/LeftTree.model').deleteSelected();\n}"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"LeftProjectTree","|showNoProjectSelected":"function() {\n this.get('/StandardErrorDialog').show(\"Select a Project first.\"); \n}\n","|getActiveProject":"function() {\n return this.project;\n}\n","listeners":{"leave_notify_event":"function (self, event) {\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","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 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}"},"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true","id":"render"},{"|xns":"Gtk","xtype":"ListStore","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 \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","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":1,"|init":"function() {\n XObject.prototype.init.call(this);\nvar 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}\n","id":"view","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 \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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // id..\n ] );\n \n}\n","|loadProject":"function(pr) {\n this.el.clear();\n if (!pr) {\n return;\n }\n this.get('/LeftProjectTree').project = pr;\n this.load(pr.toTree());\n this.get('/LeftProjectTree.view').el.expand_all();\n}\n","|load":"function(tr,iter) {\n console.dump(tr);\n console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n \n var _this = this;\n tr.forEach(function (r) {\n if (!iter) {\n _this.el.append(citer); \n } else {\n _this.el.insert(citer,iter,-1);\n }\n _this.el.set_value(citer, 0, '' + r.getTitle() ); // title \n _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip\n _this.el.set_value(citer, 2, '' + r.id ); //id\n if (r.cn && r.cn.length) {\n _this.load(r.cn, citer);\n }\n \n });\n}\n","|getValue":"function(iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]},{"|xns":"Gtk","xtype":"VBox","listeners":{},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","id":"LeftProps","items":[{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('props');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Property"}]}]},{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('events');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Handler"}]}]},{"|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}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Other"}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"AddPropertyPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Using this.get('*someid') will find any id in an application.","label":"ID","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : 'id', \n type : 'string',\n val : '',\n //skel : skel,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add what type of packing is to be used","label":"PACK","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : 'pack', \n \t type : 'string',\n \t val : 'add',\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Override the init method","label":"INIT","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : '|init', \n type : 'function',\n val : \"function() {\\n XObject.prototype.init.call(this);\\n}\\n\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined string property","label":"String","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'string',\n val : \"\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined number property","label":"Number","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'number',\n val : 0,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined boolean property","label":"Boolean","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'boolean',\n val : false,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user function boolean property","label":"Function","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : '|', \n type : 'function',\n val : \"function() {\\n \\n}\\n\",\n etype : 'props'\n });\n}"}}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","id":"LeftPanel","pack":"add","|shadow_type":"Gtk.ShadowType.IN","editing":false,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","id":"view","tooltip_column":1,"|headers_visible":false,"|enable_tree_lines":true,"|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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 5, [\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 \n ]);\n}\n","|toShort":"function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\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 \n // sort!!!?\n var iter = new Gtk.TreeIter();\n for (var i in ar) {\n if (typeof(ar[i]) == 'object') {\n continue;\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 }\n ar.listeners = ar.listeners || {};\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 }\n return ret;\n}\n","|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 == '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","|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","|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","activePath":false,"|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 // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \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","|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 'boolean':\n return val == 'true' ? true : false;\n default: \n return val;\n }\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)) {\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('/RightEditor').el.show();\n\t\t _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 \n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\n this.el.add_attribute(this.items[0].el , 'markup', 2 );\n this.get('/LeftPanel').propertyColumn = this;\n}\n","title":"key","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start","listeners":{"editing_started":"function (self, editable, path) {\n\n this.get('/LeftPanel.model').activePath = path;\n\n}","edited":"function (self, object, p0) {\n\tvar model = this.get('/LeftPanel.model');\n var path = model.activePath;\n var iter = new Gtk.TreeIter();\n model.el.get_iter(iter, new Gtk.TreePath.from_string(path));\n model.el.set_value(iter, 0, p0);\n model.el.set_value(iter, 2, p0);\n \n\tmodel.activePath = false;\n\n\tthis.get('/LeftTree.model').changed(model.toJS(), true); \n this.el.editable = false;\n}"}}]},{"|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","|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","items":[{"|xns":"Gtk","xtype":"CellRendererCombo","pack":"pack_start","|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":"Menu","pack":false,"id":"LeftPanelPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Delete","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').deleteSelected();\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Edit","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').startEditing(false, 0);\n}"}}]}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"pack_end,false,true,0","id":"MidPropTree","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n XObject.prototype.init.call(this); \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n this.el.set_size_request ( 150, -1 );\n this.shown = true;\n}\n","activeElement":false,"|hideWin":"function() {\n \n if (!this.shown) {\n return;\n }\n \n \n if (this.get('/Window.left').el.position < 160) {\n return;\n }\n this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;\n \n this.el.hide();\n this.shown = false;\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|enable_tree_lines":true,"|headers_visible":false,"tooltip_column":2,"|init":"function() {\n\tXObject.prototype.init.call(this); \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 \n\n \n \n \n}\n","pack":"add","listeners":{"cursor_changed":"function (self) {\n var iter = new Gtk.TreeIter();\n \n //console.log('changed');\n var m = this.get('model');\n\tif (!this.selection){\n\t\tthis.selection = this.el.get_selection();\n\t}\n\n var s = this.selection;\n if (!s.get_selected(m.el, iter)) {\n\t\treturn; \n\t}\n var tp = m.el.get_path(iter).to_string();\n \n \n // var val = \"\";\n \n var key = m.getValue(tp, 0);\n \n var type = m.getValue(tp, 1);\n var skel = m.getValue(tp, 3);\n var etype = m.getValue(tp, 5);\n \n \n this.get('/MidPropTree').hideWin();\n\n if (type == 'function') {\n \n if (etype != 'events') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add({\n key : key, \n type : type,\n val : skel,\n etype : etype\n }) \n return;\n }\n \n if (type.indexOf('.') > -1 || \n type == 'boolean') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add( {\n key : key, \n type : type,\n //skel : skel,\n etype : etype\n }) //, \n}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|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","|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}","|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);\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( '' + p.name +' ['+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, '' + p.name +' ['+p.type+']' + \"\\n\" + p.desc);\n this.el.set_value(iter, 3, p.sig ? p.sig : '');\n this.el.set_value(iter, 4, '' + p.name +' ['+p.type+']');\n this.el.set_value(iter, 5, type);\n \n }\n \n}\n","id":"model"},{"|xns":"Gtk","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,"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true"}]}]}]}]},{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"VPaned","pack":"add","position":300,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Notebook","pack":"pack_start,true,true","id":"view-help-nb","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Preview\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Help\" }));\n}\n","items":[{"|xns":"Gtk","xtype":"Notebook","pack":"add","id":"view-notebook","tab_border":0,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_current_page(0);\n print(\"SET LABEL?\")\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Roo View\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Gtk View\" }));\n}\n","|show_tabs":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightBrowser","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Dump HTML to console","listeners":{"activate":"function (self) {\n \tthis.get('/RightBrowser.view').el.execute_script(\n \"console.log(document.body.innerHTML);\");\n this.get('/RightBrowser.view').el.execute_script(\n\t \"console.log(Builder.dump(Builder));\"); \n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"WebKit","xtype":"WebView","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n // this may not work!?\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","|renderJS":"function(data) {\n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n Seed.print(\"RENDER:\" + str);\n imports.File.File.write('/tmp/builder.debug.js', \"Builder.render(\" + JSON.stringify(data) + \");\");\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n}\n","listeners":{"load_finished":"function (self, object) {\n\t if (this.ready) { // dont do it twice!\n\t return; \n\t}\n\tthis.ready = true;\n\n\tthis.renderJS(this.get('/LeftTree.model').toJS()[0]);\n}","script_alert":"function (self, object, p0) {\n \tprint(p0);\n return false;\n return true; // do not display anything...\n}","console_message":"function (self, object, p0, p1) {\n console.log(object);\n if (!object.match(/^\\{/)) {\n return false; // do not handle!!! -> later maybe in console..\n }\n console.log(object);\n var val = JSON.parse(object);\n\n if (typeof(val['hover-node']) != 'undefined') {\n this.activeNode = val['hover-node'];\n console.log('active node: ' + this.activeNode);\n return true;\n }\n\n var ret = false;\n if (typeof(val['id']) != 'undefined') {\n // this.activeNode = val['id'];\n var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); \n if (!tg) {\n return false;\n }\n this.get('/LeftTree.view').selectNode(tg[0]);\n ret = true;\n \n } \n if (ret && typeof(val['set']) != 'undefined') {\n this.get('/LeftPanel.model').add({\n key : val['set'],\n val : val['value']\n });\n //console.log('active node: ' + this.activeNode);\n \n }\n //Seed.print('a:'+a);\n //Seed.print('b:'+b);\n //Seed.print('c:'+c);\n return ret;\n}","drag_motion":"function (w, ctx, x, y, time, ud) {\n // console.log('DRAG MOTION'); \n // status:\n // if lastCurrentNode == this.currentNode.. -- don't change anything..\n this.targetData = [];\n this.el.execute_script(\"Builder.overPos(\" + x +','+ y + \");\");\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n \n var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (w, ctx, x, y,time, ud) {\n\tprint(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n\treturn is_valid_drop_site;\n}","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 }"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightGtkView","|renderJS":"function(data, withDebug)\n{\n if (!data) {\n return; \n }\n this.withDebug = false;\n \n if (this.renderedEl) {\n this.get('view').el.remove(this.renderedEl);\n this.renderedEl.destroy();\n this.renderedEl = false;\n }\n \n var tree = this.get('/LeftTree.model').toJS(false,true)[0];\n // in theory tree is actually window.. \n try {\n this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);\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 \n this.renderedEl.set_size_request(\n tree.default_width || 600,\n tree.default_height || 400\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 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 }\n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n kv = true;\n }\n ctr_args[k] = kv;\n \n } \n \n \n var el = new ctr(ctr_args);\n \n //print(\"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 _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}","|widgetExposeEvent":"function() {\n /// print(\"WIDGET EXPOSE\"); // draw highlight??\n return false;\n}\n","|widgetDragMotionEvent":"function() {\n print(\"WIDGET DRAGMOTION\"); \n return true;\n}\n","|widgetDragDropEvent":"function() {\n print(\"WIDGET DRAGDROP\"); \n return true;\n}\n","|widgetPressEvent":"function(w,e,u,d) {\n if (this.get('view').pressed) {\n return false;\n }\nthis.get('view').pressed = true;\n print(\"WIDGET PRESS \" + d.xtreepath ); \n this.get('/LeftTree.view').selectNode( d.xtreepath ); \n return false;\n}\n","|widgetReleaseEvent":"function() {\n this.get('view').pressed = false;\n return false;\n}\n","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Run The Application","listeners":{"button_press_event":"function (self, event) {\n // call render on left tree - with special option!?!\n \n\n\n\tprint(\"GET PROEJCT\");\n\tvar pr = this.get('/LeftProjectTree').getActiveProject();\n \nvar dir = '';\n for (var i in pr.paths) { \n dir = i;\n break;\n }\n var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; \n print (\"RUN DIR:\" + dir);\n \n this.get('/BottomPane').el.set_current_page(1);\n this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) \n\t, false,false,false); \n var cmd = \"/usr/bin/seed \" + runner + \" \" + dir + \"\\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n return false;\n \n\n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"view-sw","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"add_with_viewport","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0x9F00, green: 0xB800 , blue : 0xA800\n }));\n} \n","items":[{"|xns":"Gtk","xtype":"Fixed","pack":"add","|init":"function() {\n\tXObject.prototype.init.call(this);\n\t//this.el.set_hadjustment(this.parent.el.get_hadjustment());\n\t//this.el.set_vadjustment(this.parent.el.get_vadjustment());\n \n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"put,10,10","|init":"function() {\n\t//this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);\n\tXObject.prototype.init.call(this);\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","ready":false,"|getActiveNode":"function(x,y)\n{\n // workout what node is here..\n return '0'; // top..\n}","id":"view","listeners":{"drag_motion":"function (self, ctx, x, y, time) {\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n var activeNode = this.getActiveNode(x, y);\n \n \n var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (self,ctx, x, y, time) {\n\tSeed.print(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n self, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the this.gDnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return is_valid_drop_site;\n \n}","drag_data_received":"function (w, ctx, x, y, sel_data, target_type, time, ud) \n {\n Seed.print(\"GtkView: drag-data-received\");\n var delete_selection_data = false;\n var dnd_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 Seed.print(\"Browser: source.DRAGDATA? \" + source.dragData);\n if (this.targetData) {\n Seed.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 }","button_press_event":"function (self, event) {\n this.pressed = false;\n return false;\n}"}}]}]}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"Help","items":[{"|xns":"WebKit","xtype":"WebView","pack":"add","id":"help-view","|init":"function() {\n XObject.prototype.init.call(this);\n this.get('/Window.help-view').el.open(\n \"http://devel.akbkhome.com/seed/\");\n\n}\n"}]}]}]},{"|xns":"Gtk","xtype":"Notebook","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Code Editor\" }));\n \tthis.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Console\" }));\n}\n","id":"BottomPane","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"RightEditor","items":[{"|xns":"GtkSource","xtype":"View","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n var description = Pango.Font.description_from_string(\"monospace\")\n description.set_size(8000);\n this.el.modify_font(description);\n\n}\n","|load":"function(str) {\n\n// show the help page for the active node..\n this.get('/Window.view-help-nb').el.set_current_page(1);\n\n// get the active element being edited.\n var xtype = this.get('/LeftTree.model').file.guessName(\n\tthis.get('/MidPropTree').activeElement);\n// now load the help info in the page..\n this.get('/Window.help-view').el.open(\n \"http://devel.akbkhome.com/seed/\" + xtype + \".html\");\n\n\n this.get('/BottomPane').el.set_current_page(0);\n this.el.get_buffer().set_text(str, str.length);\n var lm = GtkSource.LanguageManager.get_default();\n \n this.el.get_buffer().set_language(lm.get_language('js'));\n var buf = this.el.get_buffer();\n var cursor = buf.get_mark(\"insert\");\n var iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n \n cursor = buf.get_mark(\"selection_bound\");\n iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n this.el.grab_focus();\n}","items":[{"|xns":"GtkSource","xtype":"Buffer","pack":"set_buffer","listeners":{"changed":"function (self) {\n var s = new Gtk.TextIter();\n var e = new Gtk.TextIter();\n this.el.get_start_iter(s);\n this.el.get_end_iter(e);\n var str = this.el.get_text(s,e,true);\n try {\n Seed.check_syntax('var e = ' + str);\n } catch (e) {\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n }));\n print(\"SYNTAX ERROR IN EDITOR\"); \n print(e);\n console.dump(e);\n return;\n }\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n }));\n \n this.get('/LeftPanel.model').changed( str , false);\n}"}}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","items":[{"|xns":"Vte","xtype":"Terminal","pack":"add","id":"Terminal","|feed":"function(str) {\n this.el.feed(str,str.length);\n}\n"}]}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"pack_start,false,false","id":"RightPalete","|hide":"function() {\n \n this.get('buttonbar').el.show();\n this.get('viewbox').el.hide();\n print(\"TRIED TO HIDE\");\n}\n","|show":"function() {\n this.get('buttonbar').el.hide();\n this.get('viewbox').el.show();\n // this.get('model').expanded();\n \n}\n","provider":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"buttonbar","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').show();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_FIRST","|icon_size":"Gtk.IconSize.MENU"}]},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete","angle":270,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","listeners":{"enter_notify_event":"function (self, event) {\n this.get('/RightPalete').show();\n return false;\n}"}}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"viewbox","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true","items":[{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete"},{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').hide();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_LAST","|icon_size":"Gtk.IconSize.MENU"}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\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}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING // tip\n \n ] );\n}\n","id":"model","|load":"function(tr,iter)\n{\n if (!iter) {\n this.el.clear();\n }\n //console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (!iter) {\n \n this.el.append(citer); \n } else {\n this.el.insert(citer,iter,-1);\n }\n \n var r = tr[i];\n //Seed.print(r);\n this.el.set_value(citer, 0, '' + r ); // title \n \n //this.el.set_value(citer, 1, new GObject.Value( r)); //id\n //if (r.cn && r.cn.length) {\n // this.load(r.cn, citer);\n //}\n }\n \n \n}","|getValue":"function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]}]}]}]}]} \ No newline at end of file diff --git a/Builder/Window.js b/Builder/Window.js index b6869929e..2fdbcf523 100644 --- a/Builder/Window.js +++ b/Builder/Window.js @@ -2345,675 +2345,687 @@ Window=new XObject({ { xtype: Gtk.Notebook, pack : "pack_start,true,true", - id : "view-notebook", - tab_border : 0, + id : "view-help-nb", init : function() { XObject.prototype.init.call(this); - this.el.set_current_page(0); - print("SET LABEL?") - this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" })); - this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" })); + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" })); }, - show_tabs : false, items : [ { - xtype: Gtk.VBox, + xtype: Gtk.Notebook, pack : "add", - id : "RightBrowser", + id : "view-notebook", + tab_border : 0, + init : function() { + XObject.prototype.init.call(this); + this.el.set_current_page(0); + print("SET LABEL?") + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" })); + }, + show_tabs : false, items : [ { - xtype: Gtk.HBox, - pack : "pack_start,false,true,0", + xtype: Gtk.VBox, + pack : "add", + id : "RightBrowser", items : [ { - xtype: Gtk.Button, - pack : "pack_start,false,false,0", - label : "Dump HTML to console", - listeners : { - "activate":function (self) { - this.get('/RightBrowser.view').el.execute_script( - "console.log(document.body.innerHTML);"); - this.get('/RightBrowser.view').el.execute_script( - "console.log(Builder.dump(Builder));"); + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + pack : "pack_start,false,false,0", + label : "Dump HTML to console", + listeners : { + "activate":function (self) { + this.get('/RightBrowser.view').el.execute_script( + "console.log(document.body.innerHTML);"); + this.get('/RightBrowser.view').el.execute_script( + "console.log(Builder.dump(Builder));"); + } + } } - } - } - ] - }, - { - xtype: Gtk.ScrolledWindow, - pack : "add", - shadow_type : Gtk.ShadowType.IN, - init : function() { - XObject.prototype.init.call(this); - this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - }, - items : [ + ] + }, { - xtype: WebKit.WebView, + xtype: Gtk.ScrolledWindow, pack : "add", - id : "view", + shadow_type : Gtk.ShadowType.IN, init : function() { XObject.prototype.init.call(this); - // this may not work!? - this.el.open('file:///' + __script_path__ + '/../builder.html'); - - Gtk.drag_dest_set - ( - this.el, /* widget that will accept a drop */ - Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, - null, /* lists of target to support */ - 0, /* size of list */ - Gdk.DragAction.COPY /* what to do with data after dropped */ - ); - - // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); - Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }, - renderJS : function(data) { - this.renderedData = data; - var str = JSON.stringify(data) ; - - if (!this.ready) { - console.log('not loaded yet'); - } - Seed.print("RENDER:" + str); - imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");"); - this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");"); - }, - listeners : { - "load_finished":function (self, object) { - if (this.ready) { // dont do it twice! - return; - } - this.ready = true; - - this.renderJS(this.get('/LeftTree.model').toJS()[0]); - }, - "script_alert":function (self, object, p0) { - print(p0); - return false; - return true; // do not display anything... - }, - "console_message":function (self, object, p0, p1) { - console.log(object); - if (!object.match(/^\{/)) { - return false; // do not handle!!! -> later maybe in console.. - } - console.log(object); - var val = JSON.parse(object); - - if (typeof(val['hover-node']) != 'undefined') { - this.activeNode = val['hover-node']; - console.log('active node: ' + this.activeNode); - return true; + items : [ + { + xtype: WebKit.WebView, + pack : "add", + id : "view", + init : function() { + XObject.prototype.init.call(this); + // this may not work!? + this.el.open('file:///' + __script_path__ + '/../builder.html'); + + Gtk.drag_dest_set + ( + this.el, /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + }, + renderJS : function(data) { + this.renderedData = data; + var str = JSON.stringify(data) ; + + if (!this.ready) { + console.log('not loaded yet'); } - - var ret = false; - if (typeof(val['id']) != 'undefined') { - // this.activeNode = val['id']; - var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); - if (!tg) { + Seed.print("RENDER:" + str); + imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");"); + this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");"); + }, + listeners : { + "load_finished":function (self, object) { + if (this.ready) { // dont do it twice! + return; + } + this.ready = true; + + this.renderJS(this.get('/LeftTree.model').toJS()[0]); + }, + "script_alert":function (self, object, p0) { + print(p0); return false; - } - this.get('/LeftTree.view').selectNode(tg[0]); - ret = true; - - } - if (ret && typeof(val['set']) != 'undefined') { - this.get('/LeftPanel.model').add({ - key : val['set'], - val : val['value'] - }); - //console.log('active node: ' + this.activeNode); - - } - //Seed.print('a:'+a); - //Seed.print('b:'+b); - //Seed.print('c:'+c); - return ret; - }, - "drag_motion":function (w, ctx, x, y, time, ud) { - // console.log('DRAG MOTION'); - // status: - // if lastCurrentNode == this.currentNode.. -- don't change anything.. - this.targetData = []; - this.el.execute_script("Builder.overPos(" + x +','+ y + ");"); - - // A) find out from drag all the places that node could be dropped. - var src = Gtk.drag_get_source_widget(ctx); - if (!src.dropList) { - Gdk.drag_status(ctx, 0, time); - return true; - } - // b) get what we are over.. (from activeNode) - // tree is empty.. - list should be correct.. - if (!this.get('/LeftTree.model').currentTree) { - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - return true; - - } - // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + return true; // do not display anything... + }, + "console_message":function (self, object, p0, p1) { + console.log(object); + if (!object.match(/^\{/)) { + return false; // do not handle!!! -> later maybe in console.. + } + console.log(object); + var val = JSON.parse(object); - var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList); - console.dump(tg); - if (!tg.length) { - Gdk.drag_status(ctx, 0,time); - this.get('/LeftTree.view').highlight(false); - return true; - } - - // if we have a target.. - // -> highlight it! (in browser) - // -> highlight it! (in tree) + if (typeof(val['hover-node']) != 'undefined') { + this.activeNode = val['hover-node']; + console.log('active node: ' + this.activeNode); + return true; + } - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - this.get('/LeftTree.view').highlight(tg); - this.targetData = tg; - // for tree we should handle this... - return true; - }, - "drag_drop":function (w, ctx, x, y,time, ud) { - print("TARGET: drag-drop"); - var is_valid_drop_site = true; + var ret = false; + if (typeof(val['id']) != 'undefined') { + // this.activeNode = val['id']; + var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); + if (!tg) { + return false; + } + this.get('/LeftTree.view').selectNode(tg[0]); + ret = true; + + } + if (ret && typeof(val['set']) != 'undefined') { + this.get('/LeftPanel.model').add({ + key : val['set'], + val : val['value'] + }); + //console.log('active node: ' + this.activeNode); + + } + //Seed.print('a:'+a); + //Seed.print('b:'+b); + //Seed.print('c:'+c); + return ret; + }, + "drag_motion":function (w, ctx, x, y, time, ud) { + // console.log('DRAG MOTION'); + // status: + // if lastCurrentNode == this.currentNode.. -- don't change anything.. + this.targetData = []; + this.el.execute_script("Builder.overPos(" + x +','+ y + ");"); + + // A) find out from drag all the places that node could be dropped. + var src = Gtk.drag_get_source_widget(ctx); + if (!src.dropList) { + Gdk.drag_status(ctx, 0, time); + return true; + } + // b) get what we are over.. (from activeNode) + // tree is empty.. - list should be correct.. + if (!this.get('/LeftTree.model').currentTree) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + return true; + + } + // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + + var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList); + console.dump(tg); + if (!tg.length) { + Gdk.drag_status(ctx, 0,time); + this.get('/LeftTree.view').highlight(false); + return true; + } + + // if we have a target.. + // -> highlight it! (in browser) + // -> highlight it! (in tree) + + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + this.get('/LeftTree.view').highlight(tg); + this.targetData = tg; + // for tree we should handle this... + return true; + }, + "drag_drop":function (w, ctx, x, y,time, ud) { + print("TARGET: drag-drop"); + var is_valid_drop_site = true; + + + Gtk.drag_get_data + ( + w, /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the DnD */ + this.get('/Window').atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); + + + /* No target offered by source => error */ + - - Gtk.drag_get_data - ( - w, /* will receive 'drag-data-received' signal */ - ctx, /* represents the current state of the DnD */ - this.get('/Window').atoms["STRING"], /* the target type we want */ - time /* time stamp */ - ); - - - /* No target offered by source => error */ - - - return is_valid_drop_site; - }, - "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) - { - print("Browser: drag-data-received"); - var delete_selection_data = false; - vardnd_success = false; - /* Deal with what we are given from source */ - if( sel_data && sel_data.length ) { - - if (ctx.action == Gdk.DragAction.ASK) { - /* Ask the user to move or copy, then set the ctx action. */ - } - - if (ctx.action == Gdk.DragAction.MOVE) { - delete_selection_data = true; - } - var source = Gtk.drag_get_source_widget(ctx); - - print("Browser: source.DRAGDATA? " + source.dragData); - if (this.targetData) { - print(this.targetData); - this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); - } - - - - dnd_success = true; - - } - - if (dnd_success == false) - { - Seed.print ("DnD data transfer failed!\n"); - } + return is_valid_drop_site; + }, + "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) + { + print("Browser: drag-data-received"); + var delete_selection_data = false; + vardnd_success = false; + /* Deal with what we are given from source */ + if( sel_data && sel_data.length ) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } - Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); - return true; + if (ctx.action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + var source = Gtk.drag_get_source_widget(ctx); + + print("Browser: source.DRAGDATA? " + source.dragData); + if (this.targetData) { + print(this.targetData); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } + + + + dnd_success = true; + + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); + return true; + } } - } + } + ] } ] - } - ] - }, - { - xtype: Gtk.VBox, - pack : "add", - id : "RightGtkView", - renderJS : function(data, withDebug) - { - if (!data) { - return; - } - this.withDebug = false; - - if (this.renderedEl) { - this.get('view').el.remove(this.renderedEl); - this.renderedEl.destroy(); - this.renderedEl = false; - } - - var tree = this.get('/LeftTree.model').toJS(false,true)[0]; - // in theory tree is actually window.. - try { - this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el); - } catch (e) { - print(e.message); - return; - } - this.get('view').el.set_size_request( - tree.default_width * 1 || 400, tree.default_height * 1 || 400 - ) ; - - this.renderedEl.set_size_request( - tree.default_width || 600, - tree.default_height || 400 - ); - this.get('view').el.show_all(); - - - - }, - showInWindow : function() { - print("GET PROEJCT"); - var pr = this.get('/LeftProjectTree').getActiveProject(); - - console.log(pr.paths); - return; - /* - var src= this.buildJS( - this.get('/LeftTree.model').toJS()[0], - true); - // show term?? - - - //var x = new imports.sandbox.Context(); - //x.add_globals(); - //print(src); - try { - Seed.check_syntax('var e = ' + src); - //x.eval(src); - } catch( e) { - this.get('/Terminal').feed(e.message || e.toString() + "\n"); - this.get('/Terminal').feed(console._dump(e)+"\n"); - if (e.line) { - var lines = src.split("\n"); - var start = Math.max(0, e.line - 10); - var end = Math.min(lines.length, e.line + 10); - for (var i =start ; i < end; i++) { - if (i == e.line) { - this.get('/Terminal').feed(">>>>>" + lines[i] + "\n"); - continue; - } - this.get('/Terminal').feed(lines[i] + "\n"); + }, + { + xtype: Gtk.VBox, + pack : "add", + id : "RightGtkView", + renderJS : function(data, withDebug) + { + if (!data) { + return; } + this.withDebug = false; - } + if (this.renderedEl) { + this.get('view').el.remove(this.renderedEl); + this.renderedEl.destroy(); + this.renderedEl = false; + } + + var tree = this.get('/LeftTree.model').toJS(false,true)[0]; + // in theory tree is actually window.. + try { + this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el); + } catch (e) { + print(e.message); + return; + } + this.get('view').el.set_size_request( + tree.default_width * 1 || 400, tree.default_height * 1 || 400 + ) ; + + this.renderedEl.set_size_request( + tree.default_width || 600, + tree.default_height || 400 + ); + this.get('view').el.show_all(); + + + + }, + showInWindow : function() { + print("GET PROEJCT"); + var pr = this.get('/LeftProjectTree').getActiveProject(); + + console.log(pr.paths); + return; + /* + var src= this.buildJS( + this.get('/LeftTree.model').toJS()[0], + true); + // show term?? - return; - } - this.get('/BottomPane').el.set_current_page(1); - this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); - var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n"; - this.get('/Terminal').el.feed_child(cmd, cmd.length); - /* - var _top = x.get_global_object()._top; - - _top.el.set_screen(Gdk.Screen.get_default()); // just in case.. - _top.el.show_all(); - if (_top.el.popup) { - _top.el.popup(null, null, null, null, 3, null); - } - */ - }, - viewAdd : function(item, par) - { - // does something similar to xobject.. - item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack; - - if (item.pack===false || item.pack === 'false') { // no ; - return; - } - print("CREATE: " + item['|xns'] + '.' + item['xtype']); - var ns = imports.gi[item['|xns']]; - var ctr = ns[item['xtype']]; - var ctr_args = { }; - for(var k in item) { - var kv = item[k]; - if (typeof(kv) == 'object' || typeof(kv) == 'function') { - continue; - } - if ( - k == 'pack' || - k == 'items' || - k == 'id' || - k == 'xtype' || - k == 'xdebug' || - k == 'xns' || - k == '|xns' - ) { - continue; - } - - if (k[0] == '|' && typeof(kv) == 'string') { - - if (kv.match(new RegExp('function'))) { - continue; + + //var x = new imports.sandbox.Context(); + //x.add_globals(); + //print(src); + try { + Seed.check_syntax('var e = ' + src); + //x.eval(src); + } catch( e) { + this.get('/Terminal').feed(e.message || e.toString() + "\n"); + this.get('/Terminal').feed(console._dump(e)+"\n"); + if (e.line) { + var lines = src.split("\n"); + var start = Math.max(0, e.line - 10); + var end = Math.min(lines.length, e.line + 10); + for (var i =start ; i < end; i++) { + if (i == e.line) { + this.get('/Terminal').feed(">>>>>" + lines[i] + "\n"); + continue; + } + this.get('/Terminal').feed(lines[i] + "\n"); + } + } - print("WASL " + k + '=' + kv); - try { - eval( 'kv = ' + kv); - } catch(e) { continue; } - k = k.substring(1); - print(k + '=' + kv); - } - if (k[0] == '|') { // should be boolean or number.. - k = k.substring(1); - } - if (k == 'show_tabs') { // force tab showing for notebooks. - kv = true; - } - ctr_args[k] = kv; - - } - - - var el = new ctr(ctr_args); - - //print("PACK"); - //console.dump(item.pack); - - - - - var args = []; - var pack_m = false; - if (typeof(item.pack) == 'string') { - - item.pack.split(',').forEach(function(e, i) { - - if (e == 'false') { args.push( false); return; } - if (e == 'true') { args.push( true); return; } - if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; } - args.push(e); - }); - //print(args.join(",")); + return; + } + this.get('/BottomPane').el.set_current_page(1); + this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); + var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + /* + var _top = x.get_global_object()._top; + + _top.el.set_screen(Gdk.Screen.get_default()); // just in case.. + _top.el.show_all(); + if (_top.el.popup) { + _top.el.popup(null, null, null, null, 3, null); + } + */ + }, + viewAdd : function(item, par) + { + // does something similar to xobject.. + item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack; + + if (item.pack===false || item.pack === 'false') { // no ; + return; + } + print("CREATE: " + item['|xns'] + '.' + item['xtype']); + var ns = imports.gi[item['|xns']]; + var ctr = ns[item['xtype']]; + var ctr_args = { }; + for(var k in item) { + var kv = item[k]; + if (typeof(kv) == 'object' || typeof(kv) == 'function') { + continue; + } + if ( + k == 'pack' || + k == 'items' || + k == 'id' || + k == 'xtype' || + k == 'xdebug' || + k == 'xns' || + k == '|xns' + ) { + continue; + } - pack_m = args.shift(); - } else { - pack_m = item.pack.shift(); - args = item.pack; - } - - // handle error. - if (pack_m && typeof(par[pack_m]) == 'undefined') { - throw { - name: "ArgumentError", - message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m + - "ADDING : " + item.id + " " + el - - }; - - return; - } - - console.dump(args); - args.unshift(el); - //if (XObject.debug) print(pack_m + '[' + args.join(',') +']'); - //Seed.print('args: ' + args.length); - if (pack_m) { - par[pack_m].apply(par, args); - } - - var _this = this; - item.items = item.items || []; - item.items.forEach(function(ch) { - _this.viewAdd(ch, el); - }); - - - - // add the signal handlers. - // is it a widget!?!!? - - - try { - + if (k[0] == '|' && typeof(kv) == 'string') { - el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true)); - el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true)); - el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true)); - el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true )); - el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true )); - } catch(e) { - // ignore! - } - - - - return el; - - }, - widgetExposeEvent : function() { - /// print("WIDGET EXPOSE"); // draw highlight?? - return false; - }, - widgetDragMotionEvent : function() { - print("WIDGET DRAGMOTION"); - return true; - }, - widgetDragDropEvent : function() { - print("WIDGET DRAGDROP"); - return true; - }, - widgetPressEvent : function(w,e,u,d) { - if (this.get('view').pressed) { - return false; - } - this.get('view').pressed = true; - print("WIDGET PRESS " + d.xtreepath ); - this.get('/LeftTree.view').selectNode( d.xtreepath ); - return false; - }, - widgetReleaseEvent : function() { - this.get('view').pressed = false; - return false; - }, - items : [ - { - xtype: Gtk.HBox, - pack : "pack_start,false,true,0", - items : [ - { - xtype: Gtk.Button, - pack : "pack_start,false,false,0", - label : "Run The Application", - listeners : { - "button_press_event":function (self, event) { - // call render on left tree - with special option!?! - - - - print("GET PROEJCT"); - var pr = this.get('/LeftProjectTree').getActiveProject(); - - var dir = ''; - for (var i in pr.paths) { - dir = i; - break; - } - var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; - print ("RUN DIR:" + dir); - - this.get('/BottomPane').el.set_current_page(1); - this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) - , false,false,false); - var cmd = "/usr/bin/seed " + runner + " " + dir + "\n"; - this.get('/Terminal').el.feed_child(cmd, cmd.length); - return false; - - - } + if (kv.match(new RegExp('function'))) { + continue; + } + print("WASL " + k + '=' + kv); + try { + eval( 'kv = ' + kv); + } catch(e) { continue; } + + k = k.substring(1); + print(k + '=' + kv); + } + if (k[0] == '|') { // should be boolean or number.. + k = k.substring(1); + } + if (k == 'show_tabs') { // force tab showing for notebooks. + kv = true; } + ctr_args[k] = kv; + + } + + + var el = new ctr(ctr_args); + + //print("PACK"); + //console.dump(item.pack); + + + + + var args = []; + var pack_m = false; + if (typeof(item.pack) == 'string') { + + item.pack.split(',').forEach(function(e, i) { + + if (e == 'false') { args.push( false); return; } + if (e == 'true') { args.push( true); return; } + if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; } + args.push(e); + }); + //print(args.join(",")); + + pack_m = args.shift(); + } else { + pack_m = item.pack.shift(); + args = item.pack; } - ] - }, - { - xtype: Gtk.ScrolledWindow, - pack : "add", - id : "view-sw", - shadow_type : Gtk.ShadowType.IN, - init : function() { - XObject.prototype.init.call(this); - this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + // handle error. + if (pack_m && typeof(par[pack_m]) == 'undefined') { + throw { + name: "ArgumentError", + message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m + + "ADDING : " + item.id + " " + el + + }; + + return; + } + + console.dump(args); + args.unshift(el); + //if (XObject.debug) print(pack_m + '[' + args.join(',') +']'); + //Seed.print('args: ' + args.length); + if (pack_m) { + par[pack_m].apply(par, args); + } + + var _this = this; + item.items = item.items || []; + item.items.forEach(function(ch) { + _this.viewAdd(ch, el); + }); + + + + // add the signal handlers. + // is it a widget!?!!? + + + try { + + + el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true)); + el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true)); + el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true)); + el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true )); + el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true )); + } catch(e) { + // ignore! + } + + + + return el; + + }, + widgetExposeEvent : function() { + /// print("WIDGET EXPOSE"); // draw highlight?? + return false; + }, + widgetDragMotionEvent : function() { + print("WIDGET DRAGMOTION"); + return true; + }, + widgetDragDropEvent : function() { + print("WIDGET DRAGDROP"); + return true; + }, + widgetPressEvent : function(w,e,u,d) { + if (this.get('view').pressed) { + return false; + } + this.get('view').pressed = true; + print("WIDGET PRESS " + d.xtreepath ); + this.get('/LeftTree.view').selectNode( d.xtreepath ); + return false; + }, + widgetReleaseEvent : function() { + this.get('view').pressed = false; + return false; }, items : [ { - xtype: Gtk.EventBox, + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + pack : "pack_start,false,false,0", + label : "Run The Application", + listeners : { + "button_press_event":function (self, event) { + // call render on left tree - with special option!?! + + + + print("GET PROEJCT"); + var pr = this.get('/LeftProjectTree').getActiveProject(); + + var dir = ''; + for (var i in pr.paths) { + dir = i; + break; + } + var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; + print ("RUN DIR:" + dir); + + this.get('/BottomPane').el.set_current_page(1); + this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) + , false,false,false); + var cmd = "/usr/bin/seed " + runner + " " + dir + "\n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + return false; + + + } + } + } + ] + }, + { + xtype: Gtk.ScrolledWindow, pack : "add", + id : "view-sw", + shadow_type : Gtk.ShadowType.IN, init : function() { XObject.prototype.init.call(this); - this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({ - red: 0x9F00, green: 0xB800 , blue : 0xA800 - })); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }, items : [ { - xtype: Gtk.Fixed, - pack : "add", + xtype: Gtk.EventBox, + pack : "add_with_viewport", init : function() { - XObject.prototype.init.call(this); - //this.el.set_hadjustment(this.parent.el.get_hadjustment()); - //this.el.set_vadjustment(this.parent.el.get_vadjustment()); - + XObject.prototype.init.call(this); + this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({ + red: 0x9F00, green: 0xB800 , blue : 0xA800 + })); }, items : [ { - xtype: Gtk.EventBox, - pack : "put,10,10", + xtype: Gtk.Fixed, + pack : "add", init : function() { - //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU); XObject.prototype.init.call(this); - - Gtk.drag_dest_set - ( - this.el, /* widget that will accept a drop */ - Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, - null, /* lists of target to support */ - 0, /* size of list */ - Gdk.DragAction.COPY /* what to do with data after dropped */ - ); - - // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); - Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); - }, - ready : false, - getActiveNode : function(x,y) - { - // workout what node is here.. - return '0'; // top.. + //this.el.set_hadjustment(this.parent.el.get_hadjustment()); + //this.el.set_vadjustment(this.parent.el.get_vadjustment()); + }, - id : "view", - listeners : { - "drag_motion":function (self, ctx, x, y, time) { + items : [ + { + xtype: Gtk.EventBox, + pack : "put,10,10", + init : function() { + //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU); + XObject.prototype.init.call(this); - // A) find out from drag all the places that node could be dropped. - var src = Gtk.drag_get_source_widget(ctx); - if (!src.dropList) { - Gdk.drag_status(ctx, 0, time); - return true; - } - // b) get what we are over.. (from activeNode) - // tree is empty.. - list should be correct.. - if (!this.get('/LeftTree.model').currentTree) { - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - return true; - - } - // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) - var activeNode = this.getActiveNode(x, y); + Gtk.drag_dest_set + ( + this.el, /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + }, + ready : false, + getActiveNode : function(x,y) + { + // workout what node is here.. + return '0'; // top.. + }, + id : "view", + listeners : { + "drag_motion":function (self, ctx, x, y, time) { + + // A) find out from drag all the places that node could be dropped. + var src = Gtk.drag_get_source_widget(ctx); + if (!src.dropList) { + Gdk.drag_status(ctx, 0, time); + return true; + } + // b) get what we are over.. (from activeNode) + // tree is empty.. - list should be correct.. + if (!this.get('/LeftTree.model').currentTree) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + return true; + + } + // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + var activeNode = this.getActiveNode(x, y); + + + var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList); + console.dump(tg); + if (!tg.length) { + Gdk.drag_status(ctx, 0,time); + this.get('/LeftTree.view').highlight(false); + return true; + } + + // if we have a target.. + // -> highlight it! (in browser) + // -> highlight it! (in tree) + + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + this.get('/LeftTree.view').highlight(tg); + this.targetData = tg; + // for tree we should handle this... + return true; + }, + "drag_drop":function (self,ctx, x, y, time) { + Seed.print("TARGET: drag-drop"); + var is_valid_drop_site = true; - var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList); - console.dump(tg); - if (!tg.length) { - Gdk.drag_status(ctx, 0,time); - this.get('/LeftTree.view').highlight(false); - return true; - } - // if we have a target.. - // -> highlight it! (in browser) - // -> highlight it! (in tree) + Gtk.drag_get_data + ( + self, /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the this.gDnD */ + this.get('/Window').atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - this.get('/LeftTree.view').highlight(tg); - this.targetData = tg; - // for tree we should handle this... - return true; - }, - "drag_drop":function (self,ctx, x, y, time) { - Seed.print("TARGET: drag-drop"); - var is_valid_drop_site = true; + + /* No target offered by source => error */ + - - Gtk.drag_get_data - ( - self, /* will receive 'drag-data-received' signal */ - ctx, /* represents the current state of the this.gDnD */ - this.get('/Window').atoms["STRING"], /* the target type we want */ - time /* time stamp */ - ); + return is_valid_drop_site; + + }, + "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) + { + Seed.print("GtkView: drag-data-received"); + var delete_selection_data = false; + var dnd_success = false; + /* Deal with what we are given from source */ + if( sel_data && sel_data.length ) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + if (ctx.action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + var source = Gtk.drag_get_source_widget(ctx); - /* No target offered by source => error */ - - - return is_valid_drop_site; - - }, - "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) - { - Seed.print("GtkView: drag-data-received"); - var delete_selection_data = false; - var dnd_success = false; - /* Deal with what we are given from source */ - if( sel_data && sel_data.length ) { - - if (ctx.action == Gdk.DragAction.ASK) { - /* Ask the user to move or copy, then set the ctx action. */ - } - - if (ctx.action == Gdk.DragAction.MOVE) { - delete_selection_data = true; - } - var source = Gtk.drag_get_source_widget(ctx); - - Seed.print("Browser: source.DRAGDATA? " + source.dragData); - if (this.targetData) { - Seed.print(this.targetData); - this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); - } - - - - dnd_success = true; - - } - - if (dnd_success == false) - { - Seed.print ("DnD data transfer failed!\n"); - } + Seed.print("Browser: source.DRAGDATA? " + source.dragData); + if (this.targetData) { + Seed.print(this.targetData); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } + + + + dnd_success = true; - Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); - return true; - }, - "button_press_event":function (self, event) { - this.pressed = false; - return false; + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); + return true; + }, + "button_press_event":function (self, event) { + this.pressed = false; + return false; + } + } } - } + ] } ] } @@ -3022,6 +3034,24 @@ Window=new XObject({ ] } ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + id : "Help", + items : [ + { + xtype: WebKit.WebView, + pack : "add", + id : "help-view", + init : function() { + XObject.prototype.init.call(this); + this.get('/Window.help-view').el.open( + "http://devel.akbkhome.com/seed/"); + + } + } + ] } ] } @@ -3054,6 +3084,18 @@ Window=new XObject({ }, load : function(str) { + + // show the help page for the active node.. + this.get('/Window.view-help-nb').el.set_current_page(1); + + // get the active element being edited. + var xtype = this.get('/LeftTree.model').file.guessName( + this.get('/MidPropTree').activeElement); + // now load the help info in the page.. + this.get('/Window.help-view').el.open( + "http://devel.akbkhome.com/seed/" + xtype + ".html"); + + this.get('/BottomPane').el.set_current_page(0); this.el.get_buffer().set_text(str, str.length); var lm = GtkSource.LanguageManager.get_default(); diff --git a/Sample/Window.bjs b/Sample/Window.bjs index 6f31eb83f..ef12f6aed 100644 --- a/Sample/Window.bjs +++ b/Sample/Window.bjs @@ -1 +1 @@ -{"id":"file-gtk-4","name":"Window","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/Window.bjs","items":[{"|xns":"Gtk","xtype":"Window","|type":"Gtk.WindowType.TOPLEVEL","title":"Application Builder","border_width":0,"|init":"function() {\n this.atoms = {\n \"STRING\" : Gdk.atom_intern(\"STRING\")\n\t};\n\tthis.targetList = new Gtk.TargetList();\n\tthis.targetList.add( this.atoms[\"STRING\"], 0, 0);\n\t//imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\nGtk.rc_parse_string(\n \"style \\\"gtkcombobox-style\\\" {\\n\" + \n \" GtkComboBox::appears-as-list = 1\\n\" +\n \"}\\n\"+\n \"class \\\"GtkComboBox\\\" style \\\"gtkcombobox-style\\\"\\n\");\n XObject.prototype.init.call(this);\n this.el.show_all();\n \n \n \n}\n","default_width":800,"default_height":500,"id":"Window","listeners":{"delete_event":"function (self, event) {\n return false;\n}","destroy":"function (self) {\n Gtk.main_quit();\n}","show":"function (self) {\n print(\"WINDOW SHOWING - trying to hide\");\nimports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\n \tthis.get('/MidPropTree').hideWin();\n this.get('/RightPalete').hide();\n\n}"},"items":[{"|xns":"Gtk","xtype":"VBox","id":"w-vbox","items":[{"|xns":"Gtk","xtype":"MenuBar","pack":"pack_start,false,false","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"_File","items":[{"|xns":"Gtk","xtype":"Menu","pack":"set_submenu","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"New _Project","listeners":{"activate":"function (self) {\n\tthis.get('/EditProject').show({\n\t success : function(pr) {\n\t\t this.get('/LeftProjectTree').get('combo').setValue(pr.fn);\n\t }\n\t});\n}"}},{"|xns":"Gtk","xtype":"MenuItem","label":"_New File","|use_underline":true,"listeners":{"activate":"function (self) {\n \tvar fn = this.get('/LeftProjectTree.combo').getValue();\n if (!fn) {\n this.get('/LeftProjectTree').showNoProjectSelected();\n return true;\n }\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n this.get('/DialogNewComponent').show({\n project : pm.getByFn(fn)\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"_Quit","|use_underline":true,"listeners":{"activate":"function (self) {\n Gtk.main_quit();\n} "}}]}]},{"|xns":"Gtk","xtype":"MenuItem","label":"Help"}]},{"|xns":"Gtk","xtype":"HPaned","id":"left","position":400,"items":[{"|xns":"Gtk","xtype":"HBox","items":[{"|xns":"Gtk","xtype":"VPaned","position":300,"id":"leftvpaned","items":[{"|xns":"Gtk","xtype":"VBox","id":"LeftTopPanel","items":[{"|xns":"Gtk","xtype":"Expander","label":"Select Project","id":"expander","pack":"pack_start,false,true","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","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}"}},{"|xns":"Gtk","xtype":"Notebook","id":"notebook","|show_border":false,"|show_tabs":false,"pack":"pack_start,true,true","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_current_page(0);\n\n}\n","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n","id":"LeftTree","|getPaleteProvider":"function() {\n var model = this.get('model');\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n return pm.getPalete(model.file.getType());\n}\n","|renderView":"function() {\n \t var model = this.get('model');\n\tprint(\"RENDER VIEW?\" + model.file.getType());\n\tswitch( model.file.getType()) {\n\t\tcase 'Roo':\n\t\t this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);\n\t\tcase 'Gtk':\n\t\t this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);\n\t}\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","pack":"add","id":"view","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":0,"|init":"function() {\n \tXObject.prototype.init.call(this);\n\tvar description = new Pango.FontDescription.c_new();\n\tdescription.set_size(8000);\n\tthis.el.modify_font(description);\n\n\tthis.selection = this.el.get_selection();\n\tthis.selection.set_mode( Gtk.SelectionMode.SINGLE);\n\tvar _this = this;\n\tthis.selection.signal['changed'].connect(function() {\n\t\t_this.get('/LeftTree.view').listeners.cursor_changed.apply(\n\t\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n\t\t);\n\t});\n\n\tGtk.drag_source_set (\n\t\tthis.el, /* widget will be drag-able */\n\t\tGdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n\t\tnull, /* lists of target to support */\n\t\t0, /* size of list */\n\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n\n\tGtk.drag_source_add_text_targets(this.el); \n\tGtk.drag_dest_set\n\t(\n\t this.el, /* widget that will accept a drop */\n\t Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n\t null, /* lists of target to support */\n\t 0, /* size of list */\n\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n\tGtk.drag_dest_add_text_targets(this.el);\n}\n","|highlight":"function(treepath_ar) {\n if (treepath_ar.length && treepath_ar[0].length ) {\n this.el.set_drag_dest_row( \n new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n }","|selectNode":"function(treepath_str) {\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n","listeners":{"button_press_event":"function (self, ev) {\n \tconsole.log(\"button press?\");\n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {\n print(\"click\" + ev.type);\n return false;\n }\n \n \n var res = {}; \n this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);\n \n if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();\n \n this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());\n this.get('/LeftTreeMenu').el.show_all();\n this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);\n print(\"click:\" + res.path.to_string());\n return false;\n}","drag_begin":"function (self, drag_context) {\n\tprint('SOURCE: drag-begin');\n this.targetData = false;\n // find what is selected in our tree...\n var iter = new Gtk.TreeIter();\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n var xname = this.get('/LeftTree.model').file.guessName(data);\n \n this.el.dragData = xname;\n this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);\n \n\n // make the drag icon a picture of the node that was selected\n var path = this.get('/LeftTree.model').el.get_path(iter);\n this.el.treepath = path.to_string();\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_pixmap (ctx,\n pix.get_colormap(),\n pix,\n null,\n -10,\n -10);\n \n return true;\n}","drag_end":"function (self, drag_context) {\n\tSeed.print('LEFT-TREE: drag-end');\n this.el.dragData = false;\n this.el.dropList = false;\n this.targetData = false;\n this.get('/LeftTree.view').highlight(false);\n return true;\n}","drag_motion":"function (self, ctx, x, y, time) {\n console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n\n // a drag from elsewhere...- prevent drop..\n if (!src.dragData) {\n print(\"no drag data!\");\n Gdk.drag_status(ctx, 0, time);\n this.targetData = false;\n return true;\n }\n var action = Gdk.DragAction.COPY;\n if (src == this.el) {\n // unless we are copying!!! ctl button..\n action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n }\n var data = {};\n\n\t\tif (!this.get('/LeftTree.model').el.iter_n_children(null)) {\n\t\t\t// no children.. -- asume it's ok..\n\t\t\tthis.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];\n\t\t\tGdk.drag_status(ctx, action ,time);\n\t\t\treturn true;\n\t\t}\n\n print(\"GETTING POS\");\n var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);\n print(\"ISOVER? \" + isOver);\n if (!isOver) {\n Gdk.drag_status(ctx, 0 ,time);\n return false; // not over apoint!?!\n }\n // drag node is parent of child..\n console.log(\"SRC TREEPATH: \" + src.treepath);\n console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n if (typeof(src.treepath) != 'undefined' && \n src.treepath == data.path.to_string().substring(0,src.treepath.length)) {\n print(\"subpath drag\");\n Gdk.drag_status(ctx, 0 ,time);\n return false;\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n print(data.path.to_string() +' => '+ data.pos);\n var tg = this.get('/LeftTree.model').findDropNodeByPath(\n data.path.to_string(), src.dropList, data.pos);\n \n this.get('/LeftTree.view').highlight(tg);\n if (!tg.length) {\n print(\"Can not find drop node path\");\n this.targetData = false;\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n //console.dump(tg);\n this.targetData = tg; \n \n \n Gdk.drag_status(ctx, action ,time);\n \n return true;\n}","drag_drop":"function (w, ctx, x, y, time) {\n Seed.print(\"TARGET: drag-drop\");\n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return true;\n}","drag_data_received":"function (self, ctx, x, y, sel_data, info, time) {\n\t print(\"Tree: drag-data-received\");\n\n var delete_selection_data = false;\n var dnd_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 \n var source = Gtk.drag_get_source_widget(ctx);\n\n if (this.targetData) {\n if (source != this.el) {\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n } else {\n // drag around.. - reorder..\n this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);\n \n \n }\n //Seed.print(this.targetData);\n \n }\n \n \n \n // we can send stuff to souce here...\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}","cursor_changed":"function (self) {\n if (this.blockChanges) {\n return true;\n }\n var iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n this.get('/LeftPanel.model').load( false);\n this.get('/MidPropTree').activeElement = false;\n this.get('/MidPropTree').hideWin();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/LeftTree').getPaleteProvider()) {\n // it may not be loaded yet..\n return true;\n }\n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n return true;\n }\n \n //console.log('changed');\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n \n \n // var val = \"\";\n value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();\n \n var data = JSON.parse(value.value);\n this.get('/MidPropTree').activeElement = data;\n this.get('/MidPropTree').hideWin();\n this.get('/LeftPanel.model').load( data);\n \n console.log(value.value);\n // _g.button.set_label(''+value.get_string());\n\n var pm =this.get('/RightPalete.model');\n pm.load( this.get('/RightPalete').provider.gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n \n \n \n //Seed.print( value.get_string());\n return true;\n \n}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // source..\n ] );\n}\n","activePath":false,"|changed":"function(n, refresh) {\n print(\"MODEL CHANGED CALLED\" + this.activePath);\n if (this.activePath) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))\n this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n \n this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);\n }\n //this.currentTree = this.toJS(false, true)[0];\n this.file.items = this.toJS(false, false);\n print(\"AFTER CHANGED\");\n //console.dump(this.file.items);\n this.file.save();\n this.currentTree = this.file.items[0];\n //console.log(this.file.toSource());\n \n if (refresh) {\n print(\"REDNER BROWSER?!\");\n this.get('/LeftTree').renderView();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/RightPalete').provider) {\n pm.load([]);\n return;\n }\n \n \n pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));\n //imports['Builder/RightBrowser.js'].renderJS(this.toJS());\n }\n\t \n}\n","|loadFile":"function(f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n if (!f) {\n console.log('missing file');\n return;\n }\n \n // load the file if not loaded..\n if (f.items === false) {\n var _this = this;\n f.loadItems(function() {\n _this.loadFile(f);\n });\n return;\n \n }\n if (f.items.length && typeof(f.items[0]) == 'string') {\n \n this.get('/RightEditor').el.show();\n this.get('/RightEditor.view').load( f.items[0]);\n return;\n }\n print(\"LOAD\");\n //console.dump(f.items);\n this.load(f.items);\n this.get('/LeftTree.view').el.expand_all();\n\n if (!f.items.length) {\n // single item..\n \n this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n this.get('/LeftTree.view').el.set_cursor( \n new Gtk.TreePath.from_string('0'), null, false);\n \n \n } else {\n this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n \n //print(\"hide right editior\");\n this.get('/RightEditor').el.hide();\n //print(\"set current tree\");\n this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n this.currentTree = this.currentTree || { items: [] };\n this.get('/LeftTree').renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n \n}\n","|findDropNode":"function(treepath_str, targets) {\n\n// this is used by the dragdrop code in the roo version AFAIR..\n\n \t\tvar path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (!this.el.iter_n_children(null)) {\n print(\"NO KEYS\");\n return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];\n }\n print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n if (!treepath_str.match(/^builder-/)) {\n return []; // nothing!\n }\n if (targets === true) {\n return [ path ];\n }\n return this.findDropNodeByPath(path,targets) \n}\n","|findDropNodeByPath":"function(treepath_str, targets, pref) {\n var path = treepath_str + ''; // dupe it..\n pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;\n var last = false;\n //console.dump(this.treemap);\n while (path.length) {\n print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.singleNodeToJS(path);\n if (node_data === false) {\n print(\"node not found\");\n return [];\n }\n \n var xname = this.get('/LeftTree.model').file.guessName(node_data);\n var match = false;\n var prop = '';\n targets.forEach(function(tg) {\n if (match) {\n return;;\n }\n if ((tg == xname) ) {\n match = tg;\n }\n if (tg.indexOf(xname +':') === 0) {\n match = tg;\n prop = tg.split(':').pop();\n }\n });\n \n if (match) {\n if (last) { // pref is after/before..\n // then it's after last\n if (pref > 1) {\n return []; // do not allow..\n }\n return [ last, pref , prop];\n \n }\n return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];\n }\n var par = path.split(':');\n last = path;\n par.pop();\n path = par.join(':');\n }\n \n return [];\n \n}\n","|dropNode":"function(target_data, node) {\n print(\"drop Node\");\n \t console.dump(node);\n \t console.dump(target_data);\n var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;\n \n print(\"add \" + tp + \"@\" + target_data[1] );\n var parent = tp;\n var after = false;\n if (tp && target_data[1] < 2) { // before or after..\n var ar = target_data[0].split(':');\n ar.pop();\n parent = new Gtk.TreePath.from_string( ar.join(':') );\n after = tp;\n }\n var n_iter = new Gtk.TreeIter();\n var iter_par = new Gtk.TreeIter();\n var iter_after = after ? new Gtk.TreeIter() : false;\n \n \n \n if (parent !== false) {\n this.el.get_iter(iter_par, parent);\n } else {\n iter_par = null;\n }\n \n \n if (tp && after) {\n print(target_data[1] > 0 ? 'insert_after' : 'insert_before');\n this.el.get_iter(iter_after, after);\n this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](\n n_iter, iter_par, iter_after);\n \n } else {\n this.el.append(n_iter, iter_par);\n \n }\n \n if (typeof(node) == 'string') {\n var ar = node.split('.');\n var xtype = ar.pop();\n \n node = {\n '|xns' : ar.join('.'),\n 'xtype' : xtype\n };\n if (target_data.length == 3 && target_data[2].length) {\n node['*prop'] = target_data[2];\n }\n \n }\n // work out what kind of packing to use..\n if (typeof(node.pack) == 'undefined' && parent !== false) {\n var pal = this.get('/LeftTree').getPaleteProvider();\n \n var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));\n print (\"PNAME : \" + pname);\n var cname = pal.guessName(node);\n print (\"CNAME : \" + cname);\n node.pack = pal.getDefaultPack(pname, cname);\n \n \n }\n \n \n var xitems = [];\n if (node.items) {\n xitems = node.items;\n delete node.items;\n }\n// load children - if it has any..\n\n if (xitems) {\n this.load(xitems, n_iter);\n }\n if (tp && (xitems || after)) {\n this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);\n }\n // wee need to get the empty proptypes from somewhere..\n \n //var olditer = this.activeIter;\n this.activePath = this.el.get_path(n_iter).to_string();\n\n\t // changed actually set's the node data..\n this.changed(node, true);\n \n \n \n this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);\n \n //Builder.MidPropTree._model.load(node);\n //Builder.MidPropTree._win.hideWin();\n //Builder.LeftPanel._model.load( node);\n \n \n}\n","|moveNode":"function(target_data, action) {\n //print(\"MOVE NODE\");\n // console.dump(target_data);\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var node = this.nodeToJS(old_iter,false);\n //console.dump(node);\n \n \n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n \n this.dropNode(target_data, node);\n\t if (action & Gdk.DragAction.MOVE) {\n // print(\"REMOVING OLD NODE\");\n this.el.remove(old_iter);\n \n }\n \n this.activePath= false;\n this.changed(false,true);\n}\n","|deleteSelected":"function() {\n this.get('/LeftTree.view').blockChanges = true;\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var path = this.el.get_path(old_iter).to_string();\n\n this.activePath= false; \n s.unselect_all();\n\n this.activePath= false; \n\t var iter = new Gtk.TreeIter();\n this.el.get_iter_from_string(iter, path);\n this.el.remove(iter);\n \n // rebuild treemap. -- depreciated.!!\n this.map = {};\n this.treemap = { };\n //this.toJS(null, true) // does not do anything?\n this.activePath= false; \n this.changed(false,true);\n this.get('/LeftTree.view').blockChanges = false;\n}\n","currentTree":false,"|listAllTypes":"function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n \n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n","|singleNodeToJS":"function (treepath) \n {\n var iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n \n var iv = this.getIterValue(iter, 2);\n \n return JSON.parse(iv);\n \n }","|nodeToJS":"function (iter, with_id) \n{\n var par = new Gtk.TreeIter(); \n var iv = this.getIterValue(iter, 2);\n // print(\"IV\" + iv);\n var k = JSON.parse(iv);\n if (k.json && !this.el.iter_parent( par, iter )) {\n delete k.json;\n }\n \n if (with_id) {\n var treepath_str = this.el.get_path(iter).to_string();\n // not sure how we can handle mixed id stuff..\n if (typeof(k.id) == 'undefined') {\n k.id = 'builder-'+ treepath_str ;\n }\n \n // needed??\n this.treemap[ treepath_str ] = k;\n k.xtreepath = treepath_str ;\n \n }\n if (this.el.iter_has_child(iter)) {\n citer = new Gtk.TreeIter();\n this.el.iter_children(citer, iter);\n k.items = this.toJS(citer,with_id);\n }\n return k;\n}\n","|toJS":"function(iter, with_id)\n {\n //Seed.print(\"WITHID: \"+ with_id);\n \n var first = false;\n if (!iter) {\n \n this.treemap = { }; \n \n iter = new Gtk.TreeIter();\n if (!this.el.get_iter_first(iter)) {\n return [];\n }\n first = true;\n } \n \n var ar = [];\n \n while (true) {\n \n var k = this.nodeToJS(iter, with_id); \n ar.push(k);\n \n \n if (!this.el.iter_next(iter)) {\n break;\n }\n }\n \n return ar;\n // convert the list into a json string..\n \n \n }","|getIterValue":" function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}","|nodeTitle":"function(c) {\n var txt = [];\n c = c || {};\n var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;\n if (sr) txt.push('');\n if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }\n if (c.xtype) { txt.push(c.xtype); }\n if (c.id) { txt.push('[id=' + c.id + ']'); }\n if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }\n if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }\n \n \n if (c.layout) { txt.push('' + c.layout + ''); }\n if (c.title) { txt.push('' + c.title + ''); }\n if (c.label) { txt.push('' + c.label+ ''); }\n if (c.header) { txt.push('' + c.header + ''); }\n if (c.legend) { txt.push('' + c.legend + ''); }\n if (c.text) { txt.push('' + c.text + ''); }\n if (c.name) { txt.push('' + c.name+ ''); }\n if (c.region) { txt.push('(' + c.region + ')'); }\n if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }\n \n // for flat classes...\n if (typeof(c['*class']) != 'undefined') { txt.push('' + c['*class']+ ''); }\n if (typeof(c['*extends']) != 'undefined') { txt.push(': ' + c['*extends']+ ''); }\n \n \n if (sr) txt.push('');\n return (txt.length == 0 ? \"Element\" : txt.join(\" \"));\n}\n","|nodeToJSON":"function(c) {\n var o = {}\n for (var i in c) {\n if (i == 'items') {\n continue;\n }\n o[i] = c[i];\n }\n return JSON.stringify(o);\n}\n","|load":"function(tr,iter)\n {\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (iter) {\n this.el.insert(citer,iter,-1);\n } else {\n this.el.append(citer);\n }\n \n this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);\n if (tr[i].items && tr[i].items.length) {\n this.load(tr[i].items, citer);\n }\n } \n }"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"LeftTreeMenu","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"Delete Element","listeners":{"activate":"function (self) {\n\n this.get('/LeftTree.model').deleteSelected();\n}"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"LeftProjectTree","|showNoProjectSelected":"function() {\n this.get('/StandardErrorDialog').show(\"Select a Project first.\"); \n}\n","|getActiveProject":"function() {\n return this.project;\n}\n","listeners":{"leave_notify_event":"function (self, event) {\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","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 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}"},"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true","id":"render"},{"|xns":"Gtk","xtype":"ListStore","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 \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","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":1,"|init":"function() {\n XObject.prototype.init.call(this);\nvar 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}\n","id":"view","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 \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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // id..\n ] );\n \n}\n","|loadProject":"function(pr) {\n this.el.clear();\n if (!pr) {\n return;\n }\n this.get('/LeftProjectTree').project = pr;\n this.load(pr.toTree());\n this.get('/LeftProjectTree.view').el.expand_all();\n}\n","|load":"function(tr,iter) {\n console.dump(tr);\n console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n \n var _this = this;\n tr.forEach(function (r) {\n if (!iter) {\n _this.el.append(citer); \n } else {\n _this.el.insert(citer,iter,-1);\n }\n _this.el.set_value(citer, 0, '' + r.getTitle() ); // title \n _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip\n _this.el.set_value(citer, 2, '' + r.id ); //id\n if (r.cn && r.cn.length) {\n _this.load(r.cn, citer);\n }\n \n });\n}\n","|getValue":"function(iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]},{"|xns":"Gtk","xtype":"VBox","listeners":{},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","id":"LeftProps","items":[{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('props');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Property"}]}]},{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('events');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Handler"}]}]},{"|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}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Other"}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"AddPropertyPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Using this.get('*someid') will find any id in an application.","label":"ID","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : 'id', \n type : 'string',\n val : '',\n //skel : skel,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add what type of packing is to be used","label":"PACK","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : 'pack', \n \t type : 'string',\n \t val : 'add',\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Override the init method","label":"INIT","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : '|init', \n type : 'function',\n val : \"function() {\\n XObject.prototype.init.call(this);\\n}\\n\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined string property","label":"String","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'string',\n val : \"\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined number property","label":"Number","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'number',\n val : 0,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined boolean property","label":"Boolean","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'boolean',\n val : false,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user function boolean property","label":"Function","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : '|', \n type : 'function',\n val : \"function() {\\n \\n}\\n\",\n etype : 'props'\n });\n}"}}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","id":"LeftPanel","pack":"add","|shadow_type":"Gtk.ShadowType.IN","editing":false,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","id":"view","tooltip_column":1,"|headers_visible":false,"|enable_tree_lines":true,"|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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 5, [\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 \n ]);\n}\n","|toShort":"function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\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 \n // sort!!!?\n var iter = new Gtk.TreeIter();\n for (var i in ar) {\n if (typeof(ar[i]) == 'object') {\n continue;\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 }\n ar.listeners = ar.listeners || {};\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 }\n return ret;\n}\n","|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 == '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","|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","|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","activePath":false,"|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 // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \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","|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 'boolean':\n return val == 'true' ? true : false;\n default: \n return val;\n }\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)) {\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('/RightEditor').el.show();\n\t\t _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 \n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\n this.el.add_attribute(this.items[0].el , 'markup', 2 );\n this.get('/LeftPanel').propertyColumn = this;\n}\n","title":"key","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start","listeners":{"editing_started":"function (self, editable, path) {\n\n this.get('/LeftPanel.model').activePath = path;\n\n}","edited":"function (self, object, p0) {\n\tvar model = this.get('/LeftPanel.model');\n var path = model.activePath;\n var iter = new Gtk.TreeIter();\n model.el.get_iter(iter, new Gtk.TreePath.from_string(path));\n model.el.set_value(iter, 0, p0);\n model.el.set_value(iter, 2, p0);\n \n\tmodel.activePath = false;\n\n\tthis.get('/LeftTree.model').changed(model.toJS(), true); \n this.el.editable = false;\n}"}}]},{"|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","|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","items":[{"|xns":"Gtk","xtype":"CellRendererCombo","pack":"pack_start","|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":"Menu","pack":false,"id":"LeftPanelPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Delete","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').deleteSelected();\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Edit","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').startEditing(false, 0);\n}"}}]}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"pack_end,false,true,0","id":"MidPropTree","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n XObject.prototype.init.call(this); \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n this.el.set_size_request ( 150, -1 );\n this.shown = true;\n}\n","activeElement":false,"|hideWin":"function() {\n \n if (!this.shown) {\n return;\n }\n \n \n if (this.get('/Window.left').el.position < 160) {\n return;\n }\n this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;\n \n this.el.hide();\n this.shown = false;\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|enable_tree_lines":true,"|headers_visible":false,"tooltip_column":2,"|init":"function() {\n\tXObject.prototype.init.call(this); \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 \n\n \n \n \n}\n","pack":"add","listeners":{"cursor_changed":"function (self) {\n var iter = new Gtk.TreeIter();\n \n //console.log('changed');\n var m = this.get('model');\n\tif (!this.selection){\n\t\tthis.selection = this.el.get_selection();\n\t}\n\n var s = this.selection;\n if (!s.get_selected(m.el, iter)) {\n\t\treturn; \n\t}\n var tp = m.el.get_path(iter).to_string();\n \n \n // var val = \"\";\n \n var key = m.getValue(tp, 0);\n \n var type = m.getValue(tp, 1);\n var skel = m.getValue(tp, 3);\n var etype = m.getValue(tp, 5);\n \n \n this.get('/MidPropTree').hideWin();\n\n if (type == 'function') {\n \n if (etype != 'events') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add({\n key : key, \n type : type,\n val : skel,\n etype : etype\n }) \n return;\n }\n \n if (type.indexOf('.') > -1 || \n type == 'boolean') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add( {\n key : key, \n type : type,\n //skel : skel,\n etype : etype\n }) //, \n}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|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","|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}","|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);\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( '' + p.name +' ['+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, '' + p.name +' ['+p.type+']' + \"\\n\" + p.desc);\n this.el.set_value(iter, 3, p.sig ? p.sig : '');\n this.el.set_value(iter, 4, '' + p.name +' ['+p.type+']');\n this.el.set_value(iter, 5, type);\n \n }\n \n}\n","id":"model"},{"|xns":"Gtk","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,"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true"}]}]}]}]},{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"VPaned","pack":"add","position":300,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Notebook","pack":"pack_start,true,true","id":"view-notebook","tab_border":0,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_current_page(0);\n print(\"SET LABEL?\")\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Roo View\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Gtk View\" }));\n}\n","|show_tabs":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightBrowser","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Dump HTML to console","listeners":{"activate":"function (self) {\n \tthis.get('/RightBrowser.view').el.execute_script(\n \"console.log(document.body.innerHTML);\");\n this.get('/RightBrowser.view').el.execute_script(\n\t \"console.log(Builder.dump(Builder));\"); \n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"WebKit","xtype":"WebView","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n // this may not work!?\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","|renderJS":"function(data) {\n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n Seed.print(\"RENDER:\" + str);\n imports.File.File.write('/tmp/builder.debug.js', \"Builder.render(\" + JSON.stringify(data) + \");\");\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n}\n","listeners":{"load_finished":"function (self, object) {\n\t if (this.ready) { // dont do it twice!\n\t return; \n\t}\n\tthis.ready = true;\n\n\tthis.renderJS(this.get('/LeftTree.model').toJS()[0]);\n}","script_alert":"function (self, object, p0) {\n \tprint(p0);\n return false;\n return true; // do not display anything...\n}","console_message":"function (self, object, p0, p1) {\n console.log(object);\n if (!object.match(/^\\{/)) {\n return false; // do not handle!!! -> later maybe in console..\n }\n console.log(object);\n var val = JSON.parse(object);\n\n if (typeof(val['hover-node']) != 'undefined') {\n this.activeNode = val['hover-node'];\n console.log('active node: ' + this.activeNode);\n return true;\n }\n\n var ret = false;\n if (typeof(val['id']) != 'undefined') {\n // this.activeNode = val['id'];\n var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); \n if (!tg) {\n return false;\n }\n this.get('/LeftTree.view').selectNode(tg[0]);\n ret = true;\n \n } \n if (ret && typeof(val['set']) != 'undefined') {\n this.get('/LeftPanel.model').add({\n key : val['set'],\n val : val['value']\n });\n //console.log('active node: ' + this.activeNode);\n \n }\n //Seed.print('a:'+a);\n //Seed.print('b:'+b);\n //Seed.print('c:'+c);\n return ret;\n}","drag_motion":"function (w, ctx, x, y, time, ud) {\n // console.log('DRAG MOTION'); \n // status:\n // if lastCurrentNode == this.currentNode.. -- don't change anything..\n this.targetData = [];\n this.el.execute_script(\"Builder.overPos(\" + x +','+ y + \");\");\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n \n var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (w, ctx, x, y,time, ud) {\n\tprint(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n\treturn is_valid_drop_site;\n}","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 }"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightGtkView","|renderJS":"function(data, withDebug)\n{\n if (!data) {\n return; \n }\n this.withDebug = false;\n \n if (this.renderedEl) {\n this.get('view').el.remove(this.renderedEl);\n this.renderedEl.destroy();\n this.renderedEl = false;\n }\n \n var tree = this.get('/LeftTree.model').toJS(false,true)[0];\n // in theory tree is actually window.. \n try {\n this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);\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 \n this.renderedEl.set_size_request(\n tree.default_width || 600,\n tree.default_height || 400\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 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 }\n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n kv = true;\n }\n ctr_args[k] = kv;\n \n } \n \n \n var el = new ctr(ctr_args);\n \n //print(\"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 _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}","|widgetExposeEvent":"function() {\n /// print(\"WIDGET EXPOSE\"); // draw highlight??\n return false;\n}\n","|widgetDragMotionEvent":"function() {\n print(\"WIDGET DRAGMOTION\"); \n return true;\n}\n","|widgetDragDropEvent":"function() {\n print(\"WIDGET DRAGDROP\"); \n return true;\n}\n","|widgetPressEvent":"function(w,e,u,d) {\n if (this.get('view').pressed) {\n return false;\n }\nthis.get('view').pressed = true;\n print(\"WIDGET PRESS \" + d.xtreepath ); \n this.get('/LeftTree.view').selectNode( d.xtreepath ); \n return false;\n}\n","|widgetReleaseEvent":"function() {\n this.get('view').pressed = false;\n return false;\n}\n","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Run The Application","listeners":{"button_press_event":"function (self, event) {\n // call render on left tree - with special option!?!\n \n\n\n\tprint(\"GET PROEJCT\");\n\tvar pr = this.get('/LeftProjectTree').getActiveProject();\n \nvar dir = '';\n for (var i in pr.paths) { \n dir = i;\n break;\n }\n var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; \n print (\"RUN DIR:\" + dir);\n \n this.get('/BottomPane').el.set_current_page(1);\n this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) \n\t, false,false,false); \n var cmd = \"/usr/bin/seed \" + runner + \" \" + dir + \"\\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n return false;\n \n\n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"view-sw","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0x9F00, green: 0xB800 , blue : 0xA800\n }));\n} \n","items":[{"|xns":"Gtk","xtype":"Fixed","pack":"add","|init":"function() {\n\tXObject.prototype.init.call(this);\n\t//this.el.set_hadjustment(this.parent.el.get_hadjustment());\n\t//this.el.set_vadjustment(this.parent.el.get_vadjustment());\n \n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"put,10,10","|init":"function() {\n\t//this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);\n\tXObject.prototype.init.call(this);\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","ready":false,"|getActiveNode":"function(x,y)\n{\n // workout what node is here..\n return '0'; // top..\n}","id":"view","listeners":{"drag_motion":"function (self, ctx, x, y, time) {\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n var activeNode = this.getActiveNode(x, y);\n \n \n var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (self,ctx, x, y, time) {\n\tSeed.print(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n self, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the this.gDnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return is_valid_drop_site;\n \n}","drag_data_received":"function (w, ctx, x, y, sel_data, target_type, time, ud) \n {\n Seed.print(\"GtkView: drag-data-received\");\n var delete_selection_data = false;\n var dnd_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 Seed.print(\"Browser: source.DRAGDATA? \" + source.dragData);\n if (this.targetData) {\n Seed.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 }","button_press_event":"function (self, event) {\n this.pressed = false;\n return false;\n}"}}]}]}]}]}]}]},{"|xns":"Gtk","xtype":"Notebook","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Code Editor\" }));\n \tthis.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Console\" }));\n}\n","id":"BottomPane","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"RightEditor","items":[{"|xns":"GtkSource","xtype":"View","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n var description = Pango.Font.description_from_string(\"monospace\")\n description.set_size(8000);\n this.el.modify_font(description);\n\n}\n","|load":"function(str) {\n this.get('/BottomPane').el.set_current_page(0);\n this.el.get_buffer().set_text(str, str.length);\n var lm = GtkSource.LanguageManager.get_default();\n \n this.el.get_buffer().set_language(lm.get_language('js'));\n var buf = this.el.get_buffer();\n var cursor = buf.get_mark(\"insert\");\n var iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n \n cursor = buf.get_mark(\"selection_bound\");\n iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n this.el.grab_focus();\n}","items":[{"|xns":"GtkSource","xtype":"Buffer","pack":"set_buffer","listeners":{"changed":"function (self) {\n var s = new Gtk.TextIter();\n var e = new Gtk.TextIter();\n this.el.get_start_iter(s);\n this.el.get_end_iter(e);\n var str = this.el.get_text(s,e,true);\n try {\n Seed.check_syntax('var e = ' + str);\n } catch (e) {\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n }));\n print(\"SYNTAX ERROR IN EDITOR\"); \n print(e);\n console.dump(e);\n return;\n }\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n }));\n \n this.get('/LeftPanel.model').changed( str , false);\n}"}}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","items":[{"|xns":"Vte","xtype":"Terminal","pack":"add","id":"Terminal","|feed":"function(str) {\n this.el.feed(str,str.length);\n}\n"}]}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"pack_start,false,false","id":"RightPalete","|hide":"function() {\n \n this.get('buttonbar').el.show();\n this.get('viewbox').el.hide();\n print(\"TRIED TO HIDE\");\n}\n","|show":"function() {\n this.get('buttonbar').el.hide();\n this.get('viewbox').el.show();\n // this.get('model').expanded();\n \n}\n","provider":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"buttonbar","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').show();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_FIRST","|icon_size":"Gtk.IconSize.MENU"}]},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete","angle":270,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","listeners":{"enter_notify_event":"function (self, event) {\n this.get('/RightPalete').show();\n return false;\n}"}}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"viewbox","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true","items":[{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete"},{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').hide();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_LAST","|icon_size":"Gtk.IconSize.MENU"}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\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}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING // tip\n \n ] );\n}\n","id":"model","|load":"function(tr,iter)\n{\n if (!iter) {\n this.el.clear();\n }\n //console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (!iter) {\n \n this.el.append(citer); \n } else {\n this.el.insert(citer,iter,-1);\n }\n \n var r = tr[i];\n //Seed.print(r);\n this.el.set_value(citer, 0, '' + r ); // title \n \n //this.el.set_value(citer, 1, new GObject.Value( r)); //id\n //if (r.cn && r.cn.length) {\n // this.load(r.cn, citer);\n //}\n }\n \n \n}","|getValue":"function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]}]}]}]}]} \ No newline at end of file +{"id":"file-gtk-5","name":"Window","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/Window.bjs","items":[{"|xns":"Gtk","xtype":"Window","|type":"Gtk.WindowType.TOPLEVEL","title":"Application Builder","border_width":0,"|init":"function() {\n this.atoms = {\n \"STRING\" : Gdk.atom_intern(\"STRING\")\n\t};\n\tthis.targetList = new Gtk.TargetList();\n\tthis.targetList.add( this.atoms[\"STRING\"], 0, 0);\n\t//imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\nGtk.rc_parse_string(\n \"style \\\"gtkcombobox-style\\\" {\\n\" + \n \" GtkComboBox::appears-as-list = 1\\n\" +\n \"}\\n\"+\n \"class \\\"GtkComboBox\\\" style \\\"gtkcombobox-style\\\"\\n\");\n XObject.prototype.init.call(this);\n this.el.show_all();\n \n \n \n}\n","default_width":800,"default_height":500,"id":"Window","listeners":{"delete_event":"function (self, event) {\n return false;\n}","destroy":"function (self) {\n Gtk.main_quit();\n}","show":"function (self) {\n print(\"WINDOW SHOWING - trying to hide\");\nimports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\n \tthis.get('/MidPropTree').hideWin();\n this.get('/RightPalete').hide();\n\n}"},"items":[{"|xns":"Gtk","xtype":"VBox","id":"w-vbox","items":[{"|xns":"Gtk","xtype":"MenuBar","pack":"pack_start,false,false","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"_File","items":[{"|xns":"Gtk","xtype":"Menu","pack":"set_submenu","items":[{"|xns":"Gtk","xtype":"MenuItem","|use_underline":true,"label":"New _Project","listeners":{"activate":"function (self) {\n\tthis.get('/EditProject').show({\n\t success : function(pr) {\n\t\t this.get('/LeftProjectTree').get('combo').setValue(pr.fn);\n\t }\n\t});\n}"}},{"|xns":"Gtk","xtype":"MenuItem","label":"_New File","|use_underline":true,"listeners":{"activate":"function (self) {\n \tvar fn = this.get('/LeftProjectTree.combo').getValue();\n if (!fn) {\n this.get('/LeftProjectTree').showNoProjectSelected();\n return true;\n }\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n this.get('/DialogNewComponent').show({\n project : pm.getByFn(fn)\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"_Quit","|use_underline":true,"listeners":{"activate":"function (self) {\n Gtk.main_quit();\n} "}}]}]},{"|xns":"Gtk","xtype":"MenuItem","label":"Help"}]},{"|xns":"Gtk","xtype":"HPaned","id":"left","position":400,"items":[{"|xns":"Gtk","xtype":"HBox","items":[{"|xns":"Gtk","xtype":"VPaned","position":300,"id":"leftvpaned","items":[{"|xns":"Gtk","xtype":"VBox","id":"LeftTopPanel","items":[{"|xns":"Gtk","xtype":"Expander","label":"Select Project","id":"expander","pack":"pack_start,false,true","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","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}"}},{"|xns":"Gtk","xtype":"Notebook","id":"notebook","|show_border":false,"|show_tabs":false,"pack":"pack_start,true,true","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_current_page(0);\n\n}\n","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n","id":"LeftTree","|getPaleteProvider":"function() {\n var model = this.get('model');\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n return pm.getPalete(model.file.getType());\n}\n","|renderView":"function() {\n \t var model = this.get('model');\n\tprint(\"RENDER VIEW?\" + model.file.getType());\n\tswitch( model.file.getType()) {\n\t\tcase 'Roo':\n\t\t this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);\n\t\tcase 'Gtk':\n\t\t this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);\n\t}\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","pack":"add","id":"view","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":0,"|init":"function() {\n \tXObject.prototype.init.call(this);\n\tvar description = new Pango.FontDescription.c_new();\n\tdescription.set_size(8000);\n\tthis.el.modify_font(description);\n\n\tthis.selection = this.el.get_selection();\n\tthis.selection.set_mode( Gtk.SelectionMode.SINGLE);\n\tvar _this = this;\n\tthis.selection.signal['changed'].connect(function() {\n\t\t_this.get('/LeftTree.view').listeners.cursor_changed.apply(\n\t\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n\t\t);\n\t});\n\n\tGtk.drag_source_set (\n\t\tthis.el, /* widget will be drag-able */\n\t\tGdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n\t\tnull, /* lists of target to support */\n\t\t0, /* size of list */\n\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n\n\tGtk.drag_source_add_text_targets(this.el); \n\tGtk.drag_dest_set\n\t(\n\t this.el, /* widget that will accept a drop */\n\t Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n\t null, /* lists of target to support */\n\t 0, /* size of list */\n\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */\n\t);\n\n\tGtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n\tGtk.drag_dest_add_text_targets(this.el);\n}\n","|highlight":"function(treepath_ar) {\n if (treepath_ar.length && treepath_ar[0].length ) {\n this.el.set_drag_dest_row( \n new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n }","|selectNode":"function(treepath_str) {\n //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));\n var tp = new Gtk.TreePath.from_string(treepath_str);\n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n","listeners":{"button_press_event":"function (self, ev) {\n \tconsole.log(\"button press?\");\n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {\n print(\"click\" + ev.type);\n return false;\n }\n \n \n var res = {}; \n this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);\n \n if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();\n \n this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());\n this.get('/LeftTreeMenu').el.show_all();\n this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);\n print(\"click:\" + res.path.to_string());\n return false;\n}","drag_begin":"function (self, drag_context) {\n\tprint('SOURCE: drag-begin');\n this.targetData = false;\n // find what is selected in our tree...\n var iter = new Gtk.TreeIter();\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n var xname = this.get('/LeftTree.model').file.guessName(data);\n \n this.el.dragData = xname;\n this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);\n \n\n // make the drag icon a picture of the node that was selected\n var path = this.get('/LeftTree.model').el.get_path(iter);\n this.el.treepath = path.to_string();\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_pixmap (ctx,\n pix.get_colormap(),\n pix,\n null,\n -10,\n -10);\n \n return true;\n}","drag_end":"function (self, drag_context) {\n\tSeed.print('LEFT-TREE: drag-end');\n this.el.dragData = false;\n this.el.dropList = false;\n this.targetData = false;\n this.get('/LeftTree.view').highlight(false);\n return true;\n}","drag_motion":"function (self, ctx, x, y, time) {\n console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n\n // a drag from elsewhere...- prevent drop..\n if (!src.dragData) {\n print(\"no drag data!\");\n Gdk.drag_status(ctx, 0, time);\n this.targetData = false;\n return true;\n }\n var action = Gdk.DragAction.COPY;\n if (src == this.el) {\n // unless we are copying!!! ctl button..\n action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n }\n var data = {};\n\n\t\tif (!this.get('/LeftTree.model').el.iter_n_children(null)) {\n\t\t\t// no children.. -- asume it's ok..\n\t\t\tthis.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];\n\t\t\tGdk.drag_status(ctx, action ,time);\n\t\t\treturn true;\n\t\t}\n\n print(\"GETTING POS\");\n var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);\n print(\"ISOVER? \" + isOver);\n if (!isOver) {\n Gdk.drag_status(ctx, 0 ,time);\n return false; // not over apoint!?!\n }\n // drag node is parent of child..\n console.log(\"SRC TREEPATH: \" + src.treepath);\n console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n if (typeof(src.treepath) != 'undefined' && \n src.treepath == data.path.to_string().substring(0,src.treepath.length)) {\n print(\"subpath drag\");\n Gdk.drag_status(ctx, 0 ,time);\n return false;\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n print(data.path.to_string() +' => '+ data.pos);\n var tg = this.get('/LeftTree.model').findDropNodeByPath(\n data.path.to_string(), src.dropList, data.pos);\n \n this.get('/LeftTree.view').highlight(tg);\n if (!tg.length) {\n print(\"Can not find drop node path\");\n this.targetData = false;\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n //console.dump(tg);\n this.targetData = tg; \n \n \n Gdk.drag_status(ctx, action ,time);\n \n return true;\n}","drag_drop":"function (w, ctx, x, y, time) {\n Seed.print(\"TARGET: drag-drop\");\n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return true;\n}","drag_data_received":"function (self, ctx, x, y, sel_data, info, time) {\n\t print(\"Tree: drag-data-received\");\n\n var delete_selection_data = false;\n var dnd_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 \n var source = Gtk.drag_get_source_widget(ctx);\n\n if (this.targetData) {\n if (source != this.el) {\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n } else {\n // drag around.. - reorder..\n this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);\n \n \n }\n //Seed.print(this.targetData);\n \n }\n \n \n \n // we can send stuff to souce here...\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}","cursor_changed":"function (self) {\n if (this.blockChanges) {\n return true;\n }\n var iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n this.get('/LeftPanel.model').load( false);\n this.get('/MidPropTree').activeElement = false;\n this.get('/MidPropTree').hideWin();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/LeftTree').getPaleteProvider()) {\n // it may not be loaded yet..\n return true;\n }\n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n return true;\n }\n \n //console.log('changed');\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n \n \n // var val = \"\";\n value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();\n \n var data = JSON.parse(value.value);\n this.get('/MidPropTree').activeElement = data;\n this.get('/MidPropTree').hideWin();\n this.get('/LeftPanel.model').load( data);\n \n console.log(value.value);\n // _g.button.set_label(''+value.get_string());\n\n var pm =this.get('/RightPalete.model');\n pm.load( this.get('/RightPalete').provider.gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n \n \n \n //Seed.print( value.get_string());\n return true;\n \n}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // source..\n ] );\n}\n","activePath":false,"|changed":"function(n, refresh) {\n print(\"MODEL CHANGED CALLED\" + this.activePath);\n if (this.activePath) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))\n this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);\n \n this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);\n }\n //this.currentTree = this.toJS(false, true)[0];\n this.file.items = this.toJS(false, false);\n print(\"AFTER CHANGED\");\n //console.dump(this.file.items);\n this.file.save();\n this.currentTree = this.file.items[0];\n //console.log(this.file.toSource());\n \n if (refresh) {\n print(\"REDNER BROWSER?!\");\n this.get('/LeftTree').renderView();\n\n var pm = this.get('/RightPalete.model');\n if (!this.get('/RightPalete').provider) {\n pm.load([]);\n return;\n }\n \n \n pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));\n //imports['Builder/RightBrowser.js'].renderJS(this.toJS());\n }\n\t \n}\n","|loadFile":"function(f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n if (!f) {\n console.log('missing file');\n return;\n }\n \n // load the file if not loaded..\n if (f.items === false) {\n var _this = this;\n f.loadItems(function() {\n _this.loadFile(f);\n });\n return;\n \n }\n if (f.items.length && typeof(f.items[0]) == 'string') {\n \n this.get('/RightEditor').el.show();\n this.get('/RightEditor.view').load( f.items[0]);\n return;\n }\n print(\"LOAD\");\n //console.dump(f.items);\n this.load(f.items);\n this.get('/LeftTree.view').el.expand_all();\n\n if (!f.items.length) {\n // single item..\n \n this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n this.get('/LeftTree.view').el.set_cursor( \n new Gtk.TreePath.from_string('0'), null, false);\n \n \n } else {\n this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n \n //print(\"hide right editior\");\n this.get('/RightEditor').el.hide();\n //print(\"set current tree\");\n this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n this.currentTree = this.currentTree || { items: [] };\n this.get('/LeftTree').renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n \n}\n","|findDropNode":"function(treepath_str, targets) {\n\n// this is used by the dragdrop code in the roo version AFAIR..\n\n \t\tvar path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (!this.el.iter_n_children(null)) {\n print(\"NO KEYS\");\n return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];\n }\n print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n if (!treepath_str.match(/^builder-/)) {\n return []; // nothing!\n }\n if (targets === true) {\n return [ path ];\n }\n return this.findDropNodeByPath(path,targets) \n}\n","|findDropNodeByPath":"function(treepath_str, targets, pref) {\n var path = treepath_str + ''; // dupe it..\n pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;\n var last = false;\n //console.dump(this.treemap);\n while (path.length) {\n print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.singleNodeToJS(path);\n if (node_data === false) {\n print(\"node not found\");\n return [];\n }\n \n var xname = this.get('/LeftTree.model').file.guessName(node_data);\n var match = false;\n var prop = '';\n targets.forEach(function(tg) {\n if (match) {\n return;;\n }\n if ((tg == xname) ) {\n match = tg;\n }\n if (tg.indexOf(xname +':') === 0) {\n match = tg;\n prop = tg.split(':').pop();\n }\n });\n \n if (match) {\n if (last) { // pref is after/before..\n // then it's after last\n if (pref > 1) {\n return []; // do not allow..\n }\n return [ last, pref , prop];\n \n }\n return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];\n }\n var par = path.split(':');\n last = path;\n par.pop();\n path = par.join(':');\n }\n \n return [];\n \n}\n","|dropNode":"function(target_data, node) {\n print(\"drop Node\");\n \t console.dump(node);\n \t console.dump(target_data);\n var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;\n \n print(\"add \" + tp + \"@\" + target_data[1] );\n var parent = tp;\n var after = false;\n if (tp && target_data[1] < 2) { // before or after..\n var ar = target_data[0].split(':');\n ar.pop();\n parent = new Gtk.TreePath.from_string( ar.join(':') );\n after = tp;\n }\n var n_iter = new Gtk.TreeIter();\n var iter_par = new Gtk.TreeIter();\n var iter_after = after ? new Gtk.TreeIter() : false;\n \n \n \n if (parent !== false) {\n this.el.get_iter(iter_par, parent);\n } else {\n iter_par = null;\n }\n \n \n if (tp && after) {\n print(target_data[1] > 0 ? 'insert_after' : 'insert_before');\n this.el.get_iter(iter_after, after);\n this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](\n n_iter, iter_par, iter_after);\n \n } else {\n this.el.append(n_iter, iter_par);\n \n }\n \n if (typeof(node) == 'string') {\n var ar = node.split('.');\n var xtype = ar.pop();\n \n node = {\n '|xns' : ar.join('.'),\n 'xtype' : xtype\n };\n if (target_data.length == 3 && target_data[2].length) {\n node['*prop'] = target_data[2];\n }\n \n }\n // work out what kind of packing to use..\n if (typeof(node.pack) == 'undefined' && parent !== false) {\n var pal = this.get('/LeftTree').getPaleteProvider();\n \n var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));\n print (\"PNAME : \" + pname);\n var cname = pal.guessName(node);\n print (\"CNAME : \" + cname);\n node.pack = pal.getDefaultPack(pname, cname);\n \n \n }\n \n \n var xitems = [];\n if (node.items) {\n xitems = node.items;\n delete node.items;\n }\n// load children - if it has any..\n\n if (xitems) {\n this.load(xitems, n_iter);\n }\n if (tp && (xitems || after)) {\n this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);\n }\n // wee need to get the empty proptypes from somewhere..\n \n //var olditer = this.activeIter;\n this.activePath = this.el.get_path(n_iter).to_string();\n\n\t // changed actually set's the node data..\n this.changed(node, true);\n \n \n \n this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);\n \n //Builder.MidPropTree._model.load(node);\n //Builder.MidPropTree._win.hideWin();\n //Builder.LeftPanel._model.load( node);\n \n \n}\n","|moveNode":"function(target_data, action) {\n //print(\"MOVE NODE\");\n // console.dump(target_data);\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var node = this.nodeToJS(old_iter,false);\n //console.dump(node);\n \n \n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n \n this.dropNode(target_data, node);\n\t if (action & Gdk.DragAction.MOVE) {\n // print(\"REMOVING OLD NODE\");\n this.el.remove(old_iter);\n \n }\n \n this.activePath= false;\n this.changed(false,true);\n}\n","|deleteSelected":"function() {\n this.get('/LeftTree.view').blockChanges = true;\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var path = this.el.get_path(old_iter).to_string();\n\n this.activePath= false; \n s.unselect_all();\n\n this.activePath= false; \n\t var iter = new Gtk.TreeIter();\n this.el.get_iter_from_string(iter, path);\n this.el.remove(iter);\n \n // rebuild treemap. -- depreciated.!!\n this.map = {};\n this.treemap = { };\n //this.toJS(null, true) // does not do anything?\n this.activePath= false; \n this.changed(false,true);\n this.get('/LeftTree.view').blockChanges = false;\n}\n","currentTree":false,"|listAllTypes":"function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n \n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n","|singleNodeToJS":"function (treepath) \n {\n var iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n \n var iv = this.getIterValue(iter, 2);\n \n return JSON.parse(iv);\n \n }","|nodeToJS":"function (iter, with_id) \n{\n var par = new Gtk.TreeIter(); \n var iv = this.getIterValue(iter, 2);\n // print(\"IV\" + iv);\n var k = JSON.parse(iv);\n if (k.json && !this.el.iter_parent( par, iter )) {\n delete k.json;\n }\n \n if (with_id) {\n var treepath_str = this.el.get_path(iter).to_string();\n // not sure how we can handle mixed id stuff..\n if (typeof(k.id) == 'undefined') {\n k.id = 'builder-'+ treepath_str ;\n }\n \n // needed??\n this.treemap[ treepath_str ] = k;\n k.xtreepath = treepath_str ;\n \n }\n if (this.el.iter_has_child(iter)) {\n citer = new Gtk.TreeIter();\n this.el.iter_children(citer, iter);\n k.items = this.toJS(citer,with_id);\n }\n return k;\n}\n","|toJS":"function(iter, with_id)\n {\n //Seed.print(\"WITHID: \"+ with_id);\n \n var first = false;\n if (!iter) {\n \n this.treemap = { }; \n \n iter = new Gtk.TreeIter();\n if (!this.el.get_iter_first(iter)) {\n return [];\n }\n first = true;\n } \n \n var ar = [];\n \n while (true) {\n \n var k = this.nodeToJS(iter, with_id); \n ar.push(k);\n \n \n if (!this.el.iter_next(iter)) {\n break;\n }\n }\n \n return ar;\n // convert the list into a json string..\n \n \n }","|getIterValue":" function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}","|nodeTitle":"function(c) {\n var txt = [];\n c = c || {};\n var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;\n if (sr) txt.push('');\n if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }\n if (c.xtype) { txt.push(c.xtype); }\n if (c.id) { txt.push('[id=' + c.id + ']'); }\n if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }\n if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }\n \n \n if (c.layout) { txt.push('' + c.layout + ''); }\n if (c.title) { txt.push('' + c.title + ''); }\n if (c.label) { txt.push('' + c.label+ ''); }\n if (c.header) { txt.push('' + c.header + ''); }\n if (c.legend) { txt.push('' + c.legend + ''); }\n if (c.text) { txt.push('' + c.text + ''); }\n if (c.name) { txt.push('' + c.name+ ''); }\n if (c.region) { txt.push('(' + c.region + ')'); }\n if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }\n \n // for flat classes...\n if (typeof(c['*class']) != 'undefined') { txt.push('' + c['*class']+ ''); }\n if (typeof(c['*extends']) != 'undefined') { txt.push(': ' + c['*extends']+ ''); }\n \n \n if (sr) txt.push('');\n return (txt.length == 0 ? \"Element\" : txt.join(\" \"));\n}\n","|nodeToJSON":"function(c) {\n var o = {}\n for (var i in c) {\n if (i == 'items') {\n continue;\n }\n o[i] = c[i];\n }\n return JSON.stringify(o);\n}\n","|load":"function(tr,iter)\n {\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (iter) {\n this.el.insert(citer,iter,-1);\n } else {\n this.el.append(citer);\n }\n \n this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);\n if (tr[i].items && tr[i].items.length) {\n this.load(tr[i].items, citer);\n }\n } \n }"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"LeftTreeMenu","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"add","label":"Delete Element","listeners":{"activate":"function (self) {\n\n this.get('/LeftTree.model').deleteSelected();\n}"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"LeftProjectTree","|showNoProjectSelected":"function() {\n this.get('/StandardErrorDialog').show(\"Select a Project first.\"); \n}\n","|getActiveProject":"function() {\n return this.project;\n}\n","listeners":{"leave_notify_event":"function (self, event) {\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","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 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}"},"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true","id":"render"},{"|xns":"Gtk","xtype":"ListStore","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 \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","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|headers_visible":false,"|enable_tree_lines":true,"tooltip_column":1,"|init":"function() {\n XObject.prototype.init.call(this);\nvar 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}\n","id":"view","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 \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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // id..\n ] );\n \n}\n","|loadProject":"function(pr) {\n this.el.clear();\n if (!pr) {\n return;\n }\n this.get('/LeftProjectTree').project = pr;\n this.load(pr.toTree());\n this.get('/LeftProjectTree.view').el.expand_all();\n}\n","|load":"function(tr,iter) {\n console.dump(tr);\n console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n \n var _this = this;\n tr.forEach(function (r) {\n if (!iter) {\n _this.el.append(citer); \n } else {\n _this.el.insert(citer,iter,-1);\n }\n _this.el.set_value(citer, 0, '' + r.getTitle() ); // title \n _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip\n _this.el.set_value(citer, 2, '' + r.id ); //id\n if (r.cn && r.cn.length) {\n _this.load(r.cn, citer);\n }\n \n });\n}\n","|getValue":"function(iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]},{"|xns":"Gtk","xtype":"VBox","listeners":{},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","id":"LeftProps","items":[{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('props');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Property"}]}]},{"|xns":"Gtk","xtype":"Button","pack":"add","listeners":{"button_press_event":"function (self, event) {\n this.get('/MidPropTree.model').showData('events');\n return false;\n}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Handler"}]}]},{"|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}"},"items":[{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_ADD","|icon_size":"Gtk.IconSize.MENU"},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Other"}]},{"|xns":"Gtk","xtype":"Menu","pack":false,"id":"AddPropertyPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Using this.get('*someid') will find any id in an application.","label":"ID","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : 'id', \n type : 'string',\n val : '',\n //skel : skel,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add what type of packing is to be used","label":"PACK","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : 'pack', \n \t type : 'string',\n \t val : 'add',\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Override the init method","label":"INIT","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : '|init', \n type : 'function',\n val : \"function() {\\n XObject.prototype.init.call(this);\\n}\\n\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined string property","label":"String","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'string',\n val : \"\",\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined number property","label":"Number","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'number',\n val : 0,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user defined boolean property","label":"Boolean","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'boolean',\n val : false,\n etype : 'props'\n });\n}"}},{"|xns":"Gtk","xtype":"SeparatorMenuItem","pack":"add"},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","tooltip_markup":"Add a user function boolean property","label":"Function","listeners":{"activate":"function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : '|', \n type : 'function',\n val : \"function() {\\n \\n}\\n\",\n etype : 'props'\n });\n}"}}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","id":"LeftPanel","pack":"add","|shadow_type":"Gtk.ShadowType.IN","editing":false,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","id":"view","tooltip_column":1,"|headers_visible":false,"|enable_tree_lines":true,"|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}"},"items":[{"|xns":"Gtk","xtype":"TreeStore","pack":"set_model","id":"model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 5, [\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 \n ]);\n}\n","|toShort":"function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\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 \n // sort!!!?\n var iter = new Gtk.TreeIter();\n for (var i in ar) {\n if (typeof(ar[i]) == 'object') {\n continue;\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 }\n ar.listeners = ar.listeners || {};\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 }\n return ret;\n}\n","|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 == '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","|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","|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","activePath":false,"|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 // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \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","|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 'boolean':\n return val == 'true' ? true : false;\n default: \n return val;\n }\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)) {\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('/RightEditor').el.show();\n\t\t _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 \n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\n this.el.add_attribute(this.items[0].el , 'markup', 2 );\n this.get('/LeftPanel').propertyColumn = this;\n}\n","title":"key","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start","listeners":{"editing_started":"function (self, editable, path) {\n\n this.get('/LeftPanel.model').activePath = path;\n\n}","edited":"function (self, object, p0) {\n\tvar model = this.get('/LeftPanel.model');\n var path = model.activePath;\n var iter = new Gtk.TreeIter();\n model.el.get_iter(iter, new Gtk.TreePath.from_string(path));\n model.el.set_value(iter, 0, p0);\n model.el.set_value(iter, 2, p0);\n \n\tmodel.activePath = false;\n\n\tthis.get('/LeftTree.model').changed(model.toJS(), true); \n this.el.editable = false;\n}"}}]},{"|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","|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","items":[{"|xns":"Gtk","xtype":"CellRendererCombo","pack":"pack_start","|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":"Menu","pack":false,"id":"LeftPanelPopup","items":[{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Delete","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').deleteSelected();\n}"}},{"|xns":"Gtk","xtype":"MenuItem","pack":"append","label":"Edit","listeners":{"activate":"function (self) {\n\tthis.get('/LeftPanel.model').startEditing(false, 0);\n}"}}]}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"pack_end,false,true,0","id":"MidPropTree","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n XObject.prototype.init.call(this); \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n this.el.set_size_request ( 150, -1 );\n this.shown = true;\n}\n","activeElement":false,"|hideWin":"function() {\n \n if (!this.shown) {\n return;\n }\n \n \n if (this.get('/Window.left').el.position < 160) {\n return;\n }\n this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;\n \n this.el.hide();\n this.shown = false;\n}\n","items":[{"|xns":"Gtk","xtype":"TreeView","|enable_tree_lines":true,"|headers_visible":false,"tooltip_column":2,"|init":"function() {\n\tXObject.prototype.init.call(this); \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 \n\n \n \n \n}\n","pack":"add","listeners":{"cursor_changed":"function (self) {\n var iter = new Gtk.TreeIter();\n \n //console.log('changed');\n var m = this.get('model');\n\tif (!this.selection){\n\t\tthis.selection = this.el.get_selection();\n\t}\n\n var s = this.selection;\n if (!s.get_selected(m.el, iter)) {\n\t\treturn; \n\t}\n var tp = m.el.get_path(iter).to_string();\n \n \n // var val = \"\";\n \n var key = m.getValue(tp, 0);\n \n var type = m.getValue(tp, 1);\n var skel = m.getValue(tp, 3);\n var etype = m.getValue(tp, 5);\n \n \n this.get('/MidPropTree').hideWin();\n\n if (type == 'function') {\n \n if (etype != 'events') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add({\n key : key, \n type : type,\n val : skel,\n etype : etype\n }) \n return;\n }\n \n if (type.indexOf('.') > -1 || \n type == 'boolean') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add( {\n key : key, \n type : type,\n //skel : skel,\n etype : etype\n }) //, \n}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|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","|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}","|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);\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( '' + p.name +' ['+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, '' + p.name +' ['+p.type+']' + \"\\n\" + p.desc);\n this.el.set_value(iter, 3, p.sig ? p.sig : '');\n this.el.set_value(iter, 4, '' + p.name +' ['+p.type+']');\n this.el.set_value(iter, 5, type);\n \n }\n \n}\n","id":"model"},{"|xns":"Gtk","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,"items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start,true"}]}]}]}]},{"|xns":"Gtk","xtype":"HBox","pack":"add","items":[{"|xns":"Gtk","xtype":"VPaned","pack":"add","position":300,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","items":[{"|xns":"Gtk","xtype":"Notebook","pack":"pack_start,true,true","id":"view-help-nb","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Preview\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Help\" }));\n}\n","items":[{"|xns":"Gtk","xtype":"Notebook","pack":"add","id":"view-notebook","tab_border":0,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_current_page(0);\n print(\"SET LABEL?\")\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Roo View\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Gtk View\" }));\n}\n","|show_tabs":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightBrowser","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Dump HTML to console","listeners":{"activate":"function (self) {\n \tthis.get('/RightBrowser.view').el.execute_script(\n \"console.log(document.body.innerHTML);\");\n this.get('/RightBrowser.view').el.execute_script(\n\t \"console.log(Builder.dump(Builder));\"); \n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"WebKit","xtype":"WebView","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n // this may not work!?\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","|renderJS":"function(data) {\n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n Seed.print(\"RENDER:\" + str);\n imports.File.File.write('/tmp/builder.debug.js', \"Builder.render(\" + JSON.stringify(data) + \");\");\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n}\n","listeners":{"load_finished":"function (self, object) {\n\t if (this.ready) { // dont do it twice!\n\t return; \n\t}\n\tthis.ready = true;\n\n\tthis.renderJS(this.get('/LeftTree.model').toJS()[0]);\n}","script_alert":"function (self, object, p0) {\n \tprint(p0);\n return false;\n return true; // do not display anything...\n}","console_message":"function (self, object, p0, p1) {\n console.log(object);\n if (!object.match(/^\\{/)) {\n return false; // do not handle!!! -> later maybe in console..\n }\n console.log(object);\n var val = JSON.parse(object);\n\n if (typeof(val['hover-node']) != 'undefined') {\n this.activeNode = val['hover-node'];\n console.log('active node: ' + this.activeNode);\n return true;\n }\n\n var ret = false;\n if (typeof(val['id']) != 'undefined') {\n // this.activeNode = val['id'];\n var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); \n if (!tg) {\n return false;\n }\n this.get('/LeftTree.view').selectNode(tg[0]);\n ret = true;\n \n } \n if (ret && typeof(val['set']) != 'undefined') {\n this.get('/LeftPanel.model').add({\n key : val['set'],\n val : val['value']\n });\n //console.log('active node: ' + this.activeNode);\n \n }\n //Seed.print('a:'+a);\n //Seed.print('b:'+b);\n //Seed.print('c:'+c);\n return ret;\n}","drag_motion":"function (w, ctx, x, y, time, ud) {\n // console.log('DRAG MOTION'); \n // status:\n // if lastCurrentNode == this.currentNode.. -- don't change anything..\n this.targetData = [];\n this.el.execute_script(\"Builder.overPos(\" + x +','+ y + \");\");\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n \n var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (w, ctx, x, y,time, ud) {\n\tprint(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n\treturn is_valid_drop_site;\n}","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 }"}}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"RightGtkView","|renderJS":"function(data, withDebug)\n{\n if (!data) {\n return; \n }\n this.withDebug = false;\n \n if (this.renderedEl) {\n this.get('view').el.remove(this.renderedEl);\n this.renderedEl.destroy();\n this.renderedEl = false;\n }\n \n var tree = this.get('/LeftTree.model').toJS(false,true)[0];\n // in theory tree is actually window.. \n try {\n this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);\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 \n this.renderedEl.set_size_request(\n tree.default_width || 600,\n tree.default_height || 400\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 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 }\n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n kv = true;\n }\n ctr_args[k] = kv;\n \n } \n \n \n var el = new ctr(ctr_args);\n \n //print(\"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 _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}","|widgetExposeEvent":"function() {\n /// print(\"WIDGET EXPOSE\"); // draw highlight??\n return false;\n}\n","|widgetDragMotionEvent":"function() {\n print(\"WIDGET DRAGMOTION\"); \n return true;\n}\n","|widgetDragDropEvent":"function() {\n print(\"WIDGET DRAGDROP\"); \n return true;\n}\n","|widgetPressEvent":"function(w,e,u,d) {\n if (this.get('view').pressed) {\n return false;\n }\nthis.get('view').pressed = true;\n print(\"WIDGET PRESS \" + d.xtreepath ); \n this.get('/LeftTree.view').selectNode( d.xtreepath ); \n return false;\n}\n","|widgetReleaseEvent":"function() {\n this.get('view').pressed = false;\n return false;\n}\n","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,0","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,false,0","label":"Run The Application","listeners":{"button_press_event":"function (self, event) {\n // call render on left tree - with special option!?!\n \n\n\n\tprint(\"GET PROEJCT\");\n\tvar pr = this.get('/LeftProjectTree').getActiveProject();\n \nvar dir = '';\n for (var i in pr.paths) { \n dir = i;\n break;\n }\n var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; \n print (\"RUN DIR:\" + dir);\n \n this.get('/BottomPane').el.set_current_page(1);\n this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) \n\t, false,false,false); \n var cmd = \"/usr/bin/seed \" + runner + \" \" + dir + \"\\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n return false;\n \n\n}"}}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"view-sw","|shadow_type":"Gtk.ShadowType.IN","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"add_with_viewport","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0x9F00, green: 0xB800 , blue : 0xA800\n }));\n} \n","items":[{"|xns":"Gtk","xtype":"Fixed","pack":"add","|init":"function() {\n\tXObject.prototype.init.call(this);\n\t//this.el.set_hadjustment(this.parent.el.get_hadjustment());\n\t//this.el.set_vadjustment(this.parent.el.get_vadjustment());\n \n}\n","items":[{"|xns":"Gtk","xtype":"EventBox","pack":"put,10,10","|init":"function() {\n\t//this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);\n\tXObject.prototype.init.call(this);\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","ready":false,"|getActiveNode":"function(x,y)\n{\n // workout what node is here..\n return '0'; // top..\n}","id":"view","listeners":{"drag_motion":"function (self, ctx, x, y, time) {\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n var activeNode = this.getActiveNode(x, y);\n \n \n var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}","drag_drop":"function (self,ctx, x, y, time) {\n\tSeed.print(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n self, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the this.gDnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return is_valid_drop_site;\n \n}","drag_data_received":"function (w, ctx, x, y, sel_data, target_type, time, ud) \n {\n Seed.print(\"GtkView: drag-data-received\");\n var delete_selection_data = false;\n var dnd_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 Seed.print(\"Browser: source.DRAGDATA? \" + source.dragData);\n if (this.targetData) {\n Seed.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 }","button_press_event":"function (self, event) {\n this.pressed = false;\n return false;\n}"}}]}]}]}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"Help","items":[{"|xns":"WebKit","xtype":"WebView","pack":"add","id":"help-view","|init":"function() {\n XObject.prototype.init.call(this);\n this.get('/Window.help-view').el.open(\n \"http://devel.akbkhome.com/seed/\");\n\n}\n"}]}]}]},{"|xns":"Gtk","xtype":"Notebook","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Code Editor\" }));\n \tthis.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Console\" }));\n}\n","id":"BottomPane","items":[{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","id":"RightEditor","items":[{"|xns":"GtkSource","xtype":"View","pack":"add","id":"view","|init":"function() {\n XObject.prototype.init.call(this);\n var description = Pango.Font.description_from_string(\"monospace\")\n description.set_size(8000);\n this.el.modify_font(description);\n\n}\n","|load":"function(str) {\n\n// show the help page for the active node..\n this.get('/Window.view-help-nb').el.set_current_page(1);\n\n// get the active element being edited.\n var xtype = this.get('/LeftTree.model').file.guessName(\n\tthis.get('/MidPropTree').activeElement);\n// now load the help info in the page..\n this.get('/Window.help-view').el.open(\n \"http://devel.akbkhome.com/seed/\" + xtype + \".html\");\n\n\n this.get('/BottomPane').el.set_current_page(0);\n this.el.get_buffer().set_text(str, str.length);\n var lm = GtkSource.LanguageManager.get_default();\n \n this.el.get_buffer().set_language(lm.get_language('js'));\n var buf = this.el.get_buffer();\n var cursor = buf.get_mark(\"insert\");\n var iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n \n cursor = buf.get_mark(\"selection_bound\");\n iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n this.el.grab_focus();\n}","items":[{"|xns":"GtkSource","xtype":"Buffer","pack":"set_buffer","listeners":{"changed":"function (self) {\n var s = new Gtk.TextIter();\n var e = new Gtk.TextIter();\n this.el.get_start_iter(s);\n this.el.get_end_iter(e);\n var str = this.el.get_text(s,e,true);\n try {\n Seed.check_syntax('var e = ' + str);\n } catch (e) {\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n }));\n print(\"SYNTAX ERROR IN EDITOR\"); \n print(e);\n console.dump(e);\n return;\n }\n this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n }));\n \n this.get('/LeftPanel.model').changed( str , false);\n}"}}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","items":[{"|xns":"Vte","xtype":"Terminal","pack":"add","id":"Terminal","|feed":"function(str) {\n this.el.feed(str,str.length);\n}\n"}]}]}]},{"|xns":"Gtk","xtype":"VBox","pack":"pack_start,false,false","id":"RightPalete","|hide":"function() {\n \n this.get('buttonbar').el.show();\n this.get('viewbox').el.hide();\n print(\"TRIED TO HIDE\");\n}\n","|show":"function() {\n this.get('buttonbar').el.hide();\n this.get('viewbox').el.show();\n // this.get('model').expanded();\n \n}\n","provider":false,"items":[{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"buttonbar","items":[{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').show();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_FIRST","|icon_size":"Gtk.IconSize.MENU"}]},{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete","angle":270,"|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n","listeners":{"enter_notify_event":"function (self, event) {\n this.get('/RightPalete').show();\n return false;\n}"}}]},{"|xns":"Gtk","xtype":"VBox","pack":"add","id":"viewbox","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true","items":[{"|xns":"Gtk","xtype":"Label","pack":"add","label":"Palete"},{"|xns":"Gtk","xtype":"Button","pack":"pack_start,false,true","listeners":{"clicked":"function (self) {\n\tthis.get('/RightPalete').hide();\n}"},"items":[{"|xns":"Gtk","xtype":"Image","pack":"add","|stock":"Gtk.STOCK_GOTO_LAST","|icon_size":"Gtk.IconSize.MENU"}]}]},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"add","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\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}"},"items":[{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|init":"function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING // tip\n \n ] );\n}\n","id":"model","|load":"function(tr,iter)\n{\n if (!iter) {\n this.el.clear();\n }\n //console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (!iter) {\n \n this.el.append(citer); \n } else {\n this.el.insert(citer,iter,-1);\n }\n \n var r = tr[i];\n //Seed.print(r);\n this.el.set_value(citer, 0, '' + r ); // title \n \n //this.el.set_value(citer, 1, new GObject.Value( r)); //id\n //if (r.cn && r.cn.length) {\n // this.load(r.cn, citer);\n //}\n }\n \n \n}","|getValue":"function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}"},{"|xns":"Gtk","xtype":"TreeViewColumn","pack":"append_column","|init":"function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"}]}]}]}]}]}]}]}]}]}]} \ No newline at end of file diff --git a/Sample/Window.js b/Sample/Window.js index b6869929e..2fdbcf523 100644 --- a/Sample/Window.js +++ b/Sample/Window.js @@ -2345,675 +2345,687 @@ Window=new XObject({ { xtype: Gtk.Notebook, pack : "pack_start,true,true", - id : "view-notebook", - tab_border : 0, + id : "view-help-nb", init : function() { XObject.prototype.init.call(this); - this.el.set_current_page(0); - print("SET LABEL?") - this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" })); - this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" })); + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" })); }, - show_tabs : false, items : [ { - xtype: Gtk.VBox, + xtype: Gtk.Notebook, pack : "add", - id : "RightBrowser", + id : "view-notebook", + tab_border : 0, + init : function() { + XObject.prototype.init.call(this); + this.el.set_current_page(0); + print("SET LABEL?") + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" })); + }, + show_tabs : false, items : [ { - xtype: Gtk.HBox, - pack : "pack_start,false,true,0", + xtype: Gtk.VBox, + pack : "add", + id : "RightBrowser", items : [ { - xtype: Gtk.Button, - pack : "pack_start,false,false,0", - label : "Dump HTML to console", - listeners : { - "activate":function (self) { - this.get('/RightBrowser.view').el.execute_script( - "console.log(document.body.innerHTML);"); - this.get('/RightBrowser.view').el.execute_script( - "console.log(Builder.dump(Builder));"); + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + pack : "pack_start,false,false,0", + label : "Dump HTML to console", + listeners : { + "activate":function (self) { + this.get('/RightBrowser.view').el.execute_script( + "console.log(document.body.innerHTML);"); + this.get('/RightBrowser.view').el.execute_script( + "console.log(Builder.dump(Builder));"); + } + } } - } - } - ] - }, - { - xtype: Gtk.ScrolledWindow, - pack : "add", - shadow_type : Gtk.ShadowType.IN, - init : function() { - XObject.prototype.init.call(this); - this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); - }, - items : [ + ] + }, { - xtype: WebKit.WebView, + xtype: Gtk.ScrolledWindow, pack : "add", - id : "view", + shadow_type : Gtk.ShadowType.IN, init : function() { XObject.prototype.init.call(this); - // this may not work!? - this.el.open('file:///' + __script_path__ + '/../builder.html'); - - Gtk.drag_dest_set - ( - this.el, /* widget that will accept a drop */ - Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, - null, /* lists of target to support */ - 0, /* size of list */ - Gdk.DragAction.COPY /* what to do with data after dropped */ - ); - - // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); - Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }, - renderJS : function(data) { - this.renderedData = data; - var str = JSON.stringify(data) ; - - if (!this.ready) { - console.log('not loaded yet'); - } - Seed.print("RENDER:" + str); - imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");"); - this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");"); - }, - listeners : { - "load_finished":function (self, object) { - if (this.ready) { // dont do it twice! - return; - } - this.ready = true; - - this.renderJS(this.get('/LeftTree.model').toJS()[0]); - }, - "script_alert":function (self, object, p0) { - print(p0); - return false; - return true; // do not display anything... - }, - "console_message":function (self, object, p0, p1) { - console.log(object); - if (!object.match(/^\{/)) { - return false; // do not handle!!! -> later maybe in console.. - } - console.log(object); - var val = JSON.parse(object); - - if (typeof(val['hover-node']) != 'undefined') { - this.activeNode = val['hover-node']; - console.log('active node: ' + this.activeNode); - return true; + items : [ + { + xtype: WebKit.WebView, + pack : "add", + id : "view", + init : function() { + XObject.prototype.init.call(this); + // this may not work!? + this.el.open('file:///' + __script_path__ + '/../builder.html'); + + Gtk.drag_dest_set + ( + this.el, /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + }, + renderJS : function(data) { + this.renderedData = data; + var str = JSON.stringify(data) ; + + if (!this.ready) { + console.log('not loaded yet'); } - - var ret = false; - if (typeof(val['id']) != 'undefined') { - // this.activeNode = val['id']; - var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); - if (!tg) { + Seed.print("RENDER:" + str); + imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");"); + this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");"); + }, + listeners : { + "load_finished":function (self, object) { + if (this.ready) { // dont do it twice! + return; + } + this.ready = true; + + this.renderJS(this.get('/LeftTree.model').toJS()[0]); + }, + "script_alert":function (self, object, p0) { + print(p0); return false; - } - this.get('/LeftTree.view').selectNode(tg[0]); - ret = true; - - } - if (ret && typeof(val['set']) != 'undefined') { - this.get('/LeftPanel.model').add({ - key : val['set'], - val : val['value'] - }); - //console.log('active node: ' + this.activeNode); - - } - //Seed.print('a:'+a); - //Seed.print('b:'+b); - //Seed.print('c:'+c); - return ret; - }, - "drag_motion":function (w, ctx, x, y, time, ud) { - // console.log('DRAG MOTION'); - // status: - // if lastCurrentNode == this.currentNode.. -- don't change anything.. - this.targetData = []; - this.el.execute_script("Builder.overPos(" + x +','+ y + ");"); - - // A) find out from drag all the places that node could be dropped. - var src = Gtk.drag_get_source_widget(ctx); - if (!src.dropList) { - Gdk.drag_status(ctx, 0, time); - return true; - } - // b) get what we are over.. (from activeNode) - // tree is empty.. - list should be correct.. - if (!this.get('/LeftTree.model').currentTree) { - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - return true; - - } - // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + return true; // do not display anything... + }, + "console_message":function (self, object, p0, p1) { + console.log(object); + if (!object.match(/^\{/)) { + return false; // do not handle!!! -> later maybe in console.. + } + console.log(object); + var val = JSON.parse(object); - var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList); - console.dump(tg); - if (!tg.length) { - Gdk.drag_status(ctx, 0,time); - this.get('/LeftTree.view').highlight(false); - return true; - } - - // if we have a target.. - // -> highlight it! (in browser) - // -> highlight it! (in tree) + if (typeof(val['hover-node']) != 'undefined') { + this.activeNode = val['hover-node']; + console.log('active node: ' + this.activeNode); + return true; + } - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - this.get('/LeftTree.view').highlight(tg); - this.targetData = tg; - // for tree we should handle this... - return true; - }, - "drag_drop":function (w, ctx, x, y,time, ud) { - print("TARGET: drag-drop"); - var is_valid_drop_site = true; + var ret = false; + if (typeof(val['id']) != 'undefined') { + // this.activeNode = val['id']; + var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); + if (!tg) { + return false; + } + this.get('/LeftTree.view').selectNode(tg[0]); + ret = true; + + } + if (ret && typeof(val['set']) != 'undefined') { + this.get('/LeftPanel.model').add({ + key : val['set'], + val : val['value'] + }); + //console.log('active node: ' + this.activeNode); + + } + //Seed.print('a:'+a); + //Seed.print('b:'+b); + //Seed.print('c:'+c); + return ret; + }, + "drag_motion":function (w, ctx, x, y, time, ud) { + // console.log('DRAG MOTION'); + // status: + // if lastCurrentNode == this.currentNode.. -- don't change anything.. + this.targetData = []; + this.el.execute_script("Builder.overPos(" + x +','+ y + ");"); + + // A) find out from drag all the places that node could be dropped. + var src = Gtk.drag_get_source_widget(ctx); + if (!src.dropList) { + Gdk.drag_status(ctx, 0, time); + return true; + } + // b) get what we are over.. (from activeNode) + // tree is empty.. - list should be correct.. + if (!this.get('/LeftTree.model').currentTree) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + return true; + + } + // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + + var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList); + console.dump(tg); + if (!tg.length) { + Gdk.drag_status(ctx, 0,time); + this.get('/LeftTree.view').highlight(false); + return true; + } + + // if we have a target.. + // -> highlight it! (in browser) + // -> highlight it! (in tree) + + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + this.get('/LeftTree.view').highlight(tg); + this.targetData = tg; + // for tree we should handle this... + return true; + }, + "drag_drop":function (w, ctx, x, y,time, ud) { + print("TARGET: drag-drop"); + var is_valid_drop_site = true; + + + Gtk.drag_get_data + ( + w, /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the DnD */ + this.get('/Window').atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); + + + /* No target offered by source => error */ + - - Gtk.drag_get_data - ( - w, /* will receive 'drag-data-received' signal */ - ctx, /* represents the current state of the DnD */ - this.get('/Window').atoms["STRING"], /* the target type we want */ - time /* time stamp */ - ); - - - /* No target offered by source => error */ - - - return is_valid_drop_site; - }, - "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) - { - print("Browser: drag-data-received"); - var delete_selection_data = false; - vardnd_success = false; - /* Deal with what we are given from source */ - if( sel_data && sel_data.length ) { - - if (ctx.action == Gdk.DragAction.ASK) { - /* Ask the user to move or copy, then set the ctx action. */ - } - - if (ctx.action == Gdk.DragAction.MOVE) { - delete_selection_data = true; - } - var source = Gtk.drag_get_source_widget(ctx); - - print("Browser: source.DRAGDATA? " + source.dragData); - if (this.targetData) { - print(this.targetData); - this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); - } - - - - dnd_success = true; - - } - - if (dnd_success == false) - { - Seed.print ("DnD data transfer failed!\n"); - } + return is_valid_drop_site; + }, + "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) + { + print("Browser: drag-data-received"); + var delete_selection_data = false; + vardnd_success = false; + /* Deal with what we are given from source */ + if( sel_data && sel_data.length ) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } - Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); - return true; + if (ctx.action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + var source = Gtk.drag_get_source_widget(ctx); + + print("Browser: source.DRAGDATA? " + source.dragData); + if (this.targetData) { + print(this.targetData); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } + + + + dnd_success = true; + + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); + return true; + } } - } + } + ] } ] - } - ] - }, - { - xtype: Gtk.VBox, - pack : "add", - id : "RightGtkView", - renderJS : function(data, withDebug) - { - if (!data) { - return; - } - this.withDebug = false; - - if (this.renderedEl) { - this.get('view').el.remove(this.renderedEl); - this.renderedEl.destroy(); - this.renderedEl = false; - } - - var tree = this.get('/LeftTree.model').toJS(false,true)[0]; - // in theory tree is actually window.. - try { - this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el); - } catch (e) { - print(e.message); - return; - } - this.get('view').el.set_size_request( - tree.default_width * 1 || 400, tree.default_height * 1 || 400 - ) ; - - this.renderedEl.set_size_request( - tree.default_width || 600, - tree.default_height || 400 - ); - this.get('view').el.show_all(); - - - - }, - showInWindow : function() { - print("GET PROEJCT"); - var pr = this.get('/LeftProjectTree').getActiveProject(); - - console.log(pr.paths); - return; - /* - var src= this.buildJS( - this.get('/LeftTree.model').toJS()[0], - true); - // show term?? - - - //var x = new imports.sandbox.Context(); - //x.add_globals(); - //print(src); - try { - Seed.check_syntax('var e = ' + src); - //x.eval(src); - } catch( e) { - this.get('/Terminal').feed(e.message || e.toString() + "\n"); - this.get('/Terminal').feed(console._dump(e)+"\n"); - if (e.line) { - var lines = src.split("\n"); - var start = Math.max(0, e.line - 10); - var end = Math.min(lines.length, e.line + 10); - for (var i =start ; i < end; i++) { - if (i == e.line) { - this.get('/Terminal').feed(">>>>>" + lines[i] + "\n"); - continue; - } - this.get('/Terminal').feed(lines[i] + "\n"); + }, + { + xtype: Gtk.VBox, + pack : "add", + id : "RightGtkView", + renderJS : function(data, withDebug) + { + if (!data) { + return; } + this.withDebug = false; - } + if (this.renderedEl) { + this.get('view').el.remove(this.renderedEl); + this.renderedEl.destroy(); + this.renderedEl = false; + } + + var tree = this.get('/LeftTree.model').toJS(false,true)[0]; + // in theory tree is actually window.. + try { + this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el); + } catch (e) { + print(e.message); + return; + } + this.get('view').el.set_size_request( + tree.default_width * 1 || 400, tree.default_height * 1 || 400 + ) ; + + this.renderedEl.set_size_request( + tree.default_width || 600, + tree.default_height || 400 + ); + this.get('view').el.show_all(); + + + + }, + showInWindow : function() { + print("GET PROEJCT"); + var pr = this.get('/LeftProjectTree').getActiveProject(); + + console.log(pr.paths); + return; + /* + var src= this.buildJS( + this.get('/LeftTree.model').toJS()[0], + true); + // show term?? - return; - } - this.get('/BottomPane').el.set_current_page(1); - this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); - var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n"; - this.get('/Terminal').el.feed_child(cmd, cmd.length); - /* - var _top = x.get_global_object()._top; - - _top.el.set_screen(Gdk.Screen.get_default()); // just in case.. - _top.el.show_all(); - if (_top.el.popup) { - _top.el.popup(null, null, null, null, 3, null); - } - */ - }, - viewAdd : function(item, par) - { - // does something similar to xobject.. - item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack; - - if (item.pack===false || item.pack === 'false') { // no ; - return; - } - print("CREATE: " + item['|xns'] + '.' + item['xtype']); - var ns = imports.gi[item['|xns']]; - var ctr = ns[item['xtype']]; - var ctr_args = { }; - for(var k in item) { - var kv = item[k]; - if (typeof(kv) == 'object' || typeof(kv) == 'function') { - continue; - } - if ( - k == 'pack' || - k == 'items' || - k == 'id' || - k == 'xtype' || - k == 'xdebug' || - k == 'xns' || - k == '|xns' - ) { - continue; - } - - if (k[0] == '|' && typeof(kv) == 'string') { - - if (kv.match(new RegExp('function'))) { - continue; + + //var x = new imports.sandbox.Context(); + //x.add_globals(); + //print(src); + try { + Seed.check_syntax('var e = ' + src); + //x.eval(src); + } catch( e) { + this.get('/Terminal').feed(e.message || e.toString() + "\n"); + this.get('/Terminal').feed(console._dump(e)+"\n"); + if (e.line) { + var lines = src.split("\n"); + var start = Math.max(0, e.line - 10); + var end = Math.min(lines.length, e.line + 10); + for (var i =start ; i < end; i++) { + if (i == e.line) { + this.get('/Terminal').feed(">>>>>" + lines[i] + "\n"); + continue; + } + this.get('/Terminal').feed(lines[i] + "\n"); + } + } - print("WASL " + k + '=' + kv); - try { - eval( 'kv = ' + kv); - } catch(e) { continue; } - k = k.substring(1); - print(k + '=' + kv); - } - if (k[0] == '|') { // should be boolean or number.. - k = k.substring(1); - } - if (k == 'show_tabs') { // force tab showing for notebooks. - kv = true; - } - ctr_args[k] = kv; - - } - - - var el = new ctr(ctr_args); - - //print("PACK"); - //console.dump(item.pack); - - - - - var args = []; - var pack_m = false; - if (typeof(item.pack) == 'string') { - - item.pack.split(',').forEach(function(e, i) { - - if (e == 'false') { args.push( false); return; } - if (e == 'true') { args.push( true); return; } - if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; } - args.push(e); - }); - //print(args.join(",")); + return; + } + this.get('/BottomPane').el.set_current_page(1); + this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); + var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + /* + var _top = x.get_global_object()._top; + + _top.el.set_screen(Gdk.Screen.get_default()); // just in case.. + _top.el.show_all(); + if (_top.el.popup) { + _top.el.popup(null, null, null, null, 3, null); + } + */ + }, + viewAdd : function(item, par) + { + // does something similar to xobject.. + item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack; + + if (item.pack===false || item.pack === 'false') { // no ; + return; + } + print("CREATE: " + item['|xns'] + '.' + item['xtype']); + var ns = imports.gi[item['|xns']]; + var ctr = ns[item['xtype']]; + var ctr_args = { }; + for(var k in item) { + var kv = item[k]; + if (typeof(kv) == 'object' || typeof(kv) == 'function') { + continue; + } + if ( + k == 'pack' || + k == 'items' || + k == 'id' || + k == 'xtype' || + k == 'xdebug' || + k == 'xns' || + k == '|xns' + ) { + continue; + } - pack_m = args.shift(); - } else { - pack_m = item.pack.shift(); - args = item.pack; - } - - // handle error. - if (pack_m && typeof(par[pack_m]) == 'undefined') { - throw { - name: "ArgumentError", - message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m + - "ADDING : " + item.id + " " + el - - }; - - return; - } - - console.dump(args); - args.unshift(el); - //if (XObject.debug) print(pack_m + '[' + args.join(',') +']'); - //Seed.print('args: ' + args.length); - if (pack_m) { - par[pack_m].apply(par, args); - } - - var _this = this; - item.items = item.items || []; - item.items.forEach(function(ch) { - _this.viewAdd(ch, el); - }); - - - - // add the signal handlers. - // is it a widget!?!!? - - - try { - + if (k[0] == '|' && typeof(kv) == 'string') { - el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true)); - el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true)); - el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true)); - el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true )); - el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true )); - } catch(e) { - // ignore! - } - - - - return el; - - }, - widgetExposeEvent : function() { - /// print("WIDGET EXPOSE"); // draw highlight?? - return false; - }, - widgetDragMotionEvent : function() { - print("WIDGET DRAGMOTION"); - return true; - }, - widgetDragDropEvent : function() { - print("WIDGET DRAGDROP"); - return true; - }, - widgetPressEvent : function(w,e,u,d) { - if (this.get('view').pressed) { - return false; - } - this.get('view').pressed = true; - print("WIDGET PRESS " + d.xtreepath ); - this.get('/LeftTree.view').selectNode( d.xtreepath ); - return false; - }, - widgetReleaseEvent : function() { - this.get('view').pressed = false; - return false; - }, - items : [ - { - xtype: Gtk.HBox, - pack : "pack_start,false,true,0", - items : [ - { - xtype: Gtk.Button, - pack : "pack_start,false,false,0", - label : "Run The Application", - listeners : { - "button_press_event":function (self, event) { - // call render on left tree - with special option!?! - - - - print("GET PROEJCT"); - var pr = this.get('/LeftProjectTree').getActiveProject(); - - var dir = ''; - for (var i in pr.paths) { - dir = i; - break; - } - var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; - print ("RUN DIR:" + dir); - - this.get('/BottomPane').el.set_current_page(1); - this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) - , false,false,false); - var cmd = "/usr/bin/seed " + runner + " " + dir + "\n"; - this.get('/Terminal').el.feed_child(cmd, cmd.length); - return false; - - - } + if (kv.match(new RegExp('function'))) { + continue; + } + print("WASL " + k + '=' + kv); + try { + eval( 'kv = ' + kv); + } catch(e) { continue; } + + k = k.substring(1); + print(k + '=' + kv); + } + if (k[0] == '|') { // should be boolean or number.. + k = k.substring(1); + } + if (k == 'show_tabs') { // force tab showing for notebooks. + kv = true; } + ctr_args[k] = kv; + + } + + + var el = new ctr(ctr_args); + + //print("PACK"); + //console.dump(item.pack); + + + + + var args = []; + var pack_m = false; + if (typeof(item.pack) == 'string') { + + item.pack.split(',').forEach(function(e, i) { + + if (e == 'false') { args.push( false); return; } + if (e == 'true') { args.push( true); return; } + if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; } + args.push(e); + }); + //print(args.join(",")); + + pack_m = args.shift(); + } else { + pack_m = item.pack.shift(); + args = item.pack; } - ] - }, - { - xtype: Gtk.ScrolledWindow, - pack : "add", - id : "view-sw", - shadow_type : Gtk.ShadowType.IN, - init : function() { - XObject.prototype.init.call(this); - this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + // handle error. + if (pack_m && typeof(par[pack_m]) == 'undefined') { + throw { + name: "ArgumentError", + message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m + + "ADDING : " + item.id + " " + el + + }; + + return; + } + + console.dump(args); + args.unshift(el); + //if (XObject.debug) print(pack_m + '[' + args.join(',') +']'); + //Seed.print('args: ' + args.length); + if (pack_m) { + par[pack_m].apply(par, args); + } + + var _this = this; + item.items = item.items || []; + item.items.forEach(function(ch) { + _this.viewAdd(ch, el); + }); + + + + // add the signal handlers. + // is it a widget!?!!? + + + try { + + + el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true)); + el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true)); + el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true)); + el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true )); + el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true )); + } catch(e) { + // ignore! + } + + + + return el; + + }, + widgetExposeEvent : function() { + /// print("WIDGET EXPOSE"); // draw highlight?? + return false; + }, + widgetDragMotionEvent : function() { + print("WIDGET DRAGMOTION"); + return true; + }, + widgetDragDropEvent : function() { + print("WIDGET DRAGDROP"); + return true; + }, + widgetPressEvent : function(w,e,u,d) { + if (this.get('view').pressed) { + return false; + } + this.get('view').pressed = true; + print("WIDGET PRESS " + d.xtreepath ); + this.get('/LeftTree.view').selectNode( d.xtreepath ); + return false; + }, + widgetReleaseEvent : function() { + this.get('view').pressed = false; + return false; }, items : [ { - xtype: Gtk.EventBox, + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + pack : "pack_start,false,false,0", + label : "Run The Application", + listeners : { + "button_press_event":function (self, event) { + // call render on left tree - with special option!?! + + + + print("GET PROEJCT"); + var pr = this.get('/LeftProjectTree').getActiveProject(); + + var dir = ''; + for (var i in pr.paths) { + dir = i; + break; + } + var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; + print ("RUN DIR:" + dir); + + this.get('/BottomPane').el.set_current_page(1); + this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) + , false,false,false); + var cmd = "/usr/bin/seed " + runner + " " + dir + "\n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + return false; + + + } + } + } + ] + }, + { + xtype: Gtk.ScrolledWindow, pack : "add", + id : "view-sw", + shadow_type : Gtk.ShadowType.IN, init : function() { XObject.prototype.init.call(this); - this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({ - red: 0x9F00, green: 0xB800 , blue : 0xA800 - })); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }, items : [ { - xtype: Gtk.Fixed, - pack : "add", + xtype: Gtk.EventBox, + pack : "add_with_viewport", init : function() { - XObject.prototype.init.call(this); - //this.el.set_hadjustment(this.parent.el.get_hadjustment()); - //this.el.set_vadjustment(this.parent.el.get_vadjustment()); - + XObject.prototype.init.call(this); + this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({ + red: 0x9F00, green: 0xB800 , blue : 0xA800 + })); }, items : [ { - xtype: Gtk.EventBox, - pack : "put,10,10", + xtype: Gtk.Fixed, + pack : "add", init : function() { - //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU); XObject.prototype.init.call(this); - - Gtk.drag_dest_set - ( - this.el, /* widget that will accept a drop */ - Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, - null, /* lists of target to support */ - 0, /* size of list */ - Gdk.DragAction.COPY /* what to do with data after dropped */ - ); - - // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); - Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); - }, - ready : false, - getActiveNode : function(x,y) - { - // workout what node is here.. - return '0'; // top.. + //this.el.set_hadjustment(this.parent.el.get_hadjustment()); + //this.el.set_vadjustment(this.parent.el.get_vadjustment()); + }, - id : "view", - listeners : { - "drag_motion":function (self, ctx, x, y, time) { + items : [ + { + xtype: Gtk.EventBox, + pack : "put,10,10", + init : function() { + //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU); + XObject.prototype.init.call(this); - // A) find out from drag all the places that node could be dropped. - var src = Gtk.drag_get_source_widget(ctx); - if (!src.dropList) { - Gdk.drag_status(ctx, 0, time); - return true; - } - // b) get what we are over.. (from activeNode) - // tree is empty.. - list should be correct.. - if (!this.get('/LeftTree.model').currentTree) { - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - return true; - - } - // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) - var activeNode = this.getActiveNode(x, y); + Gtk.drag_dest_set + ( + this.el, /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + }, + ready : false, + getActiveNode : function(x,y) + { + // workout what node is here.. + return '0'; // top.. + }, + id : "view", + listeners : { + "drag_motion":function (self, ctx, x, y, time) { + + // A) find out from drag all the places that node could be dropped. + var src = Gtk.drag_get_source_widget(ctx); + if (!src.dropList) { + Gdk.drag_status(ctx, 0, time); + return true; + } + // b) get what we are over.. (from activeNode) + // tree is empty.. - list should be correct.. + if (!this.get('/LeftTree.model').currentTree) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + return true; + + } + // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + var activeNode = this.getActiveNode(x, y); + + + var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList); + console.dump(tg); + if (!tg.length) { + Gdk.drag_status(ctx, 0,time); + this.get('/LeftTree.view').highlight(false); + return true; + } + + // if we have a target.. + // -> highlight it! (in browser) + // -> highlight it! (in tree) + + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + this.get('/LeftTree.view').highlight(tg); + this.targetData = tg; + // for tree we should handle this... + return true; + }, + "drag_drop":function (self,ctx, x, y, time) { + Seed.print("TARGET: drag-drop"); + var is_valid_drop_site = true; - var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList); - console.dump(tg); - if (!tg.length) { - Gdk.drag_status(ctx, 0,time); - this.get('/LeftTree.view').highlight(false); - return true; - } - // if we have a target.. - // -> highlight it! (in browser) - // -> highlight it! (in tree) + Gtk.drag_get_data + ( + self, /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the this.gDnD */ + this.get('/Window').atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); - Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); - this.get('/LeftTree.view').highlight(tg); - this.targetData = tg; - // for tree we should handle this... - return true; - }, - "drag_drop":function (self,ctx, x, y, time) { - Seed.print("TARGET: drag-drop"); - var is_valid_drop_site = true; + + /* No target offered by source => error */ + - - Gtk.drag_get_data - ( - self, /* will receive 'drag-data-received' signal */ - ctx, /* represents the current state of the this.gDnD */ - this.get('/Window').atoms["STRING"], /* the target type we want */ - time /* time stamp */ - ); + return is_valid_drop_site; + + }, + "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) + { + Seed.print("GtkView: drag-data-received"); + var delete_selection_data = false; + var dnd_success = false; + /* Deal with what we are given from source */ + if( sel_data && sel_data.length ) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + if (ctx.action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + var source = Gtk.drag_get_source_widget(ctx); - /* No target offered by source => error */ - - - return is_valid_drop_site; - - }, - "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud) - { - Seed.print("GtkView: drag-data-received"); - var delete_selection_data = false; - var dnd_success = false; - /* Deal with what we are given from source */ - if( sel_data && sel_data.length ) { - - if (ctx.action == Gdk.DragAction.ASK) { - /* Ask the user to move or copy, then set the ctx action. */ - } - - if (ctx.action == Gdk.DragAction.MOVE) { - delete_selection_data = true; - } - var source = Gtk.drag_get_source_widget(ctx); - - Seed.print("Browser: source.DRAGDATA? " + source.dragData); - if (this.targetData) { - Seed.print(this.targetData); - this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); - } - - - - dnd_success = true; - - } - - if (dnd_success == false) - { - Seed.print ("DnD data transfer failed!\n"); - } + Seed.print("Browser: source.DRAGDATA? " + source.dragData); + if (this.targetData) { + Seed.print(this.targetData); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } + + + + dnd_success = true; - Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); - return true; - }, - "button_press_event":function (self, event) { - this.pressed = false; - return false; + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); + return true; + }, + "button_press_event":function (self, event) { + this.pressed = false; + return false; + } + } } - } + ] } ] } @@ -3022,6 +3034,24 @@ Window=new XObject({ ] } ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + id : "Help", + items : [ + { + xtype: WebKit.WebView, + pack : "add", + id : "help-view", + init : function() { + XObject.prototype.init.call(this); + this.get('/Window.help-view').el.open( + "http://devel.akbkhome.com/seed/"); + + } + } + ] } ] } @@ -3054,6 +3084,18 @@ Window=new XObject({ }, load : function(str) { + + // show the help page for the active node.. + this.get('/Window.view-help-nb').el.set_current_page(1); + + // get the active element being edited. + var xtype = this.get('/LeftTree.model').file.guessName( + this.get('/MidPropTree').activeElement); + // now load the help info in the page.. + this.get('/Window.help-view').el.open( + "http://devel.akbkhome.com/seed/" + xtype + ".html"); + + this.get('/BottomPane').el.set_current_page(0); this.el.get_buffer().set_text(str, str.length); var lm = GtkSource.LanguageManager.get_default(); diff --git a/roojs1 b/roojs1 index a718a17df..e6f019d15 160000 --- a/roojs1 +++ b/roojs1 @@ -1 +1 @@ -Subproject commit a718a17df57aa6c8a053509f04c645c3766ed03c +Subproject commit e6f019d1535671672e34eb6a46fa31b9a98fedb2 -- 2.39.2