From f89e29cc068d45e9f8f985b6b1dc5d8e083a78ad Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 30 Sep 2010 17:14:48 +0800 Subject: [PATCH] updated xobject , clutter base objects started --- Builder/About.js | 1 + Builder/DialogNewComponent.bjs | 159 +++++++++++++- Builder/DialogNewComponent.js | 10 +- Builder/DialogSaveTemplate.js | 1 + Builder/DialogTemplateSelect.js | 1 + Builder/Window.bjs | 72 +++---- Builder/Window.js | 353 +++++++++++++++++++------------- ClutterTest/Window.bjs | 25 ++- ClutterTest/Window.js | 110 ---------- XObject.js | 134 ++++++++---- roojs1 | 2 +- 11 files changed, 517 insertions(+), 351 deletions(-) diff --git a/Builder/About.js b/Builder/About.js index 236cbfd6b..47cadc829 100644 --- a/Builder/About.js +++ b/Builder/About.js @@ -7,6 +7,7 @@ GObject = imports.gi.GObject; GtkSource = imports.gi.GtkSource; WebKit = imports.gi.WebKit; Vte = imports.gi.Vte; +GtkClutter = imports.gi.GtkClutter; console = imports.console; XObject = imports.XObject.XObject; About=new XObject({ diff --git a/Builder/DialogNewComponent.bjs b/Builder/DialogNewComponent.bjs index 625a196ab..f0be17b72 100644 --- a/Builder/DialogNewComponent.bjs +++ b/Builder/DialogNewComponent.bjs @@ -1 +1,158 @@ -{"id":"file-gtk-9","name":"DialogNewComponent","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/DialogNewComponent.bjs","items":[{"listeners":{"delete_event":"function (self, event) {\n this.el.hide();\n return true;\n}","response":"function (self, response_id) {\n\tif (response_id < 1) { // cancel!\n this.el.hide();\n return;\n }\n\n if (!this.get('name').el.get_text().length ) {\n this.get('/StandardErrorDialog').show(\n \"You have to set Project name \"\n );\n \n return;\n }\n var isNew = this.file.name.length ? false : true;\n \n if (this.file.name.length && this.file.name != this.get('name').el.get_text()) {\n this.get('/StandardErrorDialog').show(\n \"Sorry changing names does not work yet. \"\n );\n \n return;\n }\n for (var i in this.def) {\n this.file[i] = this.get(i).el.get_text();\n }\n \n if (!isNew) {\n this.file.save();\n this.el.hide();\n return;\n }\n \n \n\tvar dir ='';\n for (var i in this.project.paths) {\n \t\tdir = i;\n\t\tbreak;\n\t}\n\n \n \n // what about .js ?\n if (GLib.file_test (GLib.dir + '/' + this.file.name + '.bjs', GLib.FileTest.EXISTS)) {\n StandardErrorDialog.show(\n \"That file already exists\"\n ); \n return;\n }\n this.el.hide();\n \n \n //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n \n var _this = this;\n var nf = _this.project.create(dir + '/' + this.file.name + '.bjs');\n for (var i in this.file) {\n nf[i] = this.file[i];\n }\n if (this.get('/DialogNewComponent').success) {\n this.get('/DialogNewComponent').success(_this.project, nf);\n }\n}","show":"function (self) {\n this.el.show_all();\n}"},"default_height":200,"default_width":500,"id":"DialogNewComponent","title":"New Component","xtype":"Dialog","|deletable":false,"|modal":true,"|show":"function (c) \n{\n this.project = c.project;\n if (!this.el) {\n this.init();\n }\n this.def = { \n name : '' , \n title : '' ,\n region : '' ,\n parent: '',\n disable: '',\n modOrder : '0'\n };\n for (var i in this.def) {\n c[i] = c[i] || this.def[i];\n this.get(i).el.set_text(c[i]);\n }\n if (c.name) {\n this.el.set_title(\"Edit File Details - \" + c.name);\n } else {\n this.el.set_title(\"Create New File\");\n }\n \n this.file = c;\n console.log('show all');\n this.el.show_all();\n this.success = c.success;\n \n \n}","|xns":"Gtk","items":[{"|xns":"Gtk","xtype":"VBox","|pack":"function(p,e) {\n p.el.get_content_area().add(e.el)\n }\n","items":[{"n_columns":2,"n_rows":3,"pack":"pack_start,false,false,0","xtype":"Table","|homogeneous":false,"|xns":"Gtk","items":[{"label":"Component Name","pack":"add","x_options":4,"xalign":0.9,"xtype":"Label","|justify":"Gtk.Justification.RIGHT","|xns":"Gtk"},{"id":"name","pack":"add","xtype":"Entry","|visible":true,"|xns":"Gtk"},{"label":"Title","pack":"add","x_options":4,"xalign":0.9,"xtype":"Label","|justify":"Gtk.Justification.RIGHT","|visible":true,"|xns":"Gtk"},{"id":"title","pack":"add","xtype":"Entry","|visible":true,"|xns":"Gtk"},{"label":"Region","pack":"add","tooltip_text":"center, north, south, east, west","x_options":4,"xalign":0.9,"xtype":"Label","|justify":"Gtk.Justification.RIGHT","|visible":true,"|xns":"Gtk"},{"id":"region","pack":"add","xtype":"Entry","|visible":true,"|xns":"Gtk"},{"label":"Parent Name","pack":"add","x_options":4,"xalign":0.9,"xtype":"Label","|justify":"Gtk.Justification.RIGHT","|visible":true,"|xns":"Gtk"},{"id":"parent","pack":"add","xtype":"Entry","|visible":true,"|xns":"Gtk"},{"label":"Disable method","pack":"add","x_options":4,"xalign":0.9,"xtype":"Label","|justify":"Gtk.Justification.RIGHT","|visible":true,"|xns":"Gtk"},{"id":"disable","pack":"add","xtype":"Entry","|visible":true,"|xns":"Gtk"},{"label":"Order (for tabs)","pack":"add","x_options":4,"xalign":0.9,"xtype":"Label","|justify":"Gtk.Justification.RIGHT","|visible":true,"|xns":"Gtk"},{"id":"modOrder","pack":"add","xtype":"Entry","|visible":true,"|xns":"Gtk"}]}]},{"|xns":"Gtk","xtype":"Button","pack":"add_action_widget,0","label":"Cancel"},{"|xns":"Gtk","xtype":"Button","pack":"add_action_widget,1","label":"OK"}]}],"project":"{\"name\":\"Sample\",\"xtype\":\"Gtk\",\"paths\":{\"/home/alan/gitlive/app.Builder.js/Sample\":\"dir\"},\"id\":\"project-gtk-1\",\"fn\":\"329624934046af6e88a65a3f36971958\",\"file\":false}"} \ No newline at end of file +{ + "id": "file-gtk-2", + "name": "DialogNewComponent", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Sample/DialogNewComponent.bjs", + "items": [ + { + "listeners": { + "delete_event": "function (self, event) {\n this.el.hide();\n return true;\n}", + "response": "function (self, response_id) {\n\tif (response_id < 1) { // cancel!\n this.el.hide();\n return;\n }\n\n if (!this.get('name').el.get_text().length ) {\n this.get('/StandardErrorDialog').show(\n \"You have to set Project name \"\n );\n \n return;\n }\n var isNew = this.file.name.length ? false : true;\n \n if (this.file.name.length && this.file.name != this.get('name').el.get_text()) {\n this.get('/StandardErrorDialog').show(\n \"Sorry changing names does not work yet. \"\n );\n \n return;\n }\n for (var i in this.def) {\n this.file[i] = this.get(i).el.get_text();\n }\n \n if (!isNew) {\n this.file.save();\n this.el.hide();\n return;\n }\n \n \n\tvar dir ='';\n for (var i in this.project.paths) {\n \t\tdir = i;\n\t\tbreak;\n\t}\n\n \n \n // what about .js ?\n if (GLib.file_test (GLib.dir + '/' + this.file.name + '.bjs', GLib.FileTest.EXISTS)) {\n StandardErrorDialog.show(\n \"That file already exists\"\n ); \n return;\n }\n this.el.hide();\n \n \n //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n \n var _this = this;\n var nf = _this.project.create(dir + '/' + this.file.name + '.bjs');\n for (var i in this.file) {\n nf[i] = this.file[i];\n }\n if (this.get('/DialogNewComponent').success) {\n this.get('/DialogNewComponent').success(_this.project, nf);\n }\n}", + "show": "function (self) {\n this.el.show_all();\n}" + }, + "default_height": 200, + "default_width": 500, + "id": "DialogNewComponent", + "title": "New Component", + "xtype": "Dialog", + "|deletable": false, + "|modal": true, + "|show": "function (c) \n{\n this.project = c.project;\n if (!this.el) {\n this.init();\n }\n this.def = { \n name : '' , \n title : '' ,\n region : '' ,\n parent: '',\n // disable: '',\n modOrder : '0',\n permname : ''\n };\n for (var i in this.def) {\n c[i] = c[i] || this.def[i];\n this.get(i).el.set_text(c[i]);\n }\n if (c.name) {\n this.el.set_title(\"Edit File Details - \" + c.name);\n } else {\n this.el.set_title(\"Create New File\");\n }\n \n this.file = c;\n console.log('show all');\n this.el.show_all();\n this.success = c.success;\n \n \n}", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "VBox", + "|pack": "function(p,e) {\n p.el.get_content_area().add(e.el)\n }\n", + "items": [ + { + "n_columns": 2, + "n_rows": 3, + "pack": "pack_start,false,false,0", + "xtype": "Table", + "|homogeneous": false, + "|xns": "Gtk", + "items": [ + { + "label": "Component Name", + "pack": "add", + "x_options": 4, + "xalign": 0.9, + "xtype": "Label", + "|justify": "Gtk.Justification.RIGHT", + "|xns": "Gtk" + }, + { + "id": "name", + "pack": "add", + "xtype": "Entry", + "|visible": true, + "|xns": "Gtk" + }, + { + "label": "Title", + "pack": "add", + "x_options": 4, + "xalign": 0.9, + "xtype": "Label", + "|justify": "Gtk.Justification.RIGHT", + "|visible": true, + "|xns": "Gtk" + }, + { + "id": "title", + "pack": "add", + "xtype": "Entry", + "|visible": true, + "|xns": "Gtk" + }, + { + "label": "Region", + "pack": "add", + "tooltip_text": "center, north, south, east, west", + "x_options": 4, + "xalign": 0.9, + "xtype": "Label", + "|justify": "Gtk.Justification.RIGHT", + "|visible": true, + "|xns": "Gtk" + }, + { + "id": "region", + "pack": "add", + "xtype": "Entry", + "|visible": true, + "|xns": "Gtk" + }, + { + "label": "Parent Name", + "pack": "add", + "x_options": 4, + "xalign": 0.9, + "xtype": "Label", + "|justify": "Gtk.Justification.RIGHT", + "|visible": true, + "|xns": "Gtk" + }, + { + "id": "parent", + "pack": "add", + "xtype": "Entry", + "|visible": true, + "|xns": "Gtk" + }, + { + "label": "Permission Name", + "pack": "add", + "x_options": 4, + "xalign": 0.9, + "xtype": "Label", + "|justify": "Gtk.Justification.RIGHT", + "|visible": true, + "|xns": "Gtk" + }, + { + "id": "permname", + "pack": "add", + "xtype": "Entry", + "|visible": true, + "|xns": "Gtk" + }, + { + "label": "Order (for tabs)", + "pack": "add", + "x_options": 4, + "xalign": 0.9, + "xtype": "Label", + "|justify": "Gtk.Justification.RIGHT", + "|visible": true, + "|xns": "Gtk" + }, + { + "id": "modOrder", + "pack": "add", + "xtype": "Entry", + "|visible": true, + "|xns": "Gtk" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "add_action_widget,0", + "label": "Cancel" + }, + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "add_action_widget,1", + "label": "OK" + } + ] + } + ] +} \ No newline at end of file diff --git a/Builder/DialogNewComponent.js b/Builder/DialogNewComponent.js index 22f2feceb..3bf308d3d 100644 --- a/Builder/DialogNewComponent.js +++ b/Builder/DialogNewComponent.js @@ -7,6 +7,7 @@ GObject = imports.gi.GObject; GtkSource = imports.gi.GtkSource; WebKit = imports.gi.WebKit; Vte = imports.gi.Vte; +GtkClutter = imports.gi.GtkClutter; console = imports.console; XObject = imports.XObject.XObject; DialogNewComponent=new XObject({ @@ -99,8 +100,9 @@ DialogNewComponent=new XObject({ title : '' , region : '' , parent: '', - disable: '', - modOrder : '0' + // disable: '', + modOrder : '0', + permname : '' }; for (var i in this.def) { c[i] = c[i] || this.def[i]; @@ -195,7 +197,7 @@ DialogNewComponent=new XObject({ }, { xtype: Gtk.Label, - label : "Disable method", + label : "Permission Name", pack : "add", x_options : 4, xalign : 0.9, @@ -204,7 +206,7 @@ DialogNewComponent=new XObject({ }, { xtype: Gtk.Entry, - id : "disable", + id : "permname", pack : "add", visible : true }, diff --git a/Builder/DialogSaveTemplate.js b/Builder/DialogSaveTemplate.js index c82c49d3c..1464e1357 100644 --- a/Builder/DialogSaveTemplate.js +++ b/Builder/DialogSaveTemplate.js @@ -7,6 +7,7 @@ GObject = imports.gi.GObject; GtkSource = imports.gi.GtkSource; WebKit = imports.gi.WebKit; Vte = imports.gi.Vte; +GtkClutter = imports.gi.GtkClutter; console = imports.console; XObject = imports.XObject.XObject; DialogSaveTemplate=new XObject({ diff --git a/Builder/DialogTemplateSelect.js b/Builder/DialogTemplateSelect.js index 486924e36..91dfae77b 100644 --- a/Builder/DialogTemplateSelect.js +++ b/Builder/DialogTemplateSelect.js @@ -7,6 +7,7 @@ GObject = imports.gi.GObject; GtkSource = imports.gi.GtkSource; WebKit = imports.gi.WebKit; Vte = imports.gi.Vte; +GtkClutter = imports.gi.GtkClutter; console = imports.console; XObject = imports.XObject.XObject; DialogTemplateSelect=new XObject({ diff --git a/Builder/Window.bjs b/Builder/Window.bjs index df28de76a..146394d4e 100644 --- a/Builder/Window.bjs +++ b/Builder/Window.bjs @@ -255,16 +255,6 @@ "|xns": "Gtk", "items": [ { - "|xns": "Gtk", - "xtype": "TreeView", - "pack": "add", - "id": "view", - "|headers_visible": false, - "|enable_tree_lines": true, - "tooltip_column": 1, - "|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\n\t// is this really needed??\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\n // highlighting for drag/drop\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}", @@ -272,8 +262,18 @@ "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) { // probably not needed.. \n return true;\n }\n var render = this.get('/LeftTree').getRenderer(); \n \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 if (render && render.redraw) {\n render.redraw();\n }\n return true;\n }\n \n //console.log('changed');\n var s = this.selection;\n var iter = new Gtk.TreeIter();\n s.get_selected(this.get('/LeftTree.model').el, iter);\n \n \n // var val = \"\";\n var 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 if (render && render.redraw) {\n render.redraw();\n }\n \n //Seed.print( value.get_string());\n return true;\n \n}" + "cursor_changed": "function (self) {\n if (this.blockChanges) { // probably not needed.. \n return true;\n }\n var render = this.get('/LeftTree').getRenderer(); \n \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 if (render && render.redraw) {\n render.redraw();\n }\n return true;\n }\n \n //console.log('changed');\n var s = this.selection;\n var iter = new Gtk.TreeIter();\n s.get_selected(this.get('/LeftTree.model').el, iter);\n \n \n // var val = \"\";\n var 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('/LeftTree').getPaleteProvider().gatherList(\n this.get('/LeftTree.model').listAllTypes()));\n \n \n if (render && render.redraw) {\n render.redraw();\n }\n \n //Seed.print( value.get_string());\n return true;\n \n}" }, + "id": "view", + "pack": "add", + "tooltip_column": 1, + "xtype": "TreeView", + "|enable_tree_lines": true, + "|headers_visible": false, + "|highlight": "function(treepath_ar) {\n\n // highlighting for drag/drop\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 }", + "|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\n\t// is this really needed??\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", + "|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", + "|xns": "Gtk", "items": [ { "activePath": false, @@ -281,7 +281,7 @@ "id": "model", "pack": "set_model", "xtype": "TreeStore", - "|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", + "|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", "|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 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", "|dropNode": "function(target_data, node) {\n print(\"drop Node\");\n // console.dump(node);\n // 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 node = this.get('/DialogTemplateSelect').show(node);\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 if (pal.name == 'Gtk') {\n var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));\n var cname = pal.guessName(node);\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 this.get('/LeftTree.view').el.expand_row(this.el.get_path(n_iter), true);\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 // 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", "|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", @@ -660,10 +660,10 @@ "|add": "function(info) {\n // info includes key, val, skel, etype..\n console.dump(info);\n type = info.type.toLowerCase();\n var data = this.toJS();\n \n if (info.etype == 'events') {\n data.listeners = data.listeners || { };\n if (typeof(data.listeners[info.key]) != 'undefined') {\n return; //already set!\n }\n } else {\n if (typeof(data[info.key]) != 'undefined') {\n return;\n }\n }\n \n if (typeof(info.val) == 'undefined') {\n \n info.val = '';\n if (info.type.toLowerCase() == 'boolean') {\n info.val = true;\n }\n if (type == 'number') {\n info.val = 0;\n }\n // utf8 == string..\n \n \n }\n var k = info.key;\n if (info.etype == 'events') {\n \n data.listeners[info.key] = info.val;\n k = '!' + info.key;\n } else {\n data[info.key] = info.val;\n }\n \n \n var map = this.load(data);\n \n // flag it as changed to the interface..\n\n this.get('/LeftTree.model').changed(data, true); \n \n \n this.startEditing(map[k]);\n \n /*\n LeftPanel.get('view').el.row_activated(\n new Gtk.TreePath.from_string(map[k]), \n LeftPanel.editableColumn.el\n );\n */\n}\n", "|changed": "function(str, doRefresh) {\n if (!this.activePath) {\n return;\n }\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));\n \n this.el.set_value(iter, 1, '' +str);\n this.el.set_value(iter, 3, '' + this.toShort(str));\n var type = this.getIterValue(iter, 4);\n\n this.el.set_value(iter, 5, type + ' : ' + str);\n // update the tree... \n\n this.get('/LeftTree.model').changed(this.toJS(), doRefresh); \n}\n", "|deleteSelected": "function() {\n var data = this.toJS();\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.el, iter);\n \n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);\n \n var val = gval.value;\n if (val[0] == '!') {\n // listener..\n if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {\n return;\n }\n delete data.listeners[ val.substring(1)];\n if (!XObject.keys(data.listeners).length) {\n delete data.listeners;\n }\n \n } else {\n if (typeof(data[val]) == 'undefined') {\n return;\n }\n delete data[val];\n }\n \n \n this.load(data);\n this.get('/LeftTree.model').changed(data, true);\n \n}\n", - "|editSelected": "function(e) {\n print(\"EDIT SELECTED?\");\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.get('/LeftPanel.model').el, iter);\n var m = this.get('/LeftPanel.model')\n \n var gval = new GObject.Value('');\n this.el.get_value(iter, 0 ,gval);\n var val = '' + gval.value;\n \n gval = new GObject.Value('');\n this.el.get_value(iter, 1 ,gval);\n var rval = gval.value;\n var activePath = this.el.get_path(iter).to_string(); \n this.activePath = activePath ;\n // was activeIter...\n // not listener...\n\n var showEditor = false;\n \n if (val[0] == '!') {\n showEditor = true;\n }\n if (val[0] == '|') {\n if (rval.match(/function/g) || rval.match(/\\n/g)) {\n showEditor = true;\n }\n }\n \n if (showEditor) {\n var _this = this;\n this.activePath = false;\n GLib.timeout_add(0, 1, function() {\n // Gdk.threads_enter();\n _this.get('/BottomPane').el.show();\n _this.get('/RightEditor').el.show();\n _this.get('/RightEditor.view').load( rval );\n \n e.editing_done();\n e.remove_widget();\n _this.activePath = activePath ;\n \n // Gdk.threads_leave();\n return false;\n });\n return;\n }\n this.get('/BottomPane').el.hide();\n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n", + "|editSelected": "function(e) {\n print(\"EDIT SELECTED?\");\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.get('/LeftPanel.model').el, iter);\n var m = this.get('/LeftPanel.model')\n \n var gval = new GObject.Value('');\n this.el.get_value(iter, 0 ,gval);\n var val = '' + gval.value;\n \n gval = new GObject.Value('');\n this.el.get_value(iter, 1 ,gval);\n var rval = gval.value;\n var activePath = this.el.get_path(iter).to_string(); \n this.activePath = activePath ;\n // was activeIter...\n // not listener...\n\n var showEditor = false;\n \n if (val[0] == '!') {\n showEditor = true;\n }\n if (val[0] == '|') {\n if (rval.match(/function/g) || rval.match(/\\n/g) || rval.length > 20) {\n showEditor = true;\n }\n }\n \n if (showEditor) {\n var _this = this;\n this.activePath = false;\n GLib.timeout_add(0, 1, function() {\n // Gdk.threads_enter();\n _this.get('/BottomPane').el.show();\n _this.get('/RightEditor').el.show();\n _this.get('/RightEditor.view').load( rval );\n \n e.editing_done();\n e.remove_widget();\n _this.activePath = activePath ;\n \n // Gdk.threads_leave();\n return false;\n });\n return;\n }\n this.get('/BottomPane').el.hide();\n this.get('/RightEditor').el.hide();\n\n //var type = this.getValue(this.el.get_path(iter).to_string(),4);\n \n \n}\n", "|getIterValue": "function(iter, col) {\n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n", "|getType": "function(treepath) {\n return this.getValue(treepath, 4);\n}\n", - "|getValue": "function(treepath_str, col) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));\n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n var val = '' + gval.value;\n if (col != 1) {\n return val;\n }\n var type = this.getType(this.el.get_path(iter).to_string());\n print(\"TYPE: \" +type + \" - val:\" + val);\n switch(type.toLowerCase()) {\n case 'number':\n case 'uint':\n case 'int':\n return parseFloat(val); // Nan ?? invalid!!? \n case 'float':\n case 'gfloat':\n return 1.0 * parseFloat(val); // Nan ?? invalid!!?\n case 'boolean':\n return val == 'true' ? true : false;\n default: \n var nv = parseFloat(val);\n if (!isNaN(nv) && (val == ''+nv)) {\n return nv;\n }\n return val;\n }\n \n}\n", + "|getValue": "function(treepath_str, col) {\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));\n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n var val = '' + gval.value;\n if (col != 1) {\n return val;\n }\n var type = this.getType(this.el.get_path(iter).to_string());\n //print(\"TYPE: \" +type + \" - val:\" + val);\n switch(type.toLowerCase()) {\n case 'number':\n case 'uint':\n case 'int':\n return parseFloat(val); // Nan ?? invalid!!? \n case 'float':\n case 'gfloat':\n return 1.0 * parseFloat(val); // Nan ?? invalid!!?\n case 'boolean':\n return val == 'true' ? true : false;\n default: \n var nv = parseFloat(val);\n if (!isNaN(nv) && (val == ''+nv)) {\n return nv;\n }\n return val;\n }\n \n}\n", "|init": "function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 6, [\n GObject.TYPE_STRING, // 0 real key\n GObject.TYPE_STRING, // 1 real value \n GObject.TYPE_STRING, // 2 visable key\n GObject.TYPE_STRING, // 3 visable value\n GObject.TYPE_STRING, // 4 need to store type of!!!\n GObject.TYPE_STRING // 5 tooltip\n \n ]);\n}\n", "|load": "function(ar) {\n this.el.clear();\n \n this.get('/RightEditor').el.hide();\n if (ar === false) {\n return ;\n }\n var ret = {}; \n \n\n var provider = this.get('/LeftTree').getPaleteProvider();\n var iter = new Gtk.TreeIter();\n \n // sort!!!?\n var keys = XObject.keys(ar);\n keys.sort();\n ar.listeners = ar.listeners || {};\n \n for (var i in ar.listeners ) {\n this.el.append(iter);\n var p = this.el.get_path(iter).to_string();\n ret['!' + i] = p;\n \n this.el.set_value(iter, 0, '!'+ i );\n this.el.set_value(iter, 1, '' + ar.listeners[i]);\n this.el.set_value(iter, 2, ''+ i + '');\n \n this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));\n this.el.set_value(iter, 4, 'function');\n this.el.set_value(iter, 5, i + ' : ' + ar.listeners[i]);\n }\n \n \n \n var _this = this;\n keys.forEach(function(i) {\n if (typeof(ar[i]) == 'object') {\n return;\n }\n \n var type = provider.findType(ar, i, ar[i]);\n \n _this.el.append(iter);\n var p = _this.el.get_path(iter).to_string();\n ret[i] = p;\n _this.el.set_value(iter, 0, ''+i);\n _this.el.set_value(iter, 1, '' + ar[i]); \n _this.el.set_value(iter, 2, ''+i);\n _this.el.set_value(iter, 3, ''+ _this.toShort(ar[i]));\n _this.el.set_value(iter, 4, ''+type);\n _this.el.set_value(iter, 5, type + ' : ' + ar[i]);\n })\n return ret;\n}\n", "|startEditing": "function(path,col) {\n /**\n * start editing path (or selected if not set..)\n * @param {String|false} path (optional) treepath to edit - selected tree gets\n * edited by default.\n * @param {Number} 0 or 1 (optional)- column to edit. \n */\n var tp;\n if (typeof(path) == 'string') {\n tp = new Gtk.TreePath.from_string(path);\n } else {\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.el, iter);\n tp = this.el.get_path(iter);\n path = tp.to_string();\n }\n \n \n // which colum is to be edited..\n var colObj = false;\n if (typeof(col) == 'undefined') {\n var k = this.getValue(path, 0);\n colObj = (!k.length || k == '|') ? \n this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;\n } else {\n colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;\n }\n \n // make sure the pulldown is set correctly..\n // not really needed for second col...\n\n var provider = this.get('/LeftTree').getPaleteProvider();\n \n var type = this.get('/LeftPanel.model').getType(path);\n var opts = provider.findOptions(type);\n var renderer = this.get('/LeftPanel').editableColumn.items[0].el;\n \n if (opts === false) {\n this.get('/LeftPanel').editableColumn.setOptions([]);\n renderer.has_entry = true; /// probably does not have any effect.\n } else {\n this.get('/LeftPanel').editableColumn.setOptions(opts);\n renderer.has_entry = false;\n }\n \n var _this=this;\n // iter now has row...\n GLib.timeout_add(0, 100, function() {\n \n colObj.items[0].el.editable = true; // esp. need for col 0..\n _this.get('/LeftPanel.view').el.set_cursor_on_cell(\n tp,\n colObj.el,\n colObj.items[0].el,\n true\n );\n });\n \n}\n", @@ -768,13 +768,13 @@ "|xns": "Gtk", "items": [ { - "|xns": "Gtk", - "xtype": "ListStore", + "id": "model", "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", + "xtype": "ListStore", "|getValue": "function(treepath, col)\n{\n var tp = new Gtk.TreePath.from_string (treepath);\n var iter = new Gtk.TreeIter();\n this.el.get_iter (iter, tp);\n var value = new GObject.Value('');\n this.el.get_value(iter, col, value);\n return value.value;\n \n}", - "|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" + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 6, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING, // real type\n GObject.TYPE_STRING, // docs ?\n GObject.TYPE_STRING, // visable desc\n GObject.TYPE_STRING, // function desc\n GObject.TYPE_STRING // element type (event|prop)\n \n ] );\n}\n", + "|showData": "function(type) {\n this.el.clear();\n if (!this.get('/MidPropTree').activeElement || !type) {\n return; // no active element\n }\n\n var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);\n var palete = this.get('/LeftTree').getPaleteProvider();\n \n \n \n Seed.print('Showing right?');\n if (!this.get('/MidPropTree').shown) {\n\n this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;\n this.get('/MidPropTree').el.show();\n this.get('/MidPropTree').shown = true;\n }\n \n var elementList = palete.getPropertiesFor(fullpath, type).sort(function(a,b) { \n return a.name > b.name ? 1 : -1;\n });\n print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);\n // console.dump(elementList);\n \n \n var iter = new Gtk.TreeIter();\n for(var i =0 ; i < elementList.length; i++) {\n var p=elementList[i];\n this.el.append(iter);\n // console.log( '' + 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", + "|xns": "Gtk" }, { "|xns": "Gtk", @@ -834,27 +834,28 @@ "|xns": "Gtk", "items": [ { - "|xns": "Gtk", - "xtype": "ScrolledWindow", "pack": "add", + "xtype": "ScrolledWindow", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", "|shadow_type": "Gtk.ShadowType.IN", - "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", + "|xns": "Gtk", "items": [ { "listeners": { - "load_finished": "function (self, object) {\n\t// if (this.ready) { // dont do it twice!\n\t // return; \n\t//}\n\t this.el.get_inspector().show();\n\tthis.ready = true;\n this.pendingRedraw = false;\n var js = this.get('/LeftTree.model').toJS();\n if (js && js[0]) {\n \t this.renderJS(js[0]);\n \t}\n\n}", + "load_finished": "function (self, object) {\n print(\"load finished\");\n// print(\"load_finished\"); return;\n\t// if (this.ready) { // dont do it twice!\n\t // return; \n\t//}\n\tif (!this.inspectorShown) {\n this.el.get_inspector().show();\n this.inspectorShown = true;\n\t}\n\n\tthis.ready = true;\n\t\n if (this.pendingRedraw) {\n this.pendingRedraw = false;\n this.refreshRequired = true;\n }\n //var js = this.get('/LeftTree.model').toJS();\n //if (js && js[0]) {\n \t// this.renderJS(js[0]);\n \t//}\n\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 \n //this.get('/Terminal').feed(object);\n return true; // 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 || typeof(tg[0]) == 'undefined') {\n return false;\n }\n print(\"SELECT node \" + tg[0]);\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}", + "console_message": "function (self, object, p0, p1) {\n print(object);\n // console.log(object);\n if (!object.match(/^\\{/)) {\n \n //this.get('/Terminal').feed(object);\n return true; // 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 || typeof(tg[0]) == 'undefined') {\n return false;\n }\n print(\"SELECT node \" + tg[0]);\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 }", - "resource_request_starting": "function (self, object, p0, p1, p2) {\n // this.get('/Terminal').feed( p1.get_uri() );\n}" + "create_web_view": "function (self, object) {\n print(\"CREATE WEB VIEW\");\n return null; //new WebKit.WebView();\n}" }, "id": "view", "pack": "add", "xtype": "WebView", - "|init": "function() {\n XObject.prototype.init.call(this);\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_developer_extras = true;\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n var _this = this;\n \n this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {\n _this.get('/BottomPane.inspector').el.show();\n return _this.get('/BottomPane.inspector').el;\n //create_inspector_cb\n });\n \n \n this.el.open('file:///' + __script_path__ + '/../builder.html');\n \n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n null, /* lists of target to support */\n 0, /* size of list */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n \n // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n}\n", - "|renderJS": "function(data) {\n print(\"HTML RENDERING\");\n this.get('/BottomPane').el.show();\n this.get('/BottomPane').el.set_current_page(2);// webkit view!\n /// prevent looping..\n //if (this.pendingRedraw) {\n // print(\"pending redraw active?!\");\n // return;\n //}\n \n \n if (!this.get('/Window.LeftTree').getActiveFile()) {\n return;\n }\n \n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n \n project.runhtml = project.runhtml || '';\n \n\n this.runhtml = this.runhtml || '';\n \n if (project.runhtml != this.runhtml) {\n // then we need to reload the browser using\n // load_html_string..\n \n // then trigger a redraw once it's loaded..\n this.pendingRedraw = true;\n var runhtml = ''+ \"\\n\" ;\n// this.runhtml = ''+ \"\\n\" ;\n // this.runhtml += ''+ \"\\n\" ;\n // this.runhtml += ''+ \"\\n\" ;\n \n this.runhtml = project.runhtml;\n // need to modify paths\n \n \n \n var html = imports.File.File.read(__script_path__ + '/../builder.html');\n html = html.replace('', runhtml + this.runhtml + '');\n print(\"LOAD HTML \" + html);\n this.el.load_html_string( html , \n //fixme - should be a config option!\n 'http://www.akbkhome.com/e/'\n );\n // should trigger load_finished!\n return;\n \n }\n \n this.pendingRedraw = false; \n \n \n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n //Seed.print(\"RENDER:\" + str);\n //imports.File.File.write('/tmp/builder.debug.js', \"Builder.render(\" + JSON.stringify(data) + \");\");\n \n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n \n}\n", + "|init": "function() {\n XObject.prototype.init.call(this);\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_developer_extras = true;\n \n // this was an attempt to change the url perms.. did not work..\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n var _this = this;\n \n // init inspector..\n this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {\n _this.get('/BottomPane.inspector').el.show();\n return _this.get('/BottomPane.inspector').el;\n \n });\n \n // FIXME - base url of script..\n // we need it so some of the database features work.\n this.el.load_html_string( \"Render not ready\" , \n //fixme - should be a config option!\n // or should we catch stuff and fix it up..\n 'http://localhost/app.Builder/'\n );\n \n \n //this.el.open('file:///' + __script_path__ + '/../builder.html');\n \n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n null, /* lists of target to support */\n 0, /* size of list */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n \n // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n \n GLib.timeout_add_seconds(0, 1, function() {\n // print(\"run refresh?\");\n _this.runRefresh(); \n return true;\n });\n \n \n}\n", + "|renderJS": "function(data) {\n this.refreshRequired = true;\n}\n", + "|runRefresh": "function() \n{\n // this is run every 2 seconds from the init..\n\n \n \n if (!this.refreshRequired) {\n // print(\"no refresh required\");\n return;\n }\n\n if (this.lastRedraw) {\n // do not redraw if last redraw was less that 5 seconds ago.\n if (((new Date()) - this.lastRedraw) < 5000) {\n return;\n }\n }\n \n \n \n \n if (!this.get('/Window.LeftTree').getActiveFile()) {\n return;\n }\n this.refreshRequired = false;\n // print(\"HTML RENDERING\");\n \n this.get('/BottomPane').el.show();\n this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n\n \n var js = this.get('/LeftTree.model').toJS();\n if (!js || !js.length) {\n print(\"no data\");\n return;\n }\n var data = js[0];\n \n \n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n // set it to non-empty.\n project.runhtml = project.runhtml || '';\n project.runhtml = project.runhtml.length ? project.runhtml : ''; \n \n\n this.runhtml = this.runhtml || '';\n \n if (project.runhtml != this.runhtml) {\n // then we need to reload the browser using\n // load_html_string..\n \n // then trigger a redraw once it's loaded..\n this.pendingRedraw = true;\n var runhtml = ''+ \"\\n\" ;\n \n this.runhtml = project.runhtml;\n // need to modify paths\n \n \n \n var html = imports.File.File.read(__script_path__ + '/../builder.html');\n html = html.replace('', runhtml + this.runhtml + '');\n print(\"LOAD HTML \" + html);\n this.el.load_html_string( html , \n //fixme - should be a config option!\n 'http://localhost/app.Builder/'\n );\n \n // should trigger load_finished! - which in truns shoudl set refresh Required;\n return;\n \n }\n \n \n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n this.lastRedraw = new Date();\n\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n print( \"before render\" + this.lastRedraw);\n print( \"after render\" + (new Date()));\n \n}\n", "|xns": "WebKit" } ] @@ -866,9 +867,9 @@ "pack": "add", "xtype": "VBox", "|redraw": "function() {\n this.highlightWidget = false;\n print(\"REDRAW CALLED\");\n this.activePath = this.get('/LeftTree').getActivePath();\n if (this.renderedEl) {\n print(\"QUEUE DRAW CALLING\");\n this.renderedEl.queue_draw();\n }\n}\n", - "|renderJS": "function(data, withDebug)\n{\n this.highlightWidget = false;\n \n this.withDebug = false;\n \n if (this.renderedEl) {\n this.get('view').el.remove(this.renderedEl);\n this.renderedEl.destroy();\n this.renderedEl = false;\n }\n if (!data) {\n return; \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}", + "|renderJS": "function(data, withDebug)\n{\n this.highlightWidget = false;\n \n this.withDebug = false;\n while (this.get('view').el.get_children().length) {\n var c = this.get('view').el.get_children()[0];\n this.get('view').el.remove(c); \n c.destroy();\n }\n if (!data) {\n return; \n }\n \n var tree = this.get('/LeftTree.model').toJS(false,true)[0];\n // in theory tree is actually window.. \n try {\n \n this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);\n \n } catch (e) {\n print(e.message);\n return;\n }\n this.get('view').el.set_size_request(\n tree.default_width * 1 || 400, tree.default_height * 1 || 400\n ) ;\n if (this.renderedEl) {\n this.renderedEl.set_size_request(\n tree.default_width || 600,\n tree.default_height || 400\n );\n }\n this.get('view').el.show_all();\n \n \n \n}", "|showInWindow": "function() {\n print(\"GET PROEJCT\");\n\tvar pr = this.get('/LeftProjectTree').getActiveProject();\n \n\tconsole.log(pr.paths);\n return;\n/*\n var src= this.buildJS(\n\t\tthis.get('/LeftTree.model').toJS()[0], \n\t\ttrue);\n // show term?? \n\n\n //var x = new imports.sandbox.Context();\n //x.add_globals();\n //print(src);\n try {\n Seed.check_syntax('var e = ' + src);\n //x.eval(src);\n } catch( e) {\n this.get('/Terminal').feed(e.message || e.toString() + \"\\n\");\n this.get('/Terminal').feed(console._dump(e)+\"\\n\");\n if (e.line) {\n var lines = src.split(\"\\n\");\n var start = Math.max(0, e.line - 10);\n var end = Math.min(lines.length, e.line + 10);\n for (var i =start ; i < end; i++) {\n if (i == e.line) {\n this.get('/Terminal').feed(\">>>>>\" + lines[i] + \"\\n\");\n continue;\n }\n this.get('/Terminal').feed(lines[i] + \"\\n\");\n }\n \n }\n \n return;\n }\n this.get('/BottomPane').el.set_current_page(1);\n this.get('/Terminal').el.fork_command( null , [], [], \"/tmp\", false,false,false); \n var cmd = \"/usr/bin/seed /tmp/BuilderGtkView.js\\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n /*\n var _top = x.get_global_object()._top;\n \n _top.el.set_screen(Gdk.Screen.get_default()); // just in case..\n _top.el.show_all();\n if (_top.el.popup) {\n _top.el.popup(null, null, null, null, 3, null);\n }\n*/\n}\n", - "|viewAdd": "function(item, par)\n {\n // does something similar to xobject..\n item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;\n \n if (item.pack===false || item.pack === 'false') { // no ;\n return;\n }\n print(\"CREATE: \" + item['|xns'] + '.' + item['xtype']);\n var type = item['|xns'] + '.' + item['xtype'];\n var ns = imports.gi[item['|xns']];\n var ctr = ns[item['xtype']];\n var ctr_args = { };\n for(var k in item) {\n var kv = item[k];\n if (typeof(kv) == 'object' || typeof(kv) == 'function') {\n continue;\n }\n if ( \n k == 'pack' ||\n k == 'items' ||\n k == 'id' ||\n k == 'xtype' ||\n k == 'xdebug' ||\n k == 'xns' ||\n k == '|xns'\n ) {\n continue;\n }\n\n\tif (k[0] == '|' && typeof(kv) == 'string') {\n\n\t\tif (kv.match(new RegExp('function'))) {\n\t\t\tcontinue;\n }\n\t\t print(\"WASL \" + k + '=' + kv);\n\t\ttry {\n\t\t\teval( 'kv = ' + kv);\n\t\t} catch(e) { continue; }\n \n\t\tk = k.substring(1);\n // print(k + '=' + kv);\n\t}\n if (k[0] == '|') { // should be boolean or number..\n\t\tk = k.substring(1);\n\t\t//print(k + '=' + kv);\n }\n \n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n kv = true;\n }\n print(k + '=' + typeof(kv) + \" : \" + kv);\n ctr_args[k] = kv;\n \n } \n \n \n var el = new ctr(ctr_args);\n \n print(\"PACK\" + item.pack);\n //console.dump(item.pack);\n \n \n \n \n var args = [];\n var pack_m = false;\n if (typeof(item.pack) == 'string') {\n \n item.pack.split(',').forEach(function(e, i) {\n \n if (e == 'false') { args.push( false); return; }\n if (e == 'true') { args.push( true); return; }\n if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }\n args.push(e);\n });\n //print(args.join(\",\"));\n \n pack_m = args.shift();\n } else {\n pack_m = item.pack.shift();\n args = item.pack;\n }\n \n // handle error.\n if (pack_m && typeof(par[pack_m]) == 'undefined') {\n throw {\n name: \"ArgumentError\", \n message : 'pack method not available : ' + par.id + \" : \" + par + '.' + pack_m +\n \"ADDING : \" + item.id + \" \" + el\n \n\t };\n\n return;\n }\n \n console.dump(args);\n args.unshift(el);\n //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');\n //Seed.print('args: ' + args.length);\n if (pack_m) {\n par[pack_m].apply(par, args);\n }\n \n var _this = this;\n item.items = item.items || [];\n item.items.forEach(function(ch,n) {\n\n print (\"type:\" + type);\n \n print (\"ch.pack:\" + ch.pack);\n if (type == 'Gtk.Table' && ch.pack == 'add') {\n var c = n % item.n_columns;\n var r = Math.floor(n/item.n_columns);\n ch.pack = [ 'attach', c, c+1, r, r+1, \n typeof(ch.x_options) == 'undefined' ? 5 : ch.x_options,\n typeof(ch.y_options) == 'undefined' ? 5 : ch.y_options,\n typeof(ch.x_padding) == 'undefined' ? 0 : ch.x_padding,\n typeof(ch.x_padding) == 'undefined' ? 0 : ch.x_padding\n ].join(',');\n }\n \n _this.viewAdd(ch, el);\n });\n \n \n \n // add the signal handlers.\n // is it a widget!?!!?\n \n \n try {\n \n \n el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));\n el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));\n el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));\n el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));\n el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));\n } catch(e) {\n // ignore!\n }\n \n \n \n return el;\n \n}", + "|viewAdd": "function(item, par)\n {\n // does something similar to xobject..\n item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;\n \n if (item.pack===false || item.pack === 'false') { // no ;\n return;\n }\n print(\"CREATE: \" + item['|xns'] + '.' + item['xtype']);\n var type = item['|xns'] + '.' + item['xtype'];\n \n if (item['|xns'] == 'GtkClutter') { // we can not add this yet!\n return false;\n }\n var ns = imports.gi[item['|xns']];\n var ctr = ns[item['xtype']];\n var ctr_args = { };\n for(var k in item) {\n var kv = item[k];\n if (typeof(kv) == 'object' || typeof(kv) == 'function') {\n continue;\n }\n if ( \n k == 'pack' ||\n k == 'items' ||\n k == 'id' ||\n k == 'xtype' ||\n k == 'xdebug' ||\n k == 'xns' ||\n k == '|xns'\n ) {\n continue;\n }\n\n\tif (k[0] == '|' && typeof(kv) == 'string') {\n\n\t\tif (kv.match(new RegExp('function'))) {\n\t\t\tcontinue;\n }\n\t\t print(\"WASL \" + k + '=' + kv);\n\t\ttry {\n\t\t\teval( 'kv = ' + kv);\n\t\t} catch(e) { continue; }\n \n\t\tk = k.substring(1);\n // print(k + '=' + kv);\n\t}\n if (k[0] == '|') { // should be boolean or number..\n\t\tk = k.substring(1);\n\t\t//print(k + '=' + kv);\n }\n \n\tif (k == 'show_tabs') { // force tab showing for notebooks.\n kv = true;\n }\n print(k + '=' + typeof(kv) + \" : \" + kv);\n ctr_args[k] = kv;\n \n } \n \n \n var el = new ctr(ctr_args);\n \n print(\"PACK\" + item.pack);\n //console.dump(item.pack);\n \n \n \n \n var args = [];\n var pack_m = false;\n if (typeof(item.pack) == 'string') {\n \n item.pack.split(',').forEach(function(e, i) {\n \n if (e == 'false') { args.push( false); return; }\n if (e == 'true') { args.push( true); return; }\n if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }\n args.push(e);\n });\n //print(args.join(\",\"));\n \n pack_m = args.shift();\n } else {\n pack_m = item.pack.shift();\n args = item.pack;\n }\n \n // handle error.\n if (pack_m && typeof(par[pack_m]) == 'undefined') {\n throw {\n name: \"ArgumentError\", \n message : 'pack method not available : ' + par.id + \" : \" + par + '.' + pack_m +\n \"ADDING : \" + item.id + \" \" + el\n \n\t };\n\n return;\n }\n \n console.dump(args);\n args.unshift(el);\n //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');\n //Seed.print('args: ' + args.length);\n if (pack_m) {\n par[pack_m].apply(par, args);\n }\n \n var _this = this;\n item.items = item.items || [];\n item.items.forEach(function(ch,n) {\n\n print (\"type:\" + type);\n \n print (\"ch.pack:\" + ch.pack);\n if (type == 'Gtk.Table' && ch.pack == 'add') {\n var c = n % item.n_columns;\n var r = Math.floor(n/item.n_columns);\n ch.pack = [ 'attach', c, c+1, r, r+1, \n typeof(ch.x_options) == 'undefined' ? 5 : ch.x_options,\n typeof(ch.y_options) == 'undefined' ? 5 : ch.y_options,\n typeof(ch.x_padding) == 'undefined' ? 0 : ch.x_padding,\n typeof(ch.x_padding) == 'undefined' ? 0 : ch.x_padding\n ].join(',');\n }\n \n _this.viewAdd(ch, el);\n });\n \n \n \n // add the signal handlers.\n // is it a widget!?!!?\n \n \n try {\n \n \n el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));\n el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));\n el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));\n el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));\n el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));\n } catch(e) {\n // ignore!\n }\n \n \n \n return el;\n \n}", "|widgetDragDropEvent": "function() {\n print(\"WIDGET DRAGDROP\"); \n return true;\n}\n", "|widgetDragMotionEvent": "function() {\n print(\"WIDGET DRAGMOTION\"); \n return true;\n}\n", "|widgetExposeEvent": "function(w, evt, ud, item) {\n var widget = w;\n if (this.inRender) {\n return false;\n }\n \n if ( this.highlightWidget) {\n this.inRender = true;\n if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {\n Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);\n }\n this.inRender = false;\n return false;\n }\n \n \n if (this.activePath != item.xtreepath) {\n return false;\n }\n \n // print(\"HIGHLIGHT: \" + item.xtreepath ); // draw highlight??\n // work out the coords of the window..\n if (!this.gc) {\n var dr = widget.window;\n this.gc = (new Gdk.GC.c_new(dr));\n this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));\n this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);\n }\n\n \n var r = evt.expose.area;\n // console.dump([r.x, r.y, r.width, r.height ] );\n //return false;\n// print(widget.get_parent().toString().match(/GtkScrolledWindow/);\n if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak\n // happens with gtkscrollview embedded stuff..\n var np =this.activePath.split(':');\n np.pop();\n this.activePath = np.join(':');\n this.renderedEl.queue_draw();\n return true;\n\n \n }\n\n \n \n \n this.box = {\n x : r.x - 2,\n y : r.y - 2,\n w: r.width + 4,\n h: r.height + 4\n }; \n // let's draw it..\n this.inRender = true;\n\n \n this.highlightWidget = widget;\n \n \n \n\n // print(\"DRAW BOX\");\n //console.dump(this.box);\n Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);\n this.inRender = false;\n return false;\n}\n", @@ -984,12 +985,12 @@ "|show_line_numbers": true, "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}" - } + "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}" + }, + "pack": "set_buffer", + "xtype": "Buffer", + "|xns": "GtkSource" } ] } @@ -1169,5 +1170,6 @@ } ] } - ] + ], + "permname": "" } \ No newline at end of file diff --git a/Builder/Window.js b/Builder/Window.js index 7f91a896a..9c9d09688 100644 --- a/Builder/Window.js +++ b/Builder/Window.js @@ -7,6 +7,7 @@ GObject = imports.gi.GObject; GtkSource = imports.gi.GtkSource; WebKit = imports.gi.WebKit; Vte = imports.gi.Vte; +GtkClutter = imports.gi.GtkClutter; console = imports.console; XObject = imports.XObject.XObject; Window=new XObject({ @@ -452,68 +453,6 @@ Window=new XObject({ items : [ { xtype: Gtk.TreeView, - pack : "add", - id : "view", - headers_visible : false, - enable_tree_lines : true, - tooltip_column : 1, - init : function() { - XObject.prototype.init.call(this); - var description = new Pango.FontDescription.c_new(); - description.set_size(8000); - this.el.modify_font(description); - - this.selection = this.el.get_selection(); - this.selection.set_mode( Gtk.SelectionMode.SINGLE); - var _this = this; - - // is this really needed?? - this.selection.signal['changed'].connect(function() { - _this.get('/LeftTree.view').listeners.cursor_changed.apply( - _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), ''] - ); - }); - - Gtk.drag_source_set ( - this.el, /* widget will be drag-able */ - Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */ - null, /* lists of target to support */ - 0, /* size of list */ - Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */ - ); - - Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList); - - Gtk.drag_source_add_text_targets(this.el); - 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 | Gdk.DragAction.MOVE /* what to do with data after dropped */ - ); - - Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); - Gtk.drag_dest_add_text_targets(this.el); - }, - highlight : function(treepath_ar) { - - // highlighting for drag/drop - if (treepath_ar.length && treepath_ar[0].length ) { - this.el.set_drag_dest_row( - new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]); - } else { - this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER); - } - - }, - selectNode : function(treepath_str) { - //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str)); - var tp = new Gtk.TreePath.from_string(treepath_str); - this.el.set_cursor(tp, null, false); - this.el.scroll_to_cell(tp, null, false, 0,0); - }, listeners : { button_press_event : function (self, ev) { console.log("button press?"); @@ -757,7 +696,7 @@ Window=new XObject({ // _g.button.set_label(''+value.get_string()); var pm =this.get('/RightPalete.model'); - pm.load( this.get('/RightPalete').provider.gatherList( + pm.load( this.get('/LeftTree').getPaleteProvider().gatherList( this.get('/LeftTree.model').listAllTypes())); @@ -770,6 +709,68 @@ Window=new XObject({ } }, + id : "view", + pack : "add", + tooltip_column : 1, + enable_tree_lines : true, + headers_visible : false, + highlight : function(treepath_ar) { + + // highlighting for drag/drop + if (treepath_ar.length && treepath_ar[0].length ) { + this.el.set_drag_dest_row( + new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]); + } else { + this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER); + } + + }, + init : function() { + XObject.prototype.init.call(this); + var description = new Pango.FontDescription.c_new(); + description.set_size(8000); + this.el.modify_font(description); + + this.selection = this.el.get_selection(); + this.selection.set_mode( Gtk.SelectionMode.SINGLE); + var _this = this; + + // is this really needed?? + this.selection.signal['changed'].connect(function() { + _this.get('/LeftTree.view').listeners.cursor_changed.apply( + _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), ''] + ); + }); + + Gtk.drag_source_set ( + this.el, /* widget will be drag-able */ + Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */ + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */ + ); + + Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList); + + Gtk.drag_source_add_text_targets(this.el); + 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 | Gdk.DragAction.MOVE /* what to do with data after dropped */ + ); + + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + Gtk.drag_dest_add_text_targets(this.el); + }, + selectNode : function(treepath_str) { + //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str)); + var tp = new Gtk.TreePath.from_string(treepath_str); + this.el.set_cursor(tp, null, false); + this.el.scroll_to_cell(tp, null, false, 0,0); + }, items : [ { xtype: Gtk.TreeStore, @@ -778,7 +779,7 @@ Window=new XObject({ id : "model", pack : "set_model", changed : function(n, refresh) { - print("MODEL CHANGED CALLED" + this.activePath); + // print("MODEL CHANGED CALLED" + this.activePath); if (this.activePath) { var iter = new Gtk.TreeIter(); this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath)) @@ -789,7 +790,7 @@ Window=new XObject({ } //this.currentTree = this.toJS(false, true)[0]; this.file.items = this.toJS(false, false); - print("AFTER CHANGED"); + // print("AFTER CHANGED"); //console.dump(this.file.items); this.file.save(); this.currentTree = this.file.items[0]; @@ -2123,7 +2124,7 @@ Window=new XObject({ showEditor = true; } if (val[0] == '|') { - if (rval.match(/function/g) || rval.match(/\n/g)) { + if (rval.match(/function/g) || rval.match(/\n/g) || rval.length > 20) { showEditor = true; } } @@ -2172,7 +2173,7 @@ Window=new XObject({ return val; } var type = this.getType(this.el.get_path(iter).to_string()); - print("TYPE: " +type + " - val:" + val); + //print("TYPE: " +type + " - val:" + val); switch(type.toLowerCase()) { case 'number': case 'uint': @@ -2584,7 +2585,18 @@ Window=new XObject({ items : [ { xtype: Gtk.ListStore, + id : "model", pack : "set_model", + getValue : function(treepath, col) + { + var tp = new Gtk.TreePath.from_string (treepath); + var iter = new Gtk.TreeIter(); + this.el.get_iter (iter, tp); + var value = new GObject.Value(''); + this.el.get_value(iter, col, value); + return value.value; + + }, init : function() { XObject.prototype.init.call(this); this.el.set_column_types ( 6, [ @@ -2597,16 +2609,6 @@ Window=new XObject({ ] ); }, - getValue : function(treepath, col) - { - var tp = new Gtk.TreePath.from_string (treepath); - var iter = new Gtk.TreeIter(); - this.el.get_iter (iter, tp); - var value = new GObject.Value(''); - this.el.get_value(iter, col, value); - return value.value; - - }, showData : function(type) { this.el.clear(); if (!this.get('/MidPropTree').activeElement || !type) { @@ -2626,7 +2628,9 @@ Window=new XObject({ this.get('/MidPropTree').shown = true; } - var elementList = palete.getPropertiesFor(fullpath, type); + var elementList = palete.getPropertiesFor(fullpath, type).sort(function(a,b) { + return a.name > b.name ? 1 : -1; + }); print ("GOT " + elementList.length + " items for " + fullpath + "|" + type); // console.dump(elementList); @@ -2651,8 +2655,7 @@ Window=new XObject({ } - }, - id : "model" + } }, { xtype: Gtk.TreeViewColumn, @@ -2722,27 +2725,36 @@ Window=new XObject({ { 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); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }, + shadow_type : Gtk.ShadowType.IN, items : [ { xtype: WebKit.WebView, listeners : { load_finished : function (self, object) { + print("load finished"); + // print("load_finished"); return; // if (this.ready) { // dont do it twice! // return; //} - - this.el.get_inspector().show(); + if (!this.inspectorShown) { + this.el.get_inspector().show(); + this.inspectorShown = true; + } + this.ready = true; - this.pendingRedraw = false; - var js = this.get('/LeftTree.model').toJS(); - if (js && js[0]) { - this.renderJS(js[0]); - } + + if (this.pendingRedraw) { + this.pendingRedraw = false; + this.refreshRequired = true; + } + //var js = this.get('/LeftTree.model').toJS(); + //if (js && js[0]) { + // this.renderJS(js[0]); + //} }, script_alert : function (self, object, p0) { @@ -2751,6 +2763,7 @@ Window=new XObject({ return true; // do not display anything... }, console_message : function (self, object, p0, p1) { + print(object); // console.log(object); if (!object.match(/^\{/)) { @@ -2888,8 +2901,9 @@ Window=new XObject({ Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); return true; }, - resource_request_starting : function (self, object, p0, p1, p2) { - // this.get('/Terminal').feed( p1.get_uri() ); + create_web_view : function (self, object) { + print("CREATE WEB VIEW"); + return null; //new WebKit.WebView(); } }, id : "view", @@ -2899,19 +2913,30 @@ Window=new XObject({ // this may not work!? var settings = this.el.get_settings(); settings.enable_developer_extras = true; - // settings.enable_file_access_from_file_uris = true; - // settings.enable_offline_web_application_cache - true; - // settings.enable_universal_access_from_file_uris = true; + + // this was an attempt to change the url perms.. did not work.. + // settings.enable_file_access_from_file_uris = true; + // settings.enable_offline_web_application_cache - true; + // settings.enable_universal_access_from_file_uris = true; var _this = this; + // init inspector.. this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) { - _this.get('/BottomPane.inspector').el.show(); - return _this.get('/BottomPane.inspector').el; - //create_inspector_cb + _this.get('/BottomPane.inspector').el.show(); + return _this.get('/BottomPane.inspector').el; + }); - - this.el.open('file:///' + __script_path__ + '/../builder.html'); + // FIXME - base url of script.. + // we need it so some of the database features work. + this.el.load_html_string( "Render not ready" , + //fixme - should be a config option! + // or should we catch stuff and fix it up.. + 'http://localhost/app.Builder/' + ); + + + //this.el.open('file:///' + __script_path__ + '/../builder.html'); Gtk.drag_dest_set ( @@ -2924,31 +2949,67 @@ Window=new XObject({ // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + + GLib.timeout_add_seconds(0, 1, function() { + // print("run refresh?"); + _this.runRefresh(); + return true; + }); + + }, renderJS : function(data) { - print("HTML RENDERING"); - this.get('/BottomPane').el.show(); - this.get('/BottomPane').el.set_current_page(2);// webkit view! - /// prevent looping.. - //if (this.pendingRedraw) { - // print("pending redraw active?!"); - // return; - //} + this.refreshRequired = true; + }, + runRefresh : function() + { + // this is run every 2 seconds from the init.. + + + + if (!this.refreshRequired) { + // print("no refresh required"); + return; + } + + if (this.lastRedraw) { + // do not redraw if last redraw was less that 5 seconds ago. + if (((new Date()) - this.lastRedraw) < 5000) { + return; + } + } - if (!this.get('/Window.LeftTree').getActiveFile()) { + + + if (!this.get('/Window.LeftTree').getActiveFile()) { + return; + } + this.refreshRequired = false; + // print("HTML RENDERING"); + + this.get('/BottomPane').el.show(); + this.get('/BottomPane').el.set_current_page(2);// webkit inspector + + + var js = this.get('/LeftTree.model').toJS(); + if (!js || !js.length) { + print("no data"); return; } + var data = js[0]; - var project = this.get('/Window.LeftTree').getActiveFile().project; - //print (project.fn); - project.runhtml = project.runhtml || ''; + var project = this.get('/Window.LeftTree').getActiveFile().project; + //print (project.fn); + // set it to non-empty. + project.runhtml = project.runhtml || ''; + project.runhtml = project.runhtml.length ? project.runhtml : ''; - this.runhtml = this.runhtml || ''; + this.runhtml = this.runhtml || ''; - if (project.runhtml != this.runhtml) { + if (project.runhtml != this.runhtml) { // then we need to reload the browser using // load_html_string.. @@ -2957,13 +3018,6 @@ Window=new XObject({ var runhtml = ''+ "\n" ; - // this.runhtml = ''+ "\n" ; - // this.runhtml += ''+ "\n" ; - // this.runhtml += ''+ "\n" ; this.runhtml = project.runhtml; // need to modify paths @@ -2975,15 +3029,14 @@ Window=new XObject({ print("LOAD HTML " + html); this.el.load_html_string( html , //fixme - should be a config option! - 'http://www.akbkhome.com/e/' + 'http://localhost/app.Builder/' ); - // should trigger load_finished! + + // should trigger load_finished! - which in truns shoudl set refresh Required; return; } - this.pendingRedraw = false; - this.renderedData = data; var str = JSON.stringify(data) ; @@ -2991,11 +3044,12 @@ Window=new XObject({ 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.lastRedraw = new Date(); + this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");"); - + print( "before render" + this.lastRedraw); + print( "after render" + (new Date())); + } } ] @@ -3020,19 +3074,21 @@ Window=new XObject({ this.highlightWidget = false; this.withDebug = false; - - if (this.renderedEl) { - this.get('view').el.remove(this.renderedEl); - this.renderedEl.destroy(); - this.renderedEl = false; + while (this.get('view').el.get_children().length) { + var c = this.get('view').el.get_children()[0]; + this.get('view').el.remove(c); + c.destroy(); } - if (!data) { - return; + if (!data) { + return; } + 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); + + this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el); + } catch (e) { print(e.message); return; @@ -3040,11 +3096,12 @@ Window=new XObject({ 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 - ); + if (this.renderedEl) { + this.renderedEl.set_size_request( + tree.default_width || 600, + tree.default_height || 400 + ); + } this.get('view').el.show_all(); @@ -3112,6 +3169,10 @@ Window=new XObject({ } print("CREATE: " + item['|xns'] + '.' + item['xtype']); var type = item['|xns'] + '.' + item['xtype']; + + if (item['|xns'] == 'GtkClutter') { // we can not add this yet! + return false; + } var ns = imports.gi[item['|xns']]; var ctr = ns[item['xtype']]; var ctr_args = { }; @@ -3648,7 +3709,6 @@ Window=new XObject({ items : [ { xtype: GtkSource.Buffer, - pack : "set_buffer", listeners : { changed : function (self) { var s = new Gtk.TextIter(); @@ -3662,9 +3722,9 @@ Window=new XObject({ this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({ red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC })); - print("SYNTAX ERROR IN EDITOR"); - print(e); - console.dump(e); + //print("SYNTAX ERROR IN EDITOR"); + //print(e); + //console.dump(e); return; } this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({ @@ -3673,7 +3733,8 @@ Window=new XObject({ this.get('/LeftPanel.model').changed( str , false); } - } + }, + pack : "set_buffer" } ] } diff --git a/ClutterTest/Window.bjs b/ClutterTest/Window.bjs index ca897f76d..6be88a802 100644 --- a/ClutterTest/Window.bjs +++ b/ClutterTest/Window.bjs @@ -1,5 +1,5 @@ { - "id": "file-gtk-12", + "id": "file-gtk-13", "name": "Window", "parent": "", "title": false, @@ -13,24 +13,22 @@ "|xns": "Gtk", "items": [ { - "listeners": { - "show": "function() { \n var stage = this.el.get_stage(); \n print(this.items.length);\n this.items.forEach( \n function(e) { \n print(e.xtype);\n stage.add_actor(e.el);\n }\n );\n}" - }, "pack": "add", "xtype": "Embed", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "pack": false, "x": 10, "xtype": "Actor", "y": 10, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { - "clicked": "function (self) {\n Clutter = imports.gi.Clutter;\n var animate = this.parent.el.animate(\n\t\tClutter.AnimationMode.EASE_OUT_ELASTIC, 2000,\n\t\t{\n\t\t\t scale_x : 5,\n\t\t\t scale_y: 5,\n\n\t\t}\n\t\t);\n\t\tanimate.timeline.start();\n\n}" + "clicked": "function (self) {\n Clutter = imports.gi.Clutter;\n var animate = this.parent.el.animate(\n Clutter.AnimationMode.EASE_OUT_ELASTIC, 2000,\n {\n\t scale_x : 5,\n\t scale_y: 5,\n\n }\n );\n animate.timeline.start();\n\n}" }, "height_request": 100, "label": "project list", @@ -46,8 +44,8 @@ "x": 10, "xtype": "Actor", "y": 150, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n print (\"actor.items\");\n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { @@ -67,8 +65,8 @@ "x": 10, "xtype": "Actor", "y": 300, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { @@ -88,8 +86,8 @@ "x": 10, "xtype": "Actor", "y": 450, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { @@ -109,8 +107,8 @@ "x": 150, "xtype": "Actor", "y": 450, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { @@ -130,8 +128,8 @@ "x": 150, "xtype": "Actor", "y": 10, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { @@ -151,8 +149,8 @@ "x": 100, "xtype": "Actor", "y": 300, - "|init": "function() {\n\n var child = new XObject(this.items[0]);\n child.init();\n child.parent = this;\n //var contents = new Gtk.Button({ label: 'test' }); \n var contents = child.el;\n \n print(JSON.stringify(this.items));\n \n \n this.el = new GtkClutter.Actor.with_contents ( contents) ;\n XObject.prototype.init.call(this);\n}\n", "|xns": "GtkClutter", + "listeners": {}, "items": [ { "listeners": { @@ -171,5 +169,6 @@ } ] } - ] + ], + "permname": "" } \ No newline at end of file diff --git a/ClutterTest/Window.js b/ClutterTest/Window.js index 7a54c0235..24fc97268 100644 --- a/ClutterTest/Window.js +++ b/ClutterTest/Window.js @@ -21,18 +21,6 @@ Window=new XObject({ items : [ { xtype: GtkClutter.Embed, - listeners : { - show : function() { - var stage = this.el.get_stage(); - print(this.items.length); - this.items.forEach( - function(e) { - print(e.xtype); - stage.add_actor(e.el); - } - ); - } - }, pack : "add", items : [ { @@ -40,20 +28,6 @@ Window=new XObject({ pack : false, x : 10, y : 10, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, @@ -84,20 +58,6 @@ Window=new XObject({ pack : false, x : 10, y : 150, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - print ("actor.items"); - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, @@ -128,20 +88,6 @@ Window=new XObject({ pack : false, x : 10, y : 300, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, @@ -172,20 +118,6 @@ Window=new XObject({ pack : false, x : 10, y : 450, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, @@ -216,20 +148,6 @@ Window=new XObject({ pack : false, x : 150, y : 450, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, @@ -260,20 +178,6 @@ Window=new XObject({ pack : false, x : 150, y : 10, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, @@ -304,20 +208,6 @@ Window=new XObject({ pack : false, x : 100, y : 300, - init : function() { - - var child = new XObject(this.items[0]); - child.init(); - child.parent = this; - //var contents = new Gtk.Button({ label: 'test' }); - var contents = child.el; - - print(JSON.stringify(this.items)); - - - this.el = new GtkClutter.Actor.with_contents ( contents) ; - XObject.prototype.init.call(this); - }, items : [ { xtype: Gtk.Button, diff --git a/XObject.js b/XObject.js index ffa41ea40..83e335ad1 100644 --- a/XObject.js +++ b/XObject.js @@ -55,6 +55,9 @@ GObject = imports.gi.GObject; function XObject (cfg) { // first apply cfg if set. //print("new XOBJECT!!!"); + + //print ("XObject ctr"); + this.config = {}; this.constructor = XObject; @@ -63,13 +66,22 @@ function XObject (cfg) { // start by seeing if we have a base class.... try { // loocks for XObject/Gtk/TreeView.js [ TreeView = { .... } ] - var base = imports.XObject[cfg.xns][cfg.xtype][cfg.xtype]; - for (var i in base) { - this[i] = base[i]; + // xns is not a string!!!? + var gname = false; + if (typeof(cfg.xtype) == 'object') { + gname = GObject.type_name(cfg.xtype.type); + // print("GNAME:" +gname + " GTYPE:"+cfg.xtype.type); } - } catch (e) { + var base = gname ? imports.XObjectBase[gname][gname] : false; + if (base) { + // print("Overlaying XOBJBECT-BASE." + cfg.xtype); + XObject.extend(this,base); + } + } catch (e) { + // if debug? + print("error finding " + gname + " - " + e.toString()); } @@ -113,10 +125,38 @@ function XObject (cfg) { } + // interesting question should we call constructor on items here... + // as the real work is done in init anyway.. + var _this= this; - - - + var items = []; + this.items.forEach(function(i) { + items.push(i); + }); + this.items = []; + items.forEach(function(i,n) { + /* + + if (type == 'GtkTable' && i.pack == 'add') { + var c = n % _this.config.n_columns; + var r = Math.floor(n/_this.config.n_columns); + i.pack = [ 'attach', c, c+1, r, r+1, + typeof(i.x_options) == 'undefined' ? 5 : i.x_options, + typeof(i.y_options) == 'undefined' ? 5 : i.y_options, + typeof(i.x_padding) == 'undefined' ? 0 : i.x_padding, + typeof(i.x_padding) == 'undefined' ? 0 : i.x_padding + + ] + } + */ + var item = (i.constructor == XObject) ? o : new XObject(i); + item.parent = _this; + _this.items.push(item); + //_this.addItem(i); + }); + if (this.onConstruct) { + this.onConstruct.call(this); + } } @@ -150,13 +190,13 @@ XObject.prototype = { init : function() { - var items = []; - this.items.forEach(function(i) { - items.push(i); - }); + // var items = []; + //this.items.forEach(function(i) { + // items.push(i); + //}); // remove items. this.listeners = this.listeners || {}; - this.items = []; + //this.items = []; // do we need to call 'beforeInit here?' @@ -236,25 +276,11 @@ XObject.prototype = { //} var type = this.xtype.type ? GObject.type_name(this.xtype.type) : ''; - print("MAKE " + type); - + print("add children to " + type); var _this=this; - items.forEach(function(i,n) { - - if (type == 'GtkTable' && i.pack == 'add') { - var c = n % _this.config.n_columns; - var r = Math.floor(n/_this.config.n_columns); - i.pack = [ 'attach', c, c+1, r, r+1, - typeof(i.x_options) == 'undefined' ? 5 : i.x_options, - typeof(i.y_options) == 'undefined' ? 5 : i.y_options, - typeof(i.x_padding) == 'undefined' ? 0 : i.x_padding, - typeof(i.x_padding) == 'undefined' ? 0 : i.x_padding - - ] - } - - _this.addItem(i); + this.items.forEach(function(i,n) { + _this.addItem(i,n); }) @@ -262,6 +288,8 @@ XObject.prototype = { this.addListener(i, this.listeners[i]); } + this.init = XObject.emptyFn; + // delete this.listeners ? // do again so child props work! @@ -275,16 +303,16 @@ XObject.prototype = { * uses pack property to determine how to add it. * @arg cfg {Object} same as XObject constructor. */ - addItem : function(o) { - if (typeof(o) == 'undefined') { + addItem : function(item, pos) + { + + if (typeof(item) == 'undefined') { print("Invalid Item added to this!"); imports.console.dump(this); Seed.quit(); } // what about extended items!?!?!? - var item = (o.constructor == XObject) ? o : new XObject(o); - item.parent = this; - this.items.push(item); + item.init(); //print("CTR:PROTO:" + ( item.id ? item.id : '??')); // print("addItem - call init [" + item.pack.join(',') + ']'); @@ -295,15 +323,18 @@ XObject.prototype = { } - if (item.pack===false) { // no + if (item.pack===false) { // no packing.. various items have this .. return; } - if (typeof(item.pack) == 'function') { + + if (typeof(item.pack) == 'function') { // pack is a function.. // parent, child item.pack.apply(item, [ this , item ]); item.parent = this; return; } + + // pack = 'add,x,y' var args = []; var pack_m = false; if (typeof(item.pack) == 'string') { @@ -332,16 +363,32 @@ XObject.prototype = { } - - - return; } + // finally call the pack method //Seed.print('Pack ' + this.el + '.'+ pack_m + '(' + item.el + ')'); - + args.unshift(item.el); + + + + if (this.parent && this.parent.xtype == 'GtkTable' && item.pack == 'add') { + var c = n % this.parent.config.n_columns; + var r = Math.floor(pos/_this.parent.config.n_columns); + item.pack = [ 'attach', c, c+1, r, r+1, + typeof(item.x_options) == 'undefined' ? 5 : item.x_options, + typeof(item.y_options) == 'undefined' ? 5 : item.y_options, + typeof(item.x_padding) == 'undefined' ? 0 : item.x_padding, + typeof(item.x_padding) == 'undefined' ? 0 : item.x_padding + + ]; + } + + + + if (XObject.debug) print(pack_m + '[' + args.join(',') +']'); //Seed.print('args: ' + args.length); if (pack_m) { @@ -551,7 +598,12 @@ XObject.extend(XObject, * */ cache: { }, - + /** + * Empty function + * + */ + emptyFn : function () { }, + /** * Copies all the properties of config to obj, if the do not exist. * @param {Object} obj The receiver of the properties diff --git a/roojs1 b/roojs1 index 9f5cd7b88..e6f019d15 160000 --- a/roojs1 +++ b/roojs1 @@ -1 +1 @@ -Subproject commit 9f5cd7b8819fcbf8a81a376001e841245ca07ac5 +Subproject commit e6f019d1535671672e34eb6a46fa31b9a98fedb2 -- 2.39.2