From 48c8b2fc9bda5825704ed41611a97932d0a854a1 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Sun, 1 Feb 2015 21:32:29 +0800 Subject: [PATCH] Attribute changed old-javascript --- old-javascript/Builder3/About.bjs | 24 + old-javascript/Builder3/About.js | 31 + old-javascript/Builder3/DialogConfirm.bjs | 1 + old-javascript/Builder3/DialogConfirm.js | 45 + .../Builder3/DialogNewComponent.bjs | 158 + old-javascript/Builder3/DialogNewComponent.js | 244 + .../Builder3/DialogSaveTemplate.bjs | 1 + old-javascript/Builder3/DialogSaveTemplate.js | 85 + .../Builder3/DialogTemplateSelect.bjs | 1 + .../Builder3/DialogTemplateSelect.js | 156 + old-javascript/Builder3/EditProject.bjs | 1 + old-javascript/Builder3/EditProject.js | 184 + old-javascript/Builder3/Editor.bjs | 89 + old-javascript/Builder3/Editor.js | 230 + old-javascript/Builder3/Globals.js | 20 + old-javascript/Builder3/Main.js | 46 + .../Builder3/RooProjectProperties.bjs | 1 + .../Builder3/RooProjectProperties.js | 137 + .../Builder3/StandardErrorDialog.bjs | 1 + .../Builder3/StandardErrorDialog.js | 37 + old-javascript/Builder3/Window.bjs | 1186 +++++ old-javascript/Builder3/Window.js | 4340 +++++++++++++++++ old-javascript/Builder4/About.bjs | 25 + old-javascript/Builder4/About.vala | 49 + old-javascript/Builder4/Application.vala | 187 + old-javascript/Builder4/ClutterFiles.bjs | 112 + old-javascript/Builder4/ClutterFiles.vala | 378 ++ old-javascript/Builder4/DialogConfirm.bjs | 26 + old-javascript/Builder4/DialogConfirm.vala | 55 + .../Builder4/DialogNewComponent.bjs | 163 + .../Builder4/DialogNewComponent.vala | 614 +++ old-javascript/Builder4/DialogSaveModule.bjs | 56 + old-javascript/Builder4/DialogSaveModule.vala | 213 + .../Builder4/DialogSaveTemplate.bjs | 56 + .../Builder4/DialogSaveTemplate.vala | 209 + .../Builder4/DialogTemplateSelect.bjs | 74 + .../Builder4/DialogTemplateSelect.vala | 277 ++ old-javascript/Builder4/EditProject.bjs | 97 + old-javascript/Builder4/EditProject.vala | 402 ++ old-javascript/Builder4/Editor.bjs | 95 + old-javascript/Builder4/Editor.vala | 421 ++ old-javascript/Builder4/GladeExtras.vala | 12 + old-javascript/Builder4/GladeView.bjs | 19 + old-javascript/Builder4/GladeView.vala | 102 + old-javascript/Builder4/GtkView.bjs | 105 + old-javascript/Builder4/GtkView.vala | 387 ++ old-javascript/Builder4/Main.vala | 35 + old-javascript/Builder4/MainWindow.bjs | 578 +++ old-javascript/Builder4/MainWindow.vala | 2972 +++++++++++ old-javascript/Builder4/ProjectSettings.bjs | 124 + old-javascript/Builder4/ProjectSettings.vala | 439 ++ .../Builder4/RooProjectProperties.bjs | 64 + .../Builder4/RooProjectProperties.vala | 322 ++ .../Builder4/StandardErrorDialog.bjs | 25 + .../Builder4/StandardErrorDialog.vala | 69 + .../Builder4/ValaProjectSettings.bjs | 413 ++ .../Builder4/ValaProjectSettings.vala | 1675 +++++++ old-javascript/Builder4/WindowAddProp.bjs | 61 + old-javascript/Builder4/WindowAddProp.vala | 255 + .../Builder4/WindowLeftProjects.bjs | 75 + .../Builder4/WindowLeftProjects.vala | 295 ++ old-javascript/Builder4/WindowLeftProps.bjs | 305 ++ old-javascript/Builder4/WindowLeftProps.vala | 1645 +++++++ old-javascript/Builder4/WindowLeftTree.bjs | 132 + old-javascript/Builder4/WindowLeftTree.vala | 1566 ++++++ old-javascript/Builder4/WindowRightPalete.bjs | 80 + .../Builder4/WindowRightPalete.vala | 313 ++ old-javascript/Builder4/WindowRooView.bjs | 111 + old-javascript/Builder4/WindowRooView.vala | 673 +++ old-javascript/Builder4/config1.builder | 34 + old-javascript/JSDOC/Collapse.js | 260 + old-javascript/JSDOC/Identifier.js | 25 + old-javascript/JSDOC/Lang.js | 158 + old-javascript/JSDOC/TextStream.js | 49 + old-javascript/JSDOC/Token.js | 111 + old-javascript/JSDOC/TokenReader.js | 489 ++ old-javascript/JSDOC/TokenStream.js | 281 ++ old-javascript/JsRender/Base.js | 413 ++ old-javascript/JsRender/Gtk.js | 745 +++ old-javascript/JsRender/Gtk.vala | 241 + old-javascript/JsRender/JsRender.vala | 388 ++ old-javascript/JsRender/Lang.js | 155 + old-javascript/JsRender/Lang.vala | 230 + old-javascript/JsRender/Node.vala | 527 ++ old-javascript/JsRender/NodeToGlade.vala | 410 ++ old-javascript/JsRender/NodeToGtk.vala | 390 ++ old-javascript/JsRender/NodeToJs.vala | 442 ++ old-javascript/JsRender/NodeToVala.vala | 772 +++ old-javascript/JsRender/Roo.js | 673 +++ old-javascript/JsRender/Roo.vala | 640 +++ old-javascript/JsRender/webkit_extension.c | 20 + old-javascript/Palete/Base.js | 194 + old-javascript/Palete/Gir.vala | 893 ++++ old-javascript/Palete/Gtk.js | 612 +++ old-javascript/Palete/Gtk.vala | 243 + old-javascript/Palete/GtkUsage.txt | 290 ++ old-javascript/Palete/Javascript.vala | 114 + old-javascript/Palete/Palete.vala | 462 ++ old-javascript/Palete/Roo.js | 138 + old-javascript/Palete/Roo.vala | 183 + old-javascript/Palete/RooUsage.txt | 552 +++ old-javascript/Palete/ValaSource.vala | 199 + old-javascript/Palete/rooprops.json | 1 + old-javascript/Project/Base.js | 359 ++ old-javascript/Project/Gtk.js | 30 + old-javascript/Project/Gtk.vala | 318 ++ old-javascript/Project/Project.vala | 538 ++ old-javascript/Project/Roo.js | 28 + old-javascript/Project/Roo.vala | 20 + old-javascript/XObjectBase/GdkDockBar.js | 25 + old-javascript/XObjectBase/GdlDock.js | 25 + old-javascript/XObjectBase/GdlDockItem.js | 51 + .../XObjectBase/GtkCellRendererText.js | 16 + .../XObjectBase/GtkCellRendererToggle.js | 16 + old-javascript/XObjectBase/GtkClutterActor.js | 61 + old-javascript/XObjectBase/GtkClutterEmbed.js | 41 + old-javascript/XObjectBase/GtkExpander.js | 36 + old-javascript/XObjectBase/GtkListStore.js | 105 + old-javascript/XObjectBase/GtkNotebook.js | 38 + .../XObjectBase/GtkScrolledWindow.js | 31 + old-javascript/XObjectBase/GtkTable.js | 32 + .../XObjectBase/GtkTreeModelFilter.js | 71 + .../XObjectBase/GtkTreeSelection.js | 58 + old-javascript/XObjectBase/GtkTreeStore.js | 42 + old-javascript/XObjectBase/GtkTreeView.js | 121 + .../XObjectBase/GtkTreeViewColumn.js | 74 + old-javascript/XObjectBase/WebKitWebView.js | 31 + old-javascript/builder.sh | 9 + 128 files changed, 36889 insertions(+) create mode 100644 old-javascript/Builder3/About.bjs create mode 100644 old-javascript/Builder3/About.js create mode 100644 old-javascript/Builder3/DialogConfirm.bjs create mode 100644 old-javascript/Builder3/DialogConfirm.js create mode 100644 old-javascript/Builder3/DialogNewComponent.bjs create mode 100644 old-javascript/Builder3/DialogNewComponent.js create mode 100644 old-javascript/Builder3/DialogSaveTemplate.bjs create mode 100644 old-javascript/Builder3/DialogSaveTemplate.js create mode 100644 old-javascript/Builder3/DialogTemplateSelect.bjs create mode 100644 old-javascript/Builder3/DialogTemplateSelect.js create mode 100644 old-javascript/Builder3/EditProject.bjs create mode 100644 old-javascript/Builder3/EditProject.js create mode 100644 old-javascript/Builder3/Editor.bjs create mode 100644 old-javascript/Builder3/Editor.js create mode 100644 old-javascript/Builder3/Globals.js create mode 100644 old-javascript/Builder3/Main.js create mode 100644 old-javascript/Builder3/RooProjectProperties.bjs create mode 100644 old-javascript/Builder3/RooProjectProperties.js create mode 100644 old-javascript/Builder3/StandardErrorDialog.bjs create mode 100644 old-javascript/Builder3/StandardErrorDialog.js create mode 100644 old-javascript/Builder3/Window.bjs create mode 100644 old-javascript/Builder3/Window.js create mode 100644 old-javascript/Builder4/About.bjs create mode 100644 old-javascript/Builder4/About.vala create mode 100644 old-javascript/Builder4/Application.vala create mode 100644 old-javascript/Builder4/ClutterFiles.bjs create mode 100644 old-javascript/Builder4/ClutterFiles.vala create mode 100644 old-javascript/Builder4/DialogConfirm.bjs create mode 100644 old-javascript/Builder4/DialogConfirm.vala create mode 100644 old-javascript/Builder4/DialogNewComponent.bjs create mode 100644 old-javascript/Builder4/DialogNewComponent.vala create mode 100644 old-javascript/Builder4/DialogSaveModule.bjs create mode 100644 old-javascript/Builder4/DialogSaveModule.vala create mode 100644 old-javascript/Builder4/DialogSaveTemplate.bjs create mode 100644 old-javascript/Builder4/DialogSaveTemplate.vala create mode 100644 old-javascript/Builder4/DialogTemplateSelect.bjs create mode 100644 old-javascript/Builder4/DialogTemplateSelect.vala create mode 100644 old-javascript/Builder4/EditProject.bjs create mode 100644 old-javascript/Builder4/EditProject.vala create mode 100644 old-javascript/Builder4/Editor.bjs create mode 100644 old-javascript/Builder4/Editor.vala create mode 100644 old-javascript/Builder4/GladeExtras.vala create mode 100644 old-javascript/Builder4/GladeView.bjs create mode 100644 old-javascript/Builder4/GladeView.vala create mode 100644 old-javascript/Builder4/GtkView.bjs create mode 100644 old-javascript/Builder4/GtkView.vala create mode 100644 old-javascript/Builder4/Main.vala create mode 100644 old-javascript/Builder4/MainWindow.bjs create mode 100644 old-javascript/Builder4/MainWindow.vala create mode 100644 old-javascript/Builder4/ProjectSettings.bjs create mode 100644 old-javascript/Builder4/ProjectSettings.vala create mode 100644 old-javascript/Builder4/RooProjectProperties.bjs create mode 100644 old-javascript/Builder4/RooProjectProperties.vala create mode 100644 old-javascript/Builder4/StandardErrorDialog.bjs create mode 100644 old-javascript/Builder4/StandardErrorDialog.vala create mode 100644 old-javascript/Builder4/ValaProjectSettings.bjs create mode 100644 old-javascript/Builder4/ValaProjectSettings.vala create mode 100644 old-javascript/Builder4/WindowAddProp.bjs create mode 100644 old-javascript/Builder4/WindowAddProp.vala create mode 100644 old-javascript/Builder4/WindowLeftProjects.bjs create mode 100644 old-javascript/Builder4/WindowLeftProjects.vala create mode 100644 old-javascript/Builder4/WindowLeftProps.bjs create mode 100644 old-javascript/Builder4/WindowLeftProps.vala create mode 100644 old-javascript/Builder4/WindowLeftTree.bjs create mode 100644 old-javascript/Builder4/WindowLeftTree.vala create mode 100644 old-javascript/Builder4/WindowRightPalete.bjs create mode 100644 old-javascript/Builder4/WindowRightPalete.vala create mode 100644 old-javascript/Builder4/WindowRooView.bjs create mode 100644 old-javascript/Builder4/WindowRooView.vala create mode 100644 old-javascript/Builder4/config1.builder create mode 100644 old-javascript/JSDOC/Collapse.js create mode 100644 old-javascript/JSDOC/Identifier.js create mode 100644 old-javascript/JSDOC/Lang.js create mode 100644 old-javascript/JSDOC/TextStream.js create mode 100644 old-javascript/JSDOC/Token.js create mode 100644 old-javascript/JSDOC/TokenReader.js create mode 100644 old-javascript/JSDOC/TokenStream.js create mode 100644 old-javascript/JsRender/Base.js create mode 100644 old-javascript/JsRender/Gtk.js create mode 100644 old-javascript/JsRender/Gtk.vala create mode 100644 old-javascript/JsRender/JsRender.vala create mode 100644 old-javascript/JsRender/Lang.js create mode 100644 old-javascript/JsRender/Lang.vala create mode 100644 old-javascript/JsRender/Node.vala create mode 100644 old-javascript/JsRender/NodeToGlade.vala create mode 100644 old-javascript/JsRender/NodeToGtk.vala create mode 100644 old-javascript/JsRender/NodeToJs.vala create mode 100644 old-javascript/JsRender/NodeToVala.vala create mode 100644 old-javascript/JsRender/Roo.js create mode 100644 old-javascript/JsRender/Roo.vala create mode 100644 old-javascript/JsRender/webkit_extension.c create mode 100644 old-javascript/Palete/Base.js create mode 100644 old-javascript/Palete/Gir.vala create mode 100644 old-javascript/Palete/Gtk.js create mode 100644 old-javascript/Palete/Gtk.vala create mode 100644 old-javascript/Palete/GtkUsage.txt create mode 100644 old-javascript/Palete/Javascript.vala create mode 100644 old-javascript/Palete/Palete.vala create mode 100755 old-javascript/Palete/Roo.js create mode 100644 old-javascript/Palete/Roo.vala create mode 100644 old-javascript/Palete/RooUsage.txt create mode 100644 old-javascript/Palete/ValaSource.vala create mode 120000 old-javascript/Palete/rooprops.json create mode 100644 old-javascript/Project/Base.js create mode 100755 old-javascript/Project/Gtk.js create mode 100644 old-javascript/Project/Gtk.vala create mode 100644 old-javascript/Project/Project.vala create mode 100755 old-javascript/Project/Roo.js create mode 100644 old-javascript/Project/Roo.vala create mode 100644 old-javascript/XObjectBase/GdkDockBar.js create mode 100644 old-javascript/XObjectBase/GdlDock.js create mode 100644 old-javascript/XObjectBase/GdlDockItem.js create mode 100644 old-javascript/XObjectBase/GtkCellRendererText.js create mode 100644 old-javascript/XObjectBase/GtkCellRendererToggle.js create mode 100644 old-javascript/XObjectBase/GtkClutterActor.js create mode 100644 old-javascript/XObjectBase/GtkClutterEmbed.js create mode 100644 old-javascript/XObjectBase/GtkExpander.js create mode 100644 old-javascript/XObjectBase/GtkListStore.js create mode 100644 old-javascript/XObjectBase/GtkNotebook.js create mode 100644 old-javascript/XObjectBase/GtkScrolledWindow.js create mode 100644 old-javascript/XObjectBase/GtkTable.js create mode 100644 old-javascript/XObjectBase/GtkTreeModelFilter.js create mode 100644 old-javascript/XObjectBase/GtkTreeSelection.js create mode 100644 old-javascript/XObjectBase/GtkTreeStore.js create mode 100644 old-javascript/XObjectBase/GtkTreeView.js create mode 100644 old-javascript/XObjectBase/GtkTreeViewColumn.js create mode 100644 old-javascript/XObjectBase/WebKitWebView.js create mode 100755 old-javascript/builder.sh diff --git a/old-javascript/Builder3/About.bjs b/old-javascript/Builder3/About.bjs new file mode 100644 index 000000000..a3040081f --- /dev/null +++ b/old-javascript/Builder3/About.bjs @@ -0,0 +1,24 @@ +{ + "id": "file-gtk-8", + "name": "About", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Sample/About.bjs", + "items": [ + { + "listeners": { + "response": "function (self, response_id) {\n this.el.hide();\n}", + "delete_event": "function (self, event) {\n this.el.hide();\n return true;\n}" + }, + "authors": "Alan Knowles", + "copyright": "LGPL", + "license": "LGPL", + "program_name": "app.Builder.js", + "website": "http://www.akbkhome.com/blog.php", + "xtype": "AboutDialog", + "|modal": true, + "|xns": "Gtk" + } + ], + "permname": "" +} \ No newline at end of file diff --git a/old-javascript/Builder3/About.js b/old-javascript/Builder3/About.js new file mode 100644 index 000000000..122b62109 --- /dev/null +++ b/old-javascript/Builder3/About.js @@ -0,0 +1,31 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; + console = imports.console; +XObject = imports.XObject.XObject; +About=new XObject({ + xtype: Gtk.AboutDialog, + listeners : { + response : function (self, response_id) { + this.el.hide(); + }, + delete_event : function (self, event) { + this.el.hide(); + return true; + } + }, + authors : "Alan Knowles", + copyright : "LGPL", + license : "LGPL", + program_name : "app.Builder.js", + website : "http://www.akbkhome.com/blog.php", + modal : true +}); +About.init(); +XObject.cache['/About'] = About; diff --git a/old-javascript/Builder3/DialogConfirm.bjs b/old-javascript/Builder3/DialogConfirm.bjs new file mode 100644 index 000000000..9652e906b --- /dev/null +++ b/old-javascript/Builder3/DialogConfirm.bjs @@ -0,0 +1 @@ +{"id":"file-gtk-9","name":"DialogConfirm","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/DialogConfirm.bjs","items":[{"|xns":"Gtk","xtype":"MessageDialog","|show":"function(msg, success) {\n if (!this.el) {\n this.init();\n }\n this.success = success;\n this.el.text = msg;\n this.el.show_all();\n\n}\n","|buttons":"Gtk.ButtonsType.YES_NO","title":"Please Confirm","|message_type":"Gtk.MessageType.QUESTION","|use_markup":true,"text":"-","|modal":true,"listeners":{"response":"function (self, response_id) {\n this.el.hide();\nprint(\"RESPOSE: \" + response_id);\n if (response_id == -8) { //yes!\n print(\"CALL SUCCES?\")\n this.success();\n }\n}","delete_event":"function (self, event) {\n this.el.hide();\n return true;\n}"}}]} \ No newline at end of file diff --git a/old-javascript/Builder3/DialogConfirm.js b/old-javascript/Builder3/DialogConfirm.js new file mode 100644 index 000000000..70703aca5 --- /dev/null +++ b/old-javascript/Builder3/DialogConfirm.js @@ -0,0 +1,45 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +DialogConfirm=new XObject({ + xtype: Gtk.MessageDialog, + show : function(msg, success) { + if (!this.el) { + this.init(); + } + this.success = success; + this.el.text = msg; + this.el.show_all(); + + }, + buttons : Gtk.ButtonsType.YES_NO, + title : "Please Confirm", + message_type : Gtk.MessageType.QUESTION, + use_markup : true, + text : "-", + modal : true, + listeners : { + response : function (self, response_id) { + this.el.hide(); + print("RESPOSE: " + response_id); + if (response_id == -8) { //yes! + print("CALL SUCCES?") + this.success(); + } + }, + delete_event : function (self, event) { + this.el.hide(); + return true; + } + } +}); +DialogConfirm.init(); +XObject.cache['/DialogConfirm'] = DialogConfirm; diff --git a/old-javascript/Builder3/DialogNewComponent.bjs b/old-javascript/Builder3/DialogNewComponent.bjs new file mode 100644 index 000000000..f0be17b72 --- /dev/null +++ b/old-javascript/Builder3/DialogNewComponent.bjs @@ -0,0 +1,158 @@ +{ + "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/old-javascript/Builder3/DialogNewComponent.js b/old-javascript/Builder3/DialogNewComponent.js new file mode 100644 index 000000000..ed0375c51 --- /dev/null +++ b/old-javascript/Builder3/DialogNewComponent.js @@ -0,0 +1,244 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +DialogNewComponent=new XObject({ + xtype: Gtk.Dialog, + listeners : { + delete_event : function (self, event) { + this.el.hide(); + return true; + }, + response : function (self, response_id) { + if (response_id < 1) { // cancel! + this.el.hide(); + return; + } + + if (!this.get('name').el.get_text().length ) { + this.get('/StandardErrorDialog').show( + "You have to set Project name " + ); + + return; + } + var isNew = this.file.name.length ? false : true; + + if (this.file.name.length && this.file.name != this.get('name').el.get_text()) { + this.get('/StandardErrorDialog').show( + "Sorry changing names does not work yet. " + ); + + return; + } + for (var i in this.def) { + this.file[i] = this.get(i).el.get_text(); + } + + if (!isNew) { + this.file.save(); + this.el.hide(); + return; + } + + + var dir =''; + for (var i in this.project.paths) { + dir = i; + break; + } + + + + // what about .js ? + if (GLib.file_test (GLib.dir + '/' + this.file.name + '.bjs', GLib.FileTest.EXISTS)) { + StandardErrorDialog.show( + "That file already exists" + ); + return; + } + this.el.hide(); + + + //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue()); + + var _this = this; + var nf = _this.project.create(dir + '/' + this.file.name + '.bjs'); + for (var i in this.file) { + nf[i] = this.file[i]; + } + if (this.get('/DialogNewComponent').success) { + this.get('/DialogNewComponent').success(_this.project, nf); + } + }, + show : function (self) { + this.el.show_all(); + } + }, + default_height : 200, + default_width : 500, + id : "DialogNewComponent", + title : "New Component", + deletable : false, + modal : true, + show : function (c) + { + this.project = c.project; + if (!this.el) { + this.init(); + } + this.def = { + name : '' , + title : '' , + region : '' , + parent: '', + // disable: '', + modOrder : '0', + permname : '' + }; + for (var i in this.def) { + c[i] = c[i] || this.def[i]; + this.get(i).el.set_text(c[i]); + } + if (c.name) { + this.el.set_title("Edit File Details - " + c.name); + } else { + this.el.set_title("Create New File"); + } + + this.file = c; + console.log('show all'); + this.el.show_all(); + this.success = c.success; + + + }, + items : [ + { + xtype: Gtk.VBox, + pack : function(p,e) { + p.el.get_content_area().add(e.el) + }, + items : [ + { + xtype: Gtk.Table, + n_columns : 2, + n_rows : 3, + pack : "pack_start,false,false,0", + homogeneous : false, + items : [ + { + xtype: Gtk.Label, + label : "Component Name", + pack : "add", + x_options : 4, + xalign : 0.9, + justify : Gtk.Justification.RIGHT + }, + { + xtype: Gtk.Entry, + id : "name", + pack : "add", + visible : true + }, + { + xtype: Gtk.Label, + label : "Title", + pack : "add", + x_options : 4, + xalign : 0.9, + justify : Gtk.Justification.RIGHT, + visible : true + }, + { + xtype: Gtk.Entry, + id : "title", + pack : "add", + visible : true + }, + { + xtype: Gtk.Label, + label : "Region", + pack : "add", + tooltip_text : "center, north, south, east, west", + x_options : 4, + xalign : 0.9, + justify : Gtk.Justification.RIGHT, + visible : true + }, + { + xtype: Gtk.Entry, + id : "region", + pack : "add", + visible : true + }, + { + xtype: Gtk.Label, + label : "Parent Name", + pack : "add", + x_options : 4, + xalign : 0.9, + justify : Gtk.Justification.RIGHT, + visible : true + }, + { + xtype: Gtk.Entry, + id : "parent", + pack : "add", + visible : true + }, + { + xtype: Gtk.Label, + label : "Permission Name", + pack : "add", + x_options : 4, + xalign : 0.9, + justify : Gtk.Justification.RIGHT, + visible : true + }, + { + xtype: Gtk.Entry, + id : "permname", + pack : "add", + visible : true + }, + { + xtype: Gtk.Label, + label : "Order (for tabs)", + pack : "add", + x_options : 4, + xalign : 0.9, + justify : Gtk.Justification.RIGHT, + visible : true + }, + { + xtype: Gtk.Entry, + id : "modOrder", + pack : "add", + visible : true + } + ] + } + ] + }, + { + xtype: Gtk.Button, + pack : "add_action_widget,0", + label : "Cancel" + }, + { + xtype: Gtk.Button, + pack : "add_action_widget,1", + label : "OK" + } + ] +}); +DialogNewComponent.init(); +XObject.cache['/DialogNewComponent'] = DialogNewComponent; diff --git a/old-javascript/Builder3/DialogSaveTemplate.bjs b/old-javascript/Builder3/DialogSaveTemplate.bjs new file mode 100644 index 000000000..d4a4882cf --- /dev/null +++ b/old-javascript/Builder3/DialogSaveTemplate.bjs @@ -0,0 +1 @@ +{"id":"file-gtk-8","name":"DialogSaveTemplate","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/DialogSaveTemplate.bjs","items":[{"listeners":{"delete_event":"function (self, event) {\n this.el.hide();\n return true;\n}","response":"function (self, response_id) {\n\n if (!response_id) {\n this.el.hide();\n return;\n }\n var name = this.get('name').el.get_text();\n if (!name.length) {\n this.get('/StandardErrorDialog').show(\n \"You must give the template a name. \"\n );\n return;\n }\n \n if (!name.match(/^[A-Z ]+$/i) || !name.match(/[A-Z]/i)) {\n this.get('/StandardErrorDialog').show(\n \"Template Nane must contain only letters and spaces. \"\n );\n return;\n }\n this.get('/Window.LeftTree').getPaleteProvider().saveTemplate(name, this.data);\n // now we save it..\n this.el.hide();\n \n}"},"default_height":200,"default_width":400,"xtype":"Dialog","|modal":true,"|show":"function(data) {\n this.data = data;\n this.get('name').el.set_text('');\n this.el.show_all();\n}\n","|xns":"Gtk","items":[{"xtype":"HBox","|pack":"function(p,e) {\n p.el.get_content_area().add(e.el)\n }\n","|xns":"Gtk","items":[{"label":"Name","pack":"add","xtype":"Label","|xns":"Gtk","listeners":{}},{"id":"name","pack":"add","xtype":"Entry","|xns":"Gtk"}]},{"label":"Cancel","pack":"add_action_widget,0","xtype":"Button","|xns":"Gtk"},{"label":"OK","pack":"add_action_widget,1","xtype":"Button","|xns":"Gtk"}]}],"project":"{\"name\":\"Sample\",\"xtype\":\"Gtk\",\"paths\":{\"/home/alan/gitlive/app.Builder.js/Sample\":\"dir\"},\"id\":\"project-gtk-1\",\"fn\":\"329624934046af6e88a65a3f36971958\",\"file\":false,\"runhtml\":\"\"}"} \ No newline at end of file diff --git a/old-javascript/Builder3/DialogSaveTemplate.js b/old-javascript/Builder3/DialogSaveTemplate.js new file mode 100644 index 000000000..c82c49d3c --- /dev/null +++ b/old-javascript/Builder3/DialogSaveTemplate.js @@ -0,0 +1,85 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +DialogSaveTemplate=new XObject({ + xtype: Gtk.Dialog, + listeners : { + delete_event : function (self, event) { + this.el.hide(); + return true; + }, + response : function (self, response_id) { + + if (!response_id) { + this.el.hide(); + return; + } + var name = this.get('name').el.get_text(); + if (!name.length) { + this.get('/StandardErrorDialog').show( + "You must give the template a name. " + ); + return; + } + + if (!name.match(/^[A-Z ]+$/i) || !name.match(/[A-Z]/i)) { + this.get('/StandardErrorDialog').show( + "Template Nane must contain only letters and spaces. " + ); + return; + } + this.get('/Window.LeftTree').getPaleteProvider().saveTemplate(name, this.data); + // now we save it.. + this.el.hide(); + + } + }, + default_height : 200, + default_width : 400, + modal : true, + show : function(data) { + this.data = data; + this.get('name').el.set_text(''); + this.el.show_all(); + }, + items : [ + { + xtype: Gtk.HBox, + pack : function(p,e) { + p.el.get_content_area().add(e.el) + }, + items : [ + { + xtype: Gtk.Label, + label : "Name", + pack : "add" + }, + { + xtype: Gtk.Entry, + id : "name", + pack : "add" + } + ] + }, + { + xtype: Gtk.Button, + label : "Cancel", + pack : "add_action_widget,0" + }, + { + xtype: Gtk.Button, + label : "OK", + pack : "add_action_widget,1" + } + ] +}); +DialogSaveTemplate.init(); +XObject.cache['/DialogSaveTemplate'] = DialogSaveTemplate; diff --git a/old-javascript/Builder3/DialogTemplateSelect.bjs b/old-javascript/Builder3/DialogTemplateSelect.bjs new file mode 100644 index 000000000..bd33682df --- /dev/null +++ b/old-javascript/Builder3/DialogTemplateSelect.bjs @@ -0,0 +1 @@ +{"id":"file-gtk-9","name":"DialogTemplateSelect","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/DialogTemplateSelect.bjs","items":[{"listeners":{"delete_event":"function (self, event) {\n this.el.hide();\n return true;\n}"},"default_height":200,"default_width":400,"xtype":"Dialog","|modal":true,"|show":"function(node) {\n \n var pal = this.get('/Window.LeftTree').getPaleteProvider();\n var opts = pal.listTemplates(node);\n if (!opts.length) {\n return node;\n }\n \n opts.unshift({ path: '' , name :'Just add Element' });\n this.get('combo.model').loadData(opts);\n this.get('combo').el.set_active(0);\n \n this.el.show_all();\n this.el.run();\n this.el.hide();\n var ix = this.get('combo').el.get_active();\n if (ix < 1 ) {\n return node;\n }\n \n\n return pal.loadTemplate(opts[ix].path)\n\n}\n","|xns":"Gtk","items":[{"xtype":"VBox","|pack":"function(p,e) {\n p.el.get_content_area().add(e.el)\n }\n","|xns":"Gtk","items":[{"pack":"pack_start,false,false,0","xtype":"HBox","|xns":"Gtk","listeners":{},"items":[{"label":"Select Template : ","pack":"pack_start,false,false","xtype":"Label","|xns":"Gtk"},{"id":"combo","pack":"add","xtype":"ComboBox","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 1 );\n}\n","|xns":"Gtk","items":[{"pack":"pack_start","xtype":"CellRendererText","|xns":"Gtk"},{"id":"model","pack":"set_model","xtype":"ListStore","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING // real type\n \n \n ] );\n}\n","|loadData":"function (data) {\n this.el.clear(); \n var iter = new Gtk.TreeIter();\n var el = this.el;\n data.forEach(function(p) {\n\n el.append(iter);\n \n \n el.set_value(iter, 0, ''+ p.path);\n el.set_value(iter, 1, ''+ p.name);\n \n });\n \n \n}\n","|xns":"Gtk"}]}]}]},{"label":"OK","pack":"add_action_widget,0","xtype":"Button","|xns":"Gtk"}]}],"project":"{\"name\":\"Sample\",\"xtype\":\"Gtk\",\"paths\":{\"/home/alan/gitlive/app.Builder.js/Sample\":\"dir\"},\"id\":\"project-gtk-1\",\"fn\":\"329624934046af6e88a65a3f36971958\",\"file\":false,\"runhtml\":\"\"}"} \ No newline at end of file diff --git a/old-javascript/Builder3/DialogTemplateSelect.js b/old-javascript/Builder3/DialogTemplateSelect.js new file mode 100644 index 000000000..c561c451a --- /dev/null +++ b/old-javascript/Builder3/DialogTemplateSelect.js @@ -0,0 +1,156 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +DialogTemplateSelect=new XObject({ + xtype: Gtk.Dialog, + listeners : { + delete_event : function (self, event) { + this.el.hide(); + return true; + } + }, + default_height : 200, + default_width : 400, + modal : true, + show : function(node) { + + var pal = this.get('/Window.LeftTree').getPaleteProvider(); + var opts = pal.listTemplates(node); + if (!opts.length) { + return node; + } + + + var dopts = []; + + + dopts.push({ path: '' , name :'Just add Element' }); + + + + + var project = this.get('/Window.LeftTree').getActiveFile().project; + var m = project.dbcon ? project.dbcon + '_' : false; + + + //print (project.fn); + + opts.forEach(function(p) { + // if we have a dbname - ignore _ named. + if (m && p.name.match(/_/) && + p.name.substring(0, m.length) != m) { + return; + + } + dopts.push(p); + }); + + + this.get('combo.model').loadData(dopts); + this.get('combo').el.set_active(0); + + this.el.show_all(); + this.el.run(); + this.el.hide(); + var ix = this.get('combo').el.get_active(); + if (ix < 1 ) { + return node; + } + + return pal.loadTemplate(dopts[ix].path) + + }, + items : [ + { + xtype: Gtk.VBox, + pack : function(p,e) { + p.el.get_content_area().add(e.el) + }, + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,false,0", + items : [ + { + xtype: Gtk.Label, + label : "Select Template : ", + pack : "pack_start,false,false" + }, + { + xtype: Gtk.ComboBox, + id : "combo", + pack : "add", + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 1 ); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start" + }, + { + xtype: Gtk.ListStore, + id : "model", + pack : "set_model", + init : function() { + XObject.prototype.init.call(this); + this.el.set_column_types ( 2, [ + GObject.TYPE_STRING, // real key + GObject.TYPE_STRING // real type + + + ] ); + }, + loadData : function (data) { + this.el.clear(); + + var project = this.get('/Window.LeftTree').getActiveFile().project; + var m = project.dbcon ? project.dbcon + '_' : false; + + + //print (project.fn); + var el = this.el; + data.forEach(function(p) { + // if we have a dbname - ignore _ named. + if (m && p.name.match(/_/) && + p.name.substring(0, m.length) != m) { + return; + + } + + var iret = {}; + el.append(iret); + + + el.set_value(iret.iter, 0, ''+ p.path); + el.set_value(iret.iter, 1, ''+ p.name); + + }); + + + } + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.Button, + label : "OK", + pack : "add_action_widget,0" + } + ] +}); +DialogTemplateSelect.init(); +XObject.cache['/DialogTemplateSelect'] = DialogTemplateSelect; diff --git a/old-javascript/Builder3/EditProject.bjs b/old-javascript/Builder3/EditProject.bjs new file mode 100644 index 000000000..fca92efe6 --- /dev/null +++ b/old-javascript/Builder3/EditProject.bjs @@ -0,0 +1 @@ +{"id":"file-gtk-12","name":"EditProject","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/EditProject.bjs","items":[{"|xns":"Gtk","xtype":"Dialog","default_height":500,"default_width":600,"|deletable":true,"|modal":true,"border_width":3,"title":"Project Properties","|show":"function(c) {\n c = c || { name : '' , xtype : '' };\n this.project = c;\n if (!this.el) {\n this.init();\n }\n var _this = this;\n [ 'xtype' ].forEach(function(k) {\n _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n });\n\t// shouild set path..\n \n this.el.show_all();\n this.success = c.success;\n}\n","listeners":{"destroy_event":"function (self, event) {\n this.el.hide();\n return false;\n}","response":"function (self, id) {\n if (id < 1) {\n this.el.hide();\n return;\n }\n if (!this.get('xtype').getValue().length) {\n this.get('/StandardErrorDialog').show(\"You have to set Project type\"); \n return;\n }\n if (!this.get('dir').el.get_filename().length) {\n this.get('/StandardErrorDialog').show(\"You have to select a folder\"); \n return;\n }\n\n this.el.hide();\n \n \n var fn = this.get('dir').el.get_filename();\n \n this.project.name = GLib.basename(fn);\n this.project.xtype = this.get('xtype').getValue();\n this.project.paths = {};\n this.project.paths[fn] = 'dir' ;\n \n var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);\n \n this.success(pr);\n Seed.print(id);\n}"},"items":[{"|xns":"Gtk","xtype":"VBox","|pack":" function(p,e) {\n p.el.get_content_area().add(e.el)\n }\n","items":[{"|xns":"Gtk","xtype":"HBox","pack":"pack_start,false,true,3","items":[{"|xns":"Gtk","xtype":"Label","pack":"pack_start,false,true,3","label":"Project type :"},{"|xns":"Gtk","xtype":"ComboBox","pack":"pack_end,true,true,3","id":"xtype","|setValue":"function(v)\n {\n var el = this.el;\n el.set_active(-1);\n this.get('model').data.forEach(function(n, ix) {\n if (v == n.xtype) {\n el.set_active(ix);\n return false;\n }\n });\n }","|getValue":"function() {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return '';\n }\n return this.get('model').data[ix].xtype;\n}\n","|init":"function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 1 ); \n}\n","items":[{"|xns":"Gtk","xtype":"CellRendererText","pack":"pack_start"},{"|xns":"Gtk","xtype":"ListStore","pack":"set_model","|init":"function() {\n XObject.prototype.init.call(this);\n\n this.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING // real type\n \n \n ] );\n \n this.data = [\n { xtype: 'Roo', desc : \"Roo Project\" },\n { xtype: 'Gtk', desc : \"Gtk Project\" }, \n //{ xtype: 'JS', desc : \"Javascript Class\" }\n ]\n \n this.loadData(this.data);\n \n}\n","|loadData":"function (data) {\n \n var iter = new Gtk.TreeIter();\n var el = this.el;\n data.forEach(function(p) {\n \n el.append(iter);\n \n \n el.set_value(iter, 0, p.xtype);\n el.set_value(iter, 1, p.desc);\n \n });\n \n \n}\n","id":"model"}]}]},{"|xns":"Gtk","xtype":"FileChooserWidget","pack":"pack_end,true,true,5","|action":"Gtk.FileChooserAction.SELECT_FOLDER","id":"dir","|select_multiple":false}]},{"|xns":"Gtk","xtype":"Button","pack":"add_action_widget,1","label":"OK"},{"|xns":"Gtk","xtype":"Button","pack":"add_action_widget,0","label":"Cancel"}]}]} \ No newline at end of file diff --git a/old-javascript/Builder3/EditProject.js b/old-javascript/Builder3/EditProject.js new file mode 100644 index 000000000..28a8da02b --- /dev/null +++ b/old-javascript/Builder3/EditProject.js @@ -0,0 +1,184 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +EditProject=new XObject({ + xtype: Gtk.Dialog, + default_height : 500, + default_width : 600, + deletable : true, + modal : true, + border_width : 3, + title : "Project Properties", + show : function(c) { + c = c || { name : '' , xtype : '' }; + this.project = c; + if (!this.el) { + this.init(); + } + var _this = this; + [ 'xtype' ].forEach(function(k) { + _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]); + }); + // shouild set path.. + + this.el.show_all(); + this.success = c.success; + }, + listeners : { + destroy_event : function (self, event) { + this.el.hide(); + return false; + }, + response : function (self, id) { + if (id < 1) { + this.el.hide(); + return; + } + if (!this.get('xtype').getValue().length) { + this.get('/StandardErrorDialog').show("You have to set Project type"); + return; + } + if (!this.get('dir').el.get_filename().length) { + this.get('/StandardErrorDialog').show("You have to select a folder"); + return; + } + + this.el.hide(); + + + var fn = this.get('dir').el.get_filename(); + + this.project.name = GLib.basename(fn); + this.project.xtype = this.get('xtype').getValue(); + this.project.paths = {}; + this.project.paths[fn] = 'dir' ; + + var pr = imports.ProjectManager.ProjectManager.update(this.project); + + this.success(pr); + Seed.print(id); + } + }, + items : [ + { + xtype: Gtk.VBox, + pack : function(p,e) { + p.el.get_content_area().pack_start(e.el,true,true,3); + }, + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true,3", + items : [ + { + xtype: Gtk.Label, + pack : "pack_start,false,true,3", + label : "Project type :" + }, + { + xtype: Gtk.ComboBox, + pack : "pack_end,true,true,3", + id : "xtype", + setValue : function(v) + { + var el = this.el; + el.set_active(-1); + this.get('model').data.forEach(function(n, ix) { + if (v == n.xtype) { + el.set_active(ix); + return false; + } + return true; + }); + }, + getValue : function() { + var ix = this.el.get_active(); + if (ix < 0 ) { + return ''; + } + return this.get('model').data[ix].xtype; + }, + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 1 ); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start" + }, + { + xtype: Gtk.ListStore, + pack : "set_model", + init : function() { + XObject.prototype.init.call(this); + + this.el.set_column_types ( 2, [ + GObject.TYPE_STRING, // real key + GObject.TYPE_STRING // real type + + + ] ); + + this.data = [ + { xtype: 'Roo', desc : "Roo Project" }, + { xtype: 'Gtk', desc : "Gtk Project" }, + //{ xtype: 'JS', desc : "Javascript Class" } + ] + + this.loadData(this.data); + + }, + loadData : function (data) { + + var el = this.el; + data.forEach(function(p) { + var ret = {}; + el.append(ret); + + + el.set_value(ret.iter, 0, p.xtype); + el.set_value(ret.iter, 1, p.desc); + + }); + + + }, + id : "model" + } + ] + } + ] + }, + + { + xtype: Gtk.FileChooserWidget, + pack : "pack_end,true,true,5", + action : Gtk.FileChooserAction.SELECT_FOLDER, + id : "dir", + select_multiple : false + } + ] + }, + { + xtype: Gtk.Button, + pack : "add_action_widget,1", + label : "OK" + }, + { + xtype: Gtk.Button, + pack : "add_action_widget,0", + label : "Cancel" + } + ] +}); +EditProject.init(); +XObject.cache['/EditProject'] = EditProject; diff --git a/old-javascript/Builder3/Editor.bjs b/old-javascript/Builder3/Editor.bjs new file mode 100644 index 000000000..28a678499 --- /dev/null +++ b/old-javascript/Builder3/Editor.bjs @@ -0,0 +1,89 @@ +{ + "id": "file-gtk-10", + "name": "Editor", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Sample/Editor.bjs", + "items": [ + { + "listeners": { + "delete_event": "function (self, event) {\n if (!this.get('/Editor.RightEditor').save()) {\n // no hiding with errors.\n return true;\n }\n this.el.hide();\n this.get('/Editor').activePath = false;\n return true;\n}", + "configure_event": "function (self, object) {\n this.pos = this.el.get_position();\n\n\n return false;\n}", + "show": "function (self) {\n if (this.pos) {\n this.el.set_uposition(this.pos.root_x,this.pos.root_y);\n }\n}" + }, + "height_request": 300, + "id": "EditorWindow", + "title": "Application Builder - Editor", + "width_request": 500, + "xtype": "Window", + "|save": "function (self, event) {\n if (!this.get('/Editor.RightEditor').save()) {\n // no hiding with errors.\n return true;\n }\n this.get('/Editor').activePath = false;\n this.el.hide();\n return true;\n}", + "|init": "function() {\n XObject.prototype.init.call(this);\n // this.show_all();\n}\n", + "|xns": "Gtk", + "items": [ + { + "pack": "add", + "xtype": "VBox", + "|xns": "Gtk", + "items": [ + { + "pack": "pack_start,false,true", + "xtype": "Toolbar", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "clicked": "function (self) {\n\n this.get('/Editor.RightEditor').save();\n}" + }, + "id": "save_button", + "label": "Save", + "xtype": "Button", + "|xns": "Gtk" + } + ] + }, + { + "id": "RightEditor", + "pack": "add", + "xtype": "ScrolledWindow", + "|save": "function() {\n // make sure we have an active path..\n if (!this.get('/Editor').activePath) {\n return true;\n }\n \n var str = this.get('/Editor.buffer').toString();\n if (!this.get('/Editor.buffer').checkSyntax()) {\n this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n return false;\n }\n \n this.get('/LeftPanel.model').changed( str , false);\n this.get('/Editor').dirty = false;\n this.get('/Editor.save_button').el.sensitive = false;\n return true;\n}\n", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "key_release_event": "function (self, event) {\n \n if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {\n print(\"SAVE: ctrl-S pressed\");\n this.save();\n return false;\n }\n // print(event.key.keyval)\n \n return false;\n}" + }, + "id": "view", + "indent_width": 4, + "pack": "add", + "xtype": "View", + "|auto_indent": true, + "|init": "function() {\n XObject.prototype.init.call(this);\n var description = Pango.Font.description_from_string(\"monospace\")\n description.set_size(8000);\n this.el.modify_font(description);\n\n}\n", + "|insert_spaces_instead_of_tabs": true, + "|load": "function(str) {\n\n// show the help page for the active node..\n //this.get('/Help').show();\n\n\n // this.get('/BottomPane').el.set_current_page(0);\n this.el.get_buffer().set_text(str, str.length);\n var lm = GtkSource.LanguageManager.get_default();\n \n this.el.get_buffer().set_language(lm.get_language('js'));\n var buf = this.el.get_buffer();\n var cursor = buf.get_mark(\"insert\");\n var iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n \n cursor = buf.get_mark(\"selection_bound\");\n iter= new Gtk.TextIter;\n buf.get_iter_at_mark(iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n this.get('/Editor').dirty = false;\n this.el.grab_focus();\n this.get('/Editor.save_button').el.sensitive = false;\n}", + "|save": "function() {\n \n return this.get('/Editor.RightEditor').save();\n}\n", + "|show_line_numbers": true, + "|xns": "GtkSource", + "items": [ + { + "listeners": { + "changed": "function (self) {\n\n if(this.checkSyntax()) {\n this.get('/Editor.save_button').el.sensitive = true;\n }\n // print(\"EDITOR CHANGED\");\n this.get('/Editor').dirty = true;\n\n // this.get('/LeftPanel.model').changed( str , false);\n return false;\n}" + }, + "id": "buffer", + "pack": "set_buffer", + "xtype": "Buffer", + "|checkSyntax": "function() {\n var str = this.toString();\n var res = '';\n try {\n // print('var res = ' + str);\n Seed.check_syntax('var res = ' + str);\n \n \n } catch (e) {\n \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 // print(str);\n //console.dump(e);\n return false;\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 return true;\n}\n", + "|toString": "function() {\n \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 ret = this.el.get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n", + "|xns": "GtkSource" + } + ] + } + ] + } + ] + } + ] + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/old-javascript/Builder3/Editor.js b/old-javascript/Builder3/Editor.js new file mode 100644 index 000000000..261450f9d --- /dev/null +++ b/old-javascript/Builder3/Editor.js @@ -0,0 +1,230 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; + console = imports.console; +XObject = imports.XObject.XObject; +Editor=new XObject({ + + xtype: Gtk.Window, + listeners : { + delete_event : function (self, event) { + if (!this.get('/Editor.RightEditor').save()) { + // no hiding with errors. + return true; + } + this.el.hide(); + this.get('/Editor').activePath = false; + return true; + }, + configure_event : function (self, object) { + this.pos = this.el.get_position(); + + + return false; + }, + show : function (self) { + if (this.pos) { + this.el.set_uposition(this.pos.root_x,this.pos.root_y); + } + } + }, + height_request : 300, + id : "EditorWindow", + title : "Application Builder - Editor", + width_request : 500, + save : function (self, event) { + if (!this.get('/Editor.RightEditor').save()) { + // no hiding with errors. + return true; + } + this.get('/Editor').activePath = false; + this.el.hide(); + return true; + }, + init : function() { + XObject.prototype.init.call(this); + // this.show_all(); + }, + items : [ + { + xtype: Gtk.VBox, + pack : "add", + items : [ + { + xtype: Gtk.MenuBar, + pack : "pack_start,false,true", + items : [ + { + xtype: Gtk.MenuItem, + + listeners : { + activate : function (self) { + + this.get('/Editor.RightEditor').save(); + } + }, + id : "save_button", + label : "Save" + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + id : "RightEditor", + pack : "add", + save : function() { + // make sure we have an active path.. + if (!this.get('/Editor').activePath) { + return true; + } + + var str = this.get('/Editor.buffer').toString(); + if (!this.get('/Editor.buffer').checkSyntax()) { + this.get('/StandardErrorDialog').show("Fix errors in code and save.."); + return false; + } + + this.get('/LeftPanel.model').changed( str , false); + this.get('/Editor').dirty = false; + this.get('/Editor.save_button').el.sensitive = false; + return true; + }, + items : [ + { + xtype: GtkSource.View, + listeners : { + key_release_event : function (self, event) { + + if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) { + print("SAVE: ctrl-S pressed"); + this.save(); + return false; + } + // print(event.key.keyval) + + return false; + } + }, + id : "view", + indent_width : 4, + pack : "add", + auto_indent : true, + init : function() { + XObject.prototype.init.call(this); + var description = Pango.font_description_from_string("monospace") + description.set_size(8000); + this.el.modify_font(description); + + }, + insert_spaces_instead_of_tabs : true, + load : function(str, providertype) { + + // show the help page for the active node.. + //this.get('/Help').show(); + Editor.providertype = providertype; + + // this.get('/BottomPane').el.set_current_page(0); + this.el.get_buffer().set_text(str, str.length); + var lm = GtkSource.LanguageManager.get_default(); + + this.el.get_buffer().set_language(lm.get_language('js')); + var buf = this.el.get_buffer(); + var cursor = buf.get_mark("insert"); + var ret = {}; + buf.get_iter_at_mark(ret, cursor); + ret.iter.set_line(1); + ret.iter.set_line_offset(4); + buf.move_mark(cursor, ret.iter); + + + cursor = buf.get_mark("selection_bound"); + ret = {}; + buf.get_iter_at_mark(ret, cursor); + ret.iter.set_line(1); + ret.iter.set_line_offset(4); + buf.move_mark(cursor, ret.iter); + this.get('/Editor').dirty = false; + this.el.grab_focus(); + this.get('/Editor.save_button').el.sensitive = false; + }, + save : function() { + + return this.get('/Editor.RightEditor').save(); + }, + show_line_numbers : true, + items : [ + { + xtype: GtkSource.Buffer, + listeners : { + changed : function (self) { + + if(this.checkSyntax()) { + this.get('/Editor.save_button').el.sensitive = true; + } + // print("EDITOR CHANGED"); + this.get('/Editor').dirty = true; + + // this.get('/LeftPanel.model').changed( str , false); + return false; + } + }, + id : "buffer", + pack : "set_buffer", + checkSyntax : function() { + + if (Editor.providertype == 'Gtk') { + return true; + } + + var str = this.toString(); + var res = ''; + try { + // print('var res = ' + str); + Seed.check_syntax('var res = ' + str); + + + } catch (e) { + + 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); + // print(str); + //console.dump(e); + return false; + } + this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({ + red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF + })); + + return true; + }, + toString : function() { + var s = {}; + var e = {}; + + this.el.get_start_iter(s).value; + this.el.get_end_iter(e).value; + + var ret = this.el.get_text(s.iter,e.iter,true); + //print("TO STRING? " + ret); + return ret; + } + } + ] + } + ] + } + ] + } + ] +}); +Editor.init(); +XObject.cache['/Editor'] = Editor; diff --git a/old-javascript/Builder3/Globals.js b/old-javascript/Builder3/Globals.js new file mode 100644 index 000000000..5b4cad189 --- /dev/null +++ b/old-javascript/Builder3/Globals.js @@ -0,0 +1,20 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; + + +atoms = { + "STRING" : Gdk.atom_intern("STRING") + }; +targetList = new Gtk.TargetList(); +targetList.add( atoms["STRING"], 0, 0); + + + +Gtk.rc_parse_string( + "style \"gtkcombobox-style\" {\n" + + " GtkComboBox::appears-as-list = 1\n" + + "}\n"+ + "class \"GtkComboBox\" style \"gtkcombobox-style\"\n"); + + +//imports.Window.Window.el.show_all(); diff --git a/old-javascript/Builder3/Main.js b/old-javascript/Builder3/Main.js new file mode 100644 index 000000000..c098538e2 --- /dev/null +++ b/old-javascript/Builder3/Main.js @@ -0,0 +1,46 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; + +Window = imports.Builder3.Window.Window; + +JSON.xstringify = function (o) { + var seen = []; + return JSON.stringify(o, function(_, value) { + if (typeof value === 'object' && value !== null) { + if (seen.indexOf(value) !== -1) return null; + else seen.push(value); + } + return value; + }, 4); +} + +/* +atoms = { + "STRING" : Gdk.atom_intern("STRING") + }; +targetList = new Gtk.TargetList(); +targetList.add( atoms["STRING"], 0, 0); + + + +Gtk.rc_parse_string( + "style \"gtkcombobox-style\" {\n" + + " GtkComboBox::appears-as-list = 1\n" + + "}\n"+ + "class \"GtkComboBox\" style \"gtkcombobox-style\"\n"); + +*/ +Window.el.show_all(); + + +// this ties two elements together... +// it used to hapen in the init() code for the element, it should be moved to a 'global init for a whole module' +var pm = imports.ProjectManager.ProjectManager; + +var combomodel = Window.get('/LeftProjectTree.combomodel'); +pm.on('changed', function() { + print("caught changed hook on project manager - reloading data"); + combomodel.loadData(pm.projects); + +}); + \ No newline at end of file diff --git a/old-javascript/Builder3/RooProjectProperties.bjs b/old-javascript/Builder3/RooProjectProperties.bjs new file mode 100644 index 000000000..4c4d01389 --- /dev/null +++ b/old-javascript/Builder3/RooProjectProperties.bjs @@ -0,0 +1 @@ +{"id":"file-gtk-9","name":"RooProjectProperties","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/RooProjectProperties.bjs","items":[{"|xns":"Gtk","xtype":"Dialog","|modal":true,"|show":"function() {\n // get the active project.\n var file = this.get('/Window.LeftTree').getActiveFile();\n if (!file) {\n this.get('/StandardErrorDialog').show(\"No file is currently active\");\n return;\n }\n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n project.runhtml = project.runhtml || '';\n this.get('view').el.get_buffer().set_text(project.runhtml, project.runhtml.length);\n \n this.el.show_all();\n}\n","default_width":500,"listeners":{"delete_event":"function (self, event) {\n this.el.hide()\n return true;\n}","response":"function (self, response_id) {\n print(response_id);\n if (!response_id) {\n this.el.hide();\n \n return;\n }\n var buf = this.get('view').el.get_buffer()\n var s = new Gtk.TextIter();\n var e = new Gtk.TextIter();\n buf.get_start_iter(s);\n buf.get_end_iter(e);\n var str = buf.get_text(s,e,true);\n // ideally we should syntax check it.. but it's html!?\n \n var project = this.get('/Window.LeftTree').getActiveFile().project;\n \n \n project.runhtml = str;\n \n imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();\n// print (str);\n // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);\n // ok pressed..\n this.el.hide();\n}"},"items":[{"|xns":"Gtk","xtype":"VBox","|pack":" function(p,e) {\n p.el.get_content_area().add(e.el);\n e.border_width =5;\n }\n","items":[{"|xns":"Gtk","xtype":"Label","pack":"pack_start,false,false,0","label":"HTML To insert at end of "},{"|xns":"Gtk","xtype":"ScrolledWindow","pack":"pack_end,true,true,0","items":[{"|xns":"GtkSource","xtype":"View","pack":"add","id":"view"}]}]},{"|xns":"Gtk","xtype":"Button","pack":"add_action_widget,1","label":"OK"},{"|xns":"Gtk","xtype":"Button","pack":"add_action_widget,0","label":"Cancel"}]}]} \ No newline at end of file diff --git a/old-javascript/Builder3/RooProjectProperties.js b/old-javascript/Builder3/RooProjectProperties.js new file mode 100644 index 000000000..3f907689c --- /dev/null +++ b/old-javascript/Builder3/RooProjectProperties.js @@ -0,0 +1,137 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +RooProjectProperties=new XObject({ + xtype: Gtk.Dialog, + modal : true, + show : function() { + // get the active project. + var file = this.get('/Window.LeftTree').getActiveFile(); + if (!file) { + this.get('/StandardErrorDialog').show("No file is currently active"); + return; + } + var project = this.get('/Window.LeftTree').getActiveFile().project; + //print (project.fn); + project.runhtml = project.runhtml || ''; + this.get('view').el.get_buffer().set_text(project.runhtml, project.runhtml.length); + this.get('dbcon').el.set_text(project.dbcon || ''); + print("project db: " + project.dbcon); + this.el.show_all(); + }, + default_width : 500, + listeners : { + delete_event : function (self, event) { + this.el.hide() + return true; + }, + response : function (self, response_id) { + print(response_id); + if (!response_id) { + this.el.hide(); + + return; + } + var buf = this.get('view').el.get_buffer() + + var e = {}; + var s = {}; + buf.get_start_iter(s); + buf.get_end_iter(e); + + var str = buf.get_text(s.iter,e.iter,false); + //print(str); + // ideally we should syntax check it.. but it's html!? + + var project = this.get('/Window.LeftTree').getActiveFile().project; + + + project.runhtml = str; + + project.dbcon = this.get('dbcon').el.get_text(); + + + imports.ProjectManager.ProjectManager.saveConfig(); + // print (str); + // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length); + // ok pressed.. + this.el.hide(); + } + }, + items : [ + { + xtype: Gtk.VBox, + pack : function(p,e) { + p.el.get_content_area().add(e.el); + e.border_width =5; + }, + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true,3", + items : [ + + + { + xtype: Gtk.Label, + pack : "pack_start,false,false,0", + label : "Database Name" + }, + { + xtype: Gtk.Entry, + id : "dbcon", + pack : "add", + visible : true + }, + ] + }, + + { + xtype: Gtk.Label, + pack : "pack_start,false,false,0", + label : "HTML To insert at end of " + }, + { + xtype: Gtk.ScrolledWindow, + pack : "pack_end,true,true,0", + items : [ + { + xtype: GtkSource.View, + pack : "add", + id : "view" + } + ] + } + + + + + + ] + }, + + + + + { + xtype: Gtk.Button, + pack : "add_action_widget,1", + label : "OK" + }, + { + xtype: Gtk.Button, + pack : "add_action_widget,0", + label : "Cancel" + } + ] +}); +RooProjectProperties.init(); +XObject.cache['/RooProjectProperties'] = RooProjectProperties; diff --git a/old-javascript/Builder3/StandardErrorDialog.bjs b/old-javascript/Builder3/StandardErrorDialog.bjs new file mode 100644 index 000000000..201e51800 --- /dev/null +++ b/old-javascript/Builder3/StandardErrorDialog.bjs @@ -0,0 +1 @@ +{"id":"file-gtk-17","name":"StandardErrorDialog","parent":"","title":false,"path":"/home/alan/gitlive/app.Builder.js/Sample/StandardErrorDialog.bjs","items":[{"|xns":"Gtk","xtype":"MessageDialog","|buttons":"Gtk.ButtonsType.OK","|modal":true,"|message_type":"Gtk.MessageType.ERROR","text":"fixme","|use_markup":true,"|show":"function(msg) {\n if (!this.el) {\n this.init();\n }\n this.el.text = msg;\n this.el.show_all();\n}\n","listeners":{"delete_event":"function (self, event) {\n this.el.hide();\n return true;\n}","response":"function (self, response_id) {\n this.el.hide();\n}"}}]} \ No newline at end of file diff --git a/old-javascript/Builder3/StandardErrorDialog.js b/old-javascript/Builder3/StandardErrorDialog.js new file mode 100644 index 000000000..a12c6d5be --- /dev/null +++ b/old-javascript/Builder3/StandardErrorDialog.js @@ -0,0 +1,37 @@ +Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; +StandardErrorDialog=new XObject({ + xtype: Gtk.MessageDialog, + buttons : Gtk.ButtonsType.OK, + modal : true, + message_type : Gtk.MessageType.ERROR, + text : "fixme", + use_markup : true, + show : function(msg) { + if (!this.el) { + this.init(); + } + this.el.text = msg; + this.el.show_all(); + }, + listeners : { + delete_event : function (self, event) { + this.el.hide(); + return true; + }, + response : function (self, response_id) { + this.el.hide(); + } + } +}); +StandardErrorDialog.init(); +XObject.cache['/StandardErrorDialog'] = StandardErrorDialog; diff --git a/old-javascript/Builder3/Window.bjs b/old-javascript/Builder3/Window.bjs new file mode 100644 index 000000000..cb877e8eb --- /dev/null +++ b/old-javascript/Builder3/Window.bjs @@ -0,0 +1,1186 @@ +{ + "id": "file-gtk-1", + "name": "Window", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Sample/Window.bjs", + "items": [ + { + "listeners": { + "delete_event": "function (self, event) {\n return false;\n}", + "destroy": "function (self) {\n Gtk.main_quit();\n}", + "show": "function (self) {\n print(\"WINDOW SHOWING - trying to hide\");\nimports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\n \tthis.get('/MidPropTree').hideWin();\n this.get('/RightPalete').hide();\n this.get('/BottomPane').el.hide();\n //this.get('/Editor').el.show_all();\n\n}" + }, + "border_width": 0, + "default_height": 500, + "default_width": 800, + "id": "Window", + "title": "Application Builder", + "xtype": "Window", + "|init": "function() {\n this.atoms = {\n \"STRING\" : Gdk.atom_intern(\"STRING\")\n\t};\n\tthis.targetList = new Gtk.TargetList();\n\tthis.targetList.add( this.atoms[\"STRING\"], 0, 0);\n\t//imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();\nGtk.rc_parse_string(\n \"style \\\"gtkcombobox-style\\\" {\\n\" + \n \" GtkComboBox::appears-as-list = 1\\n\" +\n \"}\\n\"+\n \"class \\\"GtkComboBox\\\" style \\\"gtkcombobox-style\\\"\\n\");\n XObject.prototype.init.call(this);\n this.el.show_all();\n \n \n \n}\n", + "|setTitle": "function(str) {\n this.el.set_title(this.title + ' - ' + str);\n}\n", + "|type": "Gtk.WindowType.TOPLEVEL", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "VBox", + "id": "w-vbox", + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuBar", + "pack": "pack_start,false,false", + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuItem", + "|use_underline": true, + "label": "_File", + "items": [ + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": "set_submenu", + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuItem", + "|use_underline": true, + "label": "New _Project", + "listeners": { + "activate": "function (self) {\n var _this = this;\n\tthis.get('/EditProject').show({\n\t success : function(pr) {\n\t\t _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);\n\t }\n\t});\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "label": "_New File", + "|use_underline": true, + "listeners": { + "activate": "function (self) {\n \tvar fn = this.get('/LeftProjectTree.combo').getValue();\n if (!fn) {\n this.get('/LeftProjectTree').showNoProjectSelected();\n return true;\n }\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n this.get('/DialogNewComponent').show({\n project : pm.getByFn(fn)\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "SeparatorMenuItem", + "pack": "add" + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "|use_underline": true, + "pack": "add", + "label": "D_elete Project", + "listeners": { + "activate": "function (self) {\n\n\tvar fn = this.get('/LeftProjectTree').get('combo').getValue();\n\tif (!fn.length) {\n\t\tthis.get('/StandardErrorDialog').show(\"Select a project\")\n\t\treturn;\n }\n\tvar pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n\tvar pr = pm.getByFn(fn);\n\n\t// confirm..\n\tthis.get('/DialogConfirm').show(\"Are you sure you want to delete project '\" + pr.name + \"'\", function() {\n\t\tpm.deleteProject(fn);\n\t\tprint(\"DELETE?\");\n\t});\n\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "SeparatorMenuItem", + "pack": "add" + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "add", + "label": "_Quit", + "|use_underline": true, + "listeners": { + "activate": "function (self) {\n Gtk.main_quit();\n} " + } + } + ] + } + ] + }, + { + "label": "_Edit", + "xtype": "MenuItem", + "|use_underline": true, + "|xns": "Gtk", + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": "set_submenu", + "listeners": {}, + "items": [ + { + "listeners": { + "activate": "function (self) {\n \tvar fn = this.get('/LeftTree').getActiveFile();\n if (!fn) {\n this.get('/StandardErrorDialog').show(\"No File active\");\n return true;\n }\n \n this.get('/DialogNewComponent').show(fn);\n return true;\n}" + }, + "label": "File _Properties", + "pack": "add", + "xtype": "MenuItem", + "|use_underline": true, + "|xns": "Gtk" + }, + { + "listeners": { + "activate": "function (self, event) {\n this.get('/RooProjectProperties').show();\n return false;\n}" + }, + "label": "Modify Project HTML ", + "pack": "add", + "xtype": "MenuItem", + "|use_underline": true, + "|xns": "Gtk" + } + ] + } + ] + }, + { + "label": "_View", + "xtype": "MenuItem", + "|use_underline": true, + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": "set_submenu", + "listeners": {}, + "items": [ + { + "listeners": { + "activate": "function (self, event) {\n var js = this.get('/LeftTree.model').toJS();\n if (js && js[0]) {\n this.get('/RightBrowser.view').renderJS(js[0], true);\n } \n return false;\n}" + }, + "label": "_Redraw (Roo)", + "pack": "add", + "xtype": "MenuItem", + "|use_underline": true, + "|xns": "Gtk" + }, + { + "listeners": { + "activate": "function (self, event) \n{\n /* Firefox testing for debugging..\n - we can create a /tmp directory, and put.\n builder.html, builder.html.js, link roojs1 \n add at the end of builder.html Roo.onload(function() {\n\t */\n\t if (!this.get('/Window.LeftTree').getActiveFile()) {\n return;\n }\n \n var js = this.get('/LeftTree.model').toJS();\n if (!js || !js[0]) {\n return;\n }\n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n \n project.runhtml = project.runhtml || '';\n\n\n\tvar File = imports.File.File;\n\t\n\tvar target = \"/tmp/firetest\"; // fixme..\n\tif (!File.isDirectory(target)) {\n\t File.mkdir(target);\n }\n\tFile.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);\n\tif (!File.exists( target+ '/roojs1')) {\n File.link( target+ '/roojs1', __script_path__ + '/../roojs1');\n \t}\n \n \n \n var html = imports.File.File.read(__script_path__ + '/../builder.html');\n html = html.replace('', project.runhtml + '');\n \n \n var jsstr = JSON.stringify(js[0], null, 4);\n \n var runbuilder = '';\n \n html = html.replace('', runbuilder + '');\n\n\tFile.write( target+ '/builder.html', html);\n\t\n this.get('/Terminal').feed(\"RUN DIR:\" + target);\n \n this.get('/Terminal').el.fork_command( null , [], [], target\n\t, false,false,false); \n var cmd = \"firefox file://\" + target + \"/builder.html \\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n return false;\n}" + }, + "label": "_Test in Firefox (Roo)", + "pack": "add", + "xtype": "MenuItem", + "|use_underline": true, + "|xns": "Gtk" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "label": "_Help", + "|use_underline": true, + "listeners": {}, + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": "set_submenu", + "listeners": {}, + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "add", + "label": "_About", + "|use_underline": true, + "listeners": { + "activate": "function (self) {\n this.get('/About').el.run();\n}" + } + } + ] + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "HPaned", + "id": "left", + "position": 400, + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "items": [ + { + "|xns": "Gtk", + "xtype": "VPaned", + "position": 300, + "id": "leftvpaned", + "items": [ + { + "|xns": "Gtk", + "xtype": "VBox", + "id": "LeftTopPanel", + "items": [ + { + "listeners": { + "activate": "function (self) {\n // this does not actually expand it..\n // that is done by GTK..\n \n \n \tif (!this.get('/Editor').save()) {\n \t // popup!! - click handled.. \n \t return true;\n }\n\n if (!this.el.expanded) {\n this.onExpand();\n } else {\n this.onCollapse();\n }\n\t \n}", + "enter_notify_event": "function (self, event) {\nreturn;\n this.el.expanded = !this.el.expanded;\n//if (this.el.expanded ) {\n this.listeners.activate.call(this);\n// }\n\nreturn true;\n}" + }, + "id": "expander", + "label": "Select Project or File", + "pack": "pack_start,false,true", + "xtype": "Expander", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n", + "|onCollapse": "function() {\n \n var nb = this.get('/LeftTopPanel.notebook');\n nb.el.set_current_page(0);\n}\n", + "|onExpand": "function() {\n var nb = this.get('/LeftTopPanel.notebook'); \n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n \n \n var model = this.get('/LeftProjectTree.combomodel');\n // print (\"loading Projects?\")\n //console.dump(pm.projects);\n model.loadData(pm.projects);\n \n \n nb.el.set_current_page(1);\n //pm.on('changed', function() {\n\t//console.log(\"CAUGHT project manager change\");\n // _combo.model.loadData(pm.projects);\n //}\n return;\n}\n", + "|xns": "Gtk" + }, + { + "id": "notebook", + "pack": "pack_start,true,true", + "xtype": "Notebook", + "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_current_page(0);\n\n}\n", + "|show_border": false, + "|show_tabs": false, + "|xns": "Gtk", + "items": [ + { + "id": "LeftTree", + "pack": "add", + "xtype": "ScrolledWindow", + "|getActiveElement": "function() { // return path to actie node.\n\n var path = this.getActivePath();\n if (!path) {\n return false;\n }\n var iter = new Gtk.TreeIter();\n this.get('model').el.get_iter_from_string(iter, path);\n \n var value = new GObject.Value('');\n this.get('model').el.get_value(iter, 2, value);\n \n return JSON.parse(value.value);\n}\n", + "|getActiveFile": "function() {\n return this.get('model').file;\n}\n", + "|getActivePath": "function() {\n var model = this.get('model');\n var view = this.get('view');\n if (view.selection.count_selected_rows() < 1) {\n return false;\n }\n var iter = new Gtk.TreeIter();\n\n view.selection.get_selected(model.el, iter);\n return model.el.get_path(iter).to_string();\n}\n", + "|getPaleteProvider": "function() {\n var model = this.get('model');\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n return pm.getPalete(model.file.getType());\n}\n", + "|getRenderer": "function() {\n\n\tswitch( this.getActiveFile().getType()) {\n\t\tcase 'Roo':\n\t\t return this.get('/RightBrowser.view');\n\t\tcase 'Gtk':\n\t\t return this.get('/RightGtkView');\n\t}\n\n}\n", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n", + "|renderView": "function() {\n var render = this.getRenderer();\n var model = this.get('model');\n if (render) {\n render.renderJS(model.toJS(false,true)[0]);\n } else {\n print(\"NO RENDER JS METHOD?\");\n }\n}\n", + "|shadow_type": "Gtk.ShadowType.IN", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "button_press_event": "function (self, ev) {\n \tconsole.log(\"button press?\");\n \t\n \tif (!this.get('/Editor').save()) {\n \t // popup!! - click handled.. \n \t return true;\n }\n \t\n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {\n print(\"click\" + ev.type);\n return false;\n }\n \n \n var res = {}; \n this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);\n \n if (!this.get('/LeftTreeMenu').el) { this.get('/LeftTreeMenu').init(); }\n \n this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());\n this.get('/LeftTreeMenu').el.show_all();\n this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);\n print(\"click:\" + res.path.to_string());\n return false;\n}", + "drag_begin": "function (self, drag_context) {\n\tprint('SOURCE: drag-begin');\n this.targetData = false;\n // find what is selected in our tree...\n var iter = new Gtk.TreeIter();\n var s = this.selection;\n s.get_selected(this.get('/LeftTree.model').el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.get('/LeftTree.model').el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n var xname = this.get('/LeftTree.model').file.guessName(data);\n \n this.el.dragData = xname;\n this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);\n \n\n // make the drag icon a picture of the node that was selected\n var path = this.get('/LeftTree.model').el.get_path(iter);\n this.el.treepath = path.to_string();\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_pixmap (ctx,\n pix.get_colormap(),\n pix,\n null,\n -10,\n -10);\n \n return true;\n}", + "drag_end": "function (self, drag_context) {\n\tSeed.print('LEFT-TREE: drag-end');\n this.el.dragData = false;\n this.el.dropList = false;\n this.targetData = false;\n this.get('/LeftTree.view').highlight(false);\n return true;\n}", + "drag_motion": "function (self, ctx, x, y, time) {\n console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n\n // a drag from elsewhere...- prevent drop..\n if (!src.dragData) {\n print(\"no drag data!\");\n Gdk.drag_status(ctx, 0, time);\n this.targetData = false;\n return true;\n }\n var action = Gdk.DragAction.COPY;\n if (src == this.el) {\n // unless we are copying!!! ctl button..\n action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n }\n var data = {};\n\n\t\tif (!this.get('/LeftTree.model').el.iter_n_children(null)) {\n\t\t\t// no children.. -- asume it's ok..\n\t\t\tthis.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];\n\t\t\tGdk.drag_status(ctx, action ,time);\n\t\t\treturn true;\n\t\t}\n\n print(\"GETTING POS\");\n var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);\n print(\"ISOVER? \" + isOver);\n if (!isOver) {\n Gdk.drag_status(ctx, 0 ,time);\n return false; // not over apoint!?!\n }\n // drag node is parent of child..\n console.log(\"SRC TREEPATH: \" + src.treepath);\n console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n \n // nned to check a few here..\n //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n //Gtk.TreeViewDropPosition.AFTER\n //Gtk.TreeViewDropPosition.BEFORE\n \n if (typeof(src.treepath) != 'undefined' && \n src.treepath == data.path.to_string().substring(0,src.treepath.length)) {\n print(\"subpath drag\");\n Gdk.drag_status(ctx, 0 ,time);\n return false;\n }\n \n // check that \n //print(\"DUMPING DATA\");\n //console.dump(data);\n // path, pos\n \n print(data.path.to_string() +' => '+ data.pos);\n var tg = this.get('/LeftTree.model').findDropNodeByPath(\n data.path.to_string(), src.dropList, data.pos);\n \n this.get('/LeftTree.view').highlight(tg);\n if (!tg.length) {\n print(\"Can not find drop node path\");\n this.targetData = false;\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n //console.dump(tg);\n this.targetData = tg; \n \n \n Gdk.drag_status(ctx, action ,time);\n \n return true;\n}", + "drag_drop": "function (w, ctx, x, y, time) {\n Seed.print(\"TARGET: drag-drop\");\n \n Gtk.drag_get_data\n (\n w, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the DnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return true;\n}", + "drag_data_received": "function (self, ctx, x, y, sel_data, info, time) {\n\t print(\"Tree: drag-data-received\");\n\n var delete_selection_data = false;\n var dnd_success = false;\n /* Deal with what we are given from source */\n if( sel_data && sel_data.length ) {\n \n if (ctx.action == Gdk.DragAction.ASK) {\n /* Ask the user to move or copy, then set the ctx action. */\n }\n\n if (ctx.action == Gdk.DragAction.MOVE) {\n //delete_selection_data = true;\n }\n \n var source = Gtk.drag_get_source_widget(ctx);\n\n if (this.targetData) {\n if (source != this.el) {\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n } else {\n // drag around.. - reorder..\n this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);\n \n \n }\n //Seed.print(this.targetData);\n \n }\n \n \n \n // we can send stuff to souce here...\n\n dnd_success = true;\n\n }\n\n if (dnd_success == false)\n {\n Seed.print (\"DnD data transfer failed!\\n\");\n }\n\n Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);\n return true;\n}", + "cursor_changed": "function (self) {\n if (this.blockChanges) { // 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, + "currentTree": false, + "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 var d = new Date();\n this.file.items = this.toJS(false, false);\n print (\"TO JS in \" + ((new Date()) - d) + \"ms\");\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", + "|findDropNodeByPath": "function(treepath_str, targets, pref) {\n var path = treepath_str + ''; // dupe it..\n pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;\n var last = false;\n //console.dump(this.treemap);\n while (path.length) {\n print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.singleNodeToJS(path);\n if (node_data === false) {\n print(\"node not found\");\n return [];\n }\n \n var xname = this.get('/LeftTree.model').file.guessName(node_data);\n var match = false;\n var prop = '';\n targets.forEach(function(tg) {\n if (match) {\n return;;\n }\n if ((tg == xname) ) {\n match = tg;\n }\n if (tg.indexOf(xname +':') === 0) {\n match = tg;\n prop = tg.split(':').pop();\n }\n });\n \n if (match) {\n if (last) { // pref is after/before..\n // then it's after last\n if (pref > 1) {\n return []; // do not allow..\n }\n return [ last, pref , prop];\n \n }\n return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];\n }\n var par = path.split(':');\n last = path;\n par.pop();\n path = par.join(':');\n }\n \n return [];\n \n}\n", + "|getIterValue": " function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // source..\n ] );\n}\n", + "|listAllTypes": "function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n if (!el) { // skip empty?\n return;\n }\n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n", + "|load": "function(tr,iter)\n {\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (iter) {\n this.el.insert(citer,iter,-1);\n } else {\n this.el.append(citer);\n }\n \n this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);\n this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);\n this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);\n if (tr[i].items && tr[i].items.length) {\n this.load(tr[i].items, citer);\n }\n } \n }", + "|loadFile": "function(f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n if (!f) {\n console.log('missing file');\n return;\n }\n \n // load the file if not loaded..\n if (f.items === false) {\n var _this = this;\n f.loadItems(function() {\n _this.loadFile(f);\n });\n return;\n \n }\n this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);\n \n if (f.items.length && typeof(f.items[0]) == 'string') {\n \n //this.get('/RightEditor').el.show();\n //this.get('/RightEditor.view').load( f.items[0]);\n return;\n }\n print(\"LOAD\");\n print(JSON.stringify(f.items, null,4));\n //console.dump(f.items);\n this.load(f.items);\n this.get('/LeftTree.view').el.expand_all();\n\n if (!f.items.length) {\n // single item..\n \n this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n this.get('/LeftTree.view').el.set_cursor( \n new Gtk.TreePath.from_string('0'), null, false);\n \n \n } else {\n this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n \n //print(\"hide right editior\");\n //this.get('/RightEditor').el.hide();\n this.get('/Editor').el.hide();\n //print(\"set current tree\");\n this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n this.currentTree = this.currentTree || { items: [] };\n this.get('/LeftTree').renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n \n}\n", + "|moveNode": "function(target_data, action) {\n //print(\"MOVE NODE\");\n // console.dump(target_data);\n var old_iter = new Gtk.TreeIter();\n var s = this.get('/LeftTree.view').selection;\n s.get_selected(this.el, old_iter);\n var node = this.nodeToJS(old_iter,false);\n //console.dump(node);\n \n \n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n \n this.dropNode(target_data, node);\n\t if (action & Gdk.DragAction.MOVE) {\n // print(\"REMOVING OLD NODE\");\n this.el.remove(old_iter);\n \n }\n \n this.activePath= false;\n this.changed(false,true);\n}\n", + "|nodeTip": "function(c) {\n var ret = this.nodeTitle(c,true);\n var funcs = '';\n\n \n for( var i in c) {\n\n if (!i.length || i[0] != '|') {\n continue;\n }\n if (i == '|init') { \n continue;\n }\n if (typeof(c[i]) != 'string') {\n continue;\n }\n //print(\"prop : \" + i + ':' + c[i]);\n if (!c[i].match(new RegExp('function'))) {\n continue;\n }\n funcs += \"\\n\" + i.substring(1) + ' : ' + c[i].split(/\\n/).shift();\n \n }\n if (funcs.length) {\n ret+=\"\\n\\nMethods:\" + funcs;\n }\n return ret;\n \n}\n", + "|nodeTitle": "function(c, renderfull) {\n var txt = [];\n c = c || {};\n var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;\n if (sr) txt.push('');\n if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }\n \n if (renderfull && c['|xns']) {\n txt.push(c['|xns']);\n }\n \n if (c.xtype) { txt.push(c.xtype); }\n if (c.id) { txt.push('[id=' + c.id + ']'); }\n if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }\n if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }\n \n \n if (c.layout) { txt.push('' + c.layout + ''); }\n if (c.title) { txt.push('' + c.title + ''); }\n if (c.label) { txt.push('' + c.label+ ''); }\n if (c.header) { txt.push('' + c.header + ''); }\n if (c.legend) { txt.push('' + c.legend + ''); }\n if (c.text) { txt.push('' + c.text + ''); }\n if (c.name) { txt.push('' + c.name+ ''); }\n if (c.region) { txt.push('(' + c.region + ')'); }\n if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }\n \n // for flat classes...\n if (typeof(c['*class']) != 'undefined') { txt.push('' + c['*class']+ ''); }\n if (typeof(c['*extends']) != 'undefined') { txt.push(': ' + c['*extends']+ ''); }\n \n \n if (sr) txt.push('');\n return (txt.length == 0 ? \"Element\" : txt.join(\" \"));\n}\n", + "|nodeToJS": "function (treepath, with_id) \n{\n \n var iter = treepath; // API used to be iter here..\n if (typeof(iter) == 'string') {\n iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n } \n var par = new Gtk.TreeIter(); \n var iv = this.getIterValue(iter, 2);\n // print(\"IV\" + iv);\n var k = JSON.parse(iv);\n if (k.json && !this.el.iter_parent( par, iter )) {\n delete k.json;\n }\n \n if (with_id) {\n var treepath_str = this.el.get_path(iter).to_string();\n // not sure how we can handle mixed id stuff..\n if (typeof(k.id) == 'undefined') {\n k.id = 'builder-'+ treepath_str ;\n }\n \n // needed??\n this.treemap[ treepath_str ] = k;\n k.xtreepath = treepath_str ;\n \n }\n if (this.el.iter_has_child(iter)) {\n citer = new Gtk.TreeIter();\n this.el.iter_children(citer, iter);\n k.items = this.toJS(citer,with_id);\n }\n return k;\n}\n", + "|nodeToJSON": "function(c) {\n var o = {}\n for (var i in c) {\n if (i == 'items') {\n continue;\n }\n o[i] = c[i];\n }\n return JSON.stringify(o);\n}\n", + "|singleNodeToJS": "function (treepath) \n {\n var iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n \n var iv = this.getIterValue(iter, 2);\n \n return JSON.parse(iv);\n \n }", + "|toJS": "function(treepath, with_id)\n{\n //Seed.print(\"WITHID: \"+ with_id);\n var iter = treepath; // API used to be iter here..\n if (typeof(iter) == 'string') {\n iter = new Gtk.TreeIter(); \n if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {\n return false;\n }\n } \n var first = false;\n if (!iter) {\n \n this.treemap = { }; \n \n iter = new Gtk.TreeIter();\n if (!this.el.get_iter_first(iter)) {\n return [];\n }\n first = true;\n } \n \n var ar = [];\n \n while (true) {\n \n var k = this.nodeToJS(iter, with_id); \n ar.push(k);\n \n \n if (!this.el.iter_next(iter)) {\n break;\n }\n }\n \n if (treepath === false) {\n //dupe!!!\n return JSON.parse(JSON.stringify(ar));\n }\n \n return ar;\n // convert the list into a json string..\n\n \n}", + "|xns": "Gtk" + }, + { + "|xns": "Gtk", + "xtype": "TreeViewColumn", + "pack": "append_column", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n", + "items": [ + { + "|xns": "Gtk", + "xtype": "CellRendererText", + "pack": "pack_start" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": false, + "id": "LeftTreeMenu", + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "add", + "label": "Delete Element", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftTree.model').deleteSelected();\n}" + } + }, + { + "listeners": { + "activate": "function (self) {\n\n var tree = this.get('/LeftTree');\n var model = this.get('/LeftTree.model');\n var el = tree.getActivePath();\n print(el);\n var js = model.toJS(el, false);\n // print(JSON.stringify(js[0], null,4));\n this.get('/DialogSaveTemplate').show(JSON.stringify(js[0], null,4));\n \n \n}" + }, + "label": "Save as Template", + "pack": "add", + "xtype": "MenuItem", + "|xns": "Gtk" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "VBox", + "pack": "add", + "id": "LeftProjectTree", + "|showNoProjectSelected": "function() {\n this.get('/StandardErrorDialog').show(\"Select a Project first.\"); \n}\n", + "|getActiveProject": "function() {\n return this.project;\n}\n", + "listeners": { + "leave_notify_event": "function (self, event) {\n return false;\n}" + }, + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "pack_start,false,false", + "items": [ + { + "listeners": { + "changed": "function (self) {\n\tvar fn = this.getValue();\n\tvar pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n\tthis.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))\n}" + }, + "id": "combo", + "xtype": "ComboBox", + "|getValue": "function() {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return false;\n }\n var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n if (typeof(data[ix]) == 'undefined') {\n \treturn false; \n }\n return data[ix].fn;\n}", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.get('render').el , 'markup', 1 ); \n}\n", + "|setValue": "function(fn)\n{\n var el = this.el;\n el.set_active(-1);\n var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;\n data.forEach(function(n, ix) {\n if (fn == n.fn) {\n el.set_active(ix);\n return false;\n }\n });\n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "CellRendererText", + "pack": "pack_start,true", + "id": "render" + }, + { + "id": "combomodel", + "pack": "set_model", + "xtype": "ListStore", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // real key\n GObject.TYPE_STRING // real type\n \n \n ] );\n // this.el.set_sort_column_id(1,Gtk.SortType.ASCENDING);\n var pm = imports.Builder.Provider.ProjectManager.ProjectManager;\n var _this = this;\n pm.on('changed', function() {\n print(\"caught changed hook on project manager - reloading data\");\n\t_this.loadData(pm.projects);\n\n });\n}\n", + "|loadData": "function(data) {\n var ov = this.get('/LeftProjectTree.combo').getValue();\n this.el.clear();\n var iter = new Gtk.TreeIter();\n var el = this.el;\n data.forEach(function(p) {\n \n el.append(iter);\n \n \n el.set_value(iter, 0, p.fn);\n el.set_value(iter, 1, p.name);\n \n });\n \n this.get('/LeftProjectTree.combo').setValue(ov);\n}\n", + "|xns": "Gtk" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "ScrolledWindow", + "pack": "add", + "|shadow_type": "Gtk.ShadowType.IN", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );\n}\n", + "items": [ + { + "listeners": { + "cursor_changed": "function (self) {\n \tvar iter = new Gtk.TreeIter();\n \n if (this.selection.count_selected_rows() < 1) {\n //XN.get('Builder.LeftTree.model').\n this.get('/LeftTree.model').load( false);\n \n return;\n }\n var model = this.get('/LeftProjectTree.model');\n //console.log('changed');\n var s = this.selection;\n s.get_selected(model, iter);\n value = new GObject.Value('');\n model.el.get_value(iter, 2, value);\n \n console.log(value.value);// id..\n \n var file = this.get('/LeftProjectTree').project.getById(value.value);\n \n file.items = false;\n console.log(file);\n \n\n\n var nb = this.get('/LeftTopPanel.expander');\n nb.el.expanded = false;\n nb.onCollapse();\n //nb.listeners.activate.call(nb);\n //_expander.el.set_expanded(false);\n\n var ltm = this.get('/LeftTree.model');\n ltm.loadFile(file);\n \n return true;\n}" + }, + "id": "view", + "tooltip_column": 1, + "xtype": "TreeView", + "|enable_tree_lines": true, + "|headers_visible": false, + "|init": "function() {\n XObject.prototype.init.call(this);\nvar description = new Pango.FontDescription.c_new();\n description.set_size(8000);\n this.el.modify_font(description);\n \n this.selection = this.el.get_selection();\n this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "TreeStore", + "pack": "set_model", + "id": "model", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_column_types ( 3, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING, // tip\n GObject.TYPE_STRING // id..\n ] );\n \n}\n", + "|loadProject": "function(pr) {\nprint(\"LOAD PROJECT\");\n this.el.clear();\n if (!pr) {\n return;\n }\n \n this.get('/LeftProjectTree').project = pr;\n this.load(pr.toTree());\n this.get('/LeftProjectTree.view').el.expand_all();\n}\n", + "|load": "function(tr,iter) {\n // console.dump(tr);\n console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n \n var _this = this;\n tr.forEach(function (r) {\n if (!iter) {\n _this.el.append(citer); \n } else {\n _this.el.insert(citer,iter,-1);\n }\n _this.el.set_value(citer, 0, '' + r.getTitle() ); // title \n _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip\n _this.el.set_value(citer, 2, '' + r.id ); //id\n if (r.cn && r.cn.length) {\n _this.load(r.cn, citer);\n }\n \n });\n}\n", + "|getValue": "function(iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return '' + gval.value;\n}\n" + }, + { + "|xns": "Gtk", + "xtype": "TreeViewColumn", + "pack": "append_column", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n", + "items": [ + { + "|xns": "Gtk", + "xtype": "CellRendererText", + "pack": "pack_start" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "VBox", + "listeners": {}, + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "pack_start,false,true,0", + "id": "LeftProps", + "items": [ + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "add", + "listeners": { + "button_press_event": "function (self, event) {\n this.get('/MidPropTree.model').showData('props');\n return false;\n}" + }, + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "Image", + "pack": "add", + "|stock": "Gtk.STOCK_ADD", + "|icon_size": "Gtk.IconSize.MENU" + }, + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "add", + "label": "Property" + } + ] + } + ] + }, + { + "listeners": { + "button_press_event": "function (self, event) {\n \n \tif (!this.get('/Editor').save()) {\n \t // popup!! - click handled.. \n \t return true;\n }\n this.get('/MidPropTree.model').showData('events');\n return false;\n}" + }, + "pack": "add", + "xtype": "Button", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "Image", + "pack": "add", + "|stock": "Gtk.STOCK_ADD", + "|icon_size": "Gtk.IconSize.MENU" + }, + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "add", + "label": "Handler" + } + ] + } + ] + }, + { + "listeners": { + "button_press_event": "function (self, ev) {\n\n \tif (!this.get('/Editor').save()) {\n \t // popup!! - click handled.. \n \t return true;\n }\n \n\tvar p = this.get('/AddPropertyPopup');\n\tif (!p.el) {\n\t\tp.init();\n\t}\n \tp.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, null, 3, ev.button.time);\n return true;\n}" + }, + "pack": "add", + "xtype": "Button", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "Image", + "pack": "add", + "|stock": "Gtk.STOCK_ADD", + "|icon_size": "Gtk.IconSize.MENU" + }, + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "add", + "label": "Other" + } + ] + }, + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": false, + "id": "AddPropertyPopup", + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Using this.get('*someid') will find any id in an application.", + "label": "ID", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : 'id', \n type : 'string',\n val : '',\n //skel : skel,\n etype : 'props'\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Add what type of packing is to be used", + "label": "PACK", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : 'pack', \n \t type : 'string',\n \t val : 'add',\n etype : 'props'\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Override the init method", + "label": "INIT", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n key : '|init', \n type : 'function',\n val : \"function() {\\n XObject.prototype.init.call(this);\\n}\\n\",\n etype : 'props'\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "SeparatorMenuItem", + "pack": "add" + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Add a user defined string property", + "label": "String", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'string',\n val : \"\",\n etype : 'props'\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Add a user defined number property", + "label": "Number", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'number',\n val : 0,\n etype : 'props'\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Add a user defined boolean property", + "label": "Boolean", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t\t key : '', \n type : 'boolean',\n val : false,\n etype : 'props'\n });\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "SeparatorMenuItem", + "pack": "add" + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "tooltip_markup": "Add a user function boolean property", + "label": "Function", + "listeners": { + "activate": "function (self) {\n\n this.get('/LeftPanel.model').add( {\n \t key : '|', \n type : 'function',\n val : \"function() {\\n \\n}\\n\",\n etype : 'props'\n });\n}" + } + } + ] + } + ] + } + ] + }, + { + "editing": false, + "id": "LeftPanel", + "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", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "button_press_event": "function (self, ev) {\n\n \n if (!this.get('/Editor').save()) {\n // popup!! - click handled.. \n return true;\n }\n var res = { }; \n \n if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {\n return false; //not on a element.\n }\n \n // right click.\n if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button.button == 3) { \n // show popup!. \n if (res.column.title == 'value' && this.get('/LeftPanel').editing) {\n return false;\n }\n //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();\n var p = this.get('/LeftPanelPopup');\n if (!p.el) {\n p.init();\n }\n\n p.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, null, 3, ev.button.time);\n //Seed.print(\"click:\" + res.column.title);\n \n \n return false;\n }\n \n \n if (res.column.title != 'value') {\n // XObject.error(\"column is not value?\");\n return false; // ignore.. - key click.. ??? should we do this??\n }\n \n // currently editing???\n// if ( this.activePath) {\n \n // this.activePath = false;\n // stop editing!!!!\n if (this.get('/Editor').dirty) {\n //if (!this.get('/Editor.buffer').checkSyntax()) {\n // this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n // return true;\n // // error Dialog\n //}\n if (!this.get('/Editor.view').save()) {\n return true;\n }\n } \n this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();\n this.get('/LeftPanel').editing = false;\n \n // XObject.error(\"Currently editing?\");\n // return false;\n // }\n \n var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..\n \n var type = this.get('/LeftPanel.model').getType(res.path.to_string());\n \n // get options for this type -- this is to support option lists etc..\n var provider = this.get('/LeftTree').getPaleteProvider();\n var opts = provider.findOptions(type);\n \n if (opts === false) {\n // it's text etnry\n this.get('/LeftPanel').editableColumn.setOptions([]);\n renderer.has_entry = true;\n } else {\n this.get('/LeftPanel').editableColumn.setOptions(opts);\n renderer.has_entry = false;\n }\n this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1);\n \n //Seed.print(\"click\" + ev.type);\n //console.dump(res);\n return false;\n\n \n \n}" + }, + "id": "view", + "tooltip_column": 5, + "xtype": "TreeView", + "|enable_tree_lines": true, + "|headers_visible": false, + "|init": "function() {\n XObject.prototype.init.call(this); \n \n this.selection = this.el.get_selection();\n this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n \n \n var description = new Pango.FontDescription.c_new();\n description.set_size(8000);\n this.el.modify_font(description);\n}\n", + "|xns": "Gtk", + "items": [ + { + "activePath": false, + "id": "model", + "pack": "set_model", + "xtype": "TreeStore", + "|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", + "|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{\n // get's the value in a row.. - keys - returns string, values - formats it..\n\n var iter = new Gtk.TreeIter();\n this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));\n \n var gval = new GObject.Value('');\n this.get('/LeftPanel.model').el.get_value(iter, col ,gval);\n var val = '' + gval.value;\n \n if (col != 1) {\n return val;\n }\n var type = this.getType(this.el.get_path(iter).to_string());\n //print(\"TYPE: \" +type + \" - val:\" + val);\n switch(type.toLowerCase()) {\n case 'number':\n case 'uint':\n case 'int':\n return parseFloat(val); // Nan ?? invalid!!? \n case 'float':\n case 'gfloat':\n return 1.0 * parseFloat(val); // Nan ?? invalid!!?\n case 'boolean':\n return val == 'true' ? true : false;\n default: \n var nv = parseFloat(val);\n if (!isNaN(nv) && (val == ''+nv)) {\n return nv;\n }\n return val;\n }\n \n}\n", + "|init": "function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 6, [\n GObject.TYPE_STRING, // 0 real key\n GObject.TYPE_STRING, // 1 real value \n GObject.TYPE_STRING, // 2 visable key\n GObject.TYPE_STRING, // 3 visable value\n GObject.TYPE_STRING, // 4 need to store type of!!!\n GObject.TYPE_STRING // 5 tooltip\n \n ]);\n}\n", + "|load": "function(ar) {\n// might casue problesm..\n // this.get('/Editor.RightEditor').save();\n\n this.get('/Editor').el.hide();\n this.get('/Editor').activePath = false;\n\n\n this.el.clear();\n \n //this.get('/RightEditor').el.hide();\n if (ar === false) {\n return ;\n }\n var ret = {}; \n \n\n var provider = this.get('/LeftTree').getPaleteProvider();\n var iter = new Gtk.TreeIter();\n \n // sort!!!?\n var keys = XObject.keys(ar);\n keys.sort();\n ar.listeners = ar.listeners || {};\n \n for (var i in ar.listeners ) {\n this.el.append(iter);\n var p = this.el.get_path(iter).to_string();\n ret['!' + i] = p;\n \n this.el.set_value(iter, 0, '!'+ i );\n this.el.set_value(iter, 1, '' + ar.listeners[i]);\n this.el.set_value(iter, 2, ''+ i + '');\n \n this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));\n this.el.set_value(iter, 4, 'function');\n this.el.set_value(iter, 5, i + ' : ' + ar.listeners[i]);\n }\n \n \n \n var _this = this;\n keys.forEach(function(i) {\n if (typeof(ar[i]) == 'object') {\n return;\n }\n \n var type = provider.findType(ar, i, ar[i]);\n \n _this.el.append(iter);\n var p = _this.el.get_path(iter).to_string();\n ret[i] = p;\n _this.el.set_value(iter, 0, ''+i);\n _this.el.set_value(iter, 1, '' + ar[i]); \n _this.el.set_value(iter, 2, ''+i);\n _this.el.set_value(iter, 3, ''+ _this.toShort(ar[i]));\n _this.el.set_value(iter, 4, ''+type);\n _this.el.set_value(iter, 5, type + ' : ' + ar[i]);\n })\n return ret;\n}\n", + "|startEditing": "function(path,col) {\n \n // alled by menu 'edit' currently..\n /**\n * start editing path (or selected if not set..)\n * @param {String|false} path (optional) treepath to edit - selected tree gets\n * edited by default.\n * @param {Number} 0 or 1 (optional)- column to edit. \n */\n // fix tp to be the 'treepath' string (eg. 0/1/2...)\n var tp;\n if (typeof(path) == 'string') {\n tp = new Gtk.TreePath.from_string(path);\n } else {\n var iter = new Gtk.TreeIter();\n var s = this.get('/LeftPanel.view').selection;\n s.get_selected(this.el, iter);\n tp = this.el.get_path(iter);\n path = tp.to_string();\n }\n \n \n // which colum is to be edited..\n var colObj = false;\n \n // not sure what this does..\n \n if (typeof(col) == 'undefined') {\n var k = this.getValue(path, 0);\n col = 1;\n colObj = (!k.length || k == '|') ? \n this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;\n } else {\n colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;\n }\n \n // make sure the pulldown is set correctly..\n // not really needed for second col...\n var showEditor = false;\n this.get('/Editor').activePath = false;\n this.get('/Editor').el.hide();\n \n if (col) {\n var provider = this.get('/LeftTree').getPaleteProvider();\n var type = this.get('/LeftPanel.model').getType(path);\n var opts = provider.findOptions(type);\n var renderer = this.get('/LeftPanel').editableColumn.items[0].el;\n \n if (opts === false) {\n this.get('/LeftPanel').editableColumn.setOptions([]);\n renderer.has_entry = true; \n } else {\n this.get('/LeftPanel').editableColumn.setOptions(opts);\n renderer.has_entry = false;/// - pulldowns do not have entries\n }\n // determine if we should use the Text editor...\n var keyname = this.getValue(path, 0);\n var data_value = this.getValue(path, 1);\n \n if ((keyname[0] == '|') || \n ( \n (typeof(data_value) == 'string' ) && \n ( data_value.match(/function/g) || data_value.match(/\\n/g)) // || (data_value.length > 20))\n )) {\n showEditor = true;\n }\n print(\"SHOW EDITOR\" + showEditor ? 'YES' :'no');\n \n }\n var _this = this; \n // end editing..\n // this.get('/BottomPane').el.hide();\n //this.get('/RightEditor').el.hide();\n \n \n if (showEditor) {\n\n this.activePath = false;\n \n _this.get('/Editor').el.show_all();\n GLib.timeout_add(0, 1, function() {\n\n //_this.get('/BottomPane').el.show();\n //_this.get('/RightEditor').el.show();\n \n _this.get('/Editor.RightEditor.view').load( _this.getValue(path, 1) );\n \n _this.get('/Editor').activePath = path;\n _this.activePath = path ;\n \n return false;\n });\n return;\n }\n \n \n \n\n // iter now has row...\n GLib.timeout_add(0, 100, function() {\n _this.activePath = path;\n colObj.items[0].el.editable = true; // esp. need for col 0..\n _this.get('/LeftPanel.view').el.set_cursor_on_cell(\n tp,\n colObj.el,\n colObj.items[0].el,\n true\n );\n });\n \n}\n", + "|toJS": "function() {\n var iter = new Gtk.TreeIter();\n this.get('/LeftPanel.model').el.get_iter_first(iter);\n var ar = {};\n \n while (true) {\n \n var k = this.getValue(this.el.get_path(iter).to_string(), 0);\n // Seed.print(k);\n if (k[0] == '!') {\n ar.listeners = ar.listeners || {};\n ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);\n \n } else {\n ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);\n }\n \n if (! this.get('/LeftPanel.model').el.iter_next(iter)) {\n break;\n }\n }\n \n \n //print(JSON.stringify(ar));\n return ar;\n // convert the l\n}\n", + "|toShort": "function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\n}\n", + "|xns": "Gtk" + }, + { + "|xns": "Gtk", + "xtype": "TreeViewColumn", + "pack": "append_column", + "|init": "function() {\n XObject.prototype.init.call(this);\n\n this.el.add_attribute(this.items[0].el , 'markup', 2 );\n this.get('/LeftPanel').propertyColumn = this;\n}\n", + "title": "key", + "items": [ + { + "|xns": "Gtk", + "xtype": "CellRendererText", + "pack": "pack_start", + "listeners": { + "editing_started": "function (self, editable, path) {\n\n this.get('/LeftPanel.model').activePath = path;\n\n}", + "edited": "function (self, object, p0) {\n\tvar model = this.get('/LeftPanel.model');\n var path = model.activePath;\n var iter = new Gtk.TreeIter();\n model.el.get_iter(iter, new Gtk.TreePath.from_string(path));\n model.el.set_value(iter, 0, p0);\n model.el.set_value(iter, 2, p0);\n \n\tmodel.activePath = false;\n\n\tthis.get('/LeftTree.model').changed(model.toJS(), true); \n this.el.editable = false;\n}" + } + } + ] + }, + { + "pack": "append_column", + "title": "value", + "xtype": "TreeViewColumn", + "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'text', 3 );\n\tthis.el.add_attribute(this.items[0].el , 'sensitive', 3 );\n\t//this.el.add_attribute(this.items[0].el , 'editable', 3 );\n // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);\n\n \tthis.get('/LeftPanel').editableColumn= this;\n}\n", + "|setOptions": "function(ar) {\n var m = this.items[0].el.model;\n m.clear();\n var iter = new Gtk.TreeIter();\n ar.forEach(function(i) {\n // sort!!!?\n m.append(iter);\n m.set_value(iter, 0, i);\n });\n \n}\n", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "edited": "function (self, object, p0) {\n \tthis.get('/LeftPanel').editing = false;\n \tvar ap = this.get('/LeftPanel.model').activePath\n\tprint(\"EDITED? \" + ap + \" - p:\" + p0 + \" t:\" + p0);\n this.get('/LeftPanel.model').changed(p0, true);\n this.get('/LeftPanel.model').activePath = false;\n this.el.editable = false;\n}", + "editing_started": "function (self, editable, path) {\n this.get('/LeftPanel').editing = true;\n\t// console.log('editing started');\n // r.has_entry = false;\n\n this.el.editable = false; // make sure it's not editor...\n \n}" + }, + "editable": false, + "pack": "pack_start", + "text_column": 0, + "xtype": "CellRendererCombo", + "|has_entry": true, + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.model = new Gtk.ListStore();\n this.el.model.set_column_types ( 1, [\n GObject.TYPE_STRING // 0 real key\n ]);\n}\n", + "|xns": "Gtk" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "Menu", + "pack": false, + "id": "LeftPanelPopup", + "items": [ + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "label": "Delete", + "listeners": { + "activate": "function (self) {\n\tthis.get('/LeftPanel.model').deleteSelected();\n}" + } + }, + { + "|xns": "Gtk", + "xtype": "MenuItem", + "pack": "append", + "label": "Edit", + "listeners": { + "activate": "function (self) {\n\tthis.get('/LeftPanel.model').startEditing(false, 0);\n}" + } + } + ] + } + ] + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "ScrolledWindow", + "pack": "pack_end,false,true,0", + "id": "MidPropTree", + "|shadow_type": "Gtk.ShadowType.IN", + "|init": "function() {\n XObject.prototype.init.call(this);\n XObject.prototype.init.call(this); \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n this.el.set_size_request ( 150, -1 );\n this.shown = true;\n}\n", + "activeElement": false, + "|hideWin": "function() {\n \n if (!this.shown) {\n return;\n }\n \n \n if (this.get('/Window.left').el.position < 160) {\n return;\n }\n this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;\n \n this.el.hide();\n this.shown = false;\n}\n", + "items": [ + { + "listeners": { + "cursor_changed": "function (self) {\n var iter = new Gtk.TreeIter();\n \n //console.log('changed');\n var m = this.get('model');\n\tif (!this.selection){\n\t\tthis.selection = this.el.get_selection();\n\t}\n\n var s = this.selection;\n if (!s.get_selected(m.el, iter)) {\n\t\treturn; \n\t}\n var tp = m.el.get_path(iter).to_string();\n \n \n // var val = \"\";\n \n var key = m.getValue(tp, 0);\n \n var type = m.getValue(tp, 1);\n var skel = m.getValue(tp, 3);\n var etype = m.getValue(tp, 5);\n \n \n this.get('/MidPropTree').hideWin();\n\n if (type.toLowerCase() == 'function') {\n \n if (etype != 'events') {\n key = '|' + key;\n }\n \n this.get('/LeftPanel.model').add({\n key : key, \n type : type,\n val : skel,\n etype : etype\n }) \n return;\n }\n // has dot in name, and is boolean???? this does not make sense..\n //if (type.indexOf('.') > -1 || type.toLowerCase() == 'boolean') {\n // key = '|' + key;\n // }\n \n this.get('/LeftPanel.model').add( {\n key : key, \n type : type,\n //skel : skel,\n etype : etype\n }) //, \n}" + }, + "pack": "add", + "tooltip_column": 2, + "xtype": "TreeView", + "|enable_tree_lines": true, + "|headers_visible": false, + "|init": "function() {\n\tXObject.prototype.init.call(this); \n \n var description = new Pango.FontDescription.c_new();\n description.set_size(8000);\n this.el.modify_font(description); \n \n //this.selection = this.el.get_selection();\n // this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n \n\n \n \n \n}\n", + "|xns": "Gtk", + "items": [ + { + "id": "model", + "pack": "set_model", + "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}", + "|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 ?this.el.set_value(iter, 0, p.name);et_value(iter, 0, p.name);\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" + }, + { + "pack": false, + "xtype": "TreeViewColumn", + "|init": "function() {\n this.el = new Gtk.TreeViewColumn();\n this.parent.el.append_column(this.el);\n \n XObject.prototype.init.call(this);\n this.el.add_attribute(this.items[0].el , 'markup', 4 );\n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "CellRendererText", + "pack": "pack_start,true" + } + ] + } + ] + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "VPaned", + "pack": "add", + "position": 300, + "items": [ + { + "|xns": "Gtk", + "xtype": "VBox", + "pack": "add", + "items": [ + { + "|xns": "Gtk", + "xtype": "Notebook", + "pack": "pack_start,true,true", + "id": "view-help-nb", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Preview\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Help\" }));\n}\n", + "items": [ + { + "id": "view-notebook", + "pack": "add", + "tab_border": 0, + "xtype": "Notebook", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_current_page(0);\n //print(\"SET LABEL?\")\n this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Roo View\" }));\n this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Gtk View\" }));\n}\n", + "|show_tabs": false, + "|xns": "Gtk", + "items": [ + { + "id": "RightBrowser", + "pack": "add", + "xtype": "VBox", + "|xns": "Gtk", + "items": [ + { + "pack": "pack_start,false,true,0", + "xtype": "HBox", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "clicked": "function (self) {\n this.get('/RightBrowser.view').renderJS(null,true);\n}" + }, + "label": "Redraw", + "pack": "pack_start,false,false,0", + "xtype": "Button", + "|xns": "Gtk" + }, + { + "listeners": { + "toggled": "function (self, state) {\n this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");\n}" + }, + "active": true, + "id": "AutoRedraw", + "label": "Auto Redraw On", + "pack": "pack_start,false,false,0", + "xtype": "CheckButton", + "|xns": "Gtk" + }, + { + "listeners": { + "clicked": "function (self) {\n this.get('/RightBrowser.view').redraws = 99;\n this.get('/RightBrowser.view').renderJS(null,true);\n}" + }, + "label": "Full Redraw", + "pack": "pack_start,false,false,0", + "xtype": "Button", + "|xns": "Gtk" + } + ] + }, + { + "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", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "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 print(object);\n // console.log(object);\n \n\n if (object.match(/variable/) && object.match(/Builder/)) {\n print(\"got builder missing message\");\n this.refreshRequired = true;\n this.lastRedraw = 0;\n this.runRefresh();\n return true;\n }\n \n \n if (!object.match(/^\\{/)) {\n \n //this.get('/Terminal').feed(object);\n return true; // do not handle!!! -> later maybe in console..\n }\n \n \n \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 }", + "create_web_view": "function (self, object) {\n print(\"CREATE WEB VIEW\");\n return null; //new WebKit.WebView();\n}" + }, + "id": "view", + "pack": "add", + "redraws": 0, + "xtype": "WebView", + "|init": "function() {\n XObject.prototype.init.call(this);\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_developer_extras = true;\n \n // this was an attempt to change the url perms.. did not work..\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n var _this = this;\n \n // init inspector..\n this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {\n _this.get('/BottomPane.inspector').el.show();\n return _this.get('/BottomPane.inspector').el;\n \n });\n \n // FIXME - base url of script..\n // we need it so some of the database features work.\n this.el.load_html_string( \"Render not ready\" , \n //fixme - should be a config option!\n // or should we catch stuff and fix it up..\n 'http://localhost/app.Builder/'\n );\n \n \n //this.el.open('file:///' + __script_path__ + '/../builder.html');\n \n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n null, /* lists of target to support */\n 0, /* size of list */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n \n // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n \n GLib.timeout_add_seconds(0, 1, function() {\n // print(\"run refresh?\");\n _this.runRefresh(); \n return true;\n });\n \n \n}\n", + "|renderJS": "function(data, force) {\n\n // this is the public redraw call..\n // we refresh in a loop privately..\n var autodraw = this.get('/RightBrowser.AutoRedraw').el.active;\n if (!autodraw && !force) {\n print(\"Skipping redraw - no force, and autodraw off\");\n return;\n }\n this.refreshRequired = true;\n}\n", + "|runRefresh": "function() \n{\n // this is run every 2 seconds from the init..\n\n \n \n if (!this.refreshRequired) {\n // print(\"no refresh required\");\n return;\n }\n\n if (this.lastRedraw) {\n // do not redraw if last redraw was less that 5 seconds ago.\n if (((new Date()) - this.lastRedraw) < 5000) {\n return;\n }\n }\n \n \n \n \n if (!this.get('/Window.LeftTree').getActiveFile()) {\n return;\n }\n this.refreshRequired = false;\n // print(\"HTML RENDERING\");\n \n this.get('/BottomPane').el.show();\n this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n\n \n var js = this.get('/LeftTree.model').toJS();\n if (!js || !js.length) {\n print(\"no data\");\n return;\n }\n var data = js[0];\n this.redraws++;\n \n var project = this.get('/Window.LeftTree').getActiveFile().project;\n //print (project.fn);\n // set it to non-empty.\n project.runhtml = project.runhtml || '';\n project.runhtml = project.runhtml.length ? project.runhtml : ''; \n \n\n this.runhtml = this.runhtml || '';\n \n if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {\n // then we need to reload the browser using\n // load_html_string..\n \n // then trigger a redraw once it's loaded..\n this.pendingRedraw = true;\n var runhtml = ''+ \"\\n\" ;\n \n this.runhtml = project.runhtml;\n // need to modify paths\n \n \n \n var html = imports.File.File.read(__script_path__ + '/../builder.html');\n html = html.replace('', runhtml + this.runhtml + '');\n print(\"LOAD HTML \" + html);\n this.el.load_html_string( html , \n //fixme - should be a config option!\n 'http://localhost/app.Builder/'\n );\n this.redraws = 0;\n // should trigger load_finished! - which in truns shoudl set refresh Required;\n return;\n \n }\n \n \n this.renderedData = data;\n var str = JSON.stringify(data) ;\n \n if (!this.ready) {\n console.log('not loaded yet');\n }\n this.lastRedraw = new Date();\n\n this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n print( \"before render\" + this.lastRedraw);\n print( \"after render\" + (new Date()));\n \n}\n", + "|xns": "WebKit" + } + ] + } + ] + }, + { + "id": "RightGtkView", + "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 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\n // does something similar to xobject..\n //item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;\n \n // pack is forced to 'false'\n if (item.pack===false || item.pack === 'false') { // no ;\n return;\n }\n \n print(\"CREATE: \" + item['|xns'] + '.' + item['xtype']);\n \n \n var type = item['|xns'] + '.' + item['xtype'];\n \n if (item['|xns'] == 'GtkClutter') { // we can not add this yet!\n return false;\n }\n \n var ns = imports.gi[item['|xns']];\n var ctr = ns[item['xtype']]; // why are we using array here..?\n \n\n \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 // value is a function..\n\tif (k[0] == '|' && typeof(kv) == 'string') {\n\n\t\tif (kv.match(new RegExp('function'))) {\n\t\t\tcontinue;\n }\n\t\tprint(\"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 var altctr = XObject.baseXObject({ xtype: ctr} );\n var pack_m = false;\n if (!item.pack && altctr) {\n // try XObject.\n print(\"SETTING PACK TO XObjectBase method\");\n pack_m = altctr.prototype.pack;\n \n \n }\n \n var el = new ctr(ctr_args);\n item.el = el;\n print(\"PACK\" + item.pack);\n //console.dump(item.pack);\n \n \n \n \n var args = [];\n if (!pack_m) {\n item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;\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 (typeof(pack_m) == 'string' && 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 (typeof(pack_m) == 'string') {\n par[pack_m].apply(par, args);\n } else if (pack_m) {\n pack_m.call(item, par, item);\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 \n \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", + "|widgetPressEvent": "function(w,e,u,d) {\n if (this.get('view').pressed) {\n return false;\n }\nthis.get('view').pressed = true;\n print(\"WIDGET PRESS \" + d.xtreepath ); \n this.get('/LeftTree.view').selectNode( d.xtreepath ); \n return false;\n}\n", + "|widgetReleaseEvent": "function() {\n this.get('view').pressed = false;\n return false;\n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "pack_start,false,true,0", + "items": [ + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "pack_start,false,false,0", + "label": "Run The Application", + "listeners": { + "button_press_event": "function (self, event) {\n // call render on left tree - with special option!?!\n \n //print(\"GET PROEJCT\");\n var pr = this.get('/LeftProjectTree').getActiveProject();\n \n var dir = '';\n for (var i in pr.paths) { \n dir = i;\n break;\n }\n var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; \n this.get('/Terminal').feed(\"RUN DIR:\" + dir);\n \n this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__) \n\t, false,false,false); \n var cmd = \"/usr/bin/seed \" + runner + \" \" + dir + \"\\n\";\n this.get('/Terminal').el.feed_child(cmd, cmd.length);\n return false;\n \n\n}" + } + } + ] + }, + { + "|xns": "Gtk", + "xtype": "ScrolledWindow", + "pack": "add", + "id": "view-sw", + "|shadow_type": "Gtk.ShadowType.IN", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", + "items": [ + { + "|xns": "Gtk", + "xtype": "EventBox", + "pack": "add_with_viewport", + "|init": "function() {\n XObject.prototype.init.call(this);\nthis.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({\n red: 0x9F00, green: 0xB800 , blue : 0xA800\n }));\n} \n", + "items": [ + { + "|xns": "Gtk", + "xtype": "Fixed", + "pack": "add", + "|init": "function() {\n\tXObject.prototype.init.call(this);\n\t//this.el.set_hadjustment(this.parent.el.get_hadjustment());\n\t//this.el.set_vadjustment(this.parent.el.get_vadjustment());\n \n}\n", + "items": [ + { + "|xns": "Gtk", + "xtype": "EventBox", + "pack": "put,10,10", + "|init": "function() {\n\t//this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);\n\tXObject.prototype.init.call(this);\n\n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n null, /* lists of target to support */\n 0, /* size of list */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n \n // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n}\n", + "ready": false, + "|getActiveNode": "function(x,y)\n{\n // workout what node is here..\n return '0'; // top..\n}", + "id": "view", + "listeners": { + "drag_motion": "function (self, ctx, x, y, time) {\n \n // A) find out from drag all the places that node could be dropped.\n var src = Gtk.drag_get_source_widget(ctx);\n if (!src.dropList) {\n Gdk.drag_status(ctx, 0, time);\n return true;\n }\n // b) get what we are over.. (from activeNode)\n // tree is empty.. - list should be correct..\n if (!this.get('/LeftTree.model').currentTree) {\n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n return true;\n \n }\n // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)\n var activeNode = this.getActiveNode(x, y);\n \n \n var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);\n console.dump(tg);\n if (!tg.length) {\n Gdk.drag_status(ctx, 0,time);\n this.get('/LeftTree.view').highlight(false);\n return true;\n }\n \n // if we have a target..\n // -> highlight it! (in browser)\n // -> highlight it! (in tree)\n \n Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);\n this.get('/LeftTree.view').highlight(tg);\n this.targetData = tg;\n // for tree we should handle this...\n return true;\n}", + "drag_drop": "function (self,ctx, x, y, time) {\n\tSeed.print(\"TARGET: drag-drop\");\n var is_valid_drop_site = true;\n \n \n Gtk.drag_get_data\n (\n self, /* will receive 'drag-data-received' signal */\n ctx, /* represents the current state of the this.gDnD */\n this.get('/Window').atoms[\"STRING\"], /* the target type we want */\n time /* time stamp */\n );\n \n \n /* No target offered by source => error */\n \n\n return is_valid_drop_site;\n \n}", + "drag_data_received": "function (w, ctx, x, y, sel_data, target_type, time, ud) \n {\n Seed.print(\"GtkView: drag-data-received\");\n var delete_selection_data = false;\n var dnd_success = false;\n /* Deal with what we are given from source */\n if( sel_data && sel_data.length ) {\n \n if (ctx.action == Gdk.DragAction.ASK) {\n /* Ask the user to move or copy, then set the ctx action. */\n }\n\n if (ctx.action == Gdk.DragAction.MOVE) {\n delete_selection_data = true;\n }\n var source = Gtk.drag_get_source_widget(ctx);\n\n Seed.print(\"Browser: source.DRAGDATA? \" + source.dragData);\n if (this.targetData) {\n Seed.print(this.targetData);\n this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);\n }\n \n \n \n dnd_success = true;\n\n }\n\n if (dnd_success == false)\n {\n Seed.print (\"DnD data transfer failed!\\n\");\n }\n \n Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);\n return true;\n }", + "button_press_event": "function (self, event) {\n this.pressed = false;\n return false;\n}" + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "Help", + "pack": "add", + "xtype": "ScrolledWindow", + "|show": "function() {\n \n var file = this.get('/LeftTree').getActiveFile();\n if (!file) {\n return;\n }\n var activeEl = this.get('/LeftTree').getActiveElement();\n var xtype = file.guessName( activeEl )\n if (!xtype || !xtype.length) {\n return;\n }\n //this.get('/Window.view-help-nb').el.set_current_page(1);\n \n // get the active element being edited.\n var helpurl = file.getHelpUrl(xtype); \n \n // now load the help info in the page..\n this.get('help-view').el.open(helpurl);\n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "WebKit", + "xtype": "WebView", + "pack": "add", + "id": "help-view", + "|init": "function() {\n XObject.prototype.init.call(this);\n this.get('/Window.help-view').el.open(\n \"http://devel.akbkhome.com/seed/\");\n\n}\n", + "zoom_level": 0.8 + } + ] + } + ] + } + ] + }, + { + "id": "BottomPane", + "pack": "add", + "xtype": "Notebook", + "|init": "function() {\n XObject.prototype.init.call(this);\n\t//this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Code Editor\" }));\n \tthis.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : \"Console\" }));\n \tthis.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : \"Inspector\" }));\n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "ScrolledWindow", + "pack": "add", + "items": [ + { + "|xns": "Vte", + "xtype": "Terminal", + "pack": "add", + "id": "Terminal", + "|feed": "function(istr) {\n var str = istr.replace(/\\n/g, \"\\r\\n\") + \"\\r\\n\";\n // we should make ourselves visable!!!\n this.get('/BottomPane').el.show();\n this.get('/BottomPane').el.set_current_page(1);\n\n this.el.feed(str ,str.length);\n}\n", + "|scroll_on_output": true, + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_size (80, 1000);\n}\n", + "scrollback_lines": 1000 + } + ] + }, + { + "xtype": "ScrolledWindow", + "|xns": "Gtk", + "pack": "add", + "listeners": {}, + "items": [ + { + "id": "inspector", + "pack": "add", + "xtype": "WebView", + "|xns": "WebKit" + } + ] + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "VBox", + "pack": "pack_start,false,false", + "id": "RightPalete", + "|hide": "function() {\n \n this.get('buttonbar').el.show();\n this.get('viewbox').el.hide();\n print(\"TRIED TO HIDE\");\n}\n", + "|show": "function() {\n this.get('buttonbar').el.hide();\n this.get('viewbox').el.show();\n // this.get('model').expanded();\n \n}\n", + "provider": false, + "items": [ + { + "|xns": "Gtk", + "xtype": "VBox", + "pack": "add", + "id": "buttonbar", + "items": [ + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "pack_start,false,true", + "listeners": { + "clicked": "function (self) {\n\tthis.get('/RightPalete').show();\n}" + }, + "items": [ + { + "|xns": "Gtk", + "xtype": "Image", + "pack": "add", + "|stock": "Gtk.STOCK_GOTO_FIRST", + "|icon_size": "Gtk.IconSize.MENU" + } + ] + }, + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "add", + "label": "Palete", + "angle": 270, + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );\n}\n", + "listeners": { + "enter_notify_event": "function (self, event) {\n this.get('/RightPalete').show();\n return false;\n}" + } + } + ] + }, + { + "|xns": "Gtk", + "xtype": "VBox", + "pack": "add", + "id": "viewbox", + "items": [ + { + "|xns": "Gtk", + "xtype": "HBox", + "pack": "pack_start,false,true", + "items": [ + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "add", + "label": "Palete" + }, + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "pack_start,false,true", + "listeners": { + "clicked": "function (self) {\n\tthis.get('/RightPalete').hide();\n}" + }, + "items": [ + { + "|xns": "Gtk", + "xtype": "Image", + "pack": "add", + "|stock": "Gtk.STOCK_GOTO_LAST", + "|icon_size": "Gtk.IconSize.MENU" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "ScrolledWindow", + "pack": "add", + "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\n}\n", + "|shadow_type": "Gtk.ShadowType.IN", + "items": [ + { + "listeners": { + "drag_begin": "function (self, ctx) {\n // we could fill this in now...\n Seed.print('SOURCE: drag-begin');\n \n \n \n var iter = new Gtk.TreeIter();\n var s = this.selection;\n s.get_selected(this.get('/RightPalete.model').el, iter);\n var path = this.get('/RightPalete.model').el.get_path(iter);\n \n var pix = this.el.create_row_drag_icon ( path);\n \n \n Gtk.drag_set_icon_pixmap (ctx,\n pix.get_colormap(),\n pix,\n null,\n -10,\n -10);\n \n var value = new GObject.Value('');\n this.get('/RightPalete.model').el.get_value(iter, 0, value);\n if (!this.get('/RightPalete').provider) {\n return false;\n }\n this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);\n this.el.dragData = value.value;\n \n \n \n \n return true;\n}", + "drag_data_get": "function (self, drag_context, selection_data, info, time) {\n \t//Seed.print('Palete: drag-data-get: ' + target_type);\n if (this.el.dragData && this.el.dragData.length ) {\n selection_data.set_text(this.el.dragData ,this.el.dragData.length);\n }\n \n \n //this.el.dragData = \"TEST from source widget\";\n \n \n}", + "drag_end": "function (self, drag_context) {\n \tSeed.print('SOURCE: drag-end');\n\tthis.el.dragData = false;\n\tthis.el.dropList = false;\n\tthis.get('/LeftTree.view').highlight(false);\n\treturn true;\n}", + "button_press_event": "function (self, event) {\n\n \tif (!this.get('/Editor').save()) {\n \t // popup!! - click handled.. \n \t return true;\n }\n return false;\n}" + }, + "pack": "add", + "xtype": "TreeView", + "|enable_tree_lines": true, + "|headers_visible": false, + "|init": "function() {\n XObject.prototype.init.call(this);\n this.el.set_size_request(150,-1);\n // set_reorderable: [1]\n \n var description = new Pango.FontDescription.c_new();\n description.set_size(8000);\n this.el.modify_font(description);\n \n this.selection = this.el.get_selection();\n this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n // this.selection.signal['changed'].connect(function() {\n // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);\n //});\n // see: http://live.gnome.org/GnomeLove/DragNDropTutorial\n \n Gtk.drag_source_set (\n this.el, /* widget will be drag-able */\n Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n null, /* lists of target to support */\n 0, /* size of list */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);\n \n Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);\n Gtk.drag_source_add_text_targets(this.el); \n /*\n print(\"RP: TARGET:\" + LeftTree.atoms[\"STRING\"]);\n targets = new Gtk.TargetList();\n targets.add( LeftTree.atoms[\"STRING\"], 0, 0);\n targets.add_text_targets( 1 );\n Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);\n \n //if you want to allow text to be output elsewhere..\n //Gtk.drag_source_add_text_targets(this.el);\n */\n return true; \n}\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "ListStore", + "pack": "set_model", + "|init": "function() {\n XObject.prototype.init.call(this);\nthis.el.set_column_types ( 2, [\n GObject.TYPE_STRING, // title \n GObject.TYPE_STRING // tip\n \n ] );\n}\n", + "id": "model", + "|load": "function(tr,iter)\n{\n if (!iter) {\n this.el.clear();\n }\n //console.log('Project tree load: ' + tr.length);\n var citer = new Gtk.TreeIter();\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.length; i++) {\n if (!iter) {\n \n this.el.append(citer); \n } else {\n this.el.insert(citer,iter,-1);\n }\n \n var r = tr[i];\n //Seed.print(r);\n this.el.set_value(citer, 0, '' + r ); // title \n \n //this.el.set_value(citer, 1, new GObject.Value( r)); //id\n //if (r.cn && r.cn.length) {\n // this.load(r.cn, citer);\n //}\n }\n \n \n}", + "|getValue": "function (iter, col) {\n var gval = new GObject.Value('');\n this.el.get_value(iter, col ,gval);\n return gval.value;\n \n \n}" + }, + { + "|xns": "Gtk", + "xtype": "TreeViewColumn", + "pack": "append_column", + "|init": "function() {\n XObject.prototype.init.call(this);\n\tthis.el.add_attribute(this.items[0].el , 'markup', 0 );\n}\n", + "items": [ + { + "|xns": "Gtk", + "xtype": "CellRendererText", + "pack": "pack_start" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/old-javascript/Builder3/Window.js b/old-javascript/Builder3/Window.js new file mode 100644 index 000000000..042744095 --- /dev/null +++ b/old-javascript/Builder3/Window.js @@ -0,0 +1,4340 @@ + Gtk = imports.gi.Gtk; +Gdk = imports.gi.Gdk; +Pango = imports.gi.Pango; +GLib = imports.gi.GLib; +Gio = imports.gi.Gio; +GObject = imports.gi.GObject; +GtkSource = imports.gi.GtkSource; +WebKit = imports.gi.WebKit; +Vte = imports.gi.Vte; +console = imports.console; +XObject = imports.XObject.XObject; + + + +Window=new XObject({ + xtype: Gtk.Window, + listeners : { + delete_event : function (self, event) { + return false; + }, + destroy : function (self) { + Gtk.main_quit(); + }, + show : function (self) { + + imports.ProjectManager.ProjectManager.loadConfig(); + + print("HIDEWIN - calling MidPropTree hidewin") + this.get('/MidPropTree').hideWin(); + this.get('/RightPalete').hide(); + this.get('/BottomPane').el.hide(); + //this.get('/Editor').el.show_all(); + + } + }, + border_width : 0, + default_height : 500, + default_width : 800, + id : "Window", + title : "Application Builder", + + setTitle : function(str) { + this.el.set_title(this.title + ' - ' + str); + }, + type : Gtk.WindowType.TOPLEVEL, + items : [ + { + xtype: Gtk.VBox, + id : "w-vbox", + items : [ + { + xtype: Gtk.MenuBar, + pack : "pack_start,false,false", + items : [ + { + xtype: Gtk.MenuItem, + use_underline : true, + label : "_File", + items : [ + { + xtype: Gtk.Menu, + pack : "set_submenu", + items : [ + { + xtype: Gtk.MenuItem, + use_underline : true, + label : "New _Project", + listeners : { + activate : function (self) { + var _this = this; + this.get('/EditProject').show({ + success : function(pr) { + _this.get('/LeftProjectTree').get('combo').setValue(pr.fn); + } + }); + } + } + }, + { + xtype: Gtk.MenuItem, + label : "_New File", + use_underline : true, + listeners : { + activate : function (self) { + var fn = this.get('/LeftProjectTree.combo').getValue(); + if (!fn) { + this.get('/LeftProjectTree').showNoProjectSelected(); + return true; + } + var pm = imports.ProjectManager.ProjectManager; + this.get('/DialogNewComponent').show({ + project : pm.getByFn(fn) + }); + } + } + }, + { + xtype: Gtk.SeparatorMenuItem, + pack : "add" + }, + { + xtype: Gtk.MenuItem, + use_underline : true, + pack : "add", + label : "D_elete Project", + listeners : { + activate : function (self) { + + var fn = this.get('/LeftProjectTree').get('combo').getValue(); + if (!fn.length) { + this.get('/StandardErrorDialog').show("Select a project") + return; + } + var pm = imports.ProjectManager.ProjectManager; + var pr = pm.getByFn(fn); + + // confirm.. + this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() { + pm.deleteProject(fn); + print("DELETE?"); + }); + + } + } + }, + { + xtype: Gtk.SeparatorMenuItem, + pack : "add" + }, + { + xtype: Gtk.MenuItem, + pack : "add", + label : "_Quit", + use_underline : true, + listeners : { + activate : function (self) { + Gtk.main_quit(); + } + } + } + ] + } + ] + }, + { + xtype: Gtk.MenuItem, + label : "_Edit", + use_underline : true, + pack : "add", + items : [ + { + xtype: Gtk.Menu, + pack : "set_submenu", + items : [ + { + xtype: Gtk.MenuItem, + listeners : { + activate : function (self) { + var fn = this.get('/LeftTree').getActiveFile(); + if (!fn) { + this.get('/StandardErrorDialog').show("No File active"); + return true; + } + + this.get('/DialogNewComponent').show(fn); + return true; + } + }, + label : "File _Properties", + pack : "add", + use_underline : true + }, + { + xtype: Gtk.MenuItem, + listeners : { + activate : function (self, event) { + this.get('/RooProjectProperties').show(); + return false; + } + }, + label : "Modify Project HTML ", + pack : "add", + use_underline : true + } + ] + } + ] + }, + { + xtype: Gtk.MenuItem, + label : "_View", + use_underline : true, + items : [ + { + xtype: Gtk.Menu, + pack : "set_submenu", + items : [ + { + xtype: Gtk.MenuItem, + listeners : { + activate : function (self, event) { + var js = this.get('/LeftTree.model').toJS(); + if (js && js[0]) { + this.get('/RightBrowser.view').renderJS(js[0], true); + } + return false; + } + }, + label : "_Redraw (Roo)", + pack : "add", + use_underline : true + }, + { + xtype: Gtk.MenuItem, + listeners : { + activate : function (self, event) + { + /* Firefox testing for debugging.. + - we can create a /tmp directory, and put. + builder.html, builder.html.js, link roojs1 + add at the end of builder.html Roo.onload(function() { + */ + if (!this.get('/Window.LeftTree').getActiveFile()) { + return; + } + + var js = this.get('/LeftTree.model').toJS(); + if (!js || !js[0]) { + return; + } + var project = this.get('/Window.LeftTree').getActiveFile().project; + //print (project.fn); + + project.runhtml = project.runhtml || ''; + + + var File = imports.File.File; + + var target = "/tmp/firetest"; // fixme.. + if (!File.isDirectory(target)) { + File.mkdir(target); + } + File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE); + if (!File.exists( target+ '/roojs1')) { + File.link( target+ '/roojs1', __script_path__ + '/../roojs1'); + } + + + + var html = imports.File.File.read(__script_path__ + '/../builder.html'); + html = html.replace('', project.runhtml + ''); + + + var jsstr = JSON.stringify(js[0], null, 4); + + var runbuilder = ''; + + html = html.replace('', runbuilder + ''); + + File.write( target+ '/builder.html', html); + + this.get('/Terminal').feed("RUN DIR:" + target); + var out = {}; + this.get('/Terminal').el.fork_command_full( + Vte.PtyFlags.DEFAULT, + target , + [], //argv + [], // env + 0, //spawn flags + null, // user func + null, // child setupdata + out + ); + var cmd = "firefox file://" + target + "/builder.html \n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + return false; + } + }, + label : "_Test in Firefox (Roo)", + pack : "add", + use_underline : true + } + ] + } + ] + }, + { + xtype: Gtk.MenuItem, + label : "_Help", + use_underline : true, + pack : "add", + items : [ + { + xtype: Gtk.Menu, + pack : "set_submenu", + items : [ + { + xtype: Gtk.MenuItem, + pack : "add", + label : "_About", + use_underline : true, + listeners : { + activate : function (self) { + this.get('/About').el.run(); + } + } + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.HPaned, + id : "left", + position : 400, + items : [ + { + xtype: Gtk.HBox, + items : [ + { + xtype: Gtk.VPaned, + position : 300, + id : "leftvpaned", + items : [ + { + xtype: Gtk.VBox, + id : "LeftTopPanel", + items : [ + { + xtype: Gtk.Expander, + events : [ + Gdk.EventMask.BUTTON_MOTION_MASK + ], + + listeners : { + activate : function (self) { + // this does not actually expand it.. + // that is done by GTK.. + + + if (!this.get('/Editor').save()) { + // popup!! - click handled.. + return true; + } + + if (!this.el.expanded) { + this.onExpand(); + } else { + this.onCollapse(); + } + return true; + + } /*, + enter_notify_event : function (self, event) { + return true; + this.el.expanded = !this.el.expanded; + //if (this.el.expanded ) { + this.listeners.activate.call(this); + // } + + return true; + } + */ + }, + id : "expander", + label : "Select Project or File", + pack : "pack_start,false,true", + + onCollapse : function() { + + var nb = this.get('/LeftTopPanel.notebook'); + nb.el.set_current_page(0); + }, + onExpand : function() { + var nb = this.get('/LeftTopPanel.notebook'); + var pm = imports.ProjectManager.ProjectManager; + + + var model = this.get('/LeftProjectTree.combomodel'); + // print ("loading Projects?") + //print(JSON.stringify(pm.projects, null,4));Seed.quit(); + //console.dump(pm.projects); + model.loadData(pm.projects); + + + nb.el.set_current_page(1); + //pm.on('changed', function() { + //console.log("CAUGHT project manager change"); + // _combo.model.loadData(pm.projects); + //} + return; + } + }, + { + xtype: Gtk.Notebook, + id : "notebook", + pack : "pack_start,true,true", + current_page : 0, + + show_border : false, + show_tabs : false, + items : [ + { + xtype: Gtk.ScrolledWindow, + id : "LeftTree", + pack : "add", + getActiveElement : function() { // return path to actie node. + + var path = this.getActivePath(); + if (!path) { + return false; + } + var ret ={} ; + this.get('model').el.get_iter_from_string(ret, path); + + var value = ''+ this.get('model').el.get_value(ret.iter, 2).value.get_string(); + + return JSON.parse(value); + }, + getActiveFile : function() { + return this.get('model').file; + }, + getActivePath : function() { + var model = this.get('model'); + var view = this.get('view'); + if (view.selection.count_selected_rows() < 1) { + return false; + } + var ret = {}; + view.selection.get_selected(ret); + return ret.model.get_path(ret.iter).to_string(); + }, + getPaleteProvider : function() { + var model = this.get('model'); + var pm = imports.ProjectManager.ProjectManager; + return pm.getPalete(model.file.getType()); + }, + getRenderer : function() { + + switch( this.getActiveFile().getType()) { + case 'Roo': + return this.get('/RightBrowser.view'); + case 'Gtk': + return this.get('/RightGtkView'); + } + return false; + + }, + + renderView : function() { + var render = this.getRenderer(); + var model = this.get('model'); + if (render) { + render.renderJS(model.toJS(false,true)[0]); + } else { + print("NO RENDER JS METHOD?"); + } + }, + shadow_type : Gtk.ShadowType.IN, + items : [ + { + xtype: Gtk.TreeView, + listeners : { + button_press_event : function (self, ev) { + console.log("button press?"); + + if (!this.get('/Editor').save()) { + // popup!! - click handled.. + return true; + } + + if (ev.button.button != 3) { + print("click" + ev.button.button); + return false; + } + + + var res = {}; + this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res); + + if (!this.get('/LeftTreeMenu').el) { + this.get('/LeftTreeMenu').init(); + } + + this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default()); + this.get('/LeftTreeMenu').el.show_all(); + this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time); + print("click:" + res.path.to_string()); + return false; + }, + drag_begin : function (self, ctx) { + print('SOURCE: drag-begin'); + this.targetData = false; + // find what is selected in our tree... + var ret ={}; + this.selection.get_selected(ret); + + // set some properties of the tree for use by the dropped element. + var value = ''+ ret.model.get_value(ret.iter, 2).value.get_string(); + var data = JSON.parse(value); + var xname = this.get('/LeftTree.model').file.guessName(data); + + this.el.dragData = xname; + this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname); + + + // make the drag icon a picture of the node that was selected + var path = ret.model.get_path(ret.iter); + this.el.treepath = path.to_string(); + + // returns a cairo surface + var pix = this.el.create_row_drag_icon ( path); + + if (Gtk.drag_set_icon_surface) { + Gtk.drag_set_icon_surface( ctx, pix ); + } else { + Gtk.drag_set_icon_pixmap (ctx, + pix.get_colormap(), pix, null, -10, -10); + } + + return true; + }, + drag_end : function (self, drag_context) { + Seed.print('LEFT-TREE: drag-end'); + this.el.dragData = false; + this.el.dropList = false; + this.targetData = false; + this.get('/LeftTree.view').highlight(false); + return true; + }, + drag_data_get : function(self, ctx, sel_data, info, time) + { + + sel_data.set_text( + "HELOLW" + + ); + + }, + + drag_motion : function (self, ctx, x, y, time) { + console.log("LEFT-TREE: drag-motion"); + var src = Gtk.drag_get_source_widget( ctx); + + // a drag from elsewhere...- prevent drop.. + if (!src.dragData) { + print("no drag data!"); + Gdk.drag_status(ctx, 0, time); + this.targetData = false; + return true; + } + var action = Gdk.DragAction.COPY; + if (src == this.el) { + // unless we are copying!!! ctl button.. + action = ctx.get_actions() & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; + } + var data = {}; + + if (!this.get('/LeftTree.model').el.iter_n_children(null)) { + // no children.. -- asume it's ok.. + this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , '']; + Gdk.drag_status(ctx, action ,time); + return true; + } + + print("GETTING POS"); + var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data); + print("ISOVER? " + isOver); + if (!isOver) { + Gdk.drag_status(ctx, 0 ,time); + return false; // not over apoint!?! + } + // drag node is parent of child.. + console.log("SRC TREEPATH: " + src.treepath); + console.log("TARGET TREEPATH: " + data.path.to_string()); + + // nned to check a few here.. + //Gtk.TreeViewDropPosition.INTO_OR_AFTER + //Gtk.TreeViewDropPosition.INTO_OR_BEFORE + //Gtk.TreeViewDropPosition.AFTER + //Gtk.TreeViewDropPosition.BEFORE + + if (typeof(src.treepath) != 'undefined' && + src.treepath == data.path.to_string().substring(0,src.treepath.length)) { + print("subpath drag"); + Gdk.drag_status( ctx, 0 ,time); + return false; + } + + // check that + //print("DUMPING DATA"); + //console.dump(data); + // path, pos + + print(data.path.to_string() +' => '+ data.pos); + var tg = this.get('/LeftTree.model').findDropNodeByPath( + data.path.to_string(), src.dropList, data.pos); + + this.get('/LeftTree.view').highlight(tg); + if (!tg.length) { + print("Can not find drop node path"); + this.targetData = false; + Gdk.drag_status(ctx, 0, time); + return true; + } + // print(JSON.stringify(tg,null,4)); + //console.dump(tg); + this.targetData = tg; + + + Gdk.drag_status(ctx, action ,time); + + return true; + }, + drag_drop : function (w, ctx, x, y, time) { + Seed.print("TARGET: drag-drop"); + //print(JSON.stringify(w.drag_dest_get_target_list(),null,4)); + w.drag_get_data + ( /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the DnD */ + imports.Builder3.Globals.atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); + + + /* No target offered by source => error */ + + + return true; + }, + drag_data_received : function (self, ctx, x, y, sel_data, info, time) { + print("Tree: drag-data-received"); + + var delete_selection_data = false; + var dnd_success = false; + //print(JSON.stringify(sel_data, null,4)); + /* Deal with what we are given from source */ + + // simce I can not be bothered to sort out + // drag drop = let's assume it worked... + + if( true || (sel_data && sel_data.length )) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + + if (ctx.action == Gdk.DragAction.MOVE) { + //delete_selection_data = true; + } + + var source = Gtk.drag_get_source_widget( ctx ); + + if (this.targetData) { + if (source != this.el) { + print("DRAG FROM ANOTHER WIDGET"); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } else { + // drag around.. - reorder.. + print("DRAG FROM SELF"); + this.get('/LeftTree.model').moveNode(this.targetData, ctx.action); + + + } + //Seed.print(this.targetData); + + } + + + + // we can send stuff to souce here... + + dnd_success = true; + + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish ( ctx, dnd_success, delete_selection_data, time); + return true; + }, + cursor_changed : function (self) { + if (this.blockChanges) { // probably not needed.. + return true; + } + var render = this.get('/LeftTree').getRenderer(); + + + if (this.selection.count_selected_rows() < 1) { + this.get('/LeftPanel.model').load( false); + this.get('/MidPropTree').activeElement = false; + this.get('/MidPropTree').hideWin(); + + var pm = this.get('/RightPalete.model'); + if (!this.get('/LeftTree').getPaleteProvider()) { + // it may not be loaded yet.. + return true; + } + pm.load( + this.get('/LeftTree').getPaleteProvider().gatherList( + this.get('/LeftTree.model').listAllTypes() + ) + ); + if (render && render.redraw) { + render.redraw(); + } + return true; + } + + //console.log('changed'); + var s = this.selection; + var ret = {}; + s.get_selected(ret); + + // var val = ""; + var value = ''+ret.model.get_value(ret.iter, 2).value.get_string(); + this.get('/LeftPanel.model').activePath = ret.model.get_path(ret.iter).to_string(); + + print("----------START EDITING: " + this.get('/LeftTree').getActivePath() ); + + + var data = JSON.parse(value); + this.get('/MidPropTree').activeElement = data; + this.get('/MidPropTree').hideWin(); + this.get('/LeftPanel.model').load( data); + + console.log(value); + // _g.button.set_label(''+value.get_string()); + + var pm =this.get('/RightPalete.model'); + pm.load( this.get('/LeftTree').getPaleteProvider().gatherList( + this.get('/LeftTree.model').listAllTypes())); + + + if (render && render.redraw) { + render.redraw(); + } + + //Seed.print( value.get_string()); + return true; + + } + }, + 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'), ''] + ); + }); + + this.el.drag_source_set( /* 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 */ + ); + + this.el.drag_source_set_target_list(imports.Builder3.Globals.targetList); + + this.el.drag_source_add_text_targets(); + this.el.drag_dest_set + ( + 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 */ + ); + + this.el.drag_dest_set_target_list( imports.Builder3.Globals.targetList); + this.el.drag_dest_add_text_targets( ); + }, + 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, + activePath : false, + currentTree : false, + id : "model", + pack : "set_model", + + setFromNode : function(tp, n) + { + if (tp === false) { + tp = this.get('/LeftTree').getActivePath(); + } + var ret= {} + this.el.get_iter(ret, new Gtk.TreePath.from_string( tp ) ); + this.el.set_value(ret.iter, 0, '' + this.nodeTitle(n)); + this.el.set_value(ret.iter, 1, '' + this.nodeTitle(n)); + this.el.set_value(ret.iter, 2, '' + this.nodeToJSON(n)); + + }, + + changed : function( refresh) { + + + + print("-------MODEL CHANGED CALLED" ); + + //this.currentTree = this.toJS(false, true)[0]; + var d = new Date(); + this.file.items = this.toJS(false, false); + print ("TO JS in " + ((new Date()) - d) + "ms"); + // print("AFTER CHANGED"); + //console.dump(this.file.items); + this.file.save(); + if (typeof(this.file.valaCompileCmd) !== 'undefined') { + var cmd = this.file.valaCompileCmd(); + print(cmd.join(" ")); + try { + + var Spawn = imports.Spawn; + var output = Spawn.run({ + cwd : '/tmp', + args : cmd, + env : [] // optional + + }); + print(output); + } catch(e) { + print(e.message); + print(e.toString()); + } + /* + print(cmd.join(' ')); + var out = {}; + this.get('/Terminal').el.fork_command_full( + Vte.PtyFlags.DEFAULT, + '/tmp', + cmd, //argv + [], // env + 0, //spawn flags + null, // user func + null, // child setupdata + out + ); + */ + //var cmd = "/usr/bin/seed " + runner + " " + dir + "\n"; + //this.get('/Terminal').el.feed_child(cmd, cmd.length); + + + + } + + this.currentTree = this.file.items[0]; + //console.log(this.file.toSource()); + + if (refresh) { + print("REDNER BROWSER?!"); + this.get('/LeftTree').renderView(); + + var pm = this.get('/RightPalete.model'); + if (!this.get('/RightPalete').provider) { + pm.load([]); + return; + } + + + pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes())); + //imports['Builder/RightBrowser.js'].renderJS(this.toJS()); + } + + }, + deleteSelected : function() { + this.get('/LeftTree.view').blockChanges = true; + var oret = {}; + var s = this.get('/LeftTree.view').selection; + s.get_selected(oret); + var path = this.el.get_path(oret.iter).to_string(); + + this.activePath= false; + s.unselect_all(); + + this.activePath= false; + var ret = {}; + this.el.get_iter_from_string(ret, path); + this.el.remove(ret.iter); + + // rebuild treemap. -- depreciated.!! + this.map = {}; + this.treemap = { }; + //this.toJS(null, true) // does not do anything? + this.activePath= false; + this.changed(true); + this.get('/LeftTree.view').blockChanges = false; + }, + dropNode : function(target_data, node) { + print("drop Node"); + // console.dump(node); + //print(JSON.Stringify(target_data, null, 4)); + var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false; + + print("add " + tp + "@" + target_data[1] ); + var parent = tp; + var after = false; + if (tp && target_data[1] < 2) { // before or after.. + var ar = target_data[0].split(':'); + ar.pop(); + parent = new Gtk.TreePath.from_string( ar.join(':') ); + after = tp; + } + var nret = {}; + var pret = {} + var aret = after ? {} : false; + + + + if (parent !== false) { + this.el.get_iter(pret, parent); + } else { + pret.iter = null; + } + + + if (tp && after) { + print(target_data[1] > 0 ? 'insert_after' : 'insert_before'); + this.el.get_iter(aret, after); + this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before']( + nret, pret.iter, aret.iter); + + } else { + this.el.append(nret, pret.iter); + + } + var new_path = this.el.get_path(nret.iter).to_string(); + print("new path = " + new_path) + if (typeof(node) == 'string') { + var ar = node.split('.'); + var xtype = ar.pop(); + + node = { + '|xns' : ar.join('.'), + 'xtype' : xtype + }; + if (target_data.length == 3 && target_data[2].length) { + node['*prop'] = target_data[2]; + } + node = this.get('/DialogTemplateSelect').show(node); + + } + // work out what kind of packing to use.. + if (typeof(node.pack) == 'undefined' && parent !== false) { + var pal = this.get('/LeftTree').getPaleteProvider(); + if (pal.name == 'Gtk') { + var pname = pal.guessName(this.singleNodeToJS(parent.to_string())); + var cname = pal.guessName(node); + node.pack = pal.getDefaultPack(pname, cname); + } + + } + + + var xitems = []; + if (node.items) { + xitems = node.items; + delete node.items; + } + // load children - if it has any.. + + if (xitems) { + this.load(xitems, nret.iter); + this.get('/LeftTree.view').el.expand_row(this.el.get_path(nret.iter), true); + } + if (tp && (xitems || after)) { + this.get('/LeftTree.view').el.expand_row(this.el.get_path(pret.iter), true); + } + // wee need to get the empty proptypes from somewhere.. + + //var olditer = this.activeIter; + //this.activePath = new_path; + print("calling changed with node data") + // changed actually set's the node data.. + this.setFromNode(new_path,node); + this.changed(true); + + + + this.get('/LeftTree.view').el.set_cursor(this.el.get_path(nret.iter), null, false); + + //Builder.MidPropTree._model.load(node); + //Builder.MidPropTree._win.hideWin(); + //Builder.LeftPanel._model.load( node); + + + }, + findDropNode : function(treepath_str, targets) { + + // this is used by the dragdrop code in the roo version AFAIR.. + + var path = treepath_str.replace(/^builder-/, ''); + // treemap is depreciated... - should really check if model has any entries.. + + if (!this.el.iter_n_children(null)) { + print("NO KEYS"); + return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER]; + } + print("FIND treepath: " + path); + //console.dump(this.treemap); + + if (!treepath_str.match(/^builder-/)) { + return []; // nothing! + } + if (targets === true) { + return [ path ]; + } + return this.findDropNodeByPath(path,targets) + }, + findDropNodeByPath : function(treepath_str, targets, pref) { + var path = treepath_str + ''; // dupe it.. + pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref; + var last = false; + //console.dump(this.treemap); + while (path.length) { + print("LOOKING FOR PATH: " + path); + var node_data = this.singleNodeToJS(path); + if (node_data === false) { + print("node not found"); + return []; + } + + var xname = this.get('/LeftTree.model').file.guessName(node_data); + var match = false; + var prop = ''; + targets.forEach(function(tg) { + if (match) { + return;; + } + if ((tg == xname) ) { + match = tg; + } + if (tg.indexOf(xname +':') === 0) { + match = tg; + prop = tg.split(':').pop(); + } + }); + + if (match) { + if (last) { // pref is after/before.. + // then it's after last + if (pref > 1) { + return []; // do not allow.. + } + return [ last, pref , prop]; + + } + return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop]; + } + var par = path.split(':'); + last = path; + par.pop(); + path = par.join(':'); + } + + return []; + + }, + getIterValue : function (iter, col) { + + var gval = ''+this.el.get_value(iter, col).value.get_string(); + return gval; + + + }, + columns : [ + GObject.TYPE_STRING, // title + GObject.TYPE_STRING, // tip + GObject.TYPE_STRING // source.. + ] , + + + + listAllTypes : function() { + var s = this.get('/LeftTree.view').selection; + print ("LIST ALL TYPES: " + s.count_selected_rows() ); + + if (s.count_selected_rows() > 0) { + var ret = {} + s.get_selected(ret); + + // set some properties of the tree for use by the dropped element. + var value = ''+ this.el.get_value(ret.iter, 2).value.get_string(); + var data = JSON.parse(value); + + + var xname = this.get('/LeftTree.model').file.guessName(data); + console.log('selected:' + xname); + if (xname.length) { + return [ xname ]; + } + return []; // could not find it.. + } + + var ret = [ ]; + + var _this = this; + function addall(li) + { + var el; + for (var i =0 ; i < li.length; i++ ) { + el = li[i]; + + // this is specific to roo!!!? + if (!el) { // skip empty? + return; + } + var fullpath = _this.file.guessName(el); + if (fullpath.length && ret.indexOf(fullpath) < 0) { + ret.push(fullpath); + } + + + if (el.items && el.items.length) { + addall(el.items); + } + + }; + + + } + + addall([this.currentTree]); + + // only if we have nothing, should we add '*top' + if (!ret.length) { + ret = [ '*top' ]; + } + //console.log('all types in tree'); + //console.dump(ret); + + return ret; + + }, + load : function(tr,iter) + { + //this.insert(citer,iter,0); + + for(var i =0 ; i < tr.length; i++) { + var ret = { }; + if (iter) { + this.el.insert(ret ,iter,-1); + } else { + this.el.append(ret); + } + //print(JSON.stringify(ret,null,4)); + //print('call nodeToJSON: ' + tr[i]); + var body = this.nodeToJSON(tr[i]); + //print(body); + //this.el.set_value(ret.iter, 0, '' _ [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]); + //this.el.set_value(ret.iter, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]); + //this.el.set_value(ret.iter, 2, [GObject.TYPE_STRING, body ]); + this.el.set_value(ret.iter, 0, '' + this.nodeTitle(tr[i]) ); + this.el.set_value(ret.iter, 1, '' + this.nodeTip(tr[i]) ); + this.el.set_value(ret.iter, 2, '' + body ); + if (tr[i].items && tr[i].items.length) { + this.load(tr[i].items, ret.iter); + } + } + }, + loadFile : function(f) { + //console.dump(f); + print("LOADFILE"); + this.el.clear(); + this.file = f; + + if (!f) { + console.log('missing file'); + return; + } + + // load the file if not loaded.. + if (f.items === false) { + var _this = this; + f.loadItems(function() { + _this.loadFile(f); + }); + return; + + } + this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name); + + if (f.items.length && typeof(f.items[0]) == 'string') { + + //this.get('/RightEditor').el.show(); + //this.get('/RightEditor.view').load( f.items[0]); + return; + } + print("LOAD"); + //print(JSON.stringify(f.items, null,4)); + //console.dump(f.items); + this.load(f.items); + this.get('/LeftTree.view').el.expand_all(); + + if (!f.items.length) { + // single item.. + + this.get('/Window.leftvpaned').el.set_position(80); + // select first... + this.get('/LeftTree.view').el.set_cursor( + new Gtk.TreePath.from_string('0'), null, false); + + + } else { + this.get('/Window.leftvpaned').el.set_position(200); + } + + //return; -- debuggin + //print("hide right editior"); + //this.get('/RightEditor').el.hide(); + this.get('/Editor').el.hide(); + print("set current tree"); + + this.currentTree = this.toJS(false, false)[0]; + + + //console.dump(this.currentTree); + this.currentTree = this.currentTree || { items: [] }; + this.get('/LeftTree').renderView(); + // console.dump(this.map); + //var RightPalete = imports.Builder.RightPalete.RightPalete; + var pm = this.get('/RightPalete.model'); + // set up provider.. + + this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider(); + + if (!this.get('/RightPalete').provider) { + print ("********* PALETE PROVIDER MISSING?!!"); + } + this.get('/LeftTree').renderView(); + + pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes())); + + + + this.get('/Window.view-notebook').el.set_current_page( + this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1); + + }, + moveNode : function(target_data, action) { + //print("MOVE NODE"); + // console.dump(target_data); + var oret = {}; + var s = this.get('/LeftTree.view').selection; + s.get_selected( oret); + var node = this.nodeToJS(oret.iter,false); + //console.dump(node); + //print(JSON.stringify(node, null,4)); + + // needs to drop first, otherwise the target_data + // treepath will be invalid. + + this.dropNode(target_data, node); + if (action & Gdk.DragAction.MOVE) { + // print("REMOVING OLD NODE"); + this.el.remove(oret.iter); + + } + + this.activePath= false; + this.changed(true); + }, + nodeTip : function(c) { + var ret = this.nodeTitle(c,true); + var funcs = ''; + + + for( var i in c) { + + if (!i.length || i[0] != '|') { + continue; + } + if (i == '|init') { + continue; + } + if (typeof(c[i]) != 'string') { + continue; + } + //print("prop : " + i + ':' + c[i]); + if (!c[i].match(new RegExp('function'))) { + continue; + } + funcs += "\n" + i.substring(1) + ' : ' + c[i].split(/\n/).shift(); + + } + if (funcs.length) { + ret+="\n\nMethods:" + funcs; + } + return ret; + + }, + nodeTitle : function(c, renderfull) { + var txt = []; + c = c || {}; + var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false; + if (sr) txt.push(''); + if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); } + + if (renderfull && c['|xns']) { + txt.push(c['|xns']); + } + + if (c.xtype) { txt.push(c.xtype); } + if (c.id) { txt.push('[id=' + c.id + ']'); } + if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); } + if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); } + + + if (c.layout) { txt.push('' + c.layout + ''); } + if (c.title) { txt.push('' + c.title + ''); } + if (c.label) { txt.push('' + c.label+ ''); } + if (c.header) { txt.push('' + c.header + ''); } + if (c.legend) { txt.push('' + c.legend + ''); } + if (c.text) { txt.push('' + c.text + ''); } + if (c.name) { txt.push('' + c.name+ ''); } + if (c.region) { txt.push('(' + c.region + ')'); } + if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); } + + // for flat classes... + if (typeof(c['*class']) != 'undefined') { txt.push('' + c['*class']+ ''); } + if (typeof(c['*extends']) != 'undefined') { txt.push(': ' + c['*extends']+ ''); } + + + if (sr) txt.push(''); + return (txt.length == 0 ? "Element" : txt.join(" ")); + }, + nodeToJS : function (treepath, with_id) + { + //print("nodeToJS : WITHID: "+ with_id); + var iter = treepath; // API used to be iter here.. + if (typeof(iter) == 'string') { + var ret = {}; + if (!this.el.get_iter(ret, + new Gtk.TreePath.from_string(treepath))) { + return false; + } + iter = ret.iter; + } + var pret = {}; + var iv = this.getIterValue(iter, 2); + // print("IV" + iv); + var k = JSON.parse(iv); + if (k && k.json && !this.el.iter_parent( pret, iter )) { + delete k.json; + } + + if (with_id) { + var treepath_str = this.el.get_path(iter).to_string(); + // not sure how we can handle mixed id stuff.. + if (typeof(k.id) == 'undefined') { + k.id = 'builder-'+ treepath_str ; + } + + // needed?? + this.treemap[ treepath_str ] = k; + k.xtreepath = treepath_str ; + + } + if (this.el.iter_has_child(iter)) { + var cret = {}; + this.el.iter_children(cret, iter); + k.items = this.toJS(cret.iter,with_id); + } + return k; + }, + nodeToJSON : function(c) { + var o = {} + for (var i in c) { + if (i == 'items') { + continue; + } + o[i] = c[i]; + } + return JSON.stringify(o); + }, + singleNodeToJS : function (treepath) + { + var ret = {}; + if (!this.el.get_iter(ret, new Gtk.TreePath.from_string(treepath))) { + return false; + } + + var iv = this.getIterValue(ret.iter, 2); + + return JSON.parse(iv); + + }, + toJS : function(treepath, with_id) + { + //print("toJS : WITHID: "+ with_id); + + var iter = treepath; // API used to be iter here.. + + if (typeof(iter) == 'string') { + var ret = {}; + if (!this.el.get_iter(ret, new Gtk.TreePath.from_string(treepath))) { + return false; + } + iter = ret.iter; + } + + var first = false; + + if (!iter) { + + this.treemap = { }; + var ret = {}; + if (!this.el.get_iter_first(ret)) { + return []; + } + iter = ret.iter; + first = true; + } + + var ar = []; + + while (true) { + + var k = this.nodeToJS(iter, with_id); + ar.push(k); + + + if (!this.el.iter_next(iter)) { + break; + } + } + + if (treepath === false) { + //dupe!!! + return JSON.parse(JSON.stringify(ar)); + } + + return ar; + // convert the list into a json string.. + + + } + }, + { + xtype: Gtk.TreeViewColumn, + pack : "append_column", + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 0 ); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start" + } + ] + } + ] + }, + { + xtype: Gtk.Menu, + pack : false, + id : "LeftTreeMenu", + items : [ + { + xtype: Gtk.MenuItem, + pack : "add", + label : "Delete Element", + listeners : { + activate : function (self) { + + this.get('/LeftTree.model').deleteSelected(); + } + } + }, + { + xtype: Gtk.MenuItem, + listeners : { + activate : function (self) { + + var tree = this.get('/LeftTree'); + var model = this.get('/LeftTree.model'); + var el = tree.getActivePath(); + print(el); + var js = model.toJS(el, false); + // print(JSON.stringify(js[0], null,4)); + this.get('/DialogSaveTemplate').show(JSON.stringify(js[0], null,4)); + + + } + }, + label : "Save as Template", + pack : "add" + } + ] + } + ] + }, + { + xtype: Gtk.VBox, + pack : "add", + id : "LeftProjectTree", + showNoProjectSelected : function() { + this.get('/StandardErrorDialog').show("Select a Project first."); + }, + getActiveProject : function() { + return this.project; + }, + listeners : { + leave_notify_event : function (self, event) { + return false; + } + }, + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,false", + items : [ + { + xtype: Gtk.ComboBox, + listeners : { + changed : function (self) { + var fn = this.getValue(); + var pm = imports.ProjectManager.ProjectManager; + this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn)) + } + }, + id : "combo", + getValue : function() { + var ix = this.el.get_active(); + if (ix < 0 ) { + return false; + } + var data = imports.ProjectManager.ProjectManager.projects; + if (typeof(data[ix]) == 'undefined') { + return false; + } + return data[ix].fn; + }, + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.get('render').el , 'markup', 1 ); + }, + setValue : function(fn) + { + var el = this.el; + el.set_active(-1); + var data = imports.ProjectManager.ProjectManager.projects; + data.forEach(function(n, ix) { + if (fn == n.fn) { + el.set_active(ix); + return false; + } + }); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start,true", + id : "render" + }, + { + xtype: Gtk.ListStore, + id : "combomodel", + pack : "set_model", + + columns : [ + GObject.TYPE_STRING, + GObject.TYPE_STRING + ], + + + + loadData : function(data) { + //print("load data called");Seed.quit(); + //print(data);Seed.quit(); + + var ov = this.get('/LeftProjectTree.combo').getValue(); + this.el.clear(); + var el = this.el; + var na = {}; + + + data.forEach(function(p) { + + el.append(na); + //print(JSON.stringify(XObject.keys(na))); + //print(typeof(na.iter)); + //print(JSON.stringify(iter)) + el.set_value(na.iter, 0, p.fn); + el.set_value(na.iter, 1, p.name); + + }); + + this.get('/LeftProjectTree.combo').setValue(ov); + } + } + ] + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + shadow_type : Gtk.ShadowType.IN, + + items : [ + { + xtype: Gtk.TreeView, + + listeners : { + cursor_changed : function (self) { + + var model = this.get('/LeftProjectTree.model'); + + + + if (model.loading) { + + + return; + } + print("LOADING IS FALSE"); + var ret = {}; + if (this.selection.count_selected_rows() < 1) { + //XN.get('Builder.LeftTree.model'). + this.get('/LeftTree.model').load( false); + + return; + } + //console.log('changed'); + var s = this.selection; + s.get_selected(ret); + var value = ''+ ret.model.get_value(ret.iter, 2).value.get_string(); + //console.log(JSON.stringify(value,null,4));// id.. + console.log("OUT?" + value);// id.. + var file = this.get('/LeftProjectTree').project.getById(value); + + file.items = false; + console.log(file); + + + + var nb = this.get('/LeftTopPanel.expander'); + nb.el.expanded = false; + nb.onCollapse(); + //nb.listeners.activate.call(nb); + //_expander.el.set_expanded(false); + + var ltm = this.get('/LeftTree.model'); + ltm.loadFile(file); + + return true; + } + }, + id : "view", + tooltip_column : 1, + enable_tree_lines : true, + headers_visible : false, + 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); + }, + items : [ + { + xtype: Gtk.TreeStore, + pack : "set_model", + id : "model", + loading : false, + columns : [ + GObject.TYPE_STRING, // title + GObject.TYPE_STRING, // tip + GObject.TYPE_STRING // id.. + ] , + + + loadProject : function(pr) { + print("LOAD PROJECT"); + var model = this.get('/LeftProjectTree.model'); + model.loading = true; + + this.el.clear(); + if (!pr) { + return; + } + + this.get('/LeftProjectTree').project = pr; + + this.load(pr.toTree()); + + this.get('/LeftProjectTree.view').el.expand_all(); + model.loading = false; + + }, + load : function(tr,iter) { + // console.dump(tr); + + + console.log('Project tree load: ' + tr.length); + var cret = {}; + //this.insert(citer,iter,0); + + var _this = this; + // recursive... + tr.forEach(function (r) { + if (!iter) { + _this.el.append(cret); + } else { + _this.el.insert(cret,iter,-1); + } + _this.el.set_value(cret.iter, 0, '' + r.getTitle() ); // title + _this.el.set_value(cret.iter, 1, '' + r.getTitleTip()); // tip + _this.el.set_value(cret.iter, 2, '' + r.id ); //id + if (r.cn && r.cn.length) { + _this.load(r.cn, cret.iter); + } + + }); + + }, + getValue : function(iter, col) { + var gval = ''+ this.el.get_value(iter, col).value.get_string(); + return gval; + } + }, + { + xtype: Gtk.TreeViewColumn, + pack : "append_column", + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 0 ); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.VBox, + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + id : "LeftProps", + items : [ + { + xtype: Gtk.Button, + pack : "add", + listeners : { + button_press_event : function (self, event) { + this.get('/MidPropTree.model').showData('props'); + return false; + } + }, + items : [ + { + xtype: Gtk.HBox, + pack : "add", + items : [ + { + xtype: Gtk.Image, + pack : "add", + stock : Gtk.STOCK_ADD, + icon_size : Gtk.IconSize.MENU + }, + { + xtype: Gtk.Label, + pack : "add", + label : "Property" + } + ] + } + ] + }, + { + xtype: Gtk.Button, + listeners : { + button_press_event : function (self, event) { + + if (!this.get('/Editor').save()) { + // popup!! - click handled.. + return true; + } + this.get('/MidPropTree.model').showData('events'); + return false; + } + }, + pack : "add", + items : [ + { + xtype: Gtk.HBox, + pack : "add", + items : [ + { + xtype: Gtk.Image, + pack : "add", + stock : Gtk.STOCK_ADD, + icon_size : Gtk.IconSize.MENU + }, + { + xtype: Gtk.Label, + pack : "add", + label : "Handler" + } + ] + } + ] + }, + { + xtype: Gtk.Button, + listeners : { + button_press_event : function (self, ev) { + + if (!this.get('/Editor').save()) { + // popup!! - click handled.. + return true; + } + + var p = this.get('/AddPropertyPopup'); + if (!p.el) { + p.init(); + } + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, null, 3, ev.button.time); + return true; + } + }, + pack : "add", + items : [ + { + xtype: Gtk.HBox, + pack : "add", + items : [ + { + xtype: Gtk.Image, + pack : "add", + stock : Gtk.STOCK_ADD, + icon_size : Gtk.IconSize.MENU + }, + { + xtype: Gtk.Label, + pack : "add", + label : "Other" + } + ] + }, + { + xtype: Gtk.Menu, + pack : false, + id : "AddPropertyPopup", + items : [ + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Using this.get('*someid') will find any id in an application.", + label : "ID", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : 'id', + type : 'string', + val : '', + //skel : skel, + etype : 'props' + }); + } + } + }, + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Add what type of packing is to be used", + label : "PACK", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : 'pack', + type : 'string', + val : 'add', + etype : 'props' + }); + } + } + }, + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Override the init method", + label : "INIT", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : '|init', + type : 'function', + val : "function() {\n XObject.prototype.init.call(this);\n}\n", + etype : 'props' + }); + } + } + }, + { + xtype: Gtk.SeparatorMenuItem, + pack : "add" + }, + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Add a user defined string property", + label : "String", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : '', + type : 'string', + val : "", + etype : 'props' + }); + } + } + }, + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Add a user defined number property", + label : "Number", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : '', + type : 'number', + val : 0, + etype : 'props' + }); + } + } + }, + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Add a user defined boolean property", + label : "Boolean", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : '', + type : 'boolean', + val : false, + etype : 'props' + }); + } + } + }, + { + xtype: Gtk.SeparatorMenuItem, + pack : "add" + }, + { + xtype: Gtk.MenuItem, + pack : "append", + tooltip_markup : "Add a user function boolean property", + label : "Function", + listeners : { + activate : function (self) { + + this.get('/LeftPanel.model').add( { + key : '|', + type : 'function', + val : "function() {\n \n}\n", + etype : 'props' + }); + } + } + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + editing : false, + id : "LeftPanel", + pack : "add", + + shadow_type : Gtk.ShadowType.IN, + items : [ + { + xtype: Gtk.TreeView, + listeners : { + button_press_event : function (self, ev) { + + + if (!this.get('/Editor').save()) { + // popup!! - click handled.. + return true; + } + var res = { }; + + if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) { + return false; //not on a element. + } + + // right click. + if (ev.button.button == 3) { + // show popup!. + if (res.column.title == 'value' && this.get('/LeftPanel').editing) { + return false; + } + //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init(); + var p = this.get('/LeftPanelPopup'); + if (!p.el) { + p.init(); + } + + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, null, 3, ev.button.time); + //Seed.print("click:" + res.column.title); + + + return false; + } + + + if (res.column.title != 'value') { + // XObject.error("column is not value?"); + return false; // ignore.. - key click.. ??? should we do this?? + } + + // currently editing??? + // if ( this.activePath) { + + // this.activePath = false; + // stop editing!!!! + if (this.get('/Editor').dirty) { + //if (!this.get('/Editor.buffer').checkSyntax()) { + // this.get('/StandardErrorDialog').show("Fix errors in code and save.."); + // return true; + // // error Dialog + //} + if (!this.get('/Editor.view').save()) { + return true; + } + } + this.get('/LeftPanel').editableColumn.items[0].el.stop_editing(); + this.get('/LeftPanel').editing = false; + + // XObject.error("Currently editing?"); + // return false; + // } + + var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry.. + + var type = this.get('/LeftPanel.model').getType(res.path.to_string()); + + // get options for this type -- this is to support option lists etc.. + var provider = this.get('/LeftTree').getPaleteProvider(); + var opts = provider.findOptions(type); + + if (opts === false) { + // it's text etnry + this.get('/LeftPanel').editableColumn.setOptions([]); + renderer.has_entry = true; + } else { + this.get('/LeftPanel').editableColumn.setOptions(opts); + renderer.has_entry = false; + } + this.get('/LeftPanel.model').startEditing(res.path.to_string(), 1); + + //Seed.print("click" + ev.type); + //console.dump(res); + return false; + + + + } + }, + id : "view", + tooltip_column : 5, + enable_tree_lines : true, + headers_visible : false, + init : function() { + XObject.prototype.init.call(this); + + this.selection = this.el.get_selection(); + this.selection.set_mode( Gtk.SelectionMode.SINGLE); + + + var description = new Pango.FontDescription.c_new(); + description.set_size(8000); + this.el.modify_font(description); + }, + items : [ + { + xtype: Gtk.TreeStore, + activePath : false, + id : "model", + pack : "set_model", + add : function(info) { + // info includes key, val, skel, etype.. + console.dump(info); + type = info.type.toLowerCase(); + var data = this.toJS(); + + if (info.etype == 'events') { + data.listeners = data.listeners || { }; + if (typeof(data.listeners[info.key]) != 'undefined') { + return; //already set! + } + } else { + if (typeof(data[info.key]) != 'undefined') { + return; + } + } + + if (typeof(info.val) == 'undefined') { + + info.val = ''; + if (info.type.toLowerCase() == 'boolean') { + info.val = true; + } + if (type == 'number') { + info.val = 0; + } + // utf8 == string.. + + + } + var k = info.key; + if (info.etype == 'events') { + + data.listeners[info.key] = info.val; + k = '!' + info.key; + } else { + data[info.key] = info.val; + } + + + var map = this.load(data); + + // flag it as changed to the interface.. + this.get('/LeftTree.model').setFromNode(false,data); + this.get('/LeftTree.model').changed(true); + + + this.startEditing(map[k]); + + /* + LeftPanel.get('view').el.row_activated( + new Gtk.TreePath.from_string(map[k]), + LeftPanel.editableColumn.el + ); + */ + }, + changed : function(str, doRefresh) { + if (!this.activePath) { + print("NO active path when changed") + return; + } + var ret = {}; + this.el.get_iter(ret, new Gtk.TreePath.from_string(this.activePath)); + + this.el.set_value(ret.iter, 1, '' +str); + this.el.set_value(ret.iter, 3, '' + this.toShort(str)); + var type = this.getIterValue(ret.iter, 4); + + this.el.set_value(ret.iter, 5, type + ' : ' + str); + // update the tree... + //print("new data: " + JSON.stringify(this.toJS() , null,4)); + this.get('/LeftTree.model').setFromNode(false,this.toJS()); + this.get('/LeftTree.model').changed(doRefresh); + + }, + deleteSelected : function() { + var data = this.toJS(); + var ret ={}; + var s = this.get('/LeftPanel.view').selection; + s.get_selected( ret); + + + var val = this.get('/LeftPanel.model').el.get_value(ret.iter, 0).value.get_string(); + + if (val[0] == '!') { + // listener.. + if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') { + return; + } + delete data.listeners[ val.substring(1)]; + if (!XObject.keys(data.listeners).length) { + delete data.listeners; + } + + } else { + if (typeof(data[val]) == 'undefined') { + return; + } + delete data[val]; + } + + + this.load(data); + + + this.get('/LeftTree.model').setFromNode(false,this.toJS()); + this.get('/LeftTree.model').changed(true); + + + }, + getIterValue : function(iter, col) { + var gval = '' + this.get('/LeftPanel.model').el.get_value(iter, col).value.get_string(); + return gval; + }, + getType : function(treepath) { + return this.getValue(treepath, 4); + }, + getValue : function(treepath_str, col) + { + // get's the value in a row.. - keys - returns string, values - formats it.. + var ret = {}; + this.el.get_iter(ret, new Gtk.TreePath.from_string(treepath_str)); + + var val = '' + this.get('/LeftPanel.model').el.get_value(ret.iter, col).value.get_string(); + + if (col != 1) { + return val; + } + var type = this.getType(this.el.get_path(ret.iter).to_string()); + //print("TYPE: " +type + " - val:" + val); + switch(type.toLowerCase()) { + case 'number': + case 'uint': + case 'int': + return parseFloat(val); // Nan ?? invalid!!? + case 'float': + case 'gfloat': + return 1.0 * parseFloat(val); // Nan ?? invalid!!? + case 'boolean': + return val == 'true' ? true : false; + default: + var nv = parseFloat(val); + if (!isNaN(nv) && (val == ''+nv)) { + return nv; + } + return val; + } + + }, + columns : [ + GObject.TYPE_STRING, // 0 real key + GObject.TYPE_STRING, // 1 real value + GObject.TYPE_STRING, // 2 visable key + GObject.TYPE_STRING, // 3 visable value + GObject.TYPE_STRING, // 4 need to store type of!!! + GObject.TYPE_STRING // 5 tooltip + + ], + + load : function(ar) { + // might casue problesm.. + // this.get('/Editor.RightEditor').save(); + + this.get('/Editor').el.hide(); + this.get('/Editor').activePath = false; + + + this.el.clear(); + + //this.get('/RightEditor').el.hide(); + if (ar === false) { + return false; + } + var ret = {}; + + + var provider = this.get('/LeftTree').getPaleteProvider(); + + + // sort!!!? + var keys = XObject.keys(ar); + keys.sort(); + ar.listeners = ar.listeners || {}; + + for (var i in ar.listeners ) { + var iret ={}; + this.el.append(iret); + var p = this.el.get_path(iret.iter).to_string(); + ret['!' + i] = p; + + this.el.set_value(iret.iter, 0, '!'+ i ); + this.el.set_value(iret.iter, 1, '' + ar.listeners[i]); + this.el.set_value(iret.iter, 2, ''+ i + ''); + + this.el.set_value(iret.iter, 3, '' + this.toShort(ar.listeners[i])); + this.el.set_value(iret.iter, 4, 'function'); + this.el.set_value(iret.iter, 5, i + ' : ' + ar.listeners[i]); + } + + + + var _this = this; + keys.forEach(function(i) { + if (typeof(ar[i]) == 'object') { + return; + } + + var type = provider.findType(ar, i, ar[i]); + var iret = {}; + _this.el.append(iret); + var p = _this.el.get_path(iret.iter).to_string(); + ret[i] = p; + _this.el.set_value(iret.iter, 0, ''+i); + _this.el.set_value(iret.iter, 1, '' + ar[i]); + _this.el.set_value(iret.iter, 2, ''+i); + _this.el.set_value(iret.iter, 3, ''+ _this.toShort(ar[i])); + _this.el.set_value(iret.iter, 4, ''+type); + _this.el.set_value(iret.iter, 5, type + ' : ' + ar[i]); + }); + return ret; + }, + startEditing : function(path,col) { + + // alled by menu 'edit' currently.. + /** + * start editing path (or selected if not set..) + * @param {String|false} path (optional) treepath to edit - selected tree gets + * edited by default. + * @param {Number} 0 or 1 (optional)- column to edit. + */ + // fix tp to be the 'treepath' string (eg. 0/1/2...) + var tp; + if (typeof(path) == 'string') { + tp = new Gtk.TreePath.from_string(path); + } else { + var itr = {}; + var s = this.get('/LeftPanel.view').selection; + s.get_selected( itr); + tp = this.el.get_path(itr.iter); + path = tp.to_string(); + } + + + // which colum is to be edited.. + var colObj = false; + + // not sure what this does.. + + if (typeof(col) == 'undefined') { + var k = this.getValue(path, 0); + col = 1; + colObj = (!k.length || k == '|') ? + this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn; + } else { + colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn; + } + + // make sure the pulldown is set correctly.. + // not really needed for second col... + var showEditor = false; + this.get('/Editor').activePath = false; + this.get('/Editor').el.hide(); + var provider = this.get('/LeftTree').getPaleteProvider(); + if (col) { + var provider = this.get('/LeftTree').getPaleteProvider(); + var type = this.get('/LeftPanel.model').getType(path); + var opts = provider.findOptions(type); + var renderer = this.get('/LeftPanel').editableColumn.items[0].el; + + if (opts === false) { + this.get('/LeftPanel').editableColumn.setOptions([]); + renderer.has_entry = true; + } else { + this.get('/LeftPanel').editableColumn.setOptions(opts); + renderer.has_entry = false;/// - pulldowns do not have entries + } + // determine if we should use the Text editor... + var keyname = this.getValue(path, 0); + var data_value = this.getValue(path, 1); + + if ((keyname[0] == '|') || + ( + (typeof(data_value) == 'string' ) && + ( data_value.match(/function/g) || data_value.match(/\n/g)) // || (data_value.length > 20)) + )) { + showEditor = true; + } + print("SHOW EDITOR" + showEditor ? 'YES' :'no'); + + } + var _this = this; + // end editing.. + // this.get('/BottomPane').el.hide(); + //this.get('/RightEditor').el.hide(); + + + if (showEditor) { + + this.activePath = false; + + _this.get('/Editor').el.show_all(); + GLib.timeout_add(0, 1, function() { + + //_this.get('/BottomPane').el.show(); + //_this.get('/RightEditor').el.show(); + + _this.get('/Editor.RightEditor.view').load( _this.getValue(path, 1), provider.name ); + + _this.get('/Editor').activePath = path; + _this.activePath = path ; + + return false; + }); + return; + } + + + + + // iter now has row... + GLib.timeout_add(0, 100, function() { + _this.activePath = path; + colObj.items[0].el.editable = true; // esp. need for col 0.. + _this.get('/LeftPanel.view').el.set_cursor_on_cell( + tp, + colObj.el, + colObj.items[0].el, + true + ); + }); + + }, + toJS : function() { + var iret = {}; + this.get('/LeftPanel.model').el.get_iter_first(iret); + + var ar = {}; + + while (true) { + + var k = this.getValue(this.el.get_path(iret.iter).to_string(), 0); + // Seed.print(k); + if (k[0] == '!') { + ar.listeners = ar.listeners || {}; + ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iret.iter).to_string(), 1); + + } else { + ar[ k ] = this.getValue(this.el.get_path(iret.iter).to_string(), 1); + } + + if (! this.get('/LeftPanel.model').el.iter_next(iret.iter)) { + break; + } + } + + + //print(JSON.stringify(ar)); + return ar; + // convert the l + }, + toShort : function(str) { + var a = typeof(str) == 'string' ? str.split("\n") : []; + return a.length > 1 ? a[0] + '....' : '' + str; + } + }, + { + xtype: Gtk.TreeViewColumn, + pack : "append_column", + init : function() { + XObject.prototype.init.call(this); + + this.el.add_attribute(this.items[0].el , 'text', 2 ); + this.get('/LeftPanel').propertyColumn = this; + }, + title : "key", + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start", + listeners : { + editing_started : function (self, editable, path) { + + this.get('/LeftPanel.model').activePath = path; + + }, + edited : function (self, object, p0) { + + //print("CHANGED VALUE:" + JSON.stringify(p0, null,4)); + // return; + var model = this.get('/LeftPanel.model'); + var path = model.activePath; + var iret = {}; + model.el.get_iter(iret, new Gtk.TreePath.from_string(path)); + model.el.set_value(iret.iter, 0, p0); + model.el.set_value(iret.iter, 2, p0); + + model.activePath = false; + this.get('/LeftTree.model').setFromNode(false,model.toJS()); + this.get('/LeftTree.model').changed(true); + + this.el.editable = false; + } + } + } + ] + }, + { + xtype: Gtk.TreeViewColumn, + pack : "append_column", + title : "value", + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'text', 3 ); + //this.el.add_attribute(this.items[0].el , 'sensitive', 3 ); + //this.el.add_attribute(this.items[0].el , 'editable', 3 ); + // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL); + + this.get('/LeftPanel').editableColumn= this; + }, + setOptions : function(ar) { + var m = this.items[0].el.model; + m.clear(); + + ar.forEach(function(i) { + // sort!!!? + var iret = {}; + m.append(iret); + m.set_value(iret.iter, 0, i); + }); + + }, + items : [ + { + xtype: Gtk.CellRendererCombo, + listeners : { + edited : function (self, object, p0) { + + this.get('/LeftPanel').editing = false; + var ap = this.get('/LeftPanel.model').activePath + print("EDITED? " + ap + " - p:" + p0 + " t:" + p0); + this.get('/LeftPanel.model').changed(p0, true); + this.get('/LeftPanel.model').activePath = false; + this.el.editable = false; + }, + editing_started : function (self, editable, path) { + this.get('/LeftPanel').editing = true; + // console.log('editing started'); + // r.has_entry = false; + + this.el.editable = false; // make sure it's not editor... + + } + }, + editable : false, + pack : "pack_start", + text_column : 0, + has_entry : true, + init : function() { + XObject.prototype.init.call(this); + this.el.model = new Gtk.ListStore(); + this.el.model.set_column_types ( 1, [ + GObject.TYPE_STRING // 0 real key + ]); + } + } + ] + } + ] + }, + { + xtype: Gtk.Menu, + pack : false, + id : "LeftPanelPopup", + items : [ + { + xtype: Gtk.MenuItem, + pack : "append", + label : "Delete", + listeners : { + activate : function (self) { + this.get('/LeftPanel.model').deleteSelected(); + } + } + }, + { + xtype: Gtk.MenuItem, + pack : "append", + label : "Edit", + listeners : { + activate : function (self) { + this.get('/LeftPanel.model').startEditing(false, 0); + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "pack_end,false,true,0", + id : "MidPropTree", + shown : true, + shadow_type : Gtk.ShadowType.IN, + init : function() { + XObject.prototype.init.call(this); + XObject.prototype.init.call(this); + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + this.el.set_size_request ( 150, -1 ); + this.shown = true; + }, + activeElement : false, + hideWin : function() { + + if (!this.shown) { + print("HIDEWIN - currently not shown") + return; + } + + + if (this.get('/Window.left').el.position < 160) { + print("HIDEWIN - small already.") + + return; + } + this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150; + print("HIDEWIN attempting to hide.") + + this.el.hide(); + this.shown = false; + }, + items : [ + { + xtype: Gtk.TreeView, + listeners : { + cursor_changed : function (self) { + // this is getting fired when we are loading elements.. + if (this.get('/MidPropTree.model').loading) { + return; + } + + var iret = {}; + + //console.log('changed'); + var m = this.get('model'); + if (!this.selection){ + this.selection = this.el.get_selection(); + } + + var s = this.selection; + if (!s.get_selected(iret)) { + return; + } + var tp = m.el.get_path(iret.iter).to_string(); + + + // var val = ""; + + var key = m.getValue(tp, 0); + + var type = m.getValue(tp, 1); + var skel = m.getValue(tp, 3); + var etype = m.getValue(tp, 5); + + + this.get('/MidPropTree').hideWin(); + + if (type.toLowerCase() == 'function') { + + if (etype != 'events') { + key = '|' + key; + } + print("cursor_changed: ADDding to left panel model"); + this.get('/LeftPanel.model').add({ + key : key, + type : type, + val : skel, + etype : etype + }) + return; + } + // has dot in name, and is boolean???? this does not make sense.. + //if (type.indexOf('.') > -1 || type.toLowerCase() == 'boolean') { + // key = '|' + key; + // } + print("cursor_changed: ADDding to left panel model"); + this.get('/LeftPanel.model').add( { + key : key, + type : type, + //skel : skel, + etype : etype + }) //, + } + }, + pack : "add", + tooltip_column : 2, + enable_tree_lines : true, + headers_visible : false, + 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); + + + + + + }, + items : [ + { + xtype: Gtk.ListStore, + id : "model", + pack : "set_model", + loading : false, + getValue : function(treepath, col) + { + var tp = new Gtk.TreePath.from_string (treepath); + var iret = {}; + this.el.get_iter (iret, tp); + var value = this.el.get_value(iret.iter, col); + return ''+ value.value.get_string(); + + }, + init : function() { + XObject.prototype.init.call(this); + this.el.set_column_types ( 6, [ + GObject.TYPE_STRING, // real key + GObject.TYPE_STRING, // real type + GObject.TYPE_STRING, // docs ? + GObject.TYPE_STRING, // visable desc + GObject.TYPE_STRING, // function desc + GObject.TYPE_STRING // element type (event|prop) + + ] ); + }, + showData : function(type) { + + + this.loading = true; + this.el.clear(); + if (!this.get('/MidPropTree').activeElement || !type) { + this.loading = false; + return; // no active element + } + + var fullpath = this.get('/LeftTree.model').file.guessName( + this.get('/MidPropTree').activeElement); + var palete = this.get('/LeftTree').getPaleteProvider(); + + + + Seed.print('Showing right?'); + if (!this.get('/MidPropTree').shown) { + + this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150; + this.get('/MidPropTree').el.show(); + this.get('/MidPropTree').shown = true; + } + + 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); + + // scope of this is off..?? + + + for(var i =0 ; i < elementList.length; i++) { + var iret = {}; + var p=elementList[i]; + this.el.append(iret); + // console.log( '' + p.name +' ['+p.type+']'); + //GObject.TYPE_STRING, // real key + // GObject.TYPE_STRING, // real type + // GObject.TYPE_STRING, // docs ?this.el.set_value(iter, 0, p.name);et_value(iter, 0, p.name); + // GObject.TYPE_STRING // func def? + + + this.el.set_value(iret.iter, 0, p.name); + this.el.set_value(iret.iter, 1, p.type); + this.el.set_value(iret.iter, 2, '' + p.name +' ['+p.type+']' + "\n" + p.desc); + this.el.set_value(iret.iter, 3, p.sig ? p.sig : ''); + this.el.set_value(iret.iter, 4, '' + p.name +' ['+p.type+']'); + this.el.set_value(iret.iter, 5, type); + + } + this.loading = false; + } + }, + { + xtype: Gtk.TreeViewColumn, + pack : false, + init : function() { + this.el = new Gtk.TreeViewColumn(); + this.parent.el.append_column(this.el); + + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 4 ); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start,true" + } + ] + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.HPaned, + pack : "add", + id : 'centereast', + position : 500, + + items : [ + { + xtype: Gtk.VPaned, + pack : "add", + position : 300, + items : [ + { + xtype: Gtk.VBox, + pack : "add", + items : [ + { + xtype: Gtk.Notebook, + pack : "pack_start,true,true", + id : "view-help-nb", + init : function() { + XObject.prototype.init.call(this); + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" })); + }, + items : [ + { + xtype: Gtk.Notebook, + id : "view-notebook", + pack : "add", + tab_border : 0, + init : function() { + XObject.prototype.init.call(this); + this.el.set_current_page(0); + //print("SET LABEL?") + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" })); + }, + show_tabs : false, + items : [ + { + xtype: Gtk.VBox, + id : "RightBrowser", + pack : "add", + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + listeners : { + clicked : function (self) { + this.get('/RightBrowser.view').renderJS(null,true); + } + }, + label : "Redraw", + pack : "pack_start,false,false,0" + }, + { + xtype: Gtk.CheckButton, + listeners : { + toggled : function (self, state) { + this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off"); + } + }, + active : true, + id : "AutoRedraw", + label : "Auto Redraw On", + pack : "pack_start,false,false,0" + }, + { + xtype: Gtk.Button, + listeners : { + clicked : function (self) { + + var view = this.get('/RightBrowser.view'); + //this.get('/RightBrowser.view').redraws = 99; + view.refreshRequired = true; + view.lastRedraw = false; + view.renderedData = false; + view.renderJS(null,true); + + } + }, + label : "Full Redraw", + pack : "pack_start,false,false,0" + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + init : function() { + XObject.prototype.init.call(this); + 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"); + var file = this.get('/LeftTree.model').file; + file.saveHTML(object); + // print("load_finished"); return; + // if (this.ready) { // dont do it twice! + // return; + //} + if (!this.inspectorShown) { + this.el.get_inspector().show(); + this.inspectorShown = true; + } + + this.ready = true; + + //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) { + // print(p0); + return false; + return true; // do not display anything... + }, + console_message : function (self, object, p0, p1) { + print(object); + // console.log(object); + + + if (object.match(/variable/) && object.match(/Builder/)) { + print("got builder missing message"); + this.refreshRequired = true; + this.lastRedraw = 0; + this.runRefresh(); + return true; + } + + + if (!object.match(/^\{/)) { + + //this.get('/Terminal').feed(object); + return true; // do not handle!!! -> later maybe in console.. + } + + + + + // console.log(object); + var val = JSON.parse(object); + + if (typeof(val['hover-node']) != 'undefined') { + this.activeNode = val['hover-node']; + console.log('active node: ' + this.activeNode); + return true; + } + + var ret = false; + if (typeof(val['id']) != 'undefined') { + // this.activeNode = val['id']; + var tg = this.get('/LeftTree.model').findDropNode(val['id'], true); + if (!tg || typeof(tg[0]) == 'undefined') { + return false; + } + print("SELECT node " + tg[0]); + + this.get('/LeftTree.view').selectNode(tg[0]); + ret = true; + + } + + if (ret && typeof(val['set']) != 'undefined') { + print("console messages: ADDding to left panel model"); + // + //this.get('/LeftPanel.model').add({ + // key : val['set'], + // val : val['value'] + // }); + //console.log('active node: ' + this.activeNode); + + } + //Seed.print('a:'+a); + //Seed.print('b:'+b); + //Seed.print('c:'+c); + return ret; + }, + drag_motion : function (w, ctx, x, y, time, ud) { + // console.log('DRAG MOTION'); + // status: + // if lastCurrentNode == this.currentNode.. -- don't change anything.. + this.targetData = []; + this.el.execute_script("Builder.overPos(" + x +','+ y + ");"); + + // A) find out from drag all the places that node could be dropped. + var src = Gtk.drag_get_source_widget(ctx); + if (!src.dropList) { + Gdk.drag_status(ctx,0, time); + return true; + } + // b) get what we are over.. (from activeNode) + // tree is empty.. - list should be correct.. + if (!this.get('/LeftTree.model').currentTree) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + return true; + + } + // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + + var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList); + console.dump(tg); + if (!tg.length) { + Gdk.drag_status(ctx, 0,time); + this.get('/LeftTree.view').highlight(false); + return true; + } + + // if we have a target.. + // -> highlight it! (in browser) + // -> highlight it! (in tree) + + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + this.get('/LeftTree.view').highlight(tg); + this.targetData = tg; + // for tree we should handle this... + return true; + }, + drag_drop : function (w, ctx, x, y,time, ud) { + print("TARGET: drag-drop"); + var is_valid_drop_site = true; + + + w.drag_get_data + ( /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the DnD */ + imports.Builder3.Globals.atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); + + + /* No target offered by source => error */ + + + return is_valid_drop_site; + }, + drag_data_received : function (w, ctx, x, y, sel_data, target_type, time, ud) + { + print("Browser: drag-data-received"); + var delete_selection_data = false; + vardnd_success = false; + /* Deal with what we are given from source */ + if( sel_data && sel_data.length ) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + + if (ctx.action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + var source = Gtk.drag_get_source_widget(ctx); + + print("Browser: source.DRAGDATA? " + source.dragData); + if (this.targetData) { + print(this.targetData); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } + + + + dnd_success = true; + + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time); + return true; + }, + create_web_view : function (self, object) { + print("CREATE WEB VIEW"); + return null; //new WebKit.WebView(); + } + }, + id : "view", + pack : "add", + redraws : 0, + init : function() { + XObject.prototype.init.call(this); + // this may not work!? + var settings = this.el.get_settings(); + settings.enable_developer_extras = 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; + + }); + + // 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'); + + this.el.drag_dest_set + ( /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + this.el.drag_dest_set_target_list( imports.Builder3.Globals.targetList); + + GLib.timeout_add_seconds(0, 1, function() { + // print("run refresh?"); + _this.runRefresh(); + return true; + }); + + + }, + renderJS : function(data, force) { + + // this is the public redraw call.. + // we refresh in a loop privately.. + var autodraw = this.get('/RightBrowser.AutoRedraw').el.active; + if (!autodraw && !force) { + print("Skipping redraw - no force, and autodraw off"); + return; + } + this.refreshRequired = true; + }, + runRefresh : function() + { + // 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()) { + return; + } + this.refreshRequired = false; + // print("HTML RENDERING"); + + this.get('/BottomPane').el.show(); + this.get('/BottomPane').el.set_current_page(2);// webkit inspector + + // before + + + + + var js = this.get('/LeftTree.model').toJS(); + if (!js || !js.length) { + print("no data"); + return; + } + var data = js[0]; + + + this.redraws++; + + 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 || ''; + + var file = this.get('/LeftTree.model').file; + var items = file.items; + file.items = this.get('/LeftTree.model').toJS(false, false); + //file.items[0].background = false; + //var p = file.parent; + //file.parent = false; + + var js_src = file.toSourcePreview(); + if (this.renderedData && js_src == this.renderedData && project.runhtml == this.runhtml) { + // unless it' sforced.. + + return; + } + + this.renderedData = js_src; + // restore stuff.. + //file.parent = p; + //file.items = items; + //print("send source as " + js_src); + + js_src += "\n" + + "Roo.onReady(function() {\n" + + "if (" + file.name +".show) " + file.name +".show({});\n" + + "Roo.XComponent.build();\n" + + + "});\n"; + + + + + + //if ((project.runhtml != this.runhtml) || (this.redraws > 10)) { + // then we need to reload the browser using + // load_html_string.. + + // then trigger a redraw once it's loaded.. + this.pendingRedraw = true; + var runhtml = ''+ "\n" ; + + this.runhtml = project.runhtml; + // need to modify paths + + + this.lastRedraw= new Date(); + var html = imports.File.File.read(__script_path__ + '/../builder.html'); + html = html.replace('', + runhtml + + this.runhtml + + '' + + + ''); + //print("LOAD HTML " + html); + this.el.load_html_string( html , + //fixme - should be a config option! + 'http://localhost/app.Builder/' + ); + this.redraws = 0; + // should trigger load_finished! - which in truns shoudl set refresh Required; + return; + + + // not used. + //this.renderedData = data; + //var str = JSON.stringify(data) ; + + if (!this.ready) { + console.log('not loaded yet'); + } + this.lastRedraw = new Date(); + + this.el.execute_script("Builder.render(" + + JSON.stringify(js_src) + + "," + + JSON.stringify(file.name) + + ");"); + + print( "before render" + this.lastRedraw); + print( "after render" + (new Date())); + + } + } + ] + } + ] + }, + { + xtype: Gtk.VBox, + id : "RightGtkView", + pack : "add", + redraw : function() { + this.highlightWidget = false; + print("REDRAW CALLED"); + this.activePath = this.get('/LeftTree').getActivePath(); + if (this.renderedEl) { + print("QUEUE DRAW CALLING"); + this.renderedEl.queue_draw(); + } + }, + renderJS : function(data, withDebug) + { + this.highlightWidget = false; + + this.withDebug = 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; + } + + var tree = this.get('/LeftTree.model').toJS(false,true)[0]; + // in theory tree is actually window.. + try { + + this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el); + + } catch (e) { + print(e.message); + return; + } + this.get('view').el.set_size_request( + tree.default_width * 1 || 400, tree.default_height * 1 || 400 + ) ; + if (this.renderedEl) { + this.renderedEl.set_size_request( + tree.default_width || 600, + tree.default_height || 400 + ); + } + this.get('view').el.show_all(); + + + + }, + showInWindow : function() { + print("GET PROEJCT"); + var pr = this.get('/LeftProjectTree').getActiveProject(); + + console.log(pr.paths); + return; + /* + var src= this.buildJS( + this.get('/LeftTree.model').toJS()[0], + true); + // show term?? + + + //var x = new imports.sandbox.Context(); + //x.add_globals(); + //print(src); + try { + Seed.check_syntax('var e = ' + src); + //x.eval(src); + } catch( e) { + this.get('/Terminal').feed(e.message || e.toString() + "\n"); + this.get('/Terminal').feed(console._dump(e)+"\n"); + if (e.line) { + var lines = src.split("\n"); + var start = Math.max(0, e.line - 10); + var end = Math.min(lines.length, e.line + 10); + for (var i =start ; i < end; i++) { + if (i == e.line) { + this.get('/Terminal').feed(">>>>>" + lines[i] + "\n"); + continue; + } + this.get('/Terminal').feed(lines[i] + "\n"); + } + + } + + return; + } + this.get('/BottomPane').el.set_current_page(1); + this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false); + var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + /* + var _top = x.get_global_object()._top; + + _top.el.set_screen(Gdk.Screen.get_default()); // just in case.. + _top.el.show_all(); + if (_top.el.popup) { + _top.el.popup(null, null, null, null, 3, null); + } + */ + }, + viewAdd : function(item, par) + { + + // does something similar to xobject.. + //item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack; + + // pack is forced to 'false' + if (item.pack===false || item.pack === 'false') { // no ; + return; + } + + 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']]; // why are we using array here..? + + + + var ctr_args = { }; + for(var k in item) { + var kv = item[k]; + if (typeof(kv) == 'object' || typeof(kv) == 'function') { + continue; + } + if ( + k == 'pack' || + k == 'items' || + k == 'id' || + k == 'xtype' || + k == 'xdebug' || + k == 'xns' || + k == '|xns' + ) { + continue; + } + // value is a function.. + if (k[0] == '|' && typeof(kv) == 'string') { + + if (kv.match(new RegExp('function'))) { + continue; + } + print("WASL " + k + '=' + kv); + try { + eval( 'kv = ' + kv); + } catch(e) { continue; } + + k = k.substring(1); + // print(k + '=' + kv); + } + if (k[0] == '|') { // should be boolean or number.. + k = k.substring(1); + //print(k + '=' + kv); + } + + if (k == 'show_tabs') { // force tab showing for notebooks. + kv = true; + } + print(k + '=' + typeof(kv) + " : " + kv); + ctr_args[k] = kv; + + } + var altctr = XObject.baseXObject({ xtype: ctr} ); + var pack_m = false; + if (!item.pack && altctr) { + // try XObject. + print("SETTING PACK TO XObjectBase method"); + pack_m = altctr.prototype.pack; + + + } + + var el = new ctr(ctr_args); + item.el = el; + print("PACK" + item.pack); + //console.dump(item.pack); + + + + + var args = []; + if (!pack_m) { + item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack; + if (typeof(item.pack) == 'string') { + + item.pack.split(',').forEach(function(e, i) { + + if (e == 'false') { args.push( false); return; } + if (e == 'true') { args.push( true); return; } + if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; } + args.push(e); + }); + //print(args.join(",")); + + pack_m = args.shift(); + } else { + pack_m = item.pack.shift(); + args = item.pack; + } + } + // handle error. + if (typeof(pack_m) == 'string' && typeof(par[pack_m]) == 'undefined') { + throw { + name: "ArgumentError", + message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m + + "ADDING : " + item.id + " " + el + + }; + + return; + } + + //console.dump(args); + args.unshift(el); + //if (XObject.debug) print(pack_m + '[' + args.join(',') +']'); + //Seed.print('args: ' + args.length); + if (typeof(pack_m) == 'string') { + par[pack_m].apply(par, args); + } else if (pack_m) { + pack_m.call(item, par, item); + } + + var _this = this; + item.items = item.items || []; + item.items.forEach(function(ch,n) { + + print ("type:" + type); + + print ("ch.pack:" + ch.pack); + + + if (type == 'Gtk.Table' && ch.pack == 'add') { + var c = n % item.n_columns; + var r = Math.floor(n/item.n_columns); + ch.pack = [ 'attach', c, c+1, r, r+1, + typeof(ch.x_options) == 'undefined' ? 5 : ch.x_options, + typeof(ch.y_options) == 'undefined' ? 5 : ch.y_options, + typeof(ch.x_padding) == 'undefined' ? 0 : ch.x_padding, + typeof(ch.x_padding) == 'undefined' ? 0 : ch.x_padding + ].join(','); + } + + _this.viewAdd(ch, el); + }); + + + + // add the signal handlers. + // is it a widget!?!!? + + + try { + + + el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true)); + el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true)); + el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true)); + el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true )); + el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true )); + } catch(e) { + // ignore! + } + + + + return el; + + }, + widgetDragDropEvent : function() { + print("WIDGET DRAGDROP"); + return true; + }, + widgetDragMotionEvent : function() { + print("WIDGET DRAGMOTION"); + return true; + }, + widgetExposeEvent : function(w, evt, ud, item) { + var widget = w; + if (this.inRender) { + return false; + } + + if ( this.highlightWidget) { + this.inRender = true; + if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) { + Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h); + } + this.inRender = false; + return false; + } + + + if (this.activePath != item.xtreepath) { + return false; + } + + // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight?? + // work out the coords of the window.. + if (!this.gc) { + var dr = widget.window; + this.gc = (new Gdk.GC.c_new(dr)); + this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 })); + this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND); + } + + + var r = evt.expose.area; + // console.dump([r.x, r.y, r.width, r.height ] ); + //return false; + // print(widget.get_parent().toString().match(/GtkScrolledWindow/); + if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak + // happens with gtkscrollview embedded stuff.. + var np =this.activePath.split(':'); + np.pop(); + this.activePath = np.join(':'); + this.renderedEl.queue_draw(); + return true; + + + } + + + + + this.box = { + x : r.x - 2, + y : r.y - 2, + w: r.width + 4, + h: r.height + 4 + }; + // let's draw it.. + this.inRender = true; + + + this.highlightWidget = widget; + + + + + // print("DRAW BOX"); + //console.dump(this.box); + Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h); + this.inRender = false; + return false; + }, + widgetPressEvent : function(w,e,u,d) { + if (this.get('view').pressed) { + return false; + } + this.get('view').pressed = true; + print("WIDGET PRESS " + d.xtreepath ); + this.get('/LeftTree.view').selectNode( d.xtreepath ); + return false; + }, + widgetReleaseEvent : function() { + this.get('view').pressed = false; + return false; + }, + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true,0", + items : [ + { + xtype: Gtk.Button, + pack : "pack_start,false,false,0", + label : "Run The Application", + listeners : { + button_press_event : function (self, event) { + // call render on left tree - with special option!?! + + //print("GET PROEJCT"); + var pr = this.get('/LeftProjectTree').getActiveProject(); + + var dir = ''; + for (var i in pr.paths) { + dir = i; + break; + } + var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js'; + this.get('/Terminal').feed("RUN DIR:" + dir); + var out = {}; + + this.get('/Terminal').el.fork_command_full( + Vte.PtyFlags.DEFAULT, + GLib.path_get_dirname (__script_path__) , + [ 'echo' , "hello"], //argv + [], // env + 0, //spawn flags + null, // user func + null, // child setupdata + out + ); + + var cmd = "/usr/bin/seed " + runner + " " + dir + "\n"; + this.get('/Terminal').el.feed_child(cmd, cmd.length); + return false; + + + } + } + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + id : "view-sw", + shadow_type : Gtk.ShadowType.IN, + init : function() { + XObject.prototype.init.call(this); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + }, + items : [ + { + xtype: Gtk.EventBox, + pack : "add_with_viewport", + init : function() { + XObject.prototype.init.call(this); + this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({ + red: 0x9F00, green: 0xB800 , blue : 0xA800 + })); + }, + items : [ + { + xtype: Gtk.Fixed, + pack : "add", + init : function() { + XObject.prototype.init.call(this); + //this.el.set_hadjustment(this.parent.el.get_hadjustment()); + //this.el.set_vadjustment(this.parent.el.get_vadjustment()); + + }, + items : [ + { + xtype: Gtk.EventBox, + pack : "put,10,10", + init : function() { + //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU); + XObject.prototype.init.call(this); + + this.el.drag_dest_set + ( /* widget that will accept a drop */ + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, /* lists of target to support */ + 0, /* size of list */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + this.el.drag_dest_set_target_list( imports.Builder3.Globals.targetList); + }, + ready : false, + getActiveNode : function(x,y) + { + // workout what node is here.. + return '0'; // top.. + }, + id : "view", + listeners : { + drag_motion : function (self, ctx, x, y, time) { + + // A) find out from drag all the places that node could be dropped. + var src = Gtk.drag_get_source_widget(ctx); + if (!src.dropList) { + Gdk.drag_status(ctx, 0, time); + return true; + } + // b) get what we are over.. (from activeNode) + // tree is empty.. - list should be correct.. + if (!this.get('/LeftTree.model').currentTree) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + return true; + + } + // c) ask tree where it should be dropped... - eg. parent.. (after node ontop) + var activeNode = this.getActiveNode(x, y); + + + var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList); + console.dump(tg); + if (!tg.length) { + Gdk.drag_status(ctx, 0,time); + this.get('/LeftTree.view').highlight(false); + return true; + } + + // if we have a target.. + // -> highlight it! (in browser) + // -> highlight it! (in tree) + + Gdk.drag_status(ctx, Gdk.DragAction.COPY,time); + this.get('/LeftTree.view').highlight(tg); + this.targetData = tg; + // for tree we should handle this... + return true; + }, + drag_drop : function (self,ctx, x, y, time) { + Seed.print("TARGET: drag-drop"); + var is_valid_drop_site = true; + + + self.drag_get_data + ( /* will receive 'drag-data-received' signal */ + ctx, /* represents the current state of the this.gDnD */ + imports.Builder3.Globals.atoms["STRING"], /* the target type we want */ + time /* time stamp */ + ); + + + /* No target offered by source => error */ + + + return is_valid_drop_site; + + }, + drag_data_received : function (w, ctx, x, y, sel_data, target_type, time, ud) + { + Seed.print("GtkView: drag-data-received"); + var delete_selection_data = false; + var dnd_success = false; + /* Deal with what we are given from source */ + if( sel_data && sel_data.length ) { + + if (ctx.action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + + if (ctx.action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + var source = Gtk.drag_get_source_widget( ctx ); + + Seed.print("Browser: source.DRAGDATA? " + source.dragData); + if (this.targetData) { + Seed.print(this.targetData); + this.get('/LeftTree.model').dropNode(this.targetData, source.dragData); + } + + + + dnd_success = true; + + } + + if (dnd_success == false) + { + Seed.print ("DnD data transfer failed!\n"); + } + + Gtk.drag_finish ( ctx, dnd_success, delete_selection_data, time); + return true; + }, + button_press_event : function (self, event) { + this.pressed = false; + return false; + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + id : "Help", + pack : "add", + show : function() { + + var file = this.get('/LeftTree').getActiveFile(); + if (!file) { + return; + } + var activeEl = this.get('/LeftTree').getActiveElement(); + var xtype = file.guessName( activeEl ) + if (!xtype || !xtype.length) { + return; + } + //this.get('/Window.view-help-nb').el.set_current_page(1); + + // get the active element being edited. + var helpurl = file.getHelpUrl(xtype); + + // now load the help info in the page.. + this.get('help-view').el.open(helpurl); + }, + items : [ + { + xtype: WebKit.WebView, + pack : "add", + id : "help-view", + init : function() { + XObject.prototype.init.call(this); + this.get('/Window.help-view').el.open( + "http://devel.akbkhome.com/seed/"); + + }, + zoom_level : 0.8 + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.Notebook, + id : "BottomPane", + pack : "add", + init : function() { + XObject.prototype.init.call(this); + //this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" })); + this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Console" })); + this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Inspector" })); + }, + items : [ + { + xtype: Gtk.ScrolledWindow, + pack : "add", + items : [ + { + xtype: Vte.Terminal, + pack : "add", + id : "Terminal", + feed : function(istr) { + var str = istr.replace(/\n/g, "\r\n") + "\r\n"; + // we should make ourselves visable!!! + this.get('/BottomPane').el.show(); + this.get('/BottomPane').el.set_current_page(1); + + this.el.feed(str ,str.length); + }, + scroll_on_output : true, + init : function() { + XObject.prototype.init.call(this); + this.el.set_size (80, 1000); + }, + scrollback_lines : 1000 + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + items : [ + { + xtype: WebKit.WebView, + id : "inspector", + pack : "add" + } + ] + } + ] + } + ] + }, + { + xtype: Gtk.VBox, + pack : "add", + id : "RightPalete", + hide : function() { + + this.get('buttonbar').el.show(); + this.get('viewbox').el.hide(); + var ce = this.get('/Window.centereast').el; + + ce.set_position(ce.get_allocated_width() - 30); + + print("TRIED TO HIDE"); + }, + show : function() { + this.get('buttonbar').el.hide(); + this.get('viewbox').el.show(); + var ce = this.get('/Window.centereast').el; + //print(JSON.stringify(XObject.keys(ce) ,null,4)); + ce.set_position(ce.get_allocated_width() - 150); + + // this.get('model').expanded(); + + }, + provider : false, + items : [ + { + xtype: Gtk.VBox, + pack : "add", + id : "buttonbar", + items : [ + { + xtype: Gtk.Button, + pack : "pack_start,false,true", + listeners : { + clicked : function (self) { + this.get('/RightPalete').show(); + } + }, + items : [ + { + xtype: Gtk.Image, + pack : "add", + stock : Gtk.STOCK_GOTO_FIRST, + icon_size : Gtk.IconSize.MENU + } + ] + }, + { + xtype: Gtk.Label, + pack : "add", + label : "Palete", + angle : 270, + init : function() { + XObject.prototype.init.call(this); + this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK ); + }, + listeners : { + enter_notify_event : function (self, event) { + this.get('/RightPalete').show(); + return false; + } + } + } + ] + }, + { + xtype: Gtk.VBox, + pack : "add", + id : "viewbox", + items : [ + { + xtype: Gtk.HBox, + pack : "pack_start,false,true", + items : [ + { + xtype: Gtk.Label, + pack : "add", + label : "Palete" + }, + { + xtype: Gtk.Button, + pack : "pack_start,false,true", + listeners : { + clicked : function (self) { + this.get('/RightPalete').hide(); + } + }, + items : [ + { + xtype: Gtk.Image, + pack : "add", + stock : Gtk.STOCK_GOTO_LAST, + icon_size : Gtk.IconSize.MENU + } + ] + } + ] + }, + { + xtype: Gtk.ScrolledWindow, + pack : "add", + init : function() { + XObject.prototype.init.call(this); + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + this.el.set_size_request(-1,200); + }, + shadow_type : Gtk.ShadowType.IN, + items : [ + { + xtype: Gtk.TreeView, + listeners : { + drag_begin : function (self, ctx) { + // we could fill this in now... + Seed.print('SOURCE: drag-begin'); + + + + var iret = {}; + var s = this.selection; + s.get_selected(iret); + var path = this.get('/RightPalete.model').el.get_path(iret.iter); + + var pix = this.el.create_row_drag_icon ( path); + + print(pix); + if (Gtk.drag_set_icon_surface) { + Gtk.drag_set_icon_surface( ctx, pix ); + } else { + Gtk.drag_set_icon_pixmap (ctx, + pix.get_colormap(), pix, null, -10, -10); + } + + var value = ''+ this.get('/RightPalete.model').el.get_value(iret.iter, 0).value.get_string(); + if (!this.get('/RightPalete').provider) { + return false; + } + this.el.dropList = this.get('/RightPalete').provider.getDropList(value); + this.el.dragData = value; + + + + + return true; + }, + drag_data_get : function (self, drag_context, selection_data, info, time) { + //Seed.print('Palete: drag-data-get: ' + target_type); + if (this.el.dragData && this.el.dragData.length ) { + selection_data.set_text(this.el.dragData ,this.el.dragData.length); + } + + + //this.el.dragData = "TEST from source widget"; + + + }, + drag_end : function (self, drag_context) { + Seed.print('SOURCE: drag-end'); + this.el.dragData = false; + this.el.dropList = false; + this.get('/LeftTree.view').highlight(false); + return true; + }, + button_press_event : function (self, event) { + + if (!this.get('/Editor').save()) { + // popup!! - click handled.. + return true; + } + return false; + } + }, + pack : "add", + enable_tree_lines : true, + headers_visible : false, + init : function() { + XObject.prototype.init.call(this); + this.el.set_size_request(150,-1); + // set_reorderable: [1] + + 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); + // this.selection.signal['changed'].connect(function() { + // _view.listeners['cursor-changed'].apply(_view, [ _view, '']); + //}); + // see: http://live.gnome.org/GnomeLove/DragNDropTutorial + + this.el.drag_source_set ( /* 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 /* what to do with data after dropped */ + ); + //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList); + + this.el.drag_source_set_target_list( imports.Builder3.Globals.targetList); + this.el.drag_source_add_text_targets( ); + /* + print("RP: TARGET:" + LeftTree.atoms["STRING"]); + targets = new Gtk.TargetList(); + targets.add( LeftTree.atoms["STRING"], 0, 0); + targets.add_text_targets( 1 ); + Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList); + + //if you want to allow text to be output elsewhere.. + //Gtk.drag_source_add_text_targets(this.el); + */ + return true; + }, + items : [ + { + xtype: Gtk.ListStore, + pack : "set_model", + init : function() { + XObject.prototype.init.call(this); + this.el.set_column_types ( 2, [ + GObject.TYPE_STRING, // title + GObject.TYPE_STRING // tip + + ] ); + }, + id : "model", + load : function(tr,iter) + { + if (!iter) { + this.el.clear(); + } + //console.log('Project tree load: ' + tr.length); + var cret ={}; + //this.insert(citer,iter,0); + for(var i =0 ; i < tr.length; i++) { + if (!iter) { + + this.el.append(cret); + } else { + this.el.insert(cret,iter,-1); + } + + var r = tr[i]; + //Seed.print(r); + this.el.set_value(cret.iter, 0, '' + r ); // title + + //this.el.set_value(citer, 1, new GObject.Value( r)); //id + //if (r.cn && r.cn.length) { + // this.load(r.cn, citer); + //} + } + + + }, + getValue : function (iter, col) { + return this.el.get_value(iter, col).value.get_string(); + + + + } + }, + { + xtype: Gtk.TreeViewColumn, + pack : "append_column", + init : function() { + XObject.prototype.init.call(this); + this.el.add_attribute(this.items[0].el , 'markup', 0 ); + }, + items : [ + { + xtype: Gtk.CellRendererText, + pack : "pack_start" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +}); +Window.init(); +XObject.cache['/Window'] = Window; diff --git a/old-javascript/Builder4/About.bjs b/old-javascript/Builder4/About.bjs new file mode 100644 index 000000000..bbc8d21bf --- /dev/null +++ b/old-javascript/Builder4/About.bjs @@ -0,0 +1,25 @@ +{ + "name" : "About", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/About.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : "(self, event) => {\n this.el.hide();\n return true;\n\n}\n ", + "response" : "(rid) => {\n this.el.hide();\n}\n" + }, + "| void show_all" : "() {\n this.el.show_all();\n}\n ", + "copyright" : "LGPL", + "xtype" : "AboutDialog", + "program_name" : "app.Builder.js", + "$ modal" : true, + "$ authors" : "{ \"Alan Knowles\" }", + "$ xns" : "Gtk", + "website" : "http://www.akbkhome.com/blog.php", + "license" : "LGPL" + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/About.vala b/old-javascript/Builder4/About.vala new file mode 100644 index 000000000..d6f49ed33 --- /dev/null +++ b/old-javascript/Builder4/About.vala @@ -0,0 +1,49 @@ +static About _About; + +public class About : Object +{ + public Gtk.AboutDialog el; + private About _this; + + public static About singleton() + { + if (_About == null) { + _About= new About(); + } + return _About; + } + + // my vars (def) + + // ctor + public About() + { + _this = this; + this.el = new Gtk.AboutDialog(); + + // my vars (dec) + + // set gobject values + this.el.program_name = "app.Builder.js"; + this.el.license = "LGPL"; + this.el.authors = { "Alan Knowles" }; + this.el.website = "http://www.akbkhome.com/blog.php"; + this.el.modal = true; + this.el.copyright = "LGPL"; + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + + }); + this.el.response.connect( (rid) => { + this.el.hide(); + }); + } + + // user defined functions + public void show_all () { + this.el.show_all(); + } +} diff --git a/old-javascript/Builder4/Application.vala b/old-javascript/Builder4/Application.vala new file mode 100644 index 000000000..61d2cc47e --- /dev/null +++ b/old-javascript/Builder4/Application.vala @@ -0,0 +1,187 @@ + + +namespace Builder4 +{ + + public class AppSettings : Object + { + + // what are we going to have as settings? + public string roo_html_dir { get; set; } + + public AppSettings() + { + this.notify.connect(() => { + this.save(); + }); + } + + public static AppSettings factory() + { + + var setting_file = Application.configDirectory() + "/builder.settings"; + + if (!FileUtils.test(setting_file, FileTest.EXISTS)) { + return new AppSettings(); + } + string data; + FileUtils.get_contents(setting_file, out data); + return Json.gobject_from_data (typeof (AppSettings), data) as AppSettings; + } + public void save() + { + var dirname = GLib.Environment.get_home_dir() + "/.Builder"; + var setting_file = dirname + "/builder.settings"; + string data = Json.gobject_to_data (this, null); + print("saving application settings\n"); + FileUtils.set_contents(setting_file, data); + } + + + } + + + public static Application application = null; + + public class Application : Gtk.Application + { + enum Target { + INT32, + STRING, + ROOTWIN + } + + + public const Gtk.TargetEntry[] targetList = { + { "INTEGER", 0, Target.INT32 }, + { "STRING", 0, Target.STRING }, + { "application/json", 0, Target.STRING }, + { "text/plain", 0, Target.STRING }, + { "application/x-rootwindow-drop", 0, Target.ROOTWIN } + }; + public AppSettings settings = null; + + + public Application () + { + Object( + application_id: "org.roojs.app-builder", + flags: ApplicationFlags.FLAGS_NONE + ); + + configDirectory(); + this.settings = AppSettings.factory(); + + this.initResources(true); + + + } + + + + public static Application singleton() + { + if (application==null) { + application = new Application(); + + + } + return application; + } + + + public static string configDirectory() + { + var dirname = GLib.Environment.get_home_dir() + "/.Builder"; + + if (!FileUtils.test(dirname,FileTest.IS_DIR)) { + var dir = File.new_for_path(dirname); + dir.make_directory(); + } + if (!FileUtils.test(dirname + "/resources",FileTest.IS_DIR)) { + var dir = File.new_for_path(dirname + "/resources"); + dir.make_directory(); + } + + + return dirname; + } + + + public void initResources(bool force = false) + { + // files to fetch from resources. + string[] res = { + "bootstrap.builder.html", + "roo.builder.html", + "roo.builder.js", + "Gir.overides" + }; + for (var i = 0; i < res.length; i++ ) { + this.fetchResource(res[i], force); + } + this.fetchResourceFrom ( + "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=Palete/RooUsage.txt", + "RooUsage.txt", + force + ); + this.fetchResourceFrom ( + "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=Palete/GtkUsage.txt", + "GtkUsage.txt", + force + ); + this.fetchResourceFrom ( + "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json", + "roodata.json", + force + ); + + + } + public void fetchResource(string res, bool force) { + if (!force && FileUtils.test(configDirectory() + "/resources/" + res, FileTest.EXISTS)) { + return; + } + this.fetchResourceFrom( + "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/" + res, + res, + force + ); + + + } + + public void fetchResourceFrom(string src, string res, bool force) { + if (!force && FileUtils.test(configDirectory() + "/resources/" + res, FileTest.EXISTS)) { + return; + } + // fetch... + print("downloading %s \nto : %s\n", src,res); + var session = new Soup.Session (); + session.user_agent = "App Builder "; + var message = new Soup.Message ("GET", + src + ); + + // send the HTTP request and wait for response + session.send_message (message); + + // output the XML result to stdout + FileUtils.set_contents( + configDirectory() + "/resources/" + res, + (string) message.response_body.data + ); + + + } + + } + + + + + + + + +} diff --git a/old-javascript/Builder4/ClutterFiles.bjs b/old-javascript/Builder4/ClutterFiles.bjs new file mode 100644 index 000000000..3efe8556d --- /dev/null +++ b/old-javascript/Builder4/ClutterFiles.bjs @@ -0,0 +1,112 @@ +{ + "name" : "ClutterFiles", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/ClutterFiles.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "scroll_event" : "( event) => {\n //Sprint(\"scroll event\");\n var y = this.filelayout.el.y;\n var dir = event.direction;\n switch (dir) {\n case Clutter.ScrollDirection.UP:\n y += event.y /2;\n break;\n case Clutter.ScrollDirection.DOWN:\n y -= event.y /2 ;\n break;\n default:\n return false;\n }\n // range of scroll -- can go up -- eg.. -ve value.\n \n y = float.min(0, y);\n \n // to work out the max -ve number\n // height of filelayout\n // height of scrollactor..\n \n var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;\n if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {\n return false;\n }\n \n \n \n \n // print(\"\\nlast child - this height = %f ==== new y %f\\n \".printf( \n // last_child_bottom - this.el.height,\n // y)); \n // y = float.min(0, y); //??\n // print(\"scroll event of %f - new y = %f \".printf(event.y, y));\n this.filelayout.el.y = y;\n return true;\n \n}" + }, + "# Gee.ArrayList fileitems" : "", + "id" : "ClutterFiles", + "| void clearFiles" : "() {\n \n this.filelayout.el.remove_all_children();\n // we need to unref all the chidren that we loaded though...\n \n}\n", + "scroll_mode" : "Clutter.ScrollMode.VERTICALLY", + "* init" : "this.fileitems = new Gee.ArrayList();\n", + "xtype" : "ScrollActor", + "$ reactive" : true, + "| void loadProject" : "(Project.Project pr) {\n // list all the files, and create new Xcls_fileitem for each one.\n \n // LEAK --- we should unref all the chilren...\n this.filelayout.el.y = 0;\n this.clearFiles();\n \n print(\"clutter files - load project: \" + pr.name +\"\\n\");\n // should unref.. them hopefully.\n this.fileitems = new Gee.ArrayList();\n\n \n\n var fiter = pr.sortedFiles().list_iterator();\n while (fiter.next()) {\n var a = new Xcls_fileitem(this,fiter.get());\n this.fileitems.add(a);\n\n// a.ref();\n print(\"add to clutter file view: \" + fiter.get().name + \"\\n\");\n this.filelayout.el.add_child(a.el);\n }\n \n \n \n this.el.show_all();\n}\n", + "# Gdk.Pixbuf missing_thumb_pixbuf" : "null", + "@ void open" : "(JsRender.JsRender file)", + "$ xns" : "Clutter", + "| void set_size" : "(float w, float h) \n{\n if (this.el == null) {\n print(\"object not ready yet?\");\n return;\n }\n _this.filelayout_manager.el.max_column_width = w - 150;\n this.el.set_size(this.el.get_stage().width-150,\n this.el.get_stage().height);\n this.el.set_position(100,50);\n}\n", + "items" : [ + { + "id" : "filelayout", + "* init" : "\nthis.el.add_constraint(\n new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)\n);\n\n", + "xtype" : "Actor", + "* pack" : "add_child", + "$ reactive" : true, + "$ xns" : "Clutter", + "items" : [ + { + "id" : "filelayout_manager", + "$ orientation" : "Clutter.FlowOrientation.HORIZONTAL", + "xtype" : "FlowLayout", + "$ xns" : "Clutter", + "row_spacing" : 20, + "* prop" : "layout_manager", + "column_spacing" : 20, + "$ homogeneous" : true + }, + { + "listeners" : { + "button_press_event" : " ( event) => {\n _this.open(this.file);\n return false;\n}", + "enter_event" : "( event) => {\n this.el.background_color = new Clutter.Color.from_string(\"#333\");\n return false;\n}", + "leave_event" : "( event) => {\n this.el.background_color = new Clutter.Color.from_string(\"#000\");\n return false;\n}" + }, + "id" : "*fileitem", + "* args" : "JsRender.JsRender file", + "* init" : "this.file = file;\nthis.el.set_size(100,100);", + "* pack" : true, + "xtype" : "Actor", + "# JsRender.JsRender file" : "", + "$ reactive" : true, + "$ xns" : "Clutter", + "items" : [ + { + "$ orientation" : "Clutter.Orientation.VERTICAL", + "spacing" : 4, + "xtype" : "BoxLayout", + "$ xns" : "Clutter", + "* prop" : "layout_manager" + }, + { + "$ margin_right" : 5, + "$ margin_top" : 5, + "id" : "+image", + "* args" : "JsRender.JsRender file", + "* init" : "{\n Gdk.Pixbuf pixbuf;\n var fname = file.getIconFileName(false);\n\n if (FileUtils.test(fname, FileTest.EXISTS)) {\n pixbuf = new Gdk.Pixbuf.from_file(fname);\n } else {\n if (_this.missing_thumb_pixbuf == null) {\n var icon_theme = Gtk.IconTheme.get_default ();\n _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);\n _this.missing_thumb_pixbuf.ref();\n }\n pixbuf = _this.missing_thumb_pixbuf;\n\n }\n\n var img = new Clutter.Image();\n img.set_data(pixbuf.get_pixels(), \n pixbuf.has_alpha \n ? Cogl.PixelFormat.RGBA_8888\n : Cogl.PixelFormat.RGB_888,\n pixbuf.get_width (),\n pixbuf.get_height (),\n pixbuf.get_rowstride ()\n );\n this.el.set_content(img);\n // should probably do smarter scaling...\n \n \n this.el.set_size(90, 70);\n}\n", + "$ x_expand" : true, + "* pack" : "add_child", + "xtype" : "Actor", + "$ y_align" : "Clutter.ActorAlign.START", + "$ margin_left" : 5, + "$ xns" : "Clutter", + "$ y_expand" : true, + "$ x_align" : "Clutter.ActorAlign.START" + }, + { + "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickType(),new Clutter.Color.from_string(\"#fff\"))", + "id" : "+typetitle", + "* args" : "JsRender.JsRender file", + "$ x_expand" : true, + "* pack" : "add_child", + "xtype" : "Text", + "$ y_align" : "Clutter.ActorAlign.START", + "$ xns" : "Clutter", + "$ y_expand" : true, + "$ x_align" : "Clutter.ActorAlign.START" + }, + { + "* ctor" : "new Clutter.Text.full(\"Sans 10px\", file.nickName(),new Clutter.Color.from_string(\"#fff\"))", + "id" : "+title", + "* args" : "JsRender.JsRender file", + "$ x_expand" : true, + "* pack" : "add_child", + "xtype" : "Text", + "$ y_align" : "Clutter.ActorAlign.START", + "$ xns" : "Clutter", + "$ y_expand" : true, + "$ x_align" : "Clutter.ActorAlign.START" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/ClutterFiles.vala b/old-javascript/Builder4/ClutterFiles.vala new file mode 100644 index 000000000..aa1a69fed --- /dev/null +++ b/old-javascript/Builder4/ClutterFiles.vala @@ -0,0 +1,378 @@ +static Xcls_ClutterFiles _ClutterFiles; + +public class Xcls_ClutterFiles : Object +{ + public Clutter.ScrollActor el; + private Xcls_ClutterFiles _this; + + public static Xcls_ClutterFiles singleton() + { + if (_ClutterFiles == null) { + _ClutterFiles= new Xcls_ClutterFiles(); + } + return _ClutterFiles; + } + public Xcls_filelayout filelayout; + public Xcls_filelayout_manager filelayout_manager; + + // my vars (def) + public Gee.ArrayList fileitems; + public Gdk.Pixbuf missing_thumb_pixbuf; + public signal void open (JsRender.JsRender file); + + // ctor + public Xcls_ClutterFiles() + { + _this = this; + this.el = new Clutter.ScrollActor(); + + // my vars (dec) + this.missing_thumb_pixbuf = null; + + // set gobject values + this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY; + this.el.reactive = true; + var child_0 = new Xcls_filelayout( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.fileitems = new Gee.ArrayList(); + // listeners + this.el.scroll_event.connect( ( event) => { + //Sprint("scroll event"); + var y = this.filelayout.el.y; + var dir = event.direction; + switch (dir) { + case Clutter.ScrollDirection.UP: + y += event.y /2; + break; + case Clutter.ScrollDirection.DOWN: + y -= event.y /2 ; + break; + default: + return false; + } + // range of scroll -- can go up -- eg.. -ve value. + + y = float.min(0, y); + + // to work out the max -ve number + // height of filelayout + // height of scrollactor.. + + var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height; + if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) { + return false; + } + + + + + // print("\nlast child - this height = %f ==== new y %f\n ".printf( + // last_child_bottom - this.el.height, + // y)); + // y = float.min(0, y); //?? + // print("scroll event of %f - new y = %f ".printf(event.y, y)); + this.filelayout.el.y = y; + return true; + + }); + } + + // user defined functions + public void clearFiles () { + + this.filelayout.el.remove_all_children(); + // we need to unref all the chidren that we loaded though... + + } + public void loadProject (Project.Project pr) { + // list all the files, and create new Xcls_fileitem for each one. + + // LEAK --- we should unref all the chilren... + this.filelayout.el.y = 0; + this.clearFiles(); + + print("clutter files - load project: " + pr.name +"\n"); + // should unref.. them hopefully. + this.fileitems = new Gee.ArrayList(); + + + + var fiter = pr.sortedFiles().list_iterator(); + while (fiter.next()) { + var a = new Xcls_fileitem(this,fiter.get()); + this.fileitems.add(a); + + // a.ref(); + print("add to clutter file view: " + fiter.get().name + "\n"); + this.filelayout.el.add_child(a.el); + } + + + + this.el.show_all(); + } + public void set_size (float w, float h) + { + if (this.el == null) { + print("object not ready yet?"); + return; + } + _this.filelayout_manager.el.max_column_width = w - 150; + this.el.set_size(this.el.get_stage().width-150, + this.el.get_stage().height); + this.el.set_position(100,50); + } + public class Xcls_filelayout : Object + { + public Clutter.Actor el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + + // ctor + public Xcls_filelayout(Xcls_ClutterFiles _owner ) + { + _this = _owner; + _this.filelayout = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + this.el.reactive = true; + var child_0 = new Xcls_filelayout_manager( _this ); + child_0.ref(); + this.el.layout_manager = child_0.el; + + // init method + + this.el.add_constraint( + new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f) + ); } + + // user defined functions + } + public class Xcls_filelayout_manager : Object + { + public Clutter.FlowLayout el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + + // ctor + public Xcls_filelayout_manager(Xcls_ClutterFiles _owner ) + { + _this = _owner; + _this.filelayout_manager = this; + this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = true; + this.el.row_spacing = 20f; + this.el.column_spacing = 20f; + } + + // user defined functions + } + public class Xcls_fileitem : Object + { + public Clutter.Actor el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + public JsRender.JsRender file; + public Xcls_image image; + public Xcls_typetitle typetitle; + public Xcls_title title; + + // ctor + public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file) + { + _this = _owner; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + this.el.reactive = true; + var child_0 = new Xcls_BoxLayout5( _this ); + child_0.ref(); + this.el.layout_manager = child_0.el; + var child_1 = new Xcls_image( _this ,file); + child_1.ref(); + this.el.add_child ( child_1.el ); + this.image = child_1; + var child_2 = new Xcls_typetitle( _this ,file); + child_2.ref(); + this.el.add_child ( child_2.el ); + this.typetitle = child_2; + var child_3 = new Xcls_title( _this ,file); + child_3.ref(); + this.el.add_child ( child_3.el ); + this.title = child_3; + + // init method + + this.file = file; + this.el.set_size(100,100); + // listeners + this.el.button_press_event.connect( ( event) => { + _this.open(this.file); + return false; + }); + this.el.enter_event.connect( ( event) => { + this.el.background_color = new Clutter.Color.from_string("#333"); + return false; + }); + this.el.leave_event.connect( ( event) => { + this.el.background_color = new Clutter.Color.from_string("#000"); + return false; + }); + } + + // user defined functions + } + public class Xcls_BoxLayout5 : Object + { + public Clutter.BoxLayout el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + + // ctor + public Xcls_BoxLayout5(Xcls_ClutterFiles _owner ) + { + _this = _owner; + this.el = new Clutter.BoxLayout(); + + // my vars (dec) + + // set gobject values + this.el.spacing = 4; + this.el.orientation = Clutter.Orientation.VERTICAL; + } + + // user defined functions + } + public class Xcls_image : Object + { + public Clutter.Actor el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + + // ctor + public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file) + { + _this = _owner; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + this.el.margin_right = 5f; + this.el.margin_left = 5f; + this.el.x_align = Clutter.ActorAlign.START; + this.el.x_expand = true; + this.el.y_align = Clutter.ActorAlign.START; + this.el.margin_top = 5f; + this.el.y_expand = true; + + // init method + + { + Gdk.Pixbuf pixbuf; + var fname = file.getIconFileName(false); + + if (FileUtils.test(fname, FileTest.EXISTS)) { + pixbuf = new Gdk.Pixbuf.from_file(fname); + } else { + if (_this.missing_thumb_pixbuf == null) { + var icon_theme = Gtk.IconTheme.get_default (); + _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0); + _this.missing_thumb_pixbuf.ref(); + } + pixbuf = _this.missing_thumb_pixbuf; + + } + + var img = new Clutter.Image(); + img.set_data(pixbuf.get_pixels(), + pixbuf.has_alpha + ? Cogl.PixelFormat.RGBA_8888 + : Cogl.PixelFormat.RGB_888, + pixbuf.get_width (), + pixbuf.get_height (), + pixbuf.get_rowstride () + ); + this.el.set_content(img); + // should probably do smarter scaling... + + + this.el.set_size(90, 70); + } } + + // user defined functions + } + public class Xcls_typetitle : Object + { + public Clutter.Text el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + + // ctor + public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file) + { + _this = _owner; + this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff")); + + // my vars (dec) + + // set gobject values + this.el.y_align = Clutter.ActorAlign.START; + this.el.x_align = Clutter.ActorAlign.START; + this.el.x_expand = true; + this.el.y_expand = true; + } + + // user defined functions + } + public class Xcls_title : Object + { + public Clutter.Text el; + private Xcls_ClutterFiles _this; + + + // my vars (def) + + // ctor + public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file) + { + _this = _owner; + this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff")); + + // my vars (dec) + + // set gobject values + this.el.y_align = Clutter.ActorAlign.START; + this.el.x_align = Clutter.ActorAlign.START; + this.el.x_expand = true; + this.el.y_expand = true; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/DialogConfirm.bjs b/old-javascript/Builder4/DialogConfirm.bjs new file mode 100644 index 000000000..e240812dd --- /dev/null +++ b/old-javascript/Builder4/DialogConfirm.bjs @@ -0,0 +1,26 @@ +{ + "name" : "DialogConfirm", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/DialogConfirm.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : " (event) => {\n this.el.response(Gtk.ResponseType.CANCEL);\n this.el.hide();\n return true;\n \n}\n \n\n\n" + }, + "$ message_type" : "Gtk.MessageType.QUESTION", + "text" : "Tests", + "title" : "Please Confirm d", + "xtype" : "MessageDialog", + "$ modal" : true, + "| int show" : " (string title, string msg) {\n //if (!this.el) { this.init(); } \n //this.success = success;\n this.el.title = title;\n this.el.text = msg;\n this.el.show_all();\n var ret = this.el.run();\n //print(\"ret got %d\", ret);\n this.el.hide();\n return ret;\n \n\n}\n \n\n\n\n", + "$ buttons" : "Gtk.ButtonsType.YES_NO", + "$ xns" : "Gtk", + "flags" : "Gtk.DialogFlags.MODAL", + "$ use_markup" : true, + "name" : "DialogConfirm" + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/DialogConfirm.vala b/old-javascript/Builder4/DialogConfirm.vala new file mode 100644 index 000000000..8b940e085 --- /dev/null +++ b/old-javascript/Builder4/DialogConfirm.vala @@ -0,0 +1,55 @@ +static DialogConfirm _DialogConfirm; + +public class DialogConfirm : Object +{ + public Gtk.MessageDialog el; + private DialogConfirm _this; + + public static DialogConfirm singleton() + { + if (_DialogConfirm == null) { + _DialogConfirm= new DialogConfirm(); + } + return _DialogConfirm; + } + + // my vars (def) + + // ctor + public DialogConfirm() + { + _this = this; + this.el = new Gtk.MessageDialog( null, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, "Tests", null ); + + // my vars (dec) + + // set gobject values + this.el.title = "Please Confirm d"; + this.el.name = "DialogConfirm"; + this.el.modal = true; + this.el.use_markup = true; + + // listeners + this.el.delete_event.connect( (event) => { + this.el.response(Gtk.ResponseType.CANCEL); + this.el.hide(); + return true; + + }); + } + + // user defined functions + public int show (string title, string msg) { + //if (!this.el) { this.init(); } + //this.success = success; + this.el.title = title; + this.el.text = msg; + this.el.show_all(); + var ret = this.el.run(); + //print("ret got %d", ret); + this.el.hide(); + return ret; + + + } +} diff --git a/old-javascript/Builder4/DialogNewComponent.bjs b/old-javascript/Builder4/DialogNewComponent.bjs new file mode 100644 index 000000000..3b0fd975b --- /dev/null +++ b/old-javascript/Builder4/DialogNewComponent.bjs @@ -0,0 +1,163 @@ +{ + "name" : "DialogNewComponent", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/DialogNewComponent.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", + "response" : " (self, response_id) => { \n \n\tif (response_id < 1) { // cancel!\n this.el.hide();\n return;\n }\n\n\n\n if (_this.name.el.get_text().length < 1) {\n StandardErrorDialog.show(\n this.el,\n \"You have to set Component name \"\n );\n \n return;\n }\n // what does this do?\n \n var isNew = _this.file.name.length > 0 ? false : true;\n /*\n if (!isNew && this.file.name != _this.name.el.get_text()) {\n Xcls_StandardErrorDialog.singleton().show(\n this.el,\n \"Sorry changing names does not work yet. \"\n );\n \n return;\n }\n */\n \n \n \n // FIXME - this may be more complicated...\n //for (var i in this.def) {\n // this.file[i] = this.get(i).el.get_text();\n //}\n\n if (!isNew) {\n try {\n this.updateFileFromEntry();\n } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n Xcls_StandardErrorDialog.singleton().show(\n this.el,\n \"The name you used already exists \"\n );\n return;\n \n }\n \n \n _this.file.save();\n this.el.hide();\n return;\n }\n var fn = this.name.el.get_text();\n var dir = _this.project.firstPath();\n \n if (GLib.FileUtils.test(dir + \"/\" + fn + \".bjs\", GLib.FileTest.EXISTS)) {\n Xcls_StandardErrorDialog.singleton().show(\n this.el,\n \"That file already exists\"\n ); \n return;\n }\n \n var f = JsRender.JsRender.factory(\n _this.file.project.xtype, \n _this.file.project, \n dir + \"/\" + fn + \".bjs\");\n\n _this.file = f;\n \n\n \n this.updateFileFromEntry();\n _this.file.save();\n _this.file.project.addFile(_this.file);\n \n\t \n // what about .js ?\n \n this.el.hide();\n \n \n //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n \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 _this.success(_this.project, _this.file);\n /*\n\n -- fixme -- needs to be a signal..\n if (DialogNewComponent.success != null) {\n DialogNewComponent.success(_this.project, nf);\n }\n */\n}", + "show" : "(self) => {\n this.el.show_all();\n //test\n}" + }, + "| void updateFileFromEntry" : "() {\n\n _this.file.title = _this.title.el.get_text();\n _this.file.region = _this.region.el.get_text(); \n _this.file.parent = _this.parent.el.get_text(); \n _this.file.permname = _this.permname.el.get_text(); \n _this.file.modOrder = _this.modOrder.el.get_text();\n \n if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {\n _this.file.renameTo(_this.name.el.get_text());\n }\n \n} ", + "@ void success" : "(Project.Project pr, JsRender.JsRender file)", + "id" : "DialogNewComponent", + "default_width" : 500, + "$ deletable" : true, + "# Project.Project project" : "", + "title" : "New Component", + "xtype" : "Dialog", + "| void show" : "(JsRender.JsRender c) \n{\n this.project = c.project;\n \n //if (!this.el) {\n //this.init();\n //}\n \n _this.name.el.set_text(c.name);\n _this.title.el.set_text(c.title);\n _this.parent.el.set_text(c.parent); \n _this.region.el.set_text(c.region);\n _this.modOrder.el.set_text(c.modOrder);\n _this.permname.el.set_text(c.permname);\n \n if (c.path.length > 0) {\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 \n //this.success = c.success;\n \n \n}", + "# JsRender.JsRender file" : "null", + "default_height" : 200, + "$ modal" : true, + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "VBox", + "$ pack" : "get_content_area().add", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack_start,false,false,0", + "xtype" : "Table", + "n_columns" : 2, + "$ xns" : "Gtk", + "n_rows" : 3, + "$ homogeneous" : true, + "items" : [ + { + "label" : "Component Name", + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,0,1", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "name", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,0,1", + "$ xns" : "Gtk" + }, + { + "label" : "Title", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,1,2", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "title", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,1,2", + "$ xns" : "Gtk" + }, + { + "label" : "Region", + "tooltip_text" : "center, north, south, east, west", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,2,3", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "region", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,2,3", + "$ xns" : "Gtk" + }, + { + "label" : "Parent Name", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,3,4", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "parent", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,3,4", + "$ xns" : "Gtk" + }, + { + "label" : "Permission Name", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,4,5", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "permname", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,4,5", + "$ xns" : "Gtk" + }, + { + "label" : "Order (for tabs)", + "$ visible" : true, + "xalign" : 0.90000000000000002, + "* pack" : "attach_defaults,0,1,5,6", + "xtype" : "Label", + "$ justify" : "Gtk.Justification.RIGHT", + "x_options" : 4, + "$ xns" : "Gtk" + }, + { + "id" : "modOrder", + "$ visible" : true, + "xtype" : "Entry", + "* pack" : "attach_defaults,1,2,5,6", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "label" : "Cancel", + "* pack" : "add_action_widget,0", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "* pack" : "add_action_widget,1", + "xtype" : "Button", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/DialogNewComponent.vala b/old-javascript/Builder4/DialogNewComponent.vala new file mode 100644 index 000000000..bca20569e --- /dev/null +++ b/old-javascript/Builder4/DialogNewComponent.vala @@ -0,0 +1,614 @@ +static Xcls_DialogNewComponent _DialogNewComponent; + +public class Xcls_DialogNewComponent : Object +{ + public Gtk.Dialog el; + private Xcls_DialogNewComponent _this; + + public static Xcls_DialogNewComponent singleton() + { + if (_DialogNewComponent == null) { + _DialogNewComponent= new Xcls_DialogNewComponent(); + } + return _DialogNewComponent; + } + public Xcls_name name; + public Xcls_title title; + public Xcls_region region; + public Xcls_parent parent; + public Xcls_permname permname; + public Xcls_modOrder modOrder; + + // my vars (def) + public signal void success (Project.Project pr, JsRender.JsRender file); + public Project.Project project; + public JsRender.JsRender file; + + // ctor + public Xcls_DialogNewComponent() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + this.file = null; + + // set gobject values + this.el.title = "New Component"; + this.el.default_height = 200; + this.el.default_width = 500; + this.el.deletable = true; + this.el.modal = true; + var child_0 = new Xcls_VBox2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button16( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + var child_2 = new Xcls_Button17( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 1 ); + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + //test + }); + this.el.response.connect( (self, response_id) => { + + if (response_id < 1) { // cancel! + this.el.hide(); + return; + } + + + + if (_this.name.el.get_text().length < 1) { + StandardErrorDialog.show( + this.el, + "You have to set Component name " + ); + + return; + } + // what does this do? + + var isNew = _this.file.name.length > 0 ? false : true; + /* + if (!isNew && this.file.name != _this.name.el.get_text()) { + Xcls_StandardErrorDialog.singleton().show( + this.el, + "Sorry changing names does not work yet. " + ); + + return; + } + */ + + + + // FIXME - this may be more complicated... + //for (var i in this.def) { + // this.file[i] = this.get(i).el.get_text(); + //} + + if (!isNew) { + try { + this.updateFileFromEntry(); + } catch( JsRender.Error.RENAME_FILE_EXISTS er) { + Xcls_StandardErrorDialog.singleton().show( + this.el, + "The name you used already exists " + ); + return; + + } + + + _this.file.save(); + this.el.hide(); + return; + } + var fn = this.name.el.get_text(); + var dir = _this.project.firstPath(); + + if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) { + Xcls_StandardErrorDialog.singleton().show( + this.el, + "That file already exists" + ); + return; + } + + var f = JsRender.JsRender.factory( + _this.file.project.xtype, + _this.file.project, + dir + "/" + fn + ".bjs"); + + _this.file = f; + + + + this.updateFileFromEntry(); + _this.file.save(); + _this.file.project.addFile(_this.file); + + + // what about .js ? + + this.el.hide(); + + + //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue()); + + //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs"); + //for (var i in this.file) { + // nf[i] = this.file[i]; + //} + _this.success(_this.project, _this.file); + /* + + -- fixme -- needs to be a signal.. + if (DialogNewComponent.success != null) { + DialogNewComponent.success(_this.project, nf); + } + */ + }); + this.el.show.connect( (self) => { + this.el.show_all(); + //test + }); + } + + // user defined functions + public void updateFileFromEntry () { + + _this.file.title = _this.title.el.get_text(); + _this.file.region = _this.region.el.get_text(); + _this.file.parent = _this.parent.el.get_text(); + _this.file.permname = _this.permname.el.get_text(); + _this.file.modOrder = _this.modOrder.el.get_text(); + + if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) { + _this.file.renameTo(_this.name.el.get_text()); + } + + } + public void show (JsRender.JsRender c) + { + this.project = c.project; + + //if (!this.el) { + //this.init(); + //} + + _this.name.el.set_text(c.name); + _this.title.el.set_text(c.title); + _this.parent.el.set_text(c.parent); + _this.region.el.set_text(c.region); + _this.modOrder.el.set_text(c.modOrder); + _this.permname.el.set_text(c.permname); + + if (c.path.length > 0) { + this.el.set_title("Edit File Details - " + c.name); + } else { + this.el.set_title("Create New File"); + } + + _this.file = c; + //console.log('show all'); + this.el.show_all(); + + //this.success = c.success; + + + } + public class Xcls_VBox2 : Object + { + public Gtk.VBox el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_VBox2(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Table3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_Table3 : Object + { + public Gtk.Table el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Table3(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Table( 3, 2, true ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label4( _this ); + child_0.ref(); + this.el.attach_defaults ( child_0.el , 0,1,0,1 ); + var child_1 = new Xcls_name( _this ); + child_1.ref(); + this.el.attach_defaults ( child_1.el , 1,2,0,1 ); + var child_2 = new Xcls_Label6( _this ); + child_2.ref(); + this.el.attach_defaults ( child_2.el , 0,1,1,2 ); + var child_3 = new Xcls_title( _this ); + child_3.ref(); + this.el.attach_defaults ( child_3.el , 1,2,1,2 ); + var child_4 = new Xcls_Label8( _this ); + child_4.ref(); + this.el.attach_defaults ( child_4.el , 0,1,2,3 ); + var child_5 = new Xcls_region( _this ); + child_5.ref(); + this.el.attach_defaults ( child_5.el , 1,2,2,3 ); + var child_6 = new Xcls_Label10( _this ); + child_6.ref(); + this.el.attach_defaults ( child_6.el , 0,1,3,4 ); + var child_7 = new Xcls_parent( _this ); + child_7.ref(); + this.el.attach_defaults ( child_7.el , 1,2,3,4 ); + var child_8 = new Xcls_Label12( _this ); + child_8.ref(); + this.el.attach_defaults ( child_8.el , 0,1,4,5 ); + var child_9 = new Xcls_permname( _this ); + child_9.ref(); + this.el.attach_defaults ( child_9.el , 1,2,4,5 ); + var child_10 = new Xcls_Label14( _this ); + child_10.ref(); + this.el.attach_defaults ( child_10.el , 0,1,5,6 ); + var child_11 = new Xcls_modOrder( _this ); + child_11.ref(); + this.el.attach_defaults ( child_11.el , 1,2,5,6 ); + } + + // user defined functions + } + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Label4(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Component Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + } + + // user defined functions + } + public class Xcls_name : Object + { + public Gtk.Entry el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_name(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + _this.name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_Label6 : Object + { + public Gtk.Label el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Label6(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Title" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_title : Object + { + public Gtk.Entry el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_title(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + _this.title = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_Label8 : Object + { + public Gtk.Label el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Label8(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Region" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.tooltip_text = "center, north, south, east, west"; + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_region : Object + { + public Gtk.Entry el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_region(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + _this.region = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_Label10 : Object + { + public Gtk.Label el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Label10(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Parent Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_parent : Object + { + public Gtk.Entry el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_parent(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + _this.parent = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_Label12 : Object + { + public Gtk.Label el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Label12(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Permission Name" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_permname : Object + { + public Gtk.Entry el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_permname(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + _this.permname = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_Label14 : Object + { + public Gtk.Label el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Label14(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Order (for tabs)" ); + + // my vars (dec) + + // set gobject values + this.el.justify = Gtk.Justification.RIGHT; + this.el.xalign = 0.900000f; + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_modOrder : Object + { + public Gtk.Entry el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_modOrder(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + _this.modOrder = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + public class Xcls_Button16 : Object + { + public Gtk.Button el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Button16(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + public class Xcls_Button17 : Object + { + public Gtk.Button el; + private Xcls_DialogNewComponent _this; + + + // my vars (def) + + // ctor + public Xcls_Button17(Xcls_DialogNewComponent _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/DialogSaveModule.bjs b/old-javascript/Builder4/DialogSaveModule.bjs new file mode 100644 index 000000000..4a32f1372 --- /dev/null +++ b/old-javascript/Builder4/DialogSaveModule.bjs @@ -0,0 +1,56 @@ +{ + "name" : "DialogSaveModule", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/DialogSaveModule.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) => {\n this.el.response(Gtk.ResponseType.CANCEL);\n return true;\n}" + }, + "default_width" : 400, + "# Project.Project project" : "", + "xtype" : "Dialog", + "default_height" : 200, + "$ modal" : true, + "# JsRender.Node data" : "", + "| string show" : " (Gtk.Window parent, Project.Project project, JsRender.Node data) {\n \n \n this.el.set_transient_for(parent);\n this.el.modal = true;\n \n this.data = data;\n this.project = project;\n this.name.el.set_text(\"\");\n this.el.show_all();\n var name = \"\";\n while (true) {\n var response_id = this.el.run();\n if (response_id < 1) {\n this.el.hide();\n return \"\";\n }\n \n name = _this.name.el.get_text();\n if (name.length < 1) {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"You must give the template a name. \"\n );\n continue;\n }\n if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9.]+$\", name) )\n {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"Template Name must contain only letters dots\"\n );\n continue;\n }\n break;\n }\n var f = project.newFile(name);\n f.tree = _this.data.deepClone();\n f.save();\n \n // now we save it..\n this.el.hide();\n \n return name;\n \n \n \n}\n", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "HBox", + "$ pack" : " get_content_area().add\n\n", + "$ xns" : "Gtk", + "items" : [ + { + "label" : "Name", + "xtype" : "Label", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "id" : "name", + "xtype" : "Entry", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Cancel", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,1", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/DialogSaveModule.vala b/old-javascript/Builder4/DialogSaveModule.vala new file mode 100644 index 000000000..f1daeead7 --- /dev/null +++ b/old-javascript/Builder4/DialogSaveModule.vala @@ -0,0 +1,213 @@ +static DialogSaveModule _DialogSaveModule; + +public class DialogSaveModule : Object +{ + public Gtk.Dialog el; + private DialogSaveModule _this; + + public static DialogSaveModule singleton() + { + if (_DialogSaveModule == null) { + _DialogSaveModule= new DialogSaveModule(); + } + return _DialogSaveModule; + } + public Xcls_name name; + + // my vars (def) + public Project.Project project; + public JsRender.Node data; + + // ctor + public DialogSaveModule() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.default_height = 200; + this.el.default_width = 400; + this.el.modal = true; + var child_0 = new Xcls_HBox2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button5( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + var child_2 = new Xcls_Button6( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 1 ); + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.response(Gtk.ResponseType.CANCEL); + return true; + }); + } + + // user defined functions + public string show (Gtk.Window parent, Project.Project project, JsRender.Node data) { + + + this.el.set_transient_for(parent); + this.el.modal = true; + + this.data = data; + this.project = project; + this.name.el.set_text(""); + this.el.show_all(); + var name = ""; + while (true) { + var response_id = this.el.run(); + if (response_id < 1) { + this.el.hide(); + return ""; + } + + name = _this.name.el.get_text(); + if (name.length < 1) { + StandardErrorDialog.singleton().show( + _this.el, + "You must give the template a name. " + ); + continue; + } + if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) ) + { + StandardErrorDialog.singleton().show( + _this.el, + "Template Name must contain only letters dots" + ); + continue; + } + break; + } + var f = project.newFile(name); + f.tree = _this.data.deepClone(); + f.save(); + + // now we save it.. + this.el.hide(); + + return name; + + + + } + public class Xcls_HBox2 : Object + { + public Gtk.HBox el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_HBox2(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_name( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Label3(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_name : Object + { + public Gtk.Entry el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_name(DialogSaveModule _owner ) + { + _this = _owner; + _this.name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Button5 : Object + { + public Gtk.Button el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Button5(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private DialogSaveModule _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(DialogSaveModule _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/DialogSaveTemplate.bjs b/old-javascript/Builder4/DialogSaveTemplate.bjs new file mode 100644 index 000000000..c8fbe2ef4 --- /dev/null +++ b/old-javascript/Builder4/DialogSaveTemplate.bjs @@ -0,0 +1,56 @@ +{ + "name" : "DialogSaveTemplate", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/DialogSaveTemplate.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) => {\n this.el.response(Gtk.ResponseType.CANCEL);\n return true;\n \n}" + }, + "default_width" : 400, + "| void show" : " (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {\n \n \n this.el.set_transient_for(parent);\n this.el.modal = true;\n \n this.name.el.set_text(\"\");\n this.el.show_all();\n var name = \"\";\n while (true) {\n var response_id = this.el.run();\n if (response_id < 1) {\n this.el.hide();\n return;\n }\n \n name = _this.name.el.get_text();\n if (name.length < 1) {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"You must give the template a name. \"\n );\n continue;\n }\n if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9. ]+$\", name) )\n {\n StandardErrorDialog.singleton().show(\n _this.el,\n \"Template Name must contain only letters dots\"\n );\n continue;\n }\n break;\n }\n palete.saveTemplate(name, data);\n \n // now we save it..\n this.el.hide();\n \n \n \n \n}\n", + "xtype" : "Dialog", + "default_height" : 200, + "# Palete.Palete palete" : "", + "$ modal" : true, + "# JsRender.Node data" : "", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "HBox", + "$ pack" : " get_content_area().add\n\n", + "$ xns" : "Gtk", + "items" : [ + { + "label" : "Name", + "xtype" : "Label", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "id" : "name", + "xtype" : "Entry", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "Cancel", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,1", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/DialogSaveTemplate.vala b/old-javascript/Builder4/DialogSaveTemplate.vala new file mode 100644 index 000000000..732527b48 --- /dev/null +++ b/old-javascript/Builder4/DialogSaveTemplate.vala @@ -0,0 +1,209 @@ +static DialogSaveTemplate _DialogSaveTemplate; + +public class DialogSaveTemplate : Object +{ + public Gtk.Dialog el; + private DialogSaveTemplate _this; + + public static DialogSaveTemplate singleton() + { + if (_DialogSaveTemplate == null) { + _DialogSaveTemplate= new DialogSaveTemplate(); + } + return _DialogSaveTemplate; + } + public Xcls_name name; + + // my vars (def) + public Palete.Palete palete; + public JsRender.Node data; + + // ctor + public DialogSaveTemplate() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.default_height = 200; + this.el.default_width = 400; + this.el.modal = true; + var child_0 = new Xcls_HBox2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button5( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + var child_2 = new Xcls_Button6( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 1 ); + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.response(Gtk.ResponseType.CANCEL); + return true; + + }); + } + + // user defined functions + public void show (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) { + + + this.el.set_transient_for(parent); + this.el.modal = true; + + this.name.el.set_text(""); + this.el.show_all(); + var name = ""; + while (true) { + var response_id = this.el.run(); + if (response_id < 1) { + this.el.hide(); + return; + } + + name = _this.name.el.get_text(); + if (name.length < 1) { + StandardErrorDialog.singleton().show( + _this.el, + "You must give the template a name. " + ); + continue; + } + if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9. ]+$", name) ) + { + StandardErrorDialog.singleton().show( + _this.el, + "Template Name must contain only letters dots" + ); + continue; + } + break; + } + palete.saveTemplate(name, data); + + // now we save it.. + this.el.hide(); + + + + + } + public class Xcls_HBox2 : Object + { + public Gtk.HBox el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_HBox2(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_name( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label3 : Object + { + public Gtk.Label el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Label3(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_name : Object + { + public Gtk.Entry el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_name(DialogSaveTemplate _owner ) + { + _this = _owner; + _this.name = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Button5 : Object + { + public Gtk.Button el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Button5(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Cancel"; + } + + // user defined functions + } + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private DialogSaveTemplate _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(DialogSaveTemplate _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/DialogTemplateSelect.bjs b/old-javascript/Builder4/DialogTemplateSelect.bjs new file mode 100644 index 000000000..d0189abbd --- /dev/null +++ b/old-javascript/Builder4/DialogTemplateSelect.bjs @@ -0,0 +1,74 @@ +{ + "name" : "DialogTemplateSelect", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/DialogTemplateSelect.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : " (self, event) =>{\n this.el.hide();\n return true;\n}" + }, + "default_width" : 400, + "title" : "Add an Object", + "xtype" : "Dialog", + "default_height" : 200, + "$ modal" : true, + "$ xns" : "Gtk", + "| JsRender.Node? show" : " (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {\n \n this.el.show_all();\n var opts = pal.listTemplates(node);\n if (opts.length() < 1) {\n this.el.hide();\n return node;\n }\n this.el.set_attached_to( pwindow);\n this.el.set_transient_for( pwindow);\n \n //opts.unshift({ path: '' , name :'Just add Element' });\n _this.model.loadData(opts);\n _this.combo.el.set_active(0);\n \n \n this.el.run();\n this.el.hide(); \n //var ix = _this.combo.el.get_active();\n //if (ix < 1 ) {\n // return node;\n // }\n Gtk.TreeIter iter;\n _this.combo.el.get_active_iter (out iter);\n Value vfname;\n this.model.el.get_value (iter, 0, out vfname);\n \n if (((string)vfname).length < 1) {\n return node;\n }\n return pal.loadTemplate((string)vfname);\n\n}\n", + "items" : [ + { + "xtype" : "VBox", + "$ pack" : "get_content_area().add ", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack_start,false,false,0", + "xtype" : "HBox", + "$ xns" : "Gtk", + "items" : [ + { + "label" : "Select Template : ", + "xtype" : "Label", + "* pack" : "pack_start,false,false", + "$ xns" : "Gtk" + }, + { + "id" : "combo", + "* init" : "this.el.add_attribute(_this.cellrenderer.el , \"markup\", 1 );", + "xtype" : "ComboBox", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "cellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "id" : "model", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (GLib.List data) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n \n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"Just add Element\");\n \n for (var i = 0; i < data.length();i++) {\n \n\n el.append(out iter);\n var str = data.nth_data(i);\n var fn = Path.get_basename (str);\n fn.replace(\".json\", \"\");\n \n el.set_value(iter, 0, str);\n el.set_value(iter, 1, fn);\n \n }\n this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING); \n \n}\n" + } + ] + } + ] + } + ] + }, + { + "label" : "OK", + "xtype" : "Button", + "* pack" : "add_action_widget,0", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/DialogTemplateSelect.vala b/old-javascript/Builder4/DialogTemplateSelect.vala new file mode 100644 index 000000000..b84791f78 --- /dev/null +++ b/old-javascript/Builder4/DialogTemplateSelect.vala @@ -0,0 +1,277 @@ +static DialogTemplateSelect _DialogTemplateSelect; + +public class DialogTemplateSelect : Object +{ + public Gtk.Dialog el; + private DialogTemplateSelect _this; + + public static DialogTemplateSelect singleton() + { + if (_DialogTemplateSelect == null) { + _DialogTemplateSelect= new DialogTemplateSelect(); + } + return _DialogTemplateSelect; + } + public Xcls_combo combo; + public Xcls_cellrenderer cellrenderer; + public Xcls_model model; + + // my vars (def) + + // ctor + public DialogTemplateSelect() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars (dec) + + // set gobject values + this.el.title = "Add an Object"; + this.el.default_height = 200; + this.el.default_width = 400; + this.el.modal = true; + var child_0 = new Xcls_VBox2( _this ); + child_0.ref(); + this.el.get_content_area().add ( child_0.el ); + var child_1 = new Xcls_Button8( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 0 ); + + // listeners + this.el.delete_event.connect( (self, event) =>{ + this.el.hide(); + return true; + }); + } + + // user defined functions + public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) { + + this.el.show_all(); + var opts = pal.listTemplates(node); + if (opts.length() < 1) { + this.el.hide(); + return node; + } + this.el.set_attached_to( pwindow); + this.el.set_transient_for( pwindow); + + //opts.unshift({ path: '' , name :'Just add Element' }); + _this.model.loadData(opts); + _this.combo.el.set_active(0); + + + this.el.run(); + this.el.hide(); + //var ix = _this.combo.el.get_active(); + //if (ix < 1 ) { + // return node; + // } + Gtk.TreeIter iter; + _this.combo.el.get_active_iter (out iter); + Value vfname; + this.model.el.get_value (iter, 0, out vfname); + + if (((string)vfname).length < 1) { + return node; + } + return pal.loadTemplate((string)vfname); + + } + public class Xcls_VBox2 : Object + { + public Gtk.VBox el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_VBox2(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_HBox3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_HBox3 : Object + { + public Gtk.HBox el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_HBox3(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label4( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false ); + var child_1 = new Xcls_combo( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Label4(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Select Template : " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_combo : Object + { + public Gtk.ComboBox el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_combo(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.combo = this; + this.el = new Gtk.ComboBox(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_cellrenderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_model( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + + this.el.add_attribute(_this.cellrenderer.el , "markup", 1 ); } + + // user defined functions + } + public class Xcls_cellrenderer : Object + { + public Gtk.CellRendererText el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_cellrenderer(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.cellrenderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_model(DialogTemplateSelect _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadData (GLib.List data) { + this.el.clear(); + Gtk.TreeIter iter; + var el = this.el; + + el.append(out iter); + + + el.set_value(iter, 0, ""); + el.set_value(iter, 1, "Just add Element"); + + for (var i = 0; i < data.length();i++) { + + + el.append(out iter); + var str = data.nth_data(i); + var fn = Path.get_basename (str); + fn.replace(".json", ""); + + el.set_value(iter, 0, str); + el.set_value(iter, 1, fn); + + } + this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING); + + } + } + public class Xcls_Button8 : Object + { + public Gtk.Button el; + private DialogTemplateSelect _this; + + + // my vars (def) + + // ctor + public Xcls_Button8(DialogTemplateSelect _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "OK"; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/EditProject.bjs b/old-javascript/Builder4/EditProject.bjs new file mode 100644 index 000000000..d8c9ac597 --- /dev/null +++ b/old-javascript/Builder4/EditProject.bjs @@ -0,0 +1,97 @@ +{ + "id": "file-gtk-8", + "name": "EditProject", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Builder4/EditProject.bjs", + "items": [ + { + "listeners": { + "destroy_event": " (self, event) => {\n this.el.response(0);\n// this.el.hide();\n return false;\n}" + }, + "border_width": 3, + "default_height": 500, + "default_width": 600, + "name": "EditProject", + "title": "Project Properties", + "xtype": "Dialog", + "|Project.Project?:show": "() {\n \n\n //[ 'xtype' ].forEach(function(k) {\n // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n //});\n\t// shouild set path..\n _this.model.loadData();\n this.el.show_all();\n \n var err_dialog = StandardErrorDialog.singleton();\n\n var id = -1;\n while (id < 0) {\n id = this.el.run();\n if (id < 1) {\n this.el.hide();\n return null;\n }\n\n \n if (_this.xtype.getValue().length < 1) {\n \n err_dialog.show(_this.el,\"You have to set Project type\"); \n id = -1;\n continue;\n }\n if (_this.dir.el.get_filename().length < 1) {\n \n err_dialog.show(_this.el,\"You have to select a folder\"); \n id = -1;\n continue;\n }\n \n }\n \n this.el.hide();\n \n \n \n \n var fn = _this.dir.el.get_filename();\n print(\"add %s\\n\" , fn);\n \n var project = Project.Project.factory(_this.xtype.getValue(), fn);\n project.save();\n Project.projects.set(project.name,project);\n \n //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);\n \n return project;\n\n \n //this.success = c.success;\n}\n", + "|deletable": "true", + "|modal": "true", + "|xns": "Gtk", + "items": [ + { + "|homogeneous": "false", + "xtype": "VBox", + "|pack": " get_content_area().add \n \n", + "|xns": "Gtk", + "items": [ + { + "|homogeneous": "false", + "pack": "pack_start,false,true,3", + "xtype": "HBox", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "pack_start,false,true,3", + "label": "Project type :" + }, + { + "id": "xtype", + "pack": "pack_end,true,true,3", + "xtype": "ComboBox", + "|init": " this.el.add_attribute(_this.cellrender.el , \"markup\", 1 ); \n \n", + "|setValue": " (v) {\n var el = this.el;\n el.set_active(-1);\n \n for (var i =0;i < this.data.length; i++ ) {\n if (v == this.data.nth_datA(i)) {\n el.set_active(ix);\n return false;\n }\n }\n }", + "|string:getValue": " () {\n var ix = this.el.get_active();\n if (ix < 0 ) {\n return \"\";\n }\n switch(ix) {\n case 0:\n return \"Roo\";\n case 1:\n return \"Gtk\";\n }\n return \"\";\n}\n", + "|xns": "Gtk", + "items": [ + { + "id": "cellrender", + "pack": "pack_start,true", + "xtype": "CellRendererText", + "|xns": "Gtk" + }, + { + "|columns": "typeof(string),typeof(string)", + "id": "model", + "n_columns": 2, + "pack": "set_model", + "xtype": "ListStore", + "|void:loadData": " ( ) {\n this.el.clear();\n \n Gtk.TreeIter iter;\n \n el.append(out iter);\n \n el.set_value(iter, 0, \"Roo\");\n el.set_value(iter, 1, \"Roo Project\");\n el.append(out iter);\n \n el.set_value(iter, 0, \"Gtk\");\n el.set_value(iter, 1, \"Gtk Project\");\n \n \n \n}\n", + "|xns": "Gtk" + } + ] + } + ] + }, + { + "|create_folders": "false", + "id": "dir", + "pack": "pack_end,true,true,5", + "xtype": "FileChooserWidget", + "|action": "Gtk.FileChooserAction.SELECT_FOLDER", + "|select_multiple": "false", + "|xns": "Gtk" + } + ] + }, + { + "label": "OK", + "pack": "add_action_widget,1", + "xtype": "Button", + "|xns": "Gtk" + }, + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "add_action_widget,0", + "label": "Cancel" + } + ] + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/old-javascript/Builder4/EditProject.vala b/old-javascript/Builder4/EditProject.vala new file mode 100644 index 000000000..0203eecc9 --- /dev/null +++ b/old-javascript/Builder4/EditProject.vala @@ -0,0 +1,402 @@ +/* -- to compile +valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \ + /tmp/EditProject.vala -o /tmp/EditProject +*/ + + +/* -- to test class +static int main (string[] args) { + Gtk.init (ref args); + new Xcls_EditProject(); + EditProject.show_all(); + Gtk.main (); + return 0; +} +*/ + + +public static Xcls_EditProject EditProject; + +public class Xcls_EditProject : Object +{ + public Gtk.Dialog el; + private Xcls_EditProject _this; + + public static Xcls_EditProject singleton() + { + if (EditProject == null) { + EditProject= new Xcls_EditProject(); + } + return EditProject; + } + public Xcls_xtype xtype; + public Xcls_cellrender cellrender; + public Xcls_model model; + public Xcls_dir dir; + + // my vars + + // ctor + public Xcls_EditProject() + { + _this = this; + this.el = new Gtk.Dialog(); + + // my vars + + // set gobject values + this.el.border_width = 3; + this.el.default_height = 500; + this.el.default_width = 600; + this.el.deletable = true; + this.el.modal = true; + this.el.name = "EditProject"; + this.el.title = "Project Properties"; + var child_0 = new Xcls_VBox2( _this ); + child_0.ref(); + this.el. get_content_area().add + + ( child_0.el ); + var child_1 = new Xcls_Button9( _this ); + child_1.ref(); + this.el.add_action_widget ( child_1.el , 1 ); + var child_2 = new Xcls_Button10( _this ); + child_2.ref(); + this.el.add_action_widget ( child_2.el , 0 ); + + // listeners + this.el.destroy_event.connect( (self, event) => { + this.el.response(0); + // this.el.hide(); + return false; + } ); + } + + // userdefined functions + public Project.Project? show() { + + + //[ 'xtype' ].forEach(function(k) { + // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]); + //}); + // shouild set path.. + _this.model.loadData(); + this.el.show_all(); + + var err_dialog = StandardErrorDialog.singleton(); + + var id = -1; + while (id < 0) { + id = this.el.run(); + if (id < 1) { + this.el.hide(); + return null; + } + + + if (_this.xtype.getValue().length < 1) { + + err_dialog.show(_this.el,"You have to set Project type"); + id = -1; + continue; + } + if (_this.dir.el.get_filename().length < 1) { + + err_dialog.show(_this.el,"You have to select a folder"); + id = -1; + continue; + } + + } + + this.el.hide(); + + + + + var fn = _this.dir.el.get_filename(); + print("add %s\n" , fn); + + var project = Project.Project.factory(_this.xtype.getValue(), fn); + project.save(); + Project.projects.set(project.name,project); + + //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project); + + return project; + + + //this.success = c.success; + } + + // skip |xns - no return type + public class Xcls_VBox2 : Object + { + public Gtk.VBox el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_VBox2(Xcls_EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( false, 0 ); + + // my vars + + // set gobject values + var child_0 = new Xcls_HBox3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,3 ); + var child_1 = new Xcls_dir( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,5 ); + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_HBox3 : Object + { + public Gtk.HBox el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_HBox3(Xcls_EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( false, 0 ); + + // my vars + + // set gobject values + var child_0 = new Xcls_Label4( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,3 ); + var child_1 = new Xcls_xtype( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,3 ); + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_Label4 : Object + { + public Gtk.Label el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_Label4(Xcls_EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Project type :" ); + + // my vars + + // set gobject values + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_xtype : Object + { + public Gtk.ComboBox el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_xtype(Xcls_EditProject _owner ) + { + _this = _owner; + _this.xtype = this; + this.el = new Gtk.ComboBox(); + + // my vars + + // set gobject values + var child_0 = new Xcls_cellrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + var child_1 = new Xcls_model( _this ); + child_1.ref(); + this.el.set_model ( child_1.el ); + + // init method + this.el.add_attribute(_this.cellrender.el , "markup", 1 ); + + } + + // userdefined functions + + // skip |setValue - no return type + public string getValue () { + var ix = this.el.get_active(); + if (ix < 0 ) { + return ""; + } + switch(ix) { + case 0: + return "Roo"; + case 1: + return "Gtk"; + } + return ""; + } + + // skip |xns - no return type + } + public class Xcls_cellrender : Object + { + public Gtk.CellRendererText el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_cellrender(Xcls_EditProject _owner ) + { + _this = _owner; + _this.cellrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars + + // set gobject values + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_model(Xcls_EditProject _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars + + // set gobject values + } + + // userdefined functions + public void loadData ( ) { + this.el.clear(); + + Gtk.TreeIter iter; + + el.append(out iter); + + el.set_value(iter, 0, "Roo"); + el.set_value(iter, 1, "Roo Project"); + el.append(out iter); + + el.set_value(iter, 0, "Gtk"); + el.set_value(iter, 1, "Gtk Project"); + + + + } + + // skip |xns - no return type + } + public class Xcls_dir : Object + { + public Gtk.FileChooserWidget el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_dir(Xcls_EditProject _owner ) + { + _this = _owner; + _this.dir = this; + this.el = new Gtk.FileChooserWidget( Gtk.FileChooserAction.SELECT_FOLDER ); + + // my vars + + // set gobject values + this.el.create_folders = false; + this.el.select_multiple = false; + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_Button9 : Object + { + public Gtk.Button el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_Button9(Xcls_EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars + + // set gobject values + this.el.label = "OK"; + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_Button10 : Object + { + public Gtk.Button el; + private Xcls_EditProject _this; + + + // my vars + + // ctor + public Xcls_Button10(Xcls_EditProject _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars + + // set gobject values + this.el.label = "Cancel"; + } + + // userdefined functions + + // skip |xns - no return type + } +} diff --git a/old-javascript/Builder4/Editor.bjs b/old-javascript/Builder4/Editor.bjs new file mode 100644 index 000000000..9c3d7e9c8 --- /dev/null +++ b/old-javascript/Builder4/Editor.bjs @@ -0,0 +1,95 @@ +{ + "name" : "Editor", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/Editor.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "# string activeEditor" : "\"\"", + "| bool saveContents" : " () {\n \n \n \n \n \n \n \n \n \n var str = _this.buffer.toString();\n \n if (!_this.buffer.checkSyntax()) {\n print(\"check syntax failed\");\n //this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n return false;\n }\n \n // LeftPanel.model.changed( str , false);\n _this.dirty = false;\n _this.save_button.el.sensitive = false;\n \n \n \n \n // find the text for the node..\n if (ptype == \"listener\") {\n this.node.listeners.set(key,str);\n \n } else {\n this.node.props.set(key,str);\n }\n\n \n \n // call the signal..\n this.save();\n \n return true;\n\n} ", + "# int pos_root_x" : "", + "# int pos_root_y" : "", + "# string ptype" : "\"\"", + "# string key" : "\"\"", + "* pack" : "add", + "xtype" : "VBox", + "| void show" : "(JsRender.JsRender file, JsRender.Node node, string ptype, string key)\n{\n this.ptype = ptype;\n this.key = key;\n this.node = node;\n this.file = file;\n \n string val = \"\";\n // find the text for the node..\n if (ptype == \"listener\") {\n val = node.listeners.get(key);\n \n } else {\n val = node.props.get(key);\n }\n this.view.load(val);\n this.key_edit.el.text = key; \n\n}", + "# JsRender.JsRender file" : "null", + "# bool pos" : false, + "string id" : "Editor", + "# bool dirty" : false, + "$ xns" : "Gtk", + "@ void save" : "()", + "$ homogeneous" : false, + "# JsRender.Node node" : "null", + "items" : [ + { + "* pack" : "pack_start,false,true", + "xtype" : "HBox", + "$ xns" : "Gtk", + "$ homogeneous" : false, + "items" : [ + { + "listeners" : { + "clicked" : " () => { \n _this.saveContents();\n}\n \n" + }, + "label" : "Save", + "id" : "save_button", + "* pack" : "pack_start,false,false", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "id" : "key_edit", + "xtype" : "Entry", + "* pack" : "pack_end,true,true", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "RightEditor", + "* init" : "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", + "xtype" : "ScrolledWindow", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "key_release_event" : " (event) => {\n \n if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n print(\"SAVE: ctrl-S pressed\");\n _this.saveContents();\n return false;\n }\n // print(event.key.keyval)\n \n return false;\n\n} \n\n" + }, + "gboolean show_line_marks" : true, + "id" : "view", + "* init" : " \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n var attrs = new Gtk.SourceMarkAttributes();\n var pink = new Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"error\", attrs, 1);\n \n ", + "$ insert_spaces_instead_of_tabs" : true, + "* pack" : "add", + "xtype" : "View", + "gboolean highlight_current_line" : true, + "$ gboolean auto_indent" : true, + "$ xns" : "GtkSource", + "| void load" : " (string str) {\n\n// show the help page for the active node..\n //this.get('/Help').show();\n\n\n // this.get('/BottomPane').el.set_current_page(0);\n this.el.get_buffer().set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n var lang = _this.file.language;\n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language(lang));\n var buf = this.el.get_buffer();\n \n /* -- what does all this do? */\n /*\n var cursor = buf.get_mark(\"insert\");\n Gtk.TextIter iter;\n buf.get_iter_at_mark(out iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n \n cursor = buf.get_mark(\"selection_bound\");\n //iter= new Gtk.TextIter;\n buf.get_iter_at_mark(out iter, cursor);\n iter.set_line(1);\n iter.set_line_offset(4);\n buf.move_mark(cursor, iter);\n \n */\n \n _this.dirty = false;\n this.el.grab_focus();\n _this.save_button.el.sensitive = false;\n}", + "indent_width" : 4, + "$ show_line_numbers" : true, + "items" : [ + { + "listeners" : { + "changed" : " () => {\n // check syntax??\n if(this.checkSyntax()) {\n _this.save_button.el.sensitive = true;\n }\n // print(\"EDITOR CHANGED\");\n _this.dirty = true;\n\n // this.get('/LeftPanel.model').changed( str , false);\n return ;\n}\n\n \n" + }, + "id" : "buffer", + "int error_line" : "-1", + "| string toString" : " () {\n \n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_start_iter(out s);\n this.el.get_end_iter(out e);\n var ret = this.el.get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n ", + "| bool checkSyntax" : " () {\n \n var p = Palete.factory(_this.file.xtype); \n \n var str = this.toString();\n \n string res = \"\";\n \n if (this.error_line > 0) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n\n this.el.remove_source_marks (start, end, null);\n }\n \n \n var validate_res = p.validateCode(\n str, \n _this.key, \n _this.ptype,\n _this.file,\n _this.node\n \n );\n \n this.error_line = validate_res.size;\n\n if (this.error_line < 1) {\n return true;\n }\n var tlines = this.el.get_line_count ();\n Gtk.TextIter iter;\n var valiter = validate_res.map_iterator();\n while (valiter.next()) {\n \n// print(\"get inter\\n\");\n var eline = valiter.get_key();\n if (eline > tlines) {\n continue;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n this.el.create_source_mark(valiter.get_value(), \"error\", iter);\n } \n \n //print(\"done mark line\\n\");\n \n return true; // at present allow saving - even if it's invalid..\n}\n", + "* pack" : "set_buffer", + "xtype" : "Buffer", + "$ xns" : "GtkSource" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/Editor.vala b/old-javascript/Builder4/Editor.vala new file mode 100644 index 000000000..454d7175b --- /dev/null +++ b/old-javascript/Builder4/Editor.vala @@ -0,0 +1,421 @@ +static Editor _Editor; + +public class Editor : Object +{ + public Gtk.VBox el; + private Editor _this; + + public static Editor singleton() + { + if (_Editor == null) { + _Editor= new Editor(); + } + return _Editor; + } + public Xcls_save_button save_button; + public Xcls_key_edit key_edit; + public Xcls_RightEditor RightEditor; + public Xcls_view view; + public Xcls_buffer buffer; + + // my vars (def) + public string activeEditor; + public int pos_root_x; + public int pos_root_y; + public string ptype; + public string key; + public JsRender.JsRender file; + public bool pos; + public bool dirty; + public signal void save (); + public JsRender.Node node; + + // ctor + public Editor() + { + _this = this; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + this.activeEditor = ""; + this.ptype = ""; + this.key = ""; + this.file = null; + this.pos = false; + this.dirty = false; + this.node = null; + + // set gobject values + var child_0 = new Xcls_HBox2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true ); + var child_1 = new Xcls_RightEditor( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + public bool saveContents () { + + + + + + + + + + var str = _this.buffer.toString(); + + if (!_this.buffer.checkSyntax()) { + print("check syntax failed"); + //this.get('/StandardErrorDialog').show("Fix errors in code and save.."); + return false; + } + + // LeftPanel.model.changed( str , false); + _this.dirty = false; + _this.save_button.el.sensitive = false; + + + + + // find the text for the node.. + if (ptype == "listener") { + this.node.listeners.set(key,str); + + } else { + this.node.props.set(key,str); + } + + + + // call the signal.. + this.save(); + + return true; + + } + public void show (JsRender.JsRender file, JsRender.Node node, string ptype, string key) + { + this.ptype = ptype; + this.key = key; + this.node = node; + this.file = file; + + string val = ""; + // find the text for the node.. + if (ptype == "listener") { + val = node.listeners.get(key); + + } else { + val = node.props.get(key); + } + this.view.load(val); + this.key_edit.el.text = key; + + } + public class Xcls_HBox2 : Object + { + public Gtk.HBox el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_HBox2(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( false, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_save_button( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false ); + var child_1 = new Xcls_key_edit( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true ); + } + + // user defined functions + } + public class Xcls_save_button : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_save_button(Editor _owner ) + { + _this = _owner; + _this.save_button = this; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save"; + + // listeners + this.el.clicked.connect( () => { + _this.saveContents(); + }); + } + + // user defined functions + } + public class Xcls_key_edit : Object + { + public Gtk.Entry el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_key_edit(Editor _owner ) + { + _this = _owner; + _this.key_edit = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_RightEditor : Object + { + public Gtk.ScrolledWindow el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_RightEditor(Editor _owner ) + { + _this = _owner; + _this.RightEditor = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.SourceView el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_view(Editor _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // set gobject values + this.el.auto_indent = true; + this.el.indent_width = 4; + this.el.show_line_marks = true; + this.el.insert_spaces_instead_of_tabs = true; + this.el.show_line_numbers = true; + this.el.highlight_current_line = true; + var child_0 = new Xcls_buffer( _this ); + child_0.ref(); + this.el.set_buffer ( child_0.el ); + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + var attrs = new Gtk.SourceMarkAttributes(); + var pink = new Gdk.RGBA(); + pink.parse ( "pink"); + attrs.set_background ( pink); + attrs.set_icon_name ( "process-stop"); + attrs.query_tooltip_text.connect(( mark) => { + print("tooltip query? %s\n", mark.name); + return mark.name; + }); + + this.el.set_mark_attributes ("error", attrs, 1); + // listeners + this.el.key_release_event.connect( (event) => { + + if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + print("SAVE: ctrl-S pressed"); + _this.saveContents(); + return false; + } + // print(event.key.keyval) + + return false; + + }); + } + + // user defined functions + public void load (string str) { + + // show the help page for the active node.. + //this.get('/Help').show(); + + + // this.get('/BottomPane').el.set_current_page(0); + this.el.get_buffer().set_text(str, str.length); + var lm = Gtk.SourceLanguageManager.get_default(); + + var lang = _this.file.language; + //?? is javascript going to work as js? + + ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language(lang)); + var buf = this.el.get_buffer(); + + /* -- what does all this do? */ + /* + var cursor = buf.get_mark("insert"); + Gtk.TextIter iter; + buf.get_iter_at_mark(out iter, cursor); + iter.set_line(1); + iter.set_line_offset(4); + buf.move_mark(cursor, iter); + + + cursor = buf.get_mark("selection_bound"); + //iter= new Gtk.TextIter; + buf.get_iter_at_mark(out iter, cursor); + iter.set_line(1); + iter.set_line_offset(4); + buf.move_mark(cursor, iter); + + */ + + _this.dirty = false; + this.el.grab_focus(); + _this.save_button.el.sensitive = false; + } + } + public class Xcls_buffer : Object + { + public Gtk.SourceBuffer el; + private Editor _this; + + + // my vars (def) + public int error_line; + + // ctor + public Xcls_buffer(Editor _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new Gtk.SourceBuffer( null ); + + // my vars (dec) + this.error_line = -1; + + // set gobject values + + // listeners + this.el.changed.connect( () => { + // check syntax?? + if(this.checkSyntax()) { + _this.save_button.el.sensitive = true; + } + // print("EDITOR CHANGED"); + _this.dirty = true; + + // this.get('/LeftPanel.model').changed( str , false); + return ; + }); + } + + // user defined functions + public string toString () { + + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_start_iter(out s); + this.el.get_end_iter(out e); + var ret = this.el.get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + public bool checkSyntax () { + + var p = Palete.factory(_this.file.xtype); + + var str = this.toString(); + + string res = ""; + + if (this.error_line > 0) { + Gtk.TextIter start; + Gtk.TextIter end; + this.el.get_bounds (out start, out end); + + this.el.remove_source_marks (start, end, null); + } + + + var validate_res = p.validateCode( + str, + _this.key, + _this.ptype, + _this.file, + _this.node + + ); + + this.error_line = validate_res.size; + + if (this.error_line < 1) { + return true; + } + var tlines = this.el.get_line_count (); + Gtk.TextIter iter; + var valiter = validate_res.map_iterator(); + while (valiter.next()) { + + // print("get inter\n"); + var eline = valiter.get_key(); + if (eline > tlines) { + continue; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + this.el.create_source_mark(valiter.get_value(), "error", iter); + } + + //print("done mark line\n"); + + return true; // at present allow saving - even if it's invalid.. + } + } +} diff --git a/old-javascript/Builder4/GladeExtras.vala b/old-javascript/Builder4/GladeExtras.vala new file mode 100644 index 000000000..ce8c8fdd8 --- /dev/null +++ b/old-javascript/Builder4/GladeExtras.vala @@ -0,0 +1,12 @@ + + + + +public class GladeExtras : Object +{ + + static void init() + { + + + } \ No newline at end of file diff --git a/old-javascript/Builder4/GladeView.bjs b/old-javascript/Builder4/GladeView.bjs new file mode 100644 index 000000000..c59b8e480 --- /dev/null +++ b/old-javascript/Builder4/GladeView.bjs @@ -0,0 +1,19 @@ +{ + "name" : "GladeView", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/GladeView.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "* ctor" : "new Glade.DesignView(new Glade.Project())", + "id" : "GladeView", + "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n var filename = this.file.getIconFileName(false);\n \n var win = this.el.get_parent_window();\n var width = win.get_width();\n var height = win.get_height();\n\n Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?\n\n screenshot.save(filename,\"png\");\n return;\n \n \n \n \n \n \n \n // should we hold until it's printed...\n \n \n\n \n \n\n\n \n \n}\n", + "| void loadFile" : "(JsRender.JsRender file)\n{\n \n\n this.file = file;\n \n\n // clear existing elements from project?\n \n var p = this.el.get_project();\n var li = p.get_objects().copy();\n // should remove all..\n for (var i =0; i < li.length(); i++) { \n p.remove_object(li.nth_data(i)); \n }\n\n if (file.tree == null) {\n return;\n }\n\n// print(\"%s\\n\",tf.tree.toJsonString());\n\tvar x = new JsRender.NodeToGlade(file.tree, \"\");\n\n\t \n\tFileIOStream iostream;\n\tvar f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);\n\tvar ostream = iostream.output_stream;\n\tvar dostream = new DataOutputStream (ostream);\n\tdostream.put_string (x.munge());\n\tthis.el.show();\n\t print(\"LOADING %s\\n\",f.get_path ());\n p.load_from_file(f.get_path ());\n \n \n\n}", + "xtype" : "DesignView", + "# JsRender.JsRender file" : "null", + "$ xns" : "Glade" + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/GladeView.vala b/old-javascript/Builder4/GladeView.vala new file mode 100644 index 000000000..921ac96c7 --- /dev/null +++ b/old-javascript/Builder4/GladeView.vala @@ -0,0 +1,102 @@ +static Xcls_GladeView _GladeView; + +public class Xcls_GladeView : Object +{ + public Glade.DesignView el; + private Xcls_GladeView _this; + + public static Xcls_GladeView singleton() + { + if (_GladeView == null) { + _GladeView= new Xcls_GladeView(); + } + return _GladeView; + } + + // my vars (def) + public JsRender.JsRender file; + + // ctor + public Xcls_GladeView() + { + _this = this; + this.el = new Glade.DesignView(new Glade.Project()); + + // my vars (dec) + this.file = null; + + // set gobject values + } + + // user defined functions + public void createThumb () { + + + if (this.file == null) { + return; + } + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + var height = win.get_height(); + + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position? + + screenshot.save(filename,"png"); + return; + + + + + + + + // should we hold until it's printed... + + + + + + + + + + } + public void loadFile (JsRender.JsRender file) + { + + + this.file = file; + + + // clear existing elements from project? + + var p = this.el.get_project(); + var li = p.get_objects().copy(); + // should remove all.. + for (var i =0; i < li.length(); i++) { + p.remove_object(li.nth_data(i)); + } + + if (file.tree == null) { + return; + } + + // print("%s\n",tf.tree.toJsonString()); + var x = new JsRender.NodeToGlade(file.tree, ""); + + + FileIOStream iostream; + var f = File.new_tmp ("tpl-XXXXXX.glade", out iostream); + var ostream = iostream.output_stream; + var dostream = new DataOutputStream (ostream); + dostream.put_string (x.munge()); + this.el.show(); + print("LOADING %s\n",f.get_path ()); + p.load_from_file(f.get_path ()); + + + + } +} diff --git a/old-javascript/Builder4/GtkView.bjs b/old-javascript/Builder4/GtkView.bjs new file mode 100644 index 000000000..01d2f487e --- /dev/null +++ b/old-javascript/Builder4/GtkView.bjs @@ -0,0 +1,105 @@ +{ + "name" : "GtkView", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/GtkView.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "id" : "GtkView", + "# Gtk.Widget lastObj" : "null", + "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n var filename = this.file.getIconFileName(false);\n \n var win = this.el.get_parent_window();\n var width = win.get_width();\n var height = win.get_height();\n\n Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?\n\n screenshot.save(filename,\"png\");\n return;\n \n \n \n \n \n \n \n // should we hold until it's printed...\n \n \n\n \n \n\n\n \n \n}\n", + "| void loadFile" : "(JsRender.JsRender file) \n{\n \n this.el.set_position((int)(this.el.max_position * 0.7));\n this.file = null;\n \n if (file.tree == null) {\n return;\n }\n this.file = file;\n if (this.lastObj != null) {\n this.container.el.remove(this.lastObj);\n }\n \n\tvar x = new JsRender.NodeToGtk(file.tree);\n var obj = x.munge() as Gtk.Widget;\n this.lastObj = null;\n\tif (obj == null) {\n \treturn;\n\t}\n\tthis.lastObj = obj;\n \n this.container.el.add(obj);\n obj.show_all();\n}\n ", + "xtype" : "VPaned", + "# JsRender.JsRender file" : "null", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack1,true,true", + "xtype" : "Viewport", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "container", + "* pack" : "add", + "xtype" : "HBox", + "$ xns" : "Gtk" + } + ] + }, + { + "* pack" : "pack2,true,true", + "xtype" : "VBox", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack_start,false,false,0", + "xtype" : "HBox", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack_start,true,true,0", + "xtype" : "Button", + "$ xns" : "Gtk", + "utf8 label" : "Full Compile" + } + ] + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "HBox", + "gboolean homogeneous" : true, + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "add", + "xtype" : "TreeView", + "$ xns" : "Gtk", + "items" : [ + { + "gint n_columns" : 1, + "columns" : " typeof(string)", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "Compile output", + "xtype" : "TreeViewColumn", + "string id" : "column", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack_start,false", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "gboolean show_line_marks" : true, + "* pack" : "add", + "xtype" : "View", + "$ xns" : "GtkSource", + "gboolean show_line_numbers" : true, + "gboolean editable" : false + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/GtkView.vala b/old-javascript/Builder4/GtkView.vala new file mode 100644 index 000000000..4d764a394 --- /dev/null +++ b/old-javascript/Builder4/GtkView.vala @@ -0,0 +1,387 @@ +static Xcls_GtkView _GtkView; + +public class Xcls_GtkView : Object +{ + public Gtk.VPaned el; + private Xcls_GtkView _this; + + public static Xcls_GtkView singleton() + { + if (_GtkView == null) { + _GtkView= new Xcls_GtkView(); + } + return _GtkView; + } + public Xcls_container container; + + // my vars (def) + public Gtk.Widget lastObj; + public JsRender.JsRender file; + + // ctor + public Xcls_GtkView() + { + _this = this; + this.el = new Gtk.VPaned(); + + // my vars (dec) + this.lastObj = null; + this.file = null; + + // set gobject values + var child_0 = new Xcls_Viewport2( _this ); + child_0.ref(); + this.el.pack1 ( child_0.el , true,true ); + var child_1 = new Xcls_VBox4( _this ); + child_1.ref(); + this.el.pack2 ( child_1.el , true,true ); + } + + // user defined functions + public void createThumb () { + + + if (this.file == null) { + return; + } + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + var height = win.get_height(); + + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position? + + screenshot.save(filename,"png"); + return; + + + + + + + + // should we hold until it's printed... + + + + + + + + + + } + public void loadFile (JsRender.JsRender file) + { + + this.el.set_position((int)(this.el.max_position * 0.7)); + this.file = null; + + if (file.tree == null) { + return; + } + this.file = file; + if (this.lastObj != null) { + this.container.el.remove(this.lastObj); + } + + var x = new JsRender.NodeToGtk(file.tree); + var obj = x.munge() as Gtk.Widget; + this.lastObj = null; + if (obj == null) { + return; + } + this.lastObj = obj; + + this.container.el.add(obj); + obj.show_all(); + } + public class Xcls_Viewport2 : Object + { + public Gtk.Viewport el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Viewport2(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Viewport( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_container( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_container : Object + { + public Gtk.HBox el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_container(Xcls_GtkView _owner ) + { + _this = _owner; + _this.container = this; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_VBox4 : Object + { + public Gtk.VBox el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_VBox4(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_HBox5( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_HBox7( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_HBox5 : Object + { + public Gtk.HBox el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_HBox5(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button6( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Full Compile"; + } + + // user defined functions + } + public class Xcls_HBox7 : Object + { + public Gtk.HBox el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_HBox7(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_TreeView8( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_ScrolledWindow12( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_TreeView8 : Object + { + public Gtk.TreeView el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_TreeView8(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_ListStore9( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_column( _this ); + child_1.ref(); + } + + // user defined functions + } + public class Xcls_ListStore9 : Object + { + public Gtk.ListStore el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_ListStore9(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.ListStore( 1, typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_column : Object + { + public Gtk.TreeViewColumn el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_column(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Compile output"; + var child_0 = new Xcls_CellRendererText11( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + } + + // user defined functions + } + public class Xcls_CellRendererText11 : Object + { + public Gtk.CellRendererText el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_CellRendererText11(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ScrolledWindow12 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow12(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_View13( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_View13 : Object + { + public Gtk.SourceView el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_View13(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // set gobject values + this.el.editable = false; + this.el.show_line_marks = true; + this.el.show_line_numbers = true; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/Main.vala b/old-javascript/Builder4/Main.vala new file mode 100644 index 000000000..5ba0d7b59 --- /dev/null +++ b/old-javascript/Builder4/Main.vala @@ -0,0 +1,35 @@ +/** + * Test the writer code... + + +*/ + +int main (string[] args) { + Gtk.init (ref args); + + var app = Builder4.Application.singleton(); + GtkClutter.init (ref args); + new JsRender.Lang_Class(); + GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); + Project.Project.loadAll(); + /*var proj = Project.Project.getProject("Pman.Core"); + if (proj == null) { + print("could not load test project Pman.Core"); + return 0; + } + proj.scanDirs(); + */ + + var w = Xcls_MainWindow.singleton(); + //w.ref(); + //w.project = proj; + + w.el.show_all(); + // it looks like showall after children causes segfault on ubuntu 14.4 + w.initChildren(); + w.hideViewEditing(); + Gtk.main(); + + + return 0; +} diff --git a/old-javascript/Builder4/MainWindow.bjs b/old-javascript/Builder4/MainWindow.bjs new file mode 100644 index 000000000..ff1de13c2 --- /dev/null +++ b/old-javascript/Builder4/MainWindow.bjs @@ -0,0 +1,578 @@ +{ + "name" : "MainWindow", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/MainWindow.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "delete_event" : " ( event) => {\n return false;\n}", + "destroy" : "() => {\n Xcls_MainWindow.singleton().no_windows--;\n \n if (Xcls_MainWindow.singleton().no_windows < 1) {\n\n Gtk.main_quit();\n }\n}", + "show" : " ( ) => {\n // hide the file editing..\n \n //this.hideViewEditing();\n}" + }, + "| void hideAddListener" : "() {\n _this.backbutton.el.hide();\n _this.projectbutton.el.show(); \n _this.projecteditbutton.el.show();\n _this.editfilebutton.el.show(); \n _this.addpropsview.el.save_easing_state();\n var el = _this.rooview.el;\n el.save_easing_state();\n\n \n el.set_scale(1.0f,1.0f);\n _this.addpropsview.el.set_scale(0.0f,0.0f);\n _this.state = \"edit\";\n\n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.addpropsview.el.restore_easing_state(); \n }", + "| void initChildren" : " () {\n // this needs putting in a better place..\n \n print(\"init children\");\n this.left_tree = new Xcls_WindowLeftTree();\n this.left_tree.ref();\n this.left_tree.main_window = _this;\n this.tree.el.pack_start(this.left_tree.el,true, true,0);\n this.left_tree.el.show_all();\n \n this.left_tree.before_node_change.connect(() => {\n if (this.state != \"codeedit\") {\n this.left_props.finish_editing();\n return true;\n }\n if (!this.code_editor.saveContents()) {\n return false;\n }\n return false;\n \n });\n \n this.left_tree.node_selected.connect((sel) => {\n \n print(\"node_selected called %s\\n\", (sel == null) ? \"NULL\" : \"a value\");\n \n if (sel == null) {\n this.left_props.el.hide();\n } \n this.left_props.el.show();\n this.left_props.load(this.left_tree.getActiveFile(), sel);\n switch (this.state) {\n case \"object\": \n \n if (sel == null) {\n this.rightpalete.clear();\n break;\n }\n this.rightpalete.load(_this.left_tree.getActiveFile().palete(), sel.fqn());\n break;\n \n \n case \"addprop\":\n if (sel == null) {\n this.add_props.clear();\n break;\n }\n this.add_props.show(_this.left_tree.getActiveFile().palete(), \"props\", sel.fqn());\n break;\n \n case \"addlistener\":\n if (sel == null) {\n this.add_props.clear();\n break;\n }\n this.add_props.show(_this.left_tree.getActiveFile().palete(), \"signals\", sel.fqn());\n break;\n\n case \"codeedit\":\n \n this.hideCodeEdit();\n break;\n \n \n }\n return ;\n \n });\n \n this.left_tree.changed.connect(() => {\n this.window_rooview.requestRedraw();\n this.left_tree.model.file.save();\n });\n \n \n\n // left properties\n\n this.left_props =new Xcls_LeftProps();\n this.left_props.ref();\n this.left_props.main_window = _this;\n this.props.el.pack_start(this.left_props.el,true, true,0);\n this.left_props.el.show_all();\n \n this.left_props.show_editor.connect( (file, node, type, key) => {\n this.showCodeEdit(file, node, type, key);\n });\n this.left_props.stop_editor.connect( () => {\n if (this.state != \"codeedit\") {\n return true;\n }\n \n var ret = this.code_editor.saveContents();\n if (!ret) {\n return false;\n }\n this.hideCodeEdit();\n return ret;\n });\n this.left_props.changed.connect(() => {\n if (this.left_tree.getActiveFile().xtype == \"Roo\" ) {\n this.window_rooview.requestRedraw();\n \n } else {\n this.window_gladeview.loadFile(this.left_tree.getActiveFile());\n }\n this.left_tree.model.updateSelected();\n this.left_tree.model.file.save();\n });\n \n\n\n\n // left projects..\n this.left_projects = new Xcls_WindowLeftProjects();\n this.left_projects.ref();\n this.leftpane.el.pack_start(this.left_projects.el,true, true,0);\n this.left_projects.el.show_all();\n this.left_projects.project_selected.connect((proj) => {\n proj.scanDirs();\n _this.clutterfiles.loadProject(proj);\n \n });\n \n \n // project edit..\n this.projectsettings =new Xcls_ProjectSettings();\n this.projectsettings.ref(); /// really?\n \n this.vala_projectsettings =new ValaProjectSettings();\n this.vala_projectsettings.ref();\n this.vala_projectsettings.window = this;\n \n ((Gtk.Container)(this.projecteditview.el.get_widget())).add(this.projectsettings.el);\n //this.projectsettings.el.show_all();\n\n var stage = _this.projecteditview.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n this.projectsettings.buttonPressed.connect((btn) => {\n if (this.left_tree.getActiveFile().xtype == \"Roo\" ) {\n \n if (btn == \"save\") {\n _this.window_rooview.view.renderJS(true);\n }\n if (btn == \"apply\") {\n _this.window_rooview.view.renderJS(true);\n return;\n }\n } else {\n // do nothing for gtk..\n }\n if (btn == \"save\" || btn == \"apply\") {\n _this.project.save();\n \n }\n \n this.hideProjectEdit();\n \n });\n \n \n // objects (palate..)\n this.rightpalete = new Xcls_RightPalete();\n this.rightpalete.ref(); /// really?\n ((Gtk.Container)(this.objectview.el.get_widget())).add(this.rightpalete.el);\n //this.projectsettings.el.show_all();\n\n stage = _this.objectview.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n /*this.projectsettings.buttonPressed.connect((btn) => {\n if (btn == \"save\") {\n _this.window_rooview.view.renderJS(true);\n }\n if (btn == \"apply\") {\n _this.window_rooview.view.renderJS(true);\n return;\n }\n this.hideProjectEdit();\n \n });\n */\n \n \n \n // Add properties\n this.add_props = new Xcls_WindowAddProp();\n this.add_props.ref(); /// really?\n ((Gtk.Container)(this.addpropsview.el.get_widget())).add(this.add_props.el);\n //this.projectsettings.el.show_all();\n\n stage = _this.addpropsview.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n \n _this.add_props.select.connect( (key,type,skel, etype) => {\n this.left_props.addProp(etype, key, skel, type);\n });\n \n // editor\n \n \n this.code_editor = new Editor();\n this.code_editor.ref(); /// really?\n ((Gtk.Container)(this.codeeditview.el.get_widget())).add(this.code_editor.el);\n //this.projectsettings.el.show_all();\n\n stage = _this.codeeditview.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n // editor.save...\n\n _this.code_editor.save.connect( () => {\n this.left_tree.model.file.save();\n this.left_tree.model.updateSelected();\n });\n \n \n \n \n // roo view\n \n this.window_rooview =new Xcls_WindowRooView();\n this.window_rooview.ref();\n ((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_rooview.el);\n this.window_rooview.el.show_all();\n\n stage = _this.rooview.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n \n // glade view\n \n this.window_gladeview =new Xcls_GtkView();\n this.window_gladeview.ref();\n\n //((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_gladeview.el);\n ///this.window_gladeview.el.hide();\n\n \n \n // clutter files\n \n \n this.clutterfiles = new Xcls_ClutterFiles();\n this.clutterfiles.ref();\n stage.add_child(this.clutterfiles.el);\n this.clutterfiles.el.show_all();\n\n\n this.clutterfiles.open.connect((file) => { \n _this.project = file.project;\n _this.showViewEditing();\n this.left_tree.model.loadFile(file);\n var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));\n var ctr_p= ((Gtk.Container)(this.projecteditview.el.get_widget()));\n if (file.xtype == \"Roo\" ) { \n ctr.foreach( (w) => { ctr.remove(w); });\n ctr_p.foreach( (w) => { ctr_p.remove(w); });\n ctr.add(this.window_rooview.el);\n ctr_p.add(this.projectsettings.el); \n this.window_rooview.loadFile(file);\n this.window_rooview.el.show_all();\n this.projectsettings.el.show_all(); \n \n } else {\n ctr.foreach( (w) => { ctr.remove(w); });\n ctr_p.foreach( (w) => { ctr_p.remove(w); }); \n ctr.add(this.window_gladeview.el);\n ctr_p.add(this.vala_projectsettings.el);\n this.window_gladeview.loadFile(file);\n this.window_gladeview.el.show_all();\n this.vala_projectsettings.el.show_all();\n }\n print(\"OPEN : \" + file.name);\n _this.editpane.el.set_position(_this.editpane.el.max_position);\n \n\n });\n\n // new file dialog\n this.new_file_dialog = new Xcls_DialogNewComponent();\n // force it modal to the main window..\n this.new_file_dialog.el.set_transient_for(this.el);\n this.new_file_dialog.el.set_modal(true);\n \n this.new_file_dialog.success.connect((project,file) =>\n {\n _this.project = project;\n _this.showViewEditing();\n this.left_tree.model.loadFile(file);\n var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));\n var ctr_p= ((Gtk.Container)(this.projecteditview.el.get_widget()));\n if (file.xtype == \"Roo\" ) { \n ctr.foreach( (w) => { ctr.remove(w); });\n ctr_p.foreach( (w) => { ctr_p.remove(w); });\n ctr.add(this.window_rooview.el);\n ctr_p.add(this.projectsettings.el); \n this.window_rooview.loadFile(file);\n this.window_rooview.el.show_all();\n this.projectsettings.el.show_all(); \n \n \n } else {\n ctr.foreach( (w) => { ctr.remove(w); });\n ctr_p.foreach( (w) => { ctr_p.remove(w); }); \n ctr.add(this.window_gladeview.el);\n ctr_p.add(this.vala_projectsettings.el);\n this.window_gladeview.loadFile(file);\n this.window_gladeview.el.show_all();\n this.vala_projectsettings.el.show_all();\n }\n \n });\n \n \n\n //w.el.show_all();\n var tl = new Clutter.Timeline(6000);\n tl.set_repeat_count(-1);\n tl.start();\n tl.ref();\n\n this.children_loaded = true;\n\n\n\n\n}\n", + "# int no_windows" : 1, + "# Project.Project project" : "null", + "# bool children_loaded" : false, + "| void hideCodeEdit" : "() {\n //this.code_editor.saveContents();\n _this.backbutton.el.hide();\n _this.projectbutton.el.show(); \n _this.projecteditbutton.el.show();\n _this.editfilebutton.el.show(); \n _this.codeeditview.el.save_easing_state();\n var el = _this.rooview.el;\n el.save_easing_state();\n\n \n el.set_scale(1.0f,1.0f);\n _this.codeeditview.el.set_scale(0.0f,0.0f);\n _this.state = \"edit\";\n\n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.codeeditview.el.restore_easing_state(); \n }", + "| void showAddProp" : "() {\n\n \n var ae = this.left_tree.getActiveElement();\n if (ae == null) {\n return;\n }\n _this.backbutton.el.show();\n _this.projectbutton.el.hide();\n _this.editfilebutton.el.hide();\n _this.projecteditbutton.el.hide(); \n \n \n \n //this.rooview.el.hide();\n this.add_props.el.show_all();\n this.add_props.show(\n Palete.factory(this.project.xtype), \n \"props\",\n ae.fqn()\n );\n\n _this.addpropsview.el.save_easing_state();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n _this.clutterembed.setSizesAlloc(\"addprop\");\n \n \n\n _this.addpropsview.el.set_scale(1.0f,1.0f);\n \n \n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.addpropsview.el.restore_easing_state();\n this.state = \"addprop\";\n}", + "| void showViewEditing" : " ( ) {\n this.editpane.el.show();\n // this.rooview.el.show();\n this.left_projects.el.hide();\n \n _this.addprojectbutton.el.hide(); \n _this.delprojectbutton.el.hide();\n _this.addfilebutton.el.hide(); \n _this.backbutton.el.hide();\n _this.new_window.el.hide(); \n \n \n _this.projectbutton.el.show(); \n _this.editfilebutton.el.show(); \n _this.projecteditbutton.el.show();\n _this.objectshowbutton.el.show();\n _this.addpropbutton.el.show(); \n _this.addlistenerbutton.el.show(); \n\n \n var el = _this.rooview.el;\n el.save_easing_state();\n \n \n el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);\n el.set_scale(1.0f,1.0f);\n _this.state = \"edit\";\n // _this.mainpane.el.set_position(_this.leftpane.lastWidth);\n _this.clutterfiles.el.hide();\n \n el.restore_easing_state();\n \n print(\"show view editing\");\n}", + "border_width" : 0, + "| void hideProjectEdit" : " () {\n // return to editing state..\n \n _this.projectbutton.el.show();\n _this.projecteditbutton.el.show();\n _this.backbutton.el.hide();\n _this.editfilebutton.el.show(); \n\n \n if (this.project.xtype == \"Roo\") {\n \n //this.projectsettings.show(this.project);\n } else {\n\n this.vala_projectsettings.project.writeConfig();\n }\n _this.projecteditview.el.save_easing_state();\n var el = _this.rooview.el;\n el.save_easing_state();\n\n \n el.set_scale(1.0f,1.0f);\n _this.projecteditview.el.set_scale(1.0f,0.0f);\n _this.state = \"edit\";\n\n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.projecteditview.el.restore_easing_state(); \n \n}\n", + "default_height" : 500, + "# Xcls_WindowLeftProjects left_projects" : "null", + "id" : "MainWindow", + "| void showProjectEdit" : " () {\n // make the browser smaller, and show the edit dialog\n \n \n _this.projectbutton.el.hide();\n _this.projecteditbutton.el.hide();\n _this.editfilebutton.el.hide();\n \n _this.backbutton.el.show();\n \n //this.rooview.el.hide();\n \n \n if (this.project.xtype == \"Roo\") {\n this.projectsettings.el.show_all();\n this.projectsettings.show(this.project);\n } else {\n this.vala_projectsettings.el.show_all();\n this.vala_projectsettings.show((Project.Gtk)this.project);\n }\n _this.projecteditview.el.save_easing_state();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n \n \n el.set_scale(0.5f,0.5f);\n\n _this.projecteditview.el.set_scale(1.0f,1.0f);\n \n _this.state = \"projectedit\";\n \n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.projecteditview.el.restore_easing_state();\n // print(\"show view browsing\");\n \n}\n", + "# Xcls_WindowRooView window_rooview" : "null", + "| void showAddListener" : "() {\n\n \n \n var ae = this.left_tree.getActiveElement();\n if (ae == null) {\n return;\n }\n \n _this.backbutton.el.show();\n _this.projectbutton.el.hide();\n _this.editfilebutton.el.hide();\n _this.projecteditbutton.el.hide(); \n \n \n //this.rooview.el.hide();\n this.add_props.el.show_all();\n this.add_props.show(\n Palete.factory(this.project.xtype), \n \"signals\",\n ae.fqn()\n );\n //this.rightpalete.show(this.project);\n\n _this.addpropsview.el.save_easing_state();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n \n _this.clutterembed.setSizesAlloc(\"addlistener\");\n\n \n \n\n _this.addpropsview.el.set_scale(1.0f,1.0f);\n \n \n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.addpropsview.el.restore_easing_state();\n this.state = \"addlistener\";\n}", + "default_width" : 800, + "xtype" : "Window", + "$ type" : "Gtk.WindowType.TOPLEVEL", + "| void hideAddProp" : "() {\n _this.backbutton.el.hide();\n _this.projectbutton.el.show(); \n _this.projecteditbutton.el.show();\n _this.editfilebutton.el.show(); \n _this.addpropsview.el.save_easing_state();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n\n \n el.set_scale(1.0f,1.0f);\n _this.addpropsview.el.set_scale(0.0f,0.0f);\n _this.state = \"edit\";\n\n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.addpropsview.el.restore_easing_state(); \n }", + "# Xcls_WindowLeftTree left_tree" : "null", + "# Editor code_editor" : "null", + "| void showCodeEdit" : "(JsRender.JsRender file, JsRender.Node node, string ptype, string key)\n{\n // this is a bit different,\n // it's not called via a button - but triggered by the prop edit class signal.\n // so it has to hide any other state..\n \n switch(this.state) {\n case \"object\":\n this.hideObject();\n break;\n case \"addprop\":\n this.hideAddProp();\n break;\n case \"addlistener\":\n this.hideAddListener();\n break;\n }\n \n _this.backbutton.el.show();\n \n _this.projectbutton.el.hide();\n _this.editfilebutton.el.hide();\n _this.projecteditbutton.el.hide(); \n // more?? \n \n //this.rooview.el.hide();\n this.code_editor.el.show_all();\n this.code_editor.show(\n file,\n node,\n ptype,\n key\n );\n\n _this.codeeditview.el.save_easing_state();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n _this.clutterembed.setSizesAlloc(\"codedit\");\n \n _this.codeeditview.el.set_scale(1.0f,1.0f);\n \n \n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.codeeditview.el.restore_easing_state();\n this.state = \"codeedit\";\n}\n", + "# Xcls_DialogNewComponent new_file_dialog" : "null", + "# Xcls_ProjectSettings projectsettings" : "null", + "| void setTitle" : " (string str) {\n this.el.set_title(this.title + \" - \" + str);\n}\n", + "| void show" : "() {\n this.left_tree =new Xcls_WindowLeftTree();\n _this.vbox.el.pack_start(this.left_tree.el,true, true,0);\n this.el.show_all();\n\n}", + "$ xns" : "Gtk", + "# Xcls_ClutterFiles clutterfiles" : "null", + "# Xcls_LeftProps left_props" : "null", + "# string state" : "", + "| void hideViewEditing" : " ( ) {\n\n// show the file navigation...\n \n if (this.left_tree.getActiveFile() != null) {\n if (this.left_tree.getActiveFile().xtype == \"Roo\" ) {\n this.window_rooview.createThumb();\n } else {\n this.window_gladeview.createThumb();\n }\n }\n \n _this.addprojectbutton.el.show(); \n _this.addfilebutton.el.show(); \n _this.backbutton.el.show();\n _this.delprojectbutton.el.show();\n _this.new_window.el.show(); \n \n _this.editfilebutton.el.hide(); \n _this.projectbutton.el.hide(); \n _this.projecteditbutton.el.hide();\n _this.objectshowbutton.el.hide();\n _this.addpropbutton.el.hide(); \n _this.addlistenerbutton.el.hide(); \n\n\n\n\n \n // show the add file button..\n \n \n \n this.editpane.el.hide();\n //this.rooview.el.hide();\n this.left_projects.el.show();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n el.set_easing_duration(1000);\n // show project / file view..\n //_this.mainpane.lastWidth = _this.leftpane.el.get_position();\n //_this.mainpane.el.set_position(0);\n // rotate y 180..\n el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);\n el.set_scale(0.0f,0.0f);\n \n _this.state = \"files\";\n if (_this.project != null) {\n _this.left_projects.selectProject(_this.project);\n }\n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n \n print(\"show view browsing\");\n}", + "# Xcls_RightPalete rightpalete" : "null", + "# string title" : "\"Application Builder\"", + "# ValaProjectSettings vala_projectsettings" : "null", + "# Xcls_WindowAddProp add_props" : "null", + "| void showObject" : "() {\n\n \n // what's the active node on the left hand side..\n \n var n = _this.left_tree.getActiveElement();\n\n if (_this.left_tree.model.file == null) {\n return;\n }\n \n if (n == null && _this.left_tree.model.file.tree != null) {\n return;\n }\n \n _this.backbutton.el.show();\n _this.projectbutton.el.hide();\n _this.editfilebutton.el.hide();\n _this.projecteditbutton.el.hide(); \n \n \n //this.rooview.el.hide();\n this.rightpalete.el.show_all();\n this.rightpalete.load(_this.left_tree.getActiveFile().palete(), n == null ? \"*top\" : n.fqn());\n\n \n //this.rightpalete.show(this.project);\n\n _this.objectview.el.save_easing_state();\n \n var el = _this.rooview.el;\n el.save_easing_state();\n \n _this.clutterembed.setSizesAlloc(\"object\");\n \n\n _this.objectview.el.set_scale(1.0f,1.0f);\n \n \n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.objectview.el.restore_easing_state();\n this.state = \"object\";\n}", + "* init" : " this.state = \"files\";\n\t \n //this.el.show_all();\n \n ", + "| void hideObject" : "() {\n // return to editing state..\n \n _this.projecteditbutton.el.show();\n _this.backbutton.el.hide();\n _this.projectbutton.el.show(); \n _this.editfilebutton.el.show(); \n _this.objectview.el.save_easing_state();\n var el = _this.rooview.el;\n el.save_easing_state();\n\n \n el.set_scale(1.0f,1.0f);\n _this.objectview.el.set_scale(0.0f,0.0f);\n _this.state = \"edit\";\n\n \n //_this.clutterfiles.loadProject(_this.project);\n\n el.restore_easing_state();\n _this.objectview.el.restore_easing_state(); \n \n\n}", + "# Xcls_GtkView window_gladeview" : "null", + "items" : [ + { + "id" : "vbox", + "* pack" : "add", + "xtype" : "VBox", + "$ xns" : "Gtk", + "$ homogeneous" : false, + "items" : [ + { + "id" : "mainpane", + "position" : 400, + "* pack" : "pack_end,true,true,0", + "# int lastWidth" : 0, + "xtype" : "HPaned", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "leftpane", + "xtype" : "VBox", + "* pack" : "add1", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "editpane", + "xtype" : "VPaned", + "* pack" : "pack_start,false,true,0", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "tree", + "xtype" : "VBox", + "* pack" : "add1", + "$ xns" : "Gtk" + }, + { + "id" : "props", + "xtype" : "VBox", + "* pack" : "add2", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "* pack" : "add2", + "xtype" : "VBox", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "size_allocate" : " ( alloc) => {\n this.setSizes(alloc, _this.state); \n \n}" + }, + "id" : "clutterembed", + "* init" : " var stage = this.el.get_stage();\n stage.set_background_color( Clutter.Color.from_string(\"#000\"));\n \n \n", + "xtype" : "Embed", + "* pack" : "pack_start,true,true,0", + "| void setSizes" : " ( Gtk.Allocation alloc, string state) {\n if (!_this.children_loaded) { return; }\n \n _this.clutterfiles.set_size(alloc.width-50, alloc.height);\n \n // project view appears at top...\n \n _this.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f);\n \n \n \n var avail = alloc.width < 50.0f ? 0 : alloc.width - 50.0f;\n \n \n var palsize = avail < 300.0f ? avail : 300.0f;\n print(\"set palsize size %f\\n\", palsize);\n // palate / props : fixed 300 pix\n \n _this.objectview.el.set_size(palsize, alloc.height); \n _this.addpropsview.el.set_size(palsize, alloc.height);\n \n \n \n // code edit min 600\n \n var codesize = avail < 800.0f ? avail : 800.0f;\n print(\"set code size %f\\n\", codesize);\n\n _this.codeeditview.el.set_size(codesize, alloc.height);\n _this.rooview.el.set_size(alloc.width-50, alloc.height); \n \n switch ( state) {\n case \"codeedit\": \n\n\tvar scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f;\n\t\n\t\n _this.rooview.el.set_scale(scale,scale);\n break;\n case \"addprop\":\n case \"addlistener\": \n case \"object\": \n\tvar scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f;\n _this.rooview.el.set_scale(scale,scale);\n break;\n }\n \n}", + "$ xns" : "GtkClutter", + "| void setSizesAlloc" : "(string state) {\n\n Gtk.Allocation alloc;\n this.el.get_allocation(out alloc);\n this.setSizes(alloc, state);\n}\n", + "items" : [ + { + "id" : "rooview", + "* init" : "{\n \n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 1.0f\n )\n );\n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(1.0f,1.0f);\n \n this.el.set_size(_this.clutterembed.el.get_stage().width-50,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "objectview", + "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "codeeditview", + "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "addpropsview", + "* init" : "{\n \n /*\n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n */\n this.el.fixed_x = 50.0f;\n this.el.fixed_y = 0.0f;\n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(0.0f,1.0f);\n this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "projecteditview", + "* init" : "{\n \n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 1.0f\n )\n );\n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.0f,0.0f);\n this.el.set_scale(1.0f,0.0f);\n this.el.set_size(_this.clutterembed.el.get_stage().width-50,\n _this.clutterembed.el.get_stage().height /2);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "GtkClutter" + }, + { + "id" : "buttonlayout", + "* init" : "{\n \n this.el.add_constraint(\n new Clutter.AlignConstraint(\n _this.clutterembed.el.get_stage(), \n Clutter.AlignAxis.X_AXIS,\n 0.0f\n )\n );\n \n \n //this.el.set_position(100,100);\n this.el.set_pivot_point(0.5f,0.5f);\n this.el.set_size(50,\n _this.clutterembed.el.get_stage().height);\n \n}", + "xtype" : "Actor", + "* pack" : "get_stage().add_child", + "$ xns" : "Clutter", + "items" : [ + { + "$ orientation" : "Clutter.Orientation.VERTICAL", + "xtype" : "BoxLayout", + "$ xns" : "Clutter", + "* prop" : "layout_manager" + }, + { + "id" : "backbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n switch (_this.state) {\n case \"edit\":\n \n _this.hideViewEditing();\n break; \n case \"files\":\n // should only occur if there is an active file..\n _this.showViewEditing();\n break; \n \n case \"addprop\":\n _this.hideAddProp();\n\n break;\n case \"addlistener\":\n _this.hideAddListener();\n\n break;\n \n case \"object\":\n _this.hideObject();\n break; \n \n case \"codeedit\":\n \n _this.hideCodeEdit(); \n break;\n \n case \"projectedit\":\n // save?\n _this.hideProjectEdit();\n break;\n \n default:\n break;\n }\n return ; \n\n}" + }, + "utf8 tooltip_text" : "Back", + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "height_request" : 50, + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "go-previous", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "projectbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n switch (_this.state) {\n case \"edit\":\n \n _this.hideViewEditing();\n break; \n case \"files\":\n _this.showViewEditing();\n break; \n \n case \"addprop\":\n _this.hideAddProp();\n _this.hideViewEditing();\n break;\n case \"addlistener\":\n _this.hideAddListener();\n _this.hideViewEditing();\n break;\n \n case \"object\":\n _this.hideObject();\n _this.hideViewEditing();\n break; \n \n default:\n break;\n }\n return ; \n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "height_request" : 50, + "$ tooltop_text" : "\"Open File\"", + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "document-open", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "editfilebutton", + "* init" : "this.el.set_size(50.0f,50.0f);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n // create a new file in project..\n if (_this.project == null || _this.left_tree.model.file == null) {\n return ;\n }\n \n _this.new_file_dialog.show(_this.left_tree.model.file);\n \n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"File Details\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "document-properties", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "projecteditbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n switch (_this.state) {\n case \"edit\":\n _this.showProjectEdit();\n break; \n case \"files\":\n // _this.showViewEditing();\n break; \n case \"projectedit\":\n _this.hideProjectEdit();\n break;\n \n \n \n case \"addprop\":\n _this.hideAddProp();\n _this.showProjectEdit();\n break;\n case \"addlistener\":\n _this.hideAddListener();\n _this.showProjectEdit();\n break;\n \n case \"object\":\n _this.hideObject();\n _this.showProjectEdit(); \n break;\n default:\n break;\n }\n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Project Details\"", + "height_request" : 50, + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "emblem-system", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "listeners" : { + "button_press_event" : " ( ) => {\n \n \n \n switch (_this.state) {\n\n \n case \"addprop\":\n _this.hideAddProp();\n _this.showObject();\n break;\n case \"addlistener\":\n _this.hideAddListener();\n _this.showObject();\n break;\n\n// show \n case \"edit\":\n _this.showObject();\n break;\n \n// hide \n case \"object\":\n _this.hideObject();\n break;\n break;\n \n default:\n print(\"unhandled add objects from %s\\n\",_this.state);\n break;\n }\n return false; \n\n\n}", + "enter_event" : "( event) => {\n this.el.background_color = new Clutter.Color.from_string(\"#333\");\n return false;\n}", + "leave_event" : "( event) => {\n this.el.background_color = new Clutter.Color.from_string(\"#000\");\n return false;\n}" + }, + "id" : "objectshowbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n \n \n switch (_this.state) {\n\n \n case \"addprop\":\n _this.hideAddProp();\n _this.showObject();\n break;\n case \"addlistener\":\n _this.hideAddListener();\n _this.showObject();\n break;\n\n// show \n case \"edit\":\n _this.showObject();\n break;\n \n// hide \n case \"object\":\n _this.hideObject();\n break;\n break;\n \n default:\n print(\"unhandled add objects from %s\\n\",_this.state);\n break;\n }\n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add Child Element\"", + "height_request" : 50, + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "list-add", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addpropbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n \n \n switch (_this.state) {\n case \"edit\":\n _this.showAddProp();\n break;\n \n case \"object\":\n _this.hideObject();\n _this.showAddProp();\n break;\n \n case \"addlistener\":\n _this.hideAddListener();\n _this.showAddProp(); \n break;\n \n \n case \"addprop\":\n _this.hideAddProp();\n break;\n \n default:\n print(\"unhandled add property from %s\\n\",_this.state);\n break;\n \n }\n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add Property\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "format-justify-left", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addlistenerbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n \n \n switch (_this.state) {\n case \"edit\":\n _this.showAddListener();\n break;\n \n \n case \"addlistener\":\n _this.hideAddListener();\n break;\n\n \n case \"addprop\":\n _this.hideAddProp();\n _this.showAddListener();\n break;\n case \"object\":\n _this.hideObject();\n _this.showAddListener();\n break;\n \n default:\n print(\"unhandled add listener from %s\\n\",_this.state);\n\n break;\n \n }\n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add Event Code\"", + "height_request" : 50, + "items" : [ + { + "xtype" : "Image", + "utf8 icon_name" : "appointment-new", + "* pack" : "set_image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addprojectbutton", + "* init" : "this.el.set_size(50.0f,50.0f);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n // create a new file in project..\n //Xcls_DialogNewComponent.singleton().show(\n var pe = Xcls_EditProject.singleton();\n pe.el.set_transient_for(_this.el);\n pe.el.set_modal(true); \n \n var p = pe.show();\n\n if (p == null) {\n return;\n }\n _this.left_projects.is_loaded = false; \n _this.left_projects.load();\n _this.left_projects.selectProject(p);\n return ; \n\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"New\\nProj.\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "folder-new", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "addfilebutton", + "* init" : "this.el.set_size(50.0f,50.0f);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " () => {\n // create a new file in project..\n \n // what's the currently selected project...\n var proj = _this.left_projects.getSelectedProject();\n \n if (proj == null) {\n return ;\n }\n \n \n \n var f = JsRender.JsRender.factory(proj.xtype, proj, \"\");\n _this.project = proj;\n _this.new_file_dialog.show(f);\n \n return ; \n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Add File\"", + "height_request" : 50, + "items" : [ + { + "* pack" : "set_image", + "xtype" : "Image", + "utf8 icon_name" : "document-new", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "delprojectbutton", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n \n var cd = DialogConfirm.singleton();\n cd.el.set_transient_for(_this.el);\n cd.el.set_modal(true);\n\n var project = _this.left_projects.getSelectedProject();\n if (project == null) {\n print(\"SKIP - no project\\n\");\n return;\n }\n \n \n if (Gtk.ResponseType.YES != cd.show(\"Confirm\", \n \"Are you sure you want to delete project %s\".printf(project.name))) {\n return;\n }\n \n\n // confirm?\n Project.Project.remove(project);\n _this.project = null;\n \n _this.left_projects.is_loaded = false;\n _this.left_projects.load();\n _this.clutterfiles.clearFiles();\n\n}" + }, + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "$ tooltip_text" : "\"Delelte Project\"", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "user-trash", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "id" : "new_window", + "* init" : "this.el.set_size(50,50);", + "xtype" : "Actor", + "* pack" : "add_child", + "$ xns" : "Clutter", + "items" : [ + { + "* init" : "((Gtk.Container)(this.el.get_widget())).add ( child_0.el);", + "* pack" : "add_child", + "xtype" : "Actor", + "$ xns" : "GtkClutter", + "items" : [ + { + "listeners" : { + "clicked" : " ( ) => {\n Xcls_MainWindow.singleton().no_windows++;\n var w = new Xcls_MainWindow();\n w.ref();\n\n w.el.show_all();\n w.initChildren();\n w.hideViewEditing();\n}" + }, + "utf8 tooltip_text" : "Open New Window", + "* pack" : false, + "xtype" : "Button", + "width_request" : 50, + "$ xns" : "Gtk", + "height_request" : 50, + "items" : [ + { + "utf8 icon_name" : "window-new", + "* pack" : "set_image", + "xtype" : "Image", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/MainWindow.vala b/old-javascript/Builder4/MainWindow.vala new file mode 100644 index 000000000..d08f76d59 --- /dev/null +++ b/old-javascript/Builder4/MainWindow.vala @@ -0,0 +1,2972 @@ +static Xcls_MainWindow _MainWindow; + +public class Xcls_MainWindow : Object +{ + public Gtk.Window el; + private Xcls_MainWindow _this; + + public static Xcls_MainWindow singleton() + { + if (_MainWindow == null) { + _MainWindow= new Xcls_MainWindow(); + } + return _MainWindow; + } + public Xcls_vbox vbox; + public Xcls_mainpane mainpane; + public Xcls_leftpane leftpane; + public Xcls_editpane editpane; + public Xcls_tree tree; + public Xcls_props props; + public Xcls_clutterembed clutterembed; + public Xcls_rooview rooview; + public Xcls_objectview objectview; + public Xcls_codeeditview codeeditview; + public Xcls_addpropsview addpropsview; + public Xcls_projecteditview projecteditview; + public Xcls_buttonlayout buttonlayout; + public Xcls_backbutton backbutton; + public Xcls_projectbutton projectbutton; + public Xcls_editfilebutton editfilebutton; + public Xcls_projecteditbutton projecteditbutton; + public Xcls_objectshowbutton objectshowbutton; + public Xcls_addpropbutton addpropbutton; + public Xcls_addlistenerbutton addlistenerbutton; + public Xcls_addprojectbutton addprojectbutton; + public Xcls_addfilebutton addfilebutton; + public Xcls_delprojectbutton delprojectbutton; + public Xcls_new_window new_window; + + // my vars (def) + public int no_windows; + public Project.Project project; + public bool children_loaded; + public Xcls_WindowLeftProjects left_projects; + public Xcls_WindowRooView window_rooview; + public Xcls_WindowLeftTree left_tree; + public Editor code_editor; + public Xcls_DialogNewComponent new_file_dialog; + public Xcls_ProjectSettings projectsettings; + public Xcls_ClutterFiles clutterfiles; + public Xcls_LeftProps left_props; + public string state; + public Xcls_RightPalete rightpalete; + public string title; + public ValaProjectSettings vala_projectsettings; + public Xcls_WindowAddProp add_props; + public Xcls_GtkView window_gladeview; + + // ctor + public Xcls_MainWindow() + { + _this = this; + this.el = new Gtk.Window( Gtk.WindowType.TOPLEVEL ); + + // my vars (dec) + this.no_windows = 1; + this.project = null; + this.children_loaded = false; + this.left_projects = null; + this.window_rooview = null; + this.left_tree = null; + this.code_editor = null; + this.new_file_dialog = null; + this.projectsettings = null; + this.clutterfiles = null; + this.left_props = null; + this.rightpalete = null; + this.title = "Application Builder"; + this.vala_projectsettings = null; + this.add_props = null; + this.window_gladeview = null; + + // set gobject values + this.el.border_width = 0; + this.el.default_height = 500; + this.el.default_width = 800; + var child_0 = new Xcls_vbox( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.state = "files"; + + //this.el.show_all(); + // listeners + this.el.delete_event.connect( ( event) => { + return false; + }); + this.el.destroy.connect( () => { + Xcls_MainWindow.singleton().no_windows--; + + if (Xcls_MainWindow.singleton().no_windows < 1) { + + Gtk.main_quit(); + } + }); + this.el.show.connect( ( ) => { + // hide the file editing.. + + //this.hideViewEditing(); + }); + } + + // user defined functions + public void hideAddListener () { + _this.backbutton.el.hide(); + _this.projectbutton.el.show(); + _this.projecteditbutton.el.show(); + _this.editfilebutton.el.show(); + _this.addpropsview.el.save_easing_state(); + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_scale(1.0f,1.0f); + _this.addpropsview.el.set_scale(0.0f,0.0f); + _this.state = "edit"; + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.addpropsview.el.restore_easing_state(); + } + public void initChildren () { + // this needs putting in a better place.. + + print("init children"); + this.left_tree = new Xcls_WindowLeftTree(); + this.left_tree.ref(); + this.left_tree.main_window = _this; + this.tree.el.pack_start(this.left_tree.el,true, true,0); + this.left_tree.el.show_all(); + + this.left_tree.before_node_change.connect(() => { + if (this.state != "codeedit") { + this.left_props.finish_editing(); + return true; + } + if (!this.code_editor.saveContents()) { + return false; + } + return false; + + }); + + this.left_tree.node_selected.connect((sel) => { + + print("node_selected called %s\n", (sel == null) ? "NULL" : "a value"); + + if (sel == null) { + this.left_props.el.hide(); + } + this.left_props.el.show(); + this.left_props.load(this.left_tree.getActiveFile(), sel); + switch (this.state) { + case "object": + + if (sel == null) { + this.rightpalete.clear(); + break; + } + this.rightpalete.load(_this.left_tree.getActiveFile().palete(), sel.fqn()); + break; + + + case "addprop": + if (sel == null) { + this.add_props.clear(); + break; + } + this.add_props.show(_this.left_tree.getActiveFile().palete(), "props", sel.fqn()); + break; + + case "addlistener": + if (sel == null) { + this.add_props.clear(); + break; + } + this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn()); + break; + + case "codeedit": + + this.hideCodeEdit(); + break; + + + } + return ; + + }); + + this.left_tree.changed.connect(() => { + this.window_rooview.requestRedraw(); + this.left_tree.model.file.save(); + }); + + + + // left properties + + this.left_props =new Xcls_LeftProps(); + this.left_props.ref(); + this.left_props.main_window = _this; + this.props.el.pack_start(this.left_props.el,true, true,0); + this.left_props.el.show_all(); + + this.left_props.show_editor.connect( (file, node, type, key) => { + this.showCodeEdit(file, node, type, key); + }); + this.left_props.stop_editor.connect( () => { + if (this.state != "codeedit") { + return true; + } + + var ret = this.code_editor.saveContents(); + if (!ret) { + return false; + } + this.hideCodeEdit(); + return ret; + }); + this.left_props.changed.connect(() => { + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.requestRedraw(); + + } else { + this.window_gladeview.loadFile(this.left_tree.getActiveFile()); + } + this.left_tree.model.updateSelected(); + this.left_tree.model.file.save(); + }); + + + + + // left projects.. + this.left_projects = new Xcls_WindowLeftProjects(); + this.left_projects.ref(); + this.leftpane.el.pack_start(this.left_projects.el,true, true,0); + this.left_projects.el.show_all(); + this.left_projects.project_selected.connect((proj) => { + proj.scanDirs(); + _this.clutterfiles.loadProject(proj); + + }); + + + // project edit.. + this.projectsettings =new Xcls_ProjectSettings(); + this.projectsettings.ref(); /// really? + + this.vala_projectsettings =new ValaProjectSettings(); + this.vala_projectsettings.ref(); + this.vala_projectsettings.window = this; + + ((Gtk.Container)(this.projecteditview.el.get_widget())).add(this.projectsettings.el); + //this.projectsettings.el.show_all(); + + var stage = _this.projecteditview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + this.projectsettings.buttonPressed.connect((btn) => { + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + + if (btn == "save") { + _this.window_rooview.view.renderJS(true); + } + if (btn == "apply") { + _this.window_rooview.view.renderJS(true); + return; + } + } else { + // do nothing for gtk.. + } + if (btn == "save" || btn == "apply") { + _this.project.save(); + + } + + this.hideProjectEdit(); + + }); + + + // objects (palate..) + this.rightpalete = new Xcls_RightPalete(); + this.rightpalete.ref(); /// really? + ((Gtk.Container)(this.objectview.el.get_widget())).add(this.rightpalete.el); + //this.projectsettings.el.show_all(); + + stage = _this.objectview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + /*this.projectsettings.buttonPressed.connect((btn) => { + if (btn == "save") { + _this.window_rooview.view.renderJS(true); + } + if (btn == "apply") { + _this.window_rooview.view.renderJS(true); + return; + } + this.hideProjectEdit(); + + }); + */ + + + + // Add properties + this.add_props = new Xcls_WindowAddProp(); + this.add_props.ref(); /// really? + ((Gtk.Container)(this.addpropsview.el.get_widget())).add(this.add_props.el); + //this.projectsettings.el.show_all(); + + stage = _this.addpropsview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + + _this.add_props.select.connect( (key,type,skel, etype) => { + this.left_props.addProp(etype, key, skel, type); + }); + + // editor + + + this.code_editor = new Editor(); + this.code_editor.ref(); /// really? + ((Gtk.Container)(this.codeeditview.el.get_widget())).add(this.code_editor.el); + //this.projectsettings.el.show_all(); + + stage = _this.codeeditview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + // editor.save... + + _this.code_editor.save.connect( () => { + this.left_tree.model.file.save(); + this.left_tree.model.updateSelected(); + }); + + + + + // roo view + + this.window_rooview =new Xcls_WindowRooView(); + this.window_rooview.ref(); + ((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_rooview.el); + this.window_rooview.el.show_all(); + + stage = _this.rooview.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + + + // glade view + + this.window_gladeview =new Xcls_GtkView(); + this.window_gladeview.ref(); + + //((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_gladeview.el); + ///this.window_gladeview.el.hide(); + + + + // clutter files + + + this.clutterfiles = new Xcls_ClutterFiles(); + this.clutterfiles.ref(); + stage.add_child(this.clutterfiles.el); + this.clutterfiles.el.show_all(); + + + this.clutterfiles.open.connect((file) => { + _this.project = file.project; + _this.showViewEditing(); + this.left_tree.model.loadFile(file); + var ctr= ((Gtk.Container)(this.rooview.el.get_widget())); + var ctr_p= ((Gtk.Container)(this.projecteditview.el.get_widget())); + if (file.xtype == "Roo" ) { + ctr.foreach( (w) => { ctr.remove(w); }); + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr.add(this.window_rooview.el); + ctr_p.add(this.projectsettings.el); + this.window_rooview.loadFile(file); + this.window_rooview.el.show_all(); + this.projectsettings.el.show_all(); + + } else { + ctr.foreach( (w) => { ctr.remove(w); }); + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr.add(this.window_gladeview.el); + ctr_p.add(this.vala_projectsettings.el); + this.window_gladeview.loadFile(file); + this.window_gladeview.el.show_all(); + this.vala_projectsettings.el.show_all(); + } + print("OPEN : " + file.name); + _this.editpane.el.set_position(_this.editpane.el.max_position); + + + }); + + // new file dialog + this.new_file_dialog = new Xcls_DialogNewComponent(); + // force it modal to the main window.. + this.new_file_dialog.el.set_transient_for(this.el); + this.new_file_dialog.el.set_modal(true); + + this.new_file_dialog.success.connect((project,file) => + { + _this.project = project; + _this.showViewEditing(); + this.left_tree.model.loadFile(file); + var ctr= ((Gtk.Container)(this.rooview.el.get_widget())); + var ctr_p= ((Gtk.Container)(this.projecteditview.el.get_widget())); + if (file.xtype == "Roo" ) { + ctr.foreach( (w) => { ctr.remove(w); }); + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr.add(this.window_rooview.el); + ctr_p.add(this.projectsettings.el); + this.window_rooview.loadFile(file); + this.window_rooview.el.show_all(); + this.projectsettings.el.show_all(); + + + } else { + ctr.foreach( (w) => { ctr.remove(w); }); + ctr_p.foreach( (w) => { ctr_p.remove(w); }); + ctr.add(this.window_gladeview.el); + ctr_p.add(this.vala_projectsettings.el); + this.window_gladeview.loadFile(file); + this.window_gladeview.el.show_all(); + this.vala_projectsettings.el.show_all(); + } + + }); + + + + //w.el.show_all(); + var tl = new Clutter.Timeline(6000); + tl.set_repeat_count(-1); + tl.start(); + tl.ref(); + + this.children_loaded = true; + + + + + } + public void hideCodeEdit () { + //this.code_editor.saveContents(); + _this.backbutton.el.hide(); + _this.projectbutton.el.show(); + _this.projecteditbutton.el.show(); + _this.editfilebutton.el.show(); + _this.codeeditview.el.save_easing_state(); + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_scale(1.0f,1.0f); + _this.codeeditview.el.set_scale(0.0f,0.0f); + _this.state = "edit"; + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.codeeditview.el.restore_easing_state(); + } + public void showAddProp () { + + + var ae = this.left_tree.getActiveElement(); + if (ae == null) { + return; + } + _this.backbutton.el.show(); + _this.projectbutton.el.hide(); + _this.editfilebutton.el.hide(); + _this.projecteditbutton.el.hide(); + + + + //this.rooview.el.hide(); + this.add_props.el.show_all(); + this.add_props.show( + Palete.factory(this.project.xtype), + "props", + ae.fqn() + ); + + _this.addpropsview.el.save_easing_state(); + + var el = _this.rooview.el; + el.save_easing_state(); + _this.clutterembed.setSizesAlloc("addprop"); + + + + _this.addpropsview.el.set_scale(1.0f,1.0f); + + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.addpropsview.el.restore_easing_state(); + this.state = "addprop"; + } + public void showViewEditing ( ) { + this.editpane.el.show(); + // this.rooview.el.show(); + this.left_projects.el.hide(); + + _this.addprojectbutton.el.hide(); + _this.delprojectbutton.el.hide(); + _this.addfilebutton.el.hide(); + _this.backbutton.el.hide(); + _this.new_window.el.hide(); + + + _this.projectbutton.el.show(); + _this.editfilebutton.el.show(); + _this.projecteditbutton.el.show(); + _this.objectshowbutton.el.show(); + _this.addpropbutton.el.show(); + _this.addlistenerbutton.el.show(); + + + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f); + el.set_scale(1.0f,1.0f); + _this.state = "edit"; + // _this.mainpane.el.set_position(_this.leftpane.lastWidth); + _this.clutterfiles.el.hide(); + + el.restore_easing_state(); + + print("show view editing"); + } + public void hideProjectEdit () { + // return to editing state.. + + _this.projectbutton.el.show(); + _this.projecteditbutton.el.show(); + _this.backbutton.el.hide(); + _this.editfilebutton.el.show(); + + + if (this.project.xtype == "Roo") { + + //this.projectsettings.show(this.project); + } else { + + this.vala_projectsettings.project.writeConfig(); + } + _this.projecteditview.el.save_easing_state(); + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_scale(1.0f,1.0f); + _this.projecteditview.el.set_scale(1.0f,0.0f); + _this.state = "edit"; + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.projecteditview.el.restore_easing_state(); + + } + public void showProjectEdit () { + // make the browser smaller, and show the edit dialog + + + _this.projectbutton.el.hide(); + _this.projecteditbutton.el.hide(); + _this.editfilebutton.el.hide(); + + _this.backbutton.el.show(); + + //this.rooview.el.hide(); + + + if (this.project.xtype == "Roo") { + this.projectsettings.el.show_all(); + this.projectsettings.show(this.project); + } else { + this.vala_projectsettings.el.show_all(); + this.vala_projectsettings.show((Project.Gtk)this.project); + } + _this.projecteditview.el.save_easing_state(); + + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_scale(0.5f,0.5f); + + _this.projecteditview.el.set_scale(1.0f,1.0f); + + _this.state = "projectedit"; + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.projecteditview.el.restore_easing_state(); + // print("show view browsing"); + + } + public void showAddListener () { + + + + var ae = this.left_tree.getActiveElement(); + if (ae == null) { + return; + } + + _this.backbutton.el.show(); + _this.projectbutton.el.hide(); + _this.editfilebutton.el.hide(); + _this.projecteditbutton.el.hide(); + + + //this.rooview.el.hide(); + this.add_props.el.show_all(); + this.add_props.show( + Palete.factory(this.project.xtype), + "signals", + ae.fqn() + ); + //this.rightpalete.show(this.project); + + _this.addpropsview.el.save_easing_state(); + + var el = _this.rooview.el; + el.save_easing_state(); + + _this.clutterembed.setSizesAlloc("addlistener"); + + + + + _this.addpropsview.el.set_scale(1.0f,1.0f); + + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.addpropsview.el.restore_easing_state(); + this.state = "addlistener"; + } + public void hideAddProp () { + _this.backbutton.el.hide(); + _this.projectbutton.el.show(); + _this.projecteditbutton.el.show(); + _this.editfilebutton.el.show(); + _this.addpropsview.el.save_easing_state(); + + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_scale(1.0f,1.0f); + _this.addpropsview.el.set_scale(0.0f,0.0f); + _this.state = "edit"; + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.addpropsview.el.restore_easing_state(); + } + public void showCodeEdit (JsRender.JsRender file, JsRender.Node node, string ptype, string key) + { + // this is a bit different, + // it's not called via a button - but triggered by the prop edit class signal. + // so it has to hide any other state.. + + switch(this.state) { + case "object": + this.hideObject(); + break; + case "addprop": + this.hideAddProp(); + break; + case "addlistener": + this.hideAddListener(); + break; + } + + _this.backbutton.el.show(); + + _this.projectbutton.el.hide(); + _this.editfilebutton.el.hide(); + _this.projecteditbutton.el.hide(); + // more?? + + //this.rooview.el.hide(); + this.code_editor.el.show_all(); + this.code_editor.show( + file, + node, + ptype, + key + ); + + _this.codeeditview.el.save_easing_state(); + + var el = _this.rooview.el; + el.save_easing_state(); + _this.clutterembed.setSizesAlloc("codedit"); + + _this.codeeditview.el.set_scale(1.0f,1.0f); + + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.codeeditview.el.restore_easing_state(); + this.state = "codeedit"; + } + public void setTitle (string str) { + this.el.set_title(this.title + " - " + str); + } + public void show () { + this.left_tree =new Xcls_WindowLeftTree(); + _this.vbox.el.pack_start(this.left_tree.el,true, true,0); + this.el.show_all(); + + } + public void hideViewEditing ( ) { + + // show the file navigation... + + if (this.left_tree.getActiveFile() != null) { + if (this.left_tree.getActiveFile().xtype == "Roo" ) { + this.window_rooview.createThumb(); + } else { + this.window_gladeview.createThumb(); + } + } + + _this.addprojectbutton.el.show(); + _this.addfilebutton.el.show(); + _this.backbutton.el.show(); + _this.delprojectbutton.el.show(); + _this.new_window.el.show(); + + _this.editfilebutton.el.hide(); + _this.projectbutton.el.hide(); + _this.projecteditbutton.el.hide(); + _this.objectshowbutton.el.hide(); + _this.addpropbutton.el.hide(); + _this.addlistenerbutton.el.hide(); + + + + + + // show the add file button.. + + + + this.editpane.el.hide(); + //this.rooview.el.hide(); + this.left_projects.el.show(); + + var el = _this.rooview.el; + el.save_easing_state(); + el.set_easing_duration(1000); + // show project / file view.. + //_this.mainpane.lastWidth = _this.leftpane.el.get_position(); + //_this.mainpane.el.set_position(0); + // rotate y 180.. + el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f); + el.set_scale(0.0f,0.0f); + + _this.state = "files"; + if (_this.project != null) { + _this.left_projects.selectProject(_this.project); + } + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + + print("show view browsing"); + } + public void showObject () { + + + // what's the active node on the left hand side.. + + var n = _this.left_tree.getActiveElement(); + + if (_this.left_tree.model.file == null) { + return; + } + + if (n == null && _this.left_tree.model.file.tree != null) { + return; + } + + _this.backbutton.el.show(); + _this.projectbutton.el.hide(); + _this.editfilebutton.el.hide(); + _this.projecteditbutton.el.hide(); + + + //this.rooview.el.hide(); + this.rightpalete.el.show_all(); + this.rightpalete.load(_this.left_tree.getActiveFile().palete(), n == null ? "*top" : n.fqn()); + + + //this.rightpalete.show(this.project); + + _this.objectview.el.save_easing_state(); + + var el = _this.rooview.el; + el.save_easing_state(); + + _this.clutterembed.setSizesAlloc("object"); + + + _this.objectview.el.set_scale(1.0f,1.0f); + + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.objectview.el.restore_easing_state(); + this.state = "object"; + } + public void hideObject () { + // return to editing state.. + + _this.projecteditbutton.el.show(); + _this.backbutton.el.hide(); + _this.projectbutton.el.show(); + _this.editfilebutton.el.show(); + _this.objectview.el.save_easing_state(); + var el = _this.rooview.el; + el.save_easing_state(); + + + el.set_scale(1.0f,1.0f); + _this.objectview.el.set_scale(0.0f,0.0f); + _this.state = "edit"; + + + //_this.clutterfiles.loadProject(_this.project); + + el.restore_easing_state(); + _this.objectview.el.restore_easing_state(); + + + } + public class Xcls_vbox : Object + { + public Gtk.VBox el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_vbox(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.vbox = this; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_mainpane( _this ); + child_0.ref(); + this.el.pack_end ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_mainpane : Object + { + public Gtk.HPaned el; + private Xcls_MainWindow _this; + + + // my vars (def) + public int lastWidth; + + // ctor + public Xcls_mainpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.mainpane = this; + this.el = new Gtk.HPaned(); + + // my vars (dec) + this.lastWidth = 0; + + // set gobject values + this.el.position = 400; + var child_0 = new Xcls_leftpane( _this ); + child_0.ref(); + this.el.add1 ( child_0.el ); + var child_1 = new Xcls_VBox8( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_leftpane : Object + { + public Gtk.VBox el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_leftpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.leftpane = this; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_editpane( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + } + + // user defined functions + } + public class Xcls_editpane : Object + { + public Gtk.VPaned el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_editpane(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.editpane = this; + this.el = new Gtk.VPaned(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_tree( _this ); + child_0.ref(); + this.el.add1 ( child_0.el ); + var child_1 = new Xcls_props( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_tree : Object + { + public Gtk.VBox el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_tree(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.tree = this; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_props : Object + { + public Gtk.VBox el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_props(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.props = this; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_VBox8 : Object + { + public Gtk.VBox el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_VBox8(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_clutterembed( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_clutterembed : Object + { + public GtkClutter.Embed el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_clutterembed(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.clutterembed = this; + this.el = new GtkClutter.Embed(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_rooview( _this ); + child_0.ref(); + this.el.get_stage().add_child ( child_0.el ); + var child_1 = new Xcls_objectview( _this ); + child_1.ref(); + this.el.get_stage().add_child ( child_1.el ); + var child_2 = new Xcls_codeeditview( _this ); + child_2.ref(); + this.el.get_stage().add_child ( child_2.el ); + var child_3 = new Xcls_addpropsview( _this ); + child_3.ref(); + this.el.get_stage().add_child ( child_3.el ); + var child_4 = new Xcls_projecteditview( _this ); + child_4.ref(); + this.el.get_stage().add_child ( child_4.el ); + var child_5 = new Xcls_buttonlayout( _this ); + child_5.ref(); + this.el.get_stage().add_child ( child_5.el ); + + // init method + + var stage = this.el.get_stage(); + stage.set_background_color( Clutter.Color.from_string("#000")); + // listeners + this.el.size_allocate.connect( ( alloc) => { + this.setSizes(alloc, _this.state); + + }); + } + + // user defined functions + public void setSizes ( Gtk.Allocation alloc, string state) { + if (!_this.children_loaded) { return; } + + _this.clutterfiles.set_size(alloc.width-50, alloc.height); + + // project view appears at top... + + _this.projecteditview.el.set_size(alloc.width-50, alloc.height / 2.0f); + + + + var avail = alloc.width < 50.0f ? 0 : alloc.width - 50.0f; + + + var palsize = avail < 300.0f ? avail : 300.0f; + print("set palsize size %f\n", palsize); + // palate / props : fixed 300 pix + + _this.objectview.el.set_size(palsize, alloc.height); + _this.addpropsview.el.set_size(palsize, alloc.height); + + + + // code edit min 600 + + var codesize = avail < 800.0f ? avail : 800.0f; + print("set code size %f\n", codesize); + + _this.codeeditview.el.set_size(codesize, alloc.height); + _this.rooview.el.set_size(alloc.width-50, alloc.height); + + switch ( state) { + case "codeedit": + + var scale = avail > 0.0f ? (avail - codesize -10 ) / avail : 0.0f; + + + _this.rooview.el.set_scale(scale,scale); + break; + case "addprop": + case "addlistener": + case "object": + var scale = avail > 0.0f ? (avail - palsize -10 ) / avail : 0.0f; + _this.rooview.el.set_scale(scale,scale); + break; + } + + } + public void setSizesAlloc (string state) { + + Gtk.Allocation alloc; + this.el.get_allocation(out alloc); + this.setSizes(alloc, state); + } + } + public class Xcls_rooview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_rooview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.rooview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 1.0f + ) + ); + + //this.el.set_position(100,100); + this.el.set_pivot_point(1.0f,1.0f); + + this.el.set_size(_this.clutterembed.el.get_stage().width-50, + _this.clutterembed.el.get_stage().height); + + } } + + // user defined functions + } + public class Xcls_objectview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_objectview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.objectview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + /* + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + */ + this.el.fixed_x = 50.0f; + this.el.fixed_y = 0.0f; + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(0.0f,1.0f); + this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2, + _this.clutterembed.el.get_stage().height); + + } } + + // user defined functions + } + public class Xcls_codeeditview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_codeeditview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.codeeditview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + /* + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + */ + this.el.fixed_x = 50.0f; + this.el.fixed_y = 0.0f; + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(0.0f,1.0f); + this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2, + _this.clutterembed.el.get_stage().height); + + } } + + // user defined functions + } + public class Xcls_addpropsview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addpropsview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addpropsview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + /* + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + */ + this.el.fixed_x = 50.0f; + this.el.fixed_y = 0.0f; + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(0.0f,1.0f); + this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2, + _this.clutterembed.el.get_stage().height); + + } } + + // user defined functions + } + public class Xcls_projecteditview : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_projecteditview(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.projecteditview = this; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + + // init method + + { + + + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 1.0f + ) + ); + + //this.el.set_position(100,100); + this.el.set_pivot_point(0.0f,0.0f); + this.el.set_scale(1.0f,0.0f); + this.el.set_size(_this.clutterembed.el.get_stage().width-50, + _this.clutterembed.el.get_stage().height /2); + + } } + + // user defined functions + } + public class Xcls_buttonlayout : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_buttonlayout(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.buttonlayout = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_BoxLayout16( _this ); + child_0.ref(); + this.el.layout_manager = child_0.el; + var child_1 = new Xcls_backbutton( _this ); + child_1.ref(); + this.el.add_child ( child_1.el ); + var child_2 = new Xcls_projectbutton( _this ); + child_2.ref(); + this.el.add_child ( child_2.el ); + var child_3 = new Xcls_editfilebutton( _this ); + child_3.ref(); + this.el.add_child ( child_3.el ); + var child_4 = new Xcls_projecteditbutton( _this ); + child_4.ref(); + this.el.add_child ( child_4.el ); + var child_5 = new Xcls_objectshowbutton( _this ); + child_5.ref(); + this.el.add_child ( child_5.el ); + var child_6 = new Xcls_addpropbutton( _this ); + child_6.ref(); + this.el.add_child ( child_6.el ); + var child_7 = new Xcls_addlistenerbutton( _this ); + child_7.ref(); + this.el.add_child ( child_7.el ); + var child_8 = new Xcls_addprojectbutton( _this ); + child_8.ref(); + this.el.add_child ( child_8.el ); + var child_9 = new Xcls_addfilebutton( _this ); + child_9.ref(); + this.el.add_child ( child_9.el ); + var child_10 = new Xcls_delprojectbutton( _this ); + child_10.ref(); + this.el.add_child ( child_10.el ); + var child_11 = new Xcls_new_window( _this ); + child_11.ref(); + this.el.add_child ( child_11.el ); + + // init method + + { + + this.el.add_constraint( + new Clutter.AlignConstraint( + _this.clutterembed.el.get_stage(), + Clutter.AlignAxis.X_AXIS, + 0.0f + ) + ); + + + //this.el.set_position(100,100); + this.el.set_pivot_point(0.5f,0.5f); + this.el.set_size(50, + _this.clutterembed.el.get_stage().height); + + } } + + // user defined functions + } + public class Xcls_BoxLayout16 : Object + { + public Clutter.BoxLayout el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_BoxLayout16(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Clutter.BoxLayout(); + + // my vars (dec) + + // set gobject values + this.el.orientation = Clutter.Orientation.VERTICAL; + } + + // user defined functions + } + public class Xcls_backbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_backbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.backbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor18( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor18 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor18(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button19( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button19 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button19(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Back"; + var child_0 = new Xcls_Image20( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + switch (_this.state) { + case "edit": + + _this.hideViewEditing(); + break; + case "files": + // should only occur if there is an active file.. + _this.showViewEditing(); + break; + + case "addprop": + _this.hideAddProp(); + + break; + case "addlistener": + _this.hideAddListener(); + + break; + + case "object": + _this.hideObject(); + break; + + case "codeedit": + + _this.hideCodeEdit(); + break; + + case "projectedit": + // save? + _this.hideProjectEdit(); + break; + + default: + break; + } + return ; + + }); + } + + // user defined functions + } + public class Xcls_Image20 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image20(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-previous"; + } + + // user defined functions + } + public class Xcls_projectbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_projectbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.projectbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor22( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor22 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor22(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button23( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button23 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button23(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + var child_0 = new Xcls_Image24( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + switch (_this.state) { + case "edit": + + _this.hideViewEditing(); + break; + case "files": + _this.showViewEditing(); + break; + + case "addprop": + _this.hideAddProp(); + _this.hideViewEditing(); + break; + case "addlistener": + _this.hideAddListener(); + _this.hideViewEditing(); + break; + + case "object": + _this.hideObject(); + _this.hideViewEditing(); + break; + + default: + break; + } + return ; + + }); + } + + // user defined functions + } + public class Xcls_Image24 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image24(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "document-open"; + } + + // user defined functions + } + public class Xcls_editfilebutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_editfilebutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.editfilebutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor26( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50.0f,50.0f); } + + // user defined functions + } + public class Xcls_Actor26 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor26(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button27( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button27 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button27(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "File Details"; + var child_0 = new Xcls_Image28( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + + // create a new file in project.. + if (_this.project == null || _this.left_tree.model.file == null) { + return ; + } + + _this.new_file_dialog.show(_this.left_tree.model.file); + + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image28 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image28(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "document-properties"; + } + + // user defined functions + } + public class Xcls_projecteditbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_projecteditbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.projecteditbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor30( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor30 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor30(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button31( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button31 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button31(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Project Details"; + var child_0 = new Xcls_Image32( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + switch (_this.state) { + case "edit": + _this.showProjectEdit(); + break; + case "files": + // _this.showViewEditing(); + break; + case "projectedit": + _this.hideProjectEdit(); + break; + + + + case "addprop": + _this.hideAddProp(); + _this.showProjectEdit(); + break; + case "addlistener": + _this.hideAddListener(); + _this.showProjectEdit(); + break; + + case "object": + _this.hideObject(); + _this.showProjectEdit(); + break; + default: + break; + } + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image32 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image32(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "emblem-system"; + } + + // user defined functions + } + public class Xcls_objectshowbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_objectshowbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.objectshowbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor34( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); + // listeners + this.el.button_press_event.connect( ( ) => { + + + + switch (_this.state) { + + + case "addprop": + _this.hideAddProp(); + _this.showObject(); + break; + case "addlistener": + _this.hideAddListener(); + _this.showObject(); + break; + + // show + case "edit": + _this.showObject(); + break; + + // hide + case "object": + _this.hideObject(); + break; + break; + + default: + print("unhandled add objects from %s\n",_this.state); + break; + } + return false; + + + }); + this.el.enter_event.connect( ( event) => { + this.el.background_color = new Clutter.Color.from_string("#333"); + return false; + }); + this.el.leave_event.connect( ( event) => { + this.el.background_color = new Clutter.Color.from_string("#000"); + return false; + }); + } + + // user defined functions + } + public class Xcls_Actor34 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor34(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button35( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button35 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button35(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add Child Element"; + var child_0 = new Xcls_Image36( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + + + + switch (_this.state) { + + + case "addprop": + _this.hideAddProp(); + _this.showObject(); + break; + case "addlistener": + _this.hideAddListener(); + _this.showObject(); + break; + + // show + case "edit": + _this.showObject(); + break; + + // hide + case "object": + _this.hideObject(); + break; + break; + + default: + print("unhandled add objects from %s\n",_this.state); + break; + } + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image36 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image36(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "list-add"; + } + + // user defined functions + } + public class Xcls_addpropbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addpropbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addpropbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor38( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor38 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor38(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button39( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button39 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button39(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add Property"; + var child_0 = new Xcls_Image40( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + + + + switch (_this.state) { + case "edit": + _this.showAddProp(); + break; + + case "object": + _this.hideObject(); + _this.showAddProp(); + break; + + case "addlistener": + _this.hideAddListener(); + _this.showAddProp(); + break; + + + case "addprop": + _this.hideAddProp(); + break; + + default: + print("unhandled add property from %s\n",_this.state); + break; + + } + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image40 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image40(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "format-justify-left"; + } + + // user defined functions + } + public class Xcls_addlistenerbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addlistenerbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addlistenerbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor42( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor42 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor42(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button43( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button43 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button43(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add Event Code"; + var child_0 = new Xcls_Image44( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + + + + switch (_this.state) { + case "edit": + _this.showAddListener(); + break; + + + case "addlistener": + _this.hideAddListener(); + break; + + + case "addprop": + _this.hideAddProp(); + _this.showAddListener(); + break; + case "object": + _this.hideObject(); + _this.showAddListener(); + break; + + default: + print("unhandled add listener from %s\n",_this.state); + + break; + + } + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image44 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image44(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "appointment-new"; + } + + // user defined functions + } + public class Xcls_addprojectbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addprojectbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addprojectbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor46( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50.0f,50.0f); } + + // user defined functions + } + public class Xcls_Actor46 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor46(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button47( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button47 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button47(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "New\nProj."; + var child_0 = new Xcls_Image48( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + + // create a new file in project.. + //Xcls_DialogNewComponent.singleton().show( + var pe = Xcls_EditProject.singleton(); + pe.el.set_transient_for(_this.el); + pe.el.set_modal(true); + + var p = pe.show(); + + if (p == null) { + return; + } + _this.left_projects.is_loaded = false; + _this.left_projects.load(); + _this.left_projects.selectProject(p); + return ; + + + }); + } + + // user defined functions + } + public class Xcls_Image48 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image48(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "folder-new"; + } + + // user defined functions + } + public class Xcls_addfilebutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_addfilebutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.addfilebutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor50( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50.0f,50.0f); } + + // user defined functions + } + public class Xcls_Actor50 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor50(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button51( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button51 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button51(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Add File"; + var child_0 = new Xcls_Image52( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( () => { + // create a new file in project.. + + // what's the currently selected project... + var proj = _this.left_projects.getSelectedProject(); + + if (proj == null) { + return ; + } + + + + var f = JsRender.JsRender.factory(proj.xtype, proj, ""); + _this.project = proj; + _this.new_file_dialog.show(f); + + return ; + }); + } + + // user defined functions + } + public class Xcls_Image52 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image52(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "document-new"; + } + + // user defined functions + } + public class Xcls_delprojectbutton : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_delprojectbutton(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.delprojectbutton = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor54( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor54 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor54(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button55( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button55 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button55(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Delelte Project"; + var child_0 = new Xcls_Image56( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + + var cd = DialogConfirm.singleton(); + cd.el.set_transient_for(_this.el); + cd.el.set_modal(true); + + var project = _this.left_projects.getSelectedProject(); + if (project == null) { + print("SKIP - no project\n"); + return; + } + + + if (Gtk.ResponseType.YES != cd.show("Confirm", + "Are you sure you want to delete project %s".printf(project.name))) { + return; + } + + + // confirm? + Project.Project.remove(project); + _this.project = null; + + _this.left_projects.is_loaded = false; + _this.left_projects.load(); + _this.clutterfiles.clearFiles(); + + }); + } + + // user defined functions + } + public class Xcls_Image56 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image56(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "user-trash"; + } + + // user defined functions + } + public class Xcls_new_window : Object + { + public Clutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_new_window(Xcls_MainWindow _owner ) + { + _this = _owner; + _this.new_window = this; + this.el = new Clutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Actor58( _this ); + child_0.ref(); + this.el.add_child ( child_0.el ); + + // init method + + this.el.set_size(50,50); } + + // user defined functions + } + public class Xcls_Actor58 : Object + { + public GtkClutter.Actor el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Actor58(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new GtkClutter.Actor(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button59( _this ); + child_0.ref(); + + // init method + + ((Gtk.Container)(this.el.get_widget())).add ( child_0.el); } + + // user defined functions + } + public class Xcls_Button59 : Object + { + public Gtk.Button el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Button59(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 50; + this.el.height_request = 50; + this.el.tooltip_text = "Open New Window"; + var child_0 = new Xcls_Image60( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + // listeners + this.el.clicked.connect( ( ) => { + Xcls_MainWindow.singleton().no_windows++; + var w = new Xcls_MainWindow(); + w.ref(); + + w.el.show_all(); + w.initChildren(); + w.hideViewEditing(); + }); + } + + // user defined functions + } + public class Xcls_Image60 : Object + { + public Gtk.Image el; + private Xcls_MainWindow _this; + + + // my vars (def) + + // ctor + public Xcls_Image60(Xcls_MainWindow _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "window-new"; + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/ProjectSettings.bjs b/old-javascript/Builder4/ProjectSettings.bjs new file mode 100644 index 000000000..05172dad4 --- /dev/null +++ b/old-javascript/Builder4/ProjectSettings.bjs @@ -0,0 +1,124 @@ +{ + "name" : "ProjectSettings", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/ProjectSettings.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "@ void buttonPressed" : "(string btn)", + "id" : "ProjectSettings", + "| void show" : " (Project.Project project) {\n _this.project = project;\n _this.path.el.label = project.firstPath();\n // get the active project.\n var lm = Gtk.SourceLanguageManager.get_default();\n \n ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(\n \n lm.get_language(\"html\"));\n \n //print (project.fn);\n //project.runhtml = project.runhtml || '';\n _this.view.el.get_buffer().set_text(project.runhtml);\n \n \n _this.rootURL.el.set_text( _this.project.rootURL );\n _this.base_template.el.set_text(_this.project.base_template); \n \n \n //this.el.show_all();\n}\n", + "# Project.Project project" : "", + "xtype" : "VBox", + "| void save" : "()\n{\n var buf = _this.view.el.get_buffer();\n Gtk.TextIter s;\n Gtk.TextIter e;\n buf.get_start_iter(out s);\n buf.get_end_iter(out e);\n _this.project.runhtml = buf.get_text(s,e,true);\n \n _this.project.rootURL = _this.rootURL.el.get_text();\n _this.project.base_template = _this.base_template.el.get_text(); \n \n \n}", + "$ xns" : "Gtk", + "border_width" : 5, + "$ homogeneous" : false, + "items" : [ + { + "* pack" : "pack_start,false,false,0", + "xtype" : "HBox", + "gboolean expand" : false, + "$ xns" : "Gtk", + "$ homogeneous" : true, + "gboolean vexpand" : false, + "items" : [ + { + "listeners" : { + "button_press_event" : "() => {\n _this.save();\n \n _this.buttonPressed(\"apply\");\n return false;\n}" + }, + "label" : "Apply", + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "button_press_event" : "() => {\n _this.save();\n \n _this.buttonPressed(\"save\");\n return false;\n}" + }, + "label" : "Save", + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk" + } + ] + }, + { + "label" : "filename", + "id" : "path", + "xalign" : 0, + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "label" : "HTML To insert at end of ", + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "* pack" : "pack_start,false,false,0", + "xtype" : "HBox", + "gboolean expand" : false, + "$ xns" : "Gtk", + "$ homogeneous" : false, + "items" : [ + { + "label" : "HTML template file", + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "id" : "base_template", + "* pack" : "add", + "xtype" : "Entry", + "$ xns" : "Gtk" + } + ] + }, + { + "* pack" : "pack_start,false,false,0", + "xtype" : "HBox", + "gboolean expand" : false, + "$ xns" : "Gtk", + "$ homogeneous" : false, + "items" : [ + { + "label" : "root URL", + "* pack" : "pack_start,false,false,0", + "xtype" : "Label", + "$ xns" : "Gtk" + }, + { + "id" : "rootURL", + "* pack" : "add", + "xtype" : "Entry", + "$ xns" : "Gtk" + } + ] + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "key_release_event" : " ( event) =>{\n if (event.keyval != 115) {\n return false;\n \n }\n if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {\n return false;\n }\n var buf = this.el.get_buffer();\n Gtk.TextIter s;\n Gtk.TextIter e;\n buf.get_start_iter(out s);\n buf.get_end_iter(out e);\n _this.project.runhtml = buf.get_text(s,e,true);\n \n \n _this.buttonPressed(\"save\");\n \n return false;\n \n}" + }, + "id" : "view", + "* init" : " \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(9000);\n this.el.override_font(description);", + "xtype" : "View", + "* pack" : "add", + "$ xns" : "GtkSource" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/ProjectSettings.vala b/old-javascript/Builder4/ProjectSettings.vala new file mode 100644 index 000000000..584d5ae77 --- /dev/null +++ b/old-javascript/Builder4/ProjectSettings.vala @@ -0,0 +1,439 @@ +static Xcls_ProjectSettings _ProjectSettings; + +public class Xcls_ProjectSettings : Object +{ + public Gtk.VBox el; + private Xcls_ProjectSettings _this; + + public static Xcls_ProjectSettings singleton() + { + if (_ProjectSettings == null) { + _ProjectSettings= new Xcls_ProjectSettings(); + } + return _ProjectSettings; + } + public Xcls_path path; + public Xcls_base_template base_template; + public Xcls_rootURL rootURL; + public Xcls_view view; + + // my vars (def) + public signal void buttonPressed (string btn); + public Project.Project project; + + // ctor + public Xcls_ProjectSettings() + { + _this = this; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + + // set gobject values + this.el.border_width = 5; + var child_0 = new Xcls_HBox2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_path( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Label6( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + var child_3 = new Xcls_HBox7( _this ); + child_3.ref(); + this.el.pack_start ( child_3.el , false,false,0 ); + var child_4 = new Xcls_HBox10( _this ); + child_4.ref(); + this.el.pack_start ( child_4.el , false,false,0 ); + var child_5 = new Xcls_ScrolledWindow13( _this ); + child_5.ref(); + this.el.pack_start ( child_5.el , true,true,0 ); + } + + // user defined functions + public void show (Project.Project project) { + _this.project = project; + _this.path.el.label = project.firstPath(); + // get the active project. + var lm = Gtk.SourceLanguageManager.get_default(); + + ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language( + + lm.get_language("html")); + + //print (project.fn); + //project.runhtml = project.runhtml || ''; + _this.view.el.get_buffer().set_text(project.runhtml); + + + _this.rootURL.el.set_text( _this.project.rootURL ); + _this.base_template.el.set_text(_this.project.base_template); + + + //this.el.show_all(); + } + public void save () + { + var buf = _this.view.el.get_buffer(); + Gtk.TextIter s; + Gtk.TextIter e; + buf.get_start_iter(out s); + buf.get_end_iter(out e); + _this.project.runhtml = buf.get_text(s,e,true); + + _this.project.rootURL = _this.rootURL.el.get_text(); + _this.project.base_template = _this.base_template.el.get_text(); + + + } + public class Xcls_HBox2 : Object + { + public Gtk.HBox el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_HBox2(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + this.el.expand = false; + this.el.vexpand = false; + var child_0 = new Xcls_Button3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_Button4( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Button3 : Object + { + public Gtk.Button el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Button3(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Apply"; + + // listeners + this.el.button_press_event.connect( () => { + _this.save(); + + _this.buttonPressed("apply"); + return false; + }); + } + + // user defined functions + } + public class Xcls_Button4 : Object + { + public Gtk.Button el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Button4(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save"; + + // listeners + this.el.button_press_event.connect( () => { + _this.save(); + + _this.buttonPressed("save"); + return false; + }); + } + + // user defined functions + } + public class Xcls_path : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_path(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.path = this; + this.el = new Gtk.Label( "filename" ); + + // my vars (dec) + + // set gobject values + this.el.xalign = 0f; + } + + // user defined functions + } + public class Xcls_Label6 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label6(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "HTML To insert at end of " ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_HBox7 : Object + { + public Gtk.HBox el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_HBox7(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( false, 0 ); + + // my vars (dec) + + // set gobject values + this.el.expand = false; + var child_0 = new Xcls_Label8( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_base_template( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label8 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label8(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "HTML template file" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_base_template : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_base_template(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.base_template = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_HBox10 : Object + { + public Gtk.HBox el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_HBox10(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( false, 0 ); + + // my vars (dec) + + // set gobject values + this.el.expand = false; + var child_0 = new Xcls_Label11( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_rootURL( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Label11 : Object + { + public Gtk.Label el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label11(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "root URL" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_rootURL : Object + { + public Gtk.Entry el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_rootURL(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.rootURL = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ScrolledWindow13 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow13(Xcls_ProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.SourceView el; + private Xcls_ProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_view(Xcls_ProjectSettings _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.SourceView(); + + // my vars (dec) + + // set gobject values + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(9000); + this.el.override_font(description); + // listeners + this.el.key_release_event.connect( ( event) =>{ + if (event.keyval != 115) { + return false; + + } + if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) { + return false; + } + var buf = this.el.get_buffer(); + Gtk.TextIter s; + Gtk.TextIter e; + buf.get_start_iter(out s); + buf.get_end_iter(out e); + _this.project.runhtml = buf.get_text(s,e,true); + + + _this.buttonPressed("save"); + + return false; + + }); + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/RooProjectProperties.bjs b/old-javascript/Builder4/RooProjectProperties.bjs new file mode 100644 index 000000000..0f8914150 --- /dev/null +++ b/old-javascript/Builder4/RooProjectProperties.bjs @@ -0,0 +1,64 @@ +{ + "id": "file-gtk-8", + "name": "RooProjectProperties", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Builder4/RooProjectProperties.bjs", + "items": [ + { + "listeners": { + "delete_event": " (self, event) => {\n this.el.hide();\n return true;\n}", + "response": " (self, response_id) => {\n //print(response_id);\n if (response_id< 1 ) {\n this.el.hide();\n \n return;\n }\n \n var buf = view.el.get_buffer();\n Gtk.TextIter s;\n Gtk.TextIter e;\n buf.get_start_iter(out s);\n buf.get_end_iter(out e);\n var str = buf.get_text(s,e,true);\n // ideally we should syntax check it.. but it's html!?\n \n //var project = this.get('/Window.LeftTree').getActiveFile().project;\n \n \n _this.project.runhtml = str;\n _this.project.save();\n \n // imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();\n// print (str);\n // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);\n // ok pressed..\n this.el.hide();\n}" + }, + ".Project.Project:project": "", + "default_width": 500, + "xtype": "Dialog", + "|modal": "true", + "|void:show": " (Project.Project project) {\n _this.project = project;\n // get the active project.\n \n //print (project.fn);\n //project.runhtml = project.runhtml || '';\n _this.view.el.get_buffer().set_text(project.runhtml);\n \n this.el.show_all();\n}\n", + "|xns": "Gtk", + "items": [ + { + "border_width": 5, + "xtype": "VBox", + "|pack": " get_content_area().add\n", + "|xns": "Gtk", + "items": [ + { + "|xns": "Gtk", + "xtype": "Label", + "pack": "pack_start,false,false,0", + "label": "HTML To insert at end of " + }, + { + "|xns": "Gtk", + "xtype": "ScrolledWindow", + "pack": "pack_end,true,true,0", + "items": [ + { + "|xns": "GtkSource", + "xtype": "View", + "pack": "add", + "id": "view" + } + ] + } + ] + }, + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "add_action_widget,1", + "label": "OK" + }, + { + "|xns": "Gtk", + "xtype": "Button", + "pack": "add_action_widget,0", + "label": "Cancel" + } + ] + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/old-javascript/Builder4/RooProjectProperties.vala b/old-javascript/Builder4/RooProjectProperties.vala new file mode 100644 index 000000000..11f0155ec --- /dev/null +++ b/old-javascript/Builder4/RooProjectProperties.vala @@ -0,0 +1,322 @@ +/* -- to compile +valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \ + /tmp/RooProjectProperties.vala -o /tmp/RooProjectProperties +*/ + + +/* -- to test class +static int main (string[] args) { + Gtk.init (ref args); + new Xcls_RooProjectProperties(); + RooProjectProperties.show_all(); + Gtk.main (); + return 0; +} +*/ + + +public static Xcls_RooProjectProperties RooProjectProperties; + +public class Xcls_RooProjectProperties +{ + public Gtk.Dialog el; + private static Xcls_RooProjectProperties _this; + + public Xcls_view view; + + // my vars + public Project.Project project; + + // ctor + public Xcls_RooProjectProperties() + { + this.el = new Gtk.Dialog(); + _this = this; + RooProjectProperties = this; + + // my vars + + // set gobject values + this.el.default_width = 500; + this.el.modal = true; + var child_0 = new Xcls_VBox2(); + this.el. get_content_area().add + ( child_0.el ); + var child_1 = new Xcls_Button6(); + this.el.add_action_widget ( child_1.el , 1 ); + var child_2 = new Xcls_Button7(); + this.el.add_action_widget ( child_2.el , 0 ); + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + } ); + this.el.response.connect( (self, response_id) => { + //print(response_id); + if (response_id< 1 ) { + this.el.hide(); + + return; + } + + var buf = view.el.get_buffer(); + Gtk.TextIter s; + Gtk.TextIter e; + buf.get_start_iter(out s); + buf.get_end_iter(out e); + var str = buf.get_text(s,e,true); + // ideally we should syntax check it.. but it's html!? + + //var project = this.get('/Window.LeftTree').getActiveFile().project; + + + _this.project.runhtml = str; + _this.project.save(); + + // imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig(); + // print (str); + // this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length); + // ok pressed.. + this.el.hide(); + } ); + } + + // userdefined functions + + // skip listeners - not pipe + + // skip .Project.Project:project - already used + + // skip default_width - already used + + // skip xtype - not pipe + + // skip |modal - already used + public void show (Project.Project project) { + _this.project = project; + // get the active project. + + //print (project.fn); + //project.runhtml = project.runhtml || ''; + _this.view.el.get_buffer().set_text(project.runhtml); + + this.el.show_all(); + } + + // skip |xns - no return type + + // skip items - not pipe + + // skip id - not pipe + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + public class Xcls_VBox2 + { + public Gtk.VBox el; + + // my vars + + // ctor + public Xcls_VBox2() + { + this.el = new Gtk.VBox( true, 0 ); + + // my vars + + // set gobject values + this.el.border_width = 5; + var child_0 = new Xcls_Label3(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_ScrolledWindow4(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // userdefined functions + + // skip border_width - already used + + // skip xtype - not pipe + + // skip |pack - already used + + // skip |xns - no return type + + // skip items - not pipe + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + } + public class Xcls_Label3 + { + public Gtk.Label el; + + // my vars + + // ctor + public Xcls_Label3() + { + this.el = new Gtk.Label( "HTML To insert at end of " ); + + // my vars + + // set gobject values + } + + // userdefined functions + + // skip |xns - no return type + + // skip xtype - not pipe + + // skip pack - not pipe + + // skip label - already used + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + } + public class Xcls_ScrolledWindow4 + { + public Gtk.ScrolledWindow el; + + // my vars + + // ctor + public Xcls_ScrolledWindow4() + { + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars + + // set gobject values + var child_0 = new Xcls_view(); + this.el.add ( child_0.el ); + } + + // userdefined functions + + // skip |xns - no return type + + // skip xtype - not pipe + + // skip pack - not pipe + + // skip items - not pipe + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + } + public class Xcls_view + { + public Gtk.SourceView el; + + // my vars + + // ctor + public Xcls_view() + { + this.el = new Gtk.SourceView(); + _this.view = this; + + // my vars + + // set gobject values + } + + // userdefined functions + + // skip |xns - no return type + + // skip xtype - not pipe + + // skip pack - not pipe + + // skip id - not pipe + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + } + public class Xcls_Button6 + { + public Gtk.Button el; + + // my vars + + // ctor + public Xcls_Button6() + { + this.el = new Gtk.Button(); + + // my vars + + // set gobject values + this.el.label = "OK"; + } + + // userdefined functions + + // skip |xns - no return type + + // skip xtype - not pipe + + // skip pack - not pipe + + // skip label - already used + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + } + public class Xcls_Button7 + { + public Gtk.Button el; + + // my vars + + // ctor + public Xcls_Button7() + { + this.el = new Gtk.Button(); + + // my vars + + // set gobject values + this.el.label = "Cancel"; + } + + // userdefined functions + + // skip |xns - no return type + + // skip xtype - not pipe + + // skip pack - not pipe + + // skip label - already used + + // skip xvala_cls - not pipe + + // skip xvala_xcls - not pipe + + // skip xvala_id - not pipe + } +} diff --git a/old-javascript/Builder4/StandardErrorDialog.bjs b/old-javascript/Builder4/StandardErrorDialog.bjs new file mode 100644 index 000000000..b9c35eaba --- /dev/null +++ b/old-javascript/Builder4/StandardErrorDialog.bjs @@ -0,0 +1,25 @@ +{ + "id": "file-gtk-14", + "name": "StandardErrorDialog", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Builder4/StandardErrorDialog.bjs", + "items": [ + { + "listeners": { + "delete_event": " (self, event) => {\n this.el.hide();\n return true;\n \n} \n", + "response": " (self, response_id) => {\n this.el.hide();\n}" + }, + "text": "fixme", + "xtype": "MessageDialog", + "|buttons": "Gtk.ButtonsType.OK", + "|message_type": "Gtk.MessageType.ERROR", + "|modal": "true", + "|use_markup": "true", + "|void:show": " (Gtk.Window win, string msg) {\n\n this.el.set_transient_for(win);\n this.el.modal = true;\n this.el.text = msg;\n this.el.show_all();\n}\n", + "|xns": "Gtk" + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/old-javascript/Builder4/StandardErrorDialog.vala b/old-javascript/Builder4/StandardErrorDialog.vala new file mode 100644 index 000000000..ec34380f7 --- /dev/null +++ b/old-javascript/Builder4/StandardErrorDialog.vala @@ -0,0 +1,69 @@ +/* -- to compile +valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \ + /tmp/StandardErrorDialog.vala -o /tmp/StandardErrorDialog +*/ + + +/* -- to test class +static int main (string[] args) { + Gtk.init (ref args); + new Xcls_StandardErrorDialog(); + StandardErrorDialog.show_all(); + Gtk.main (); + return 0; +} +*/ + + +public static Xcls_StandardErrorDialog StandardErrorDialog; + +public class Xcls_StandardErrorDialog : Object +{ + public Gtk.MessageDialog el; + private Xcls_StandardErrorDialog _this; + + public static Xcls_StandardErrorDialog singleton() + { + if (StandardErrorDialog == null) { + StandardErrorDialog= new Xcls_StandardErrorDialog(); + } + return StandardErrorDialog; + } + + // my vars + + // ctor + public Xcls_StandardErrorDialog() + { + _this = this; + this.el = new Gtk.MessageDialog( null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, "fixme" ); + + // my vars + + // set gobject values + this.el.modal = true; + this.el.use_markup = true; + + // listeners + this.el.delete_event.connect( (self, event) => { + this.el.hide(); + return true; + + } + ); + this.el.response.connect( (self, response_id) => { + this.el.hide(); + } ); + } + + // userdefined functions + public void show (Gtk.Window win, string msg) { + + this.el.set_transient_for(win); + this.el.modal = true; + this.el.text = msg; + this.el.show_all(); + } + + // skip |xns - no return type +} diff --git a/old-javascript/Builder4/ValaProjectSettings.bjs b/old-javascript/Builder4/ValaProjectSettings.bjs new file mode 100644 index 000000000..918088ffb --- /dev/null +++ b/old-javascript/Builder4/ValaProjectSettings.bjs @@ -0,0 +1,413 @@ +{ + "name" : "ValaProjectSettings", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/ValaProjectSettings.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "# Project.Gtk project" : "null", + "# Xcls_MainWindow window" : "null", + "| void show" : "(Project.Gtk project) {\n \n \n print(\"ValaProjectSettings show\\n\");\n \n this.project= project;\n\n this.compile_flags.el.text = \"\";\n \n this.default_directory_tree_store.load(); \n this.default_packages_tree_store.load(); \n this.targets_tree_store.load();\n this.files_tree_store.load();\n\n}\n", + "xtype" : "VBox", + "string id" : "ValaProjectSettings", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "pack_start,true,true,0", + "xtype" : "Notebook", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "label_global", + "xtype" : "Label", + "* pack" : false, + "$ xns" : "Gtk", + "utf8 label" : "Global" + }, + { + "id" : "label_targets", + "* pack" : false, + "xtype" : "Label", + "$ xns" : "Gtk", + "utf8 label" : "Targets" + }, + { + "xtype" : "VBox", + "* pack" : "append_page,_this.label_global.el", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "compile flags" + }, + { + "id" : "compile_flags", + "xtype" : "Entry", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "packages" + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "gboolean headers_visible" : false, + "* pack" : "add", + "xtype" : "TreeView", + "string id" : "default_packages_tree", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "default_packages_tree_store", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ n_columns" : 2, + "| void load" : "() {\n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.packages;\n \n this.el.clear();\n var pal = (Palete.Gtk) Palete.factory(\"Gtk\");\n var pkgs = pal.packages();\n print(\"ValaProjectSettings:packages load %d\\n\", pkgs.size);\n\n Gtk.TreeIter citer;\n\n for(var i =0 ; i < pkgs.size; i++) {\n this.el.append(out citer); \n \n this.el.set_value(citer, 0, pkgs.get(i) ); // title \n this.el.set_value(citer, 1, items.contains(pkgs.get(i)) );\n }\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "$ columns" : " typeof(string), // 0 key type\n typeof(bool)", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "name", + "* init" : " \n this.el.add_attribute(_this.packages_render.el , \"text\", 0 );\n ", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "gboolean expand" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "packages_render", + "* pack" : "pack_start,false", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + }, + { + "utf8 title" : "use", + "* init" : "{\n this.el.add_attribute(_this.packages_render_use.el , \"active\", 1 );\n }", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : false, + "$ xns" : "Gtk", + "gint fixed_width" : 50, + "items" : [ + { + "listeners" : { + "toggled" : "( path_string) => { \n var m = _this.default_packages_tree_store.el;\n Gtk.TreeIter iter;\n Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);\n m.get_iter (out iter, path);\n GLib.Value val;\n m.get_value(iter, 1, out val);\n m.set_value(iter, 1, ((bool) val) ? false :true); \n GLib.Value fval; \n m.get_value(iter, 0, out fval);\n var fn = (string)fval;\n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.packages;\n if ((bool)val) {\n // renive\n items.remove(fn);\n } else {\n items.add(fn);\n }\n \n}" + }, + "id" : "packages_render_use", + "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", + "$ xns" : "Gtk", + "gboolean activatable" : true + } + ] + } + ] + } + ] + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "Available Directories" + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n \n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n //Gtk.TreePath res;\n //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n // return true;\n //}\n \n // this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.default_directory_menu.el.set_screen(Gdk.Screen.get_default());\n _this.default_directory_menu.el.show_all();\n _this.default_directory_menu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}" + }, + "gboolean headers_visible" : false, + "id" : "default_directory_tree", + "* pack" : "add", + "xtype" : "TreeView", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "default_directory_tree_store", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ n_columns" : 1, + "| void load" : "() {\n \n this.el.clear();\n \n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.sources;\n \n \n Gtk.TreeIter citer;\n\n for(var i =0 ; i < items.size; i++) {\n this.el.append(out citer); \n \n this.el.set_value(citer, 0, items.get(i) ); // title \n //this.el.set_value(citer, 1, items.get(i) );\n }\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "$ columns" : " typeof(string)\n ", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "name", + "* init" : "\n this.el.add_attribute(_this.directory_render.el , \"text\", 0 );\n ", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "directory_render", + "* pack" : "pack_start,false", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "id" : "default_directory_menu", + "xtype" : "Menu", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : "() => {\n \n var chooser = new Gtk.FileChooserDialog (\n\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.SELECT_FOLDER ,\n\t\"_Cancel\",\n\tGtk.ResponseType.CANCEL,\n\t\"_Add\",\n\tGtk.ResponseType.ACCEPT);\n if (chooser.run () != Gtk.ResponseType.ACCEPT) {\n chooser.close ();\n return;\n }\n chooser.close ();\n // add the directory..\n var fn = _this.project.relPath(chooser.get_filename());\n _this.project.compilegroups.get(\"_default_\").sources.add(fn);\n _this.default_directory_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Add Directory" + }, + { + "listeners" : { + "activate" : "() => {\n \n var chooser = new Gtk.FileChooserDialog (\n\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.OPEN ,\n\t\"_Cancel\",\n\tGtk.ResponseType.CANCEL,\n\t\"_Add\",\n\tGtk.ResponseType.ACCEPT);\n if (chooser.run () != Gtk.ResponseType.ACCEPT) {\n chooser.close ();\n return;\n }\n chooser.close ();\n // add the directory..\n var fn = _this.project.relPath(chooser.get_filename());\n _this.project.compilegroups.get(\"_default_\").sources.add(fn);\n _this.default_directory_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Add File" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : "() => {\n \n //\n Gtk.TreeModel mod;\n Gtk.TreeIter iter;\n if (!_this.default_directory_tree.el.get_selection().get_selected(out mod, out iter)) {\n print(\"nothing selected\\n\");\n return;\n }\n\n \n // add the directory..\n \n \n GLib.Value val;\n mod.get_value(iter,0, out val);\n var fn = (string) val;\n \n print(\"remove: %s\\n\", fn);\n if (!_this.project.compilegroups.get(\"_default_\").sources.remove(fn)) {\n print(\"remove failed\");\n }\n _this.default_directory_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Remove File/Directory" + } + ] + } + ] + } + ] + }, + { + "gint position" : 300, + "xtype" : "HPaned", + "* pack" : "append_page,_this.label_targets.el", + "$ xns" : "Gtk", + "items" : [ + { + "* init" : "{ \nthis.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n\n}\n", + "xtype" : "ScrolledWindow", + "* pack" : "add1", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "targets_tree_menu", + "* pack" : "add", + "xtype" : "Menu", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : "() => {\n \n if (_this.project.compilegroups.has_key(\"NEW GROUP\")) {\n return;\n }\n \n // add the directory..\n \n _this.project.compilegroups.set(\"NEW GROUP\", new Project.GtkValaSettings(\"NEW GROUP\"));\n _this.targets_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Add Compile Target" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : "() => {\n \n //\n Gtk.TreeModel mod;\n Gtk.TreeIter iter;\n if (!_this.targets_tree.el.get_selection().get_selected(out mod, out iter)) {\n print(\"nothing selected\\n\");\n return;\n }\n\n \n // add the directory..\n \n \n GLib.Value val;\n mod.get_value(iter,0, out val);\n var fn = (string) val;\n \n print(\"remove: %s\\n\", fn);\n if (!_this.project.compilegroups.unset(fn)) {\n print(\"remove failed\");\n }\n _this.targets_tree_store.load();\n}" + }, + "* pack" : "add", + "xtype" : "MenuItem", + "$ xns" : "Gtk", + "utf8 label" : "Remove Target" + } + ] + }, + { + "listeners" : { + "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n \n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n //Gtk.TreePath res;\n //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n // return true;\n //}\n \n // this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.targets_tree_menu.el.set_screen(Gdk.Screen.get_default());\n _this.targets_tree_menu.el.show_all();\n _this.targets_tree_menu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}", + "cursor_changed" : " ( ) => {\n\n if (this.cursor != \"\") {\n // save the values..\n }\n \n // load the new values.\n \n\n Gtk.TreeModel mod;\n Gtk.TreeIter iter;\n if (!this.el.get_selection().get_selected(out mod, out iter)) {\n print(\"nothing selected\\n\");\n return;\n }\n\n \n // add the directory..\n \n \n GLib.Value val;\n mod.get_value(iter,0, out val);\n var fn = (string) val;\n \n this.cursor = fn;\n var cg = _this.project.compilegroups.get(fn);\n _this.build_pack_target.el.set_text(cg.target_bin);\n _this.build_compile_flags.el.set_text(cg.compile_flags);\n // load the srouces\n\n\n }" + }, + "id" : "targets_tree", + "# string cursor" : "", + "* pack" : "add", + "xtype" : "TreeView", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "targets_tree_store", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ n_columns" : 2, + "| void load" : "() {\n \n this.el.clear();\n \n \n var cg = _this.project.compilegroups;\n \n _this.targets_tree.cursor = \"\";\n Gtk.TreeIter citer;\n var iter = cg.map_iterator();\n while(iter.next()) {\n var key = iter.get_key();\n if (key == \"_default_\") {\n continue;\n }\n \n this.el.append(out citer); \n \n this.el.set_value(citer, 0, key ); // title \n //this.el.set_value(citer, 1, items.get(i) );\n };\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "$ columns" : " typeof(string), // 0 key type\n typeof(string) // ??\n ", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "name", + "* init" : " {\n this.el.add_attribute(_this.targets_render.el , \"text\", 0 );\n }", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "edited" : " (path, newtext) => {\n \n Gtk.TreeIter iter;\n _this.targets_tree_store.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n _this.targets_tree_store.el.get_value(iter,0, out gval);\n var oldval = (string)gval;\n if (oldval == newtext) {\n return;\n }\n var cg = _this.project.compilegroups.get(oldval);\n cg.name = newtext;\n _this.project.compilegroups.unset(oldval);\n _this.project.compilegroups.set(newtext, cg);\n _this.targets_tree_store.load();\n }" + }, + "id" : "targets_render", + "xtype" : "CellRendererText", + "* pack" : "pack_start,false", + "$ xns" : "Gtk", + "gboolean editable" : true + } + ] + } + ] + } + ] + }, + { + "xtype" : "VBox", + "* pack" : "add2", + "string id" : "set_vbox", + "gboolean homogeneous" : false, + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "target filename" + }, + { + "listeners" : { + "changed" : "() => {\n if (_this.targets_tree.cursor.length < 1) {\n return;\n }\n _this.project.compilegroups.get(_this.targets_tree.cursor).target_bin = this.el.text;\n}" + }, + "id" : "build_pack_target", + "xtype" : "Entry", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "compile flags" + }, + { + "listeners" : { + "changed" : "() => {\n if (_this.targets_tree.cursor.length < 1) {\n return;\n }\n _this.project.compilegroups.get(_this.targets_tree.cursor).compile_flags = this.el.text;\n}" + }, + "id" : "build_compile_flags", + "xtype" : "Entry", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "xtype" : "Label", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "utf8 label" : "Files to compile" + }, + { + "* pack" : "pack_start,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "TreeView", + "string id" : "files_tree", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "files_tree_store", + "xtype" : "ListStore", + "* pack" : "set_model", + "$ n_columns" : 2, + "| void load" : "() {\n \n this.el.clear();\n \n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.sources;\n \n \n Gtk.TreeIter citer;\n\n for(var i =0 ; i < items.size; i++) {\n this.el.append(out citer); \n \n this.el.set_value(citer, 0, items.get(i) ); // title \n this.el.set_value(citer, 1, \"dir\"); // type \n this.el.set_value(citer, 2, false ); // checked \n /*\n var files = def.files(items.get(i));\n \n for(var j =0 ; j < files.size; j++) {\n this.el.append(out citer); \n \n this.el.set_value(citer, 0, files.get(j) ); // title \n this.el.set_value(citer, 1, \"file\"); // type \n this.el.set_value(citer, 2, false ); // checked \n\n }\n */\n \n //this.el.set_value(citer, 1, items.get(i) );\n }\n this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n ", + "$ columns" : " typeof(string), // 0 file name\n typeof(string), // type (dir orfile)\n typeof(bool) // is checked.\n ", + "$ xns" : "Gtk" + }, + { + "utf8 title" : "name", + "* init" : "/* this.el.add_attribute(_this.files_render.el , \"markup\", 2 );\n// this.el.add_attribute(_this.files_render.el , \"text\", 1 ); */\n \n", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "files_render", + "* pack" : "pack_start,false", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + }, + { + "utf8 title" : "use", + "* init" : "/*\n\n this.el.add_attribute(_this.packages_render_use.el , \"active\", 1 );\n \n */\n ", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "gboolean resizable" : false, + "$ xns" : "Gtk", + "gint fixed_width" : 50, + "items" : [ + { + "listeners" : { + "toggled" : "( path_string) => { \n var m = _this.default_packages_tree_store.el;\n Gtk.TreeIter iter;\n Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);\n m.get_iter (out iter, path);\n GLib.Value val;\n m.get_value(iter, 1, out val);\n m.set_value(iter, 1, ((bool) val) ? false :true); \n GLib.Value fval; \n m.get_value(iter, 0, out fval);\n var fn = (string)fval;\n \n var def = _this.project.compilegroups.get(\"_default_\");\n var items = def.packages;\n if ((bool)val) {\n // renive\n items.remove(fn);\n } else {\n items.add(fn);\n }\n \n}" + }, + "id" : "files_render_use", + "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", + "$ xns" : "Gtk", + "gboolean activatable" : true + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/ValaProjectSettings.vala b/old-javascript/Builder4/ValaProjectSettings.vala new file mode 100644 index 000000000..79cc26e49 --- /dev/null +++ b/old-javascript/Builder4/ValaProjectSettings.vala @@ -0,0 +1,1675 @@ +static ValaProjectSettings _ValaProjectSettings; + +public class ValaProjectSettings : Object +{ + public Gtk.VBox el; + private ValaProjectSettings _this; + + public static ValaProjectSettings singleton() + { + if (_ValaProjectSettings == null) { + _ValaProjectSettings= new ValaProjectSettings(); + } + return _ValaProjectSettings; + } + public Xcls_label_global label_global; + public Xcls_label_targets label_targets; + public Xcls_compile_flags compile_flags; + public Xcls_default_packages_tree_store default_packages_tree_store; + public Xcls_packages_render packages_render; + public Xcls_packages_render_use packages_render_use; + public Xcls_default_directory_tree default_directory_tree; + public Xcls_default_directory_tree_store default_directory_tree_store; + public Xcls_directory_render directory_render; + public Xcls_default_directory_menu default_directory_menu; + public Xcls_targets_tree_menu targets_tree_menu; + public Xcls_targets_tree targets_tree; + public Xcls_targets_tree_store targets_tree_store; + public Xcls_targets_render targets_render; + public Xcls_build_pack_target build_pack_target; + public Xcls_build_compile_flags build_compile_flags; + public Xcls_files_tree_store files_tree_store; + public Xcls_files_render files_render; + public Xcls_files_render_use files_render_use; + + // my vars (def) + public Project.Gtk project; + public Xcls_MainWindow window; + + // ctor + public ValaProjectSettings() + { + _this = this; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + this.project = null; + this.window = null; + + // set gobject values + var child_0 = new Xcls_Notebook2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true,true,0 ); + } + + // user defined functions + public void show (Project.Gtk project) { + + + print("ValaProjectSettings show\n"); + + this.project= project; + + this.compile_flags.el.text = ""; + + this.default_directory_tree_store.load(); + this.default_packages_tree_store.load(); + this.targets_tree_store.load(); + this.files_tree_store.load(); + + } + public class Xcls_Notebook2 : Object + { + public Gtk.Notebook el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Notebook2(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Notebook(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_label_global( _this ); + child_0.ref(); + var child_1 = new Xcls_label_targets( _this ); + child_1.ref(); + var child_2 = new Xcls_VBox5( _this ); + child_2.ref(); + this.el.append_page ( child_2.el , _this.label_global.el ); + var child_3 = new Xcls_HPaned27( _this ); + child_3.ref(); + this.el.append_page ( child_3.el , _this.label_targets.el ); + } + + // user defined functions + } + public class Xcls_label_global : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_label_global(ValaProjectSettings _owner ) + { + _this = _owner; + _this.label_global = this; + this.el = new Gtk.Label( "Global" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_label_targets : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_label_targets(ValaProjectSettings _owner ) + { + _this = _owner; + _this.label_targets = this; + this.el = new Gtk.Label( "Targets" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_VBox5 : Object + { + public Gtk.VBox el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_VBox5(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label6( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_compile_flags( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Label8( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + var child_3 = new Xcls_ScrolledWindow9( _this ); + child_3.ref(); + this.el.pack_start ( child_3.el , true,true,0 ); + var child_4 = new Xcls_Label16( _this ); + child_4.ref(); + this.el.pack_start ( child_4.el , false,false,0 ); + var child_5 = new Xcls_ScrolledWindow17( _this ); + child_5.ref(); + this.el.pack_start ( child_5.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Label6 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label6(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "compile flags" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_compile_flags : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_compile_flags(ValaProjectSettings _owner ) + { + _this = _owner; + _this.compile_flags = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_Label8 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label8(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "packages" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ScrolledWindow9 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow9(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_default_packages_tree( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_default_packages_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_packages_tree(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.headers_visible = false; + var child_0 = new Xcls_default_packages_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn12( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + var child_2 = new Xcls_TreeViewColumn14( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + } + + // user defined functions + } + public class Xcls_default_packages_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_packages_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_packages_tree_store = this; + this.el = new Gtk.ListStore( 2, typeof(string), // 0 key type + typeof(bool) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + var def = _this.project.compilegroups.get("_default_"); + var items = def.packages; + + this.el.clear(); + var pal = (Palete.Gtk) Palete.factory("Gtk"); + var pkgs = pal.packages(); + print("ValaProjectSettings:packages load %d\n", pkgs.size); + + Gtk.TreeIter citer; + + for(var i =0 ; i < pkgs.size; i++) { + this.el.append(out citer); + + this.el.set_value(citer, 0, pkgs.get(i) ); // title + this.el.set_value(citer, 1, items.contains(pkgs.get(i)) ); + } + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + } + public class Xcls_TreeViewColumn12 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn12(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "name"; + this.el.expand = true; + this.el.resizable = true; + var child_0 = new Xcls_packages_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.packages_render.el , "text", 0 ); } + + // user defined functions + } + public class Xcls_packages_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_packages_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.packages_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_TreeViewColumn14 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn14(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "use"; + this.el.resizable = false; + this.el.fixed_width = 50; + var child_0 = new Xcls_packages_render_use( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + { + this.el.add_attribute(_this.packages_render_use.el , "active", 1 ); + } } + + // user defined functions + } + public class Xcls_packages_render_use : Object + { + public Gtk.CellRendererToggle el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_packages_render_use(ValaProjectSettings _owner ) + { + _this = _owner; + _this.packages_render_use = this; + this.el = new Gtk.CellRendererToggle(); + + // my vars (dec) + + // set gobject values + this.el.activatable = true; + + // listeners + this.el.toggled.connect( ( path_string) => { + var m = _this.default_packages_tree_store.el; + Gtk.TreeIter iter; + Gtk.TreePath path = new Gtk.TreePath.from_string (path_string); + m.get_iter (out iter, path); + GLib.Value val; + m.get_value(iter, 1, out val); + m.set_value(iter, 1, ((bool) val) ? false :true); + GLib.Value fval; + m.get_value(iter, 0, out fval); + var fn = (string)fval; + + var def = _this.project.compilegroups.get("_default_"); + var items = def.packages; + if ((bool)val) { + // renive + items.remove(fn); + } else { + items.add(fn); + } + + }); + } + + // user defined functions + } + public class Xcls_Label16 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label16(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Available Directories" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ScrolledWindow17 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow17(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_default_directory_tree( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_default_directory_menu( _this ); + child_1.ref(); + } + + // user defined functions + } + public class Xcls_default_directory_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_directory_tree(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_directory_tree = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.headers_visible = false; + var child_0 = new Xcls_default_directory_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn20( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // listeners + this.el.button_press_event.connect( ( ev) => { + //console.log("button press?"); + + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + //print("click" + ev.type); + return false; + } + //Gtk.TreePath res; + //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) { + // return true; + //} + + // this.el.get_selection().select_path(res); + + //if (!this.get('/LeftTreeMenu').el) { + // this.get('/LeftTreeMenu').init(); + // } + + _this.default_directory_menu.el.set_screen(Gdk.Screen.get_default()); + _this.default_directory_menu.el.show_all(); + _this.default_directory_menu.el.popup(null, null, null, 3, ev.time); + // print("click:" + res.path.to_string()); + return true; + }); + } + + // user defined functions + } + public class Xcls_default_directory_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_directory_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_directory_tree_store = this; + this.el = new Gtk.ListStore( 1, typeof(string) + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + this.el.clear(); + + + var def = _this.project.compilegroups.get("_default_"); + var items = def.sources; + + + Gtk.TreeIter citer; + + for(var i =0 ; i < items.size; i++) { + this.el.append(out citer); + + this.el.set_value(citer, 0, items.get(i) ); // title + //this.el.set_value(citer, 1, items.get(i) ); + } + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + } + public class Xcls_TreeViewColumn20 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn20(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "name"; + this.el.resizable = true; + var child_0 = new Xcls_directory_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.directory_render.el , "text", 0 ); } + + // user defined functions + } + public class Xcls_directory_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_directory_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.directory_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_default_directory_menu : Object + { + public Gtk.Menu el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_default_directory_menu(ValaProjectSettings _owner ) + { + _this = _owner; + _this.default_directory_menu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem23( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_MenuItem24( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_SeparatorMenuItem25( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + var child_3 = new Xcls_MenuItem26( _this ); + child_3.ref(); + this.el.add ( child_3.el ); + } + + // user defined functions + } + public class Xcls_MenuItem23 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem23(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Add Directory"; + + // listeners + this.el.activate.connect( () => { + + var chooser = new Gtk.FileChooserDialog ( + "Add a directory", _this.window.el, Gtk.FileChooserAction.SELECT_FOLDER , + "_Cancel", + Gtk.ResponseType.CANCEL, + "_Add", + Gtk.ResponseType.ACCEPT); + if (chooser.run () != Gtk.ResponseType.ACCEPT) { + chooser.close (); + return; + } + chooser.close (); + // add the directory.. + var fn = _this.project.relPath(chooser.get_filename()); + _this.project.compilegroups.get("_default_").sources.add(fn); + _this.default_directory_tree_store.load(); + }); + } + + // user defined functions + } + public class Xcls_MenuItem24 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem24(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Add File"; + + // listeners + this.el.activate.connect( () => { + + var chooser = new Gtk.FileChooserDialog ( + "Add a directory", _this.window.el, Gtk.FileChooserAction.OPEN , + "_Cancel", + Gtk.ResponseType.CANCEL, + "_Add", + Gtk.ResponseType.ACCEPT); + if (chooser.run () != Gtk.ResponseType.ACCEPT) { + chooser.close (); + return; + } + chooser.close (); + // add the directory.. + var fn = _this.project.relPath(chooser.get_filename()); + _this.project.compilegroups.get("_default_").sources.add(fn); + _this.default_directory_tree_store.load(); + }); + } + + // user defined functions + } + public class Xcls_SeparatorMenuItem25 : Object + { + public Gtk.SeparatorMenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem25(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_MenuItem26 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem26(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Remove File/Directory"; + + // listeners + this.el.activate.connect( () => { + + // + Gtk.TreeModel mod; + Gtk.TreeIter iter; + if (!_this.default_directory_tree.el.get_selection().get_selected(out mod, out iter)) { + print("nothing selected\n"); + return; + } + + + // add the directory.. + + + GLib.Value val; + mod.get_value(iter,0, out val); + var fn = (string) val; + + print("remove: %s\n", fn); + if (!_this.project.compilegroups.get("_default_").sources.remove(fn)) { + print("remove failed"); + } + _this.default_directory_tree_store.load(); + }); + } + + // user defined functions + } + public class Xcls_HPaned27 : Object + { + public Gtk.HPaned el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_HPaned27(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.HPaned(); + + // my vars (dec) + + // set gobject values + this.el.position = 300; + var child_0 = new Xcls_ScrolledWindow28( _this ); + child_0.ref(); + this.el.add1 ( child_0.el ); + var child_1 = new Xcls_set_vbox( _this ); + child_1.ref(); + this.el.add2 ( child_1.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow28 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow28(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_targets_tree_menu( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_targets_tree( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + + // init method + + { + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + } } + + // user defined functions + } + public class Xcls_targets_tree_menu : Object + { + public Gtk.Menu el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_targets_tree_menu(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_tree_menu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem30( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_SeparatorMenuItem31( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_MenuItem32( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuItem30 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem30(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Add Compile Target"; + + // listeners + this.el.activate.connect( () => { + + if (_this.project.compilegroups.has_key("NEW GROUP")) { + return; + } + + // add the directory.. + + _this.project.compilegroups.set("NEW GROUP", new Project.GtkValaSettings("NEW GROUP")); + _this.targets_tree_store.load(); + }); + } + + // user defined functions + } + public class Xcls_SeparatorMenuItem31 : Object + { + public Gtk.SeparatorMenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem31(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_MenuItem32 : Object + { + public Gtk.MenuItem el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem32(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Remove Target"; + + // listeners + this.el.activate.connect( () => { + + // + Gtk.TreeModel mod; + Gtk.TreeIter iter; + if (!_this.targets_tree.el.get_selection().get_selected(out mod, out iter)) { + print("nothing selected\n"); + return; + } + + + // add the directory.. + + + GLib.Value val; + mod.get_value(iter,0, out val); + var fn = (string) val; + + print("remove: %s\n", fn); + if (!_this.project.compilegroups.unset(fn)) { + print("remove failed"); + } + _this.targets_tree_store.load(); + }); + } + + // user defined functions + } + public class Xcls_targets_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + public string cursor; + + // ctor + public Xcls_targets_tree(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_tree = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_targets_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn35( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // listeners + this.el.button_press_event.connect( ( ev) => { + //console.log("button press?"); + + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + //print("click" + ev.type); + return false; + } + //Gtk.TreePath res; + //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) { + // return true; + //} + + // this.el.get_selection().select_path(res); + + //if (!this.get('/LeftTreeMenu').el) { + // this.get('/LeftTreeMenu').init(); + // } + + _this.targets_tree_menu.el.set_screen(Gdk.Screen.get_default()); + _this.targets_tree_menu.el.show_all(); + _this.targets_tree_menu.el.popup(null, null, null, 3, ev.time); + // print("click:" + res.path.to_string()); + return true; + }); + this.el.cursor_changed.connect( ( ) => { + + if (this.cursor != "") { + // save the values.. + } + + // load the new values. + + + Gtk.TreeModel mod; + Gtk.TreeIter iter; + if (!this.el.get_selection().get_selected(out mod, out iter)) { + print("nothing selected\n"); + return; + } + + + // add the directory.. + + + GLib.Value val; + mod.get_value(iter,0, out val); + var fn = (string) val; + + this.cursor = fn; + var cg = _this.project.compilegroups.get(fn); + _this.build_pack_target.el.set_text(cg.target_bin); + _this.build_compile_flags.el.set_text(cg.compile_flags); + // load the srouces + + + }); + } + + // user defined functions + } + public class Xcls_targets_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_targets_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_tree_store = this; + this.el = new Gtk.ListStore( 2, typeof(string), // 0 key type + typeof(string) // ?? + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + this.el.clear(); + + + var cg = _this.project.compilegroups; + + _this.targets_tree.cursor = ""; + Gtk.TreeIter citer; + var iter = cg.map_iterator(); + while(iter.next()) { + var key = iter.get_key(); + if (key == "_default_") { + continue; + } + + this.el.append(out citer); + + this.el.set_value(citer, 0, key ); // title + //this.el.set_value(citer, 1, items.get(i) ); + }; + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + } + public class Xcls_TreeViewColumn35 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn35(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "name"; + this.el.resizable = true; + var child_0 = new Xcls_targets_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + { + this.el.add_attribute(_this.targets_render.el , "text", 0 ); + } } + + // user defined functions + } + public class Xcls_targets_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_targets_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.targets_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + this.el.editable = true; + + // listeners + this.el.edited.connect( (path, newtext) => { + + Gtk.TreeIter iter; + _this.targets_tree_store.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + _this.targets_tree_store.el.get_value(iter,0, out gval); + var oldval = (string)gval; + if (oldval == newtext) { + return; + } + var cg = _this.project.compilegroups.get(oldval); + cg.name = newtext; + _this.project.compilegroups.unset(oldval); + _this.project.compilegroups.set(newtext, cg); + _this.targets_tree_store.load(); + }); + } + + // user defined functions + } + public class Xcls_set_vbox : Object + { + public Gtk.VBox el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_set_vbox(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Label38( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_build_pack_target( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Label40( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + var child_3 = new Xcls_build_compile_flags( _this ); + child_3.ref(); + this.el.pack_start ( child_3.el , false,false,0 ); + var child_4 = new Xcls_Label42( _this ); + child_4.ref(); + this.el.pack_start ( child_4.el , false,false,0 ); + var child_5 = new Xcls_ScrolledWindow43( _this ); + child_5.ref(); + this.el.pack_start ( child_5.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_Label38 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label38(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "target filename" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_build_pack_target : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_build_pack_target(ValaProjectSettings _owner ) + { + _this = _owner; + _this.build_pack_target = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + // listeners + this.el.changed.connect( () => { + if (_this.targets_tree.cursor.length < 1) { + return; + } + _this.project.compilegroups.get(_this.targets_tree.cursor).target_bin = this.el.text; + }); + } + + // user defined functions + } + public class Xcls_Label40 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label40(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "compile flags" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_build_compile_flags : Object + { + public Gtk.Entry el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_build_compile_flags(ValaProjectSettings _owner ) + { + _this = _owner; + _this.build_compile_flags = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + + // listeners + this.el.changed.connect( () => { + if (_this.targets_tree.cursor.length < 1) { + return; + } + _this.project.compilegroups.get(_this.targets_tree.cursor).compile_flags = this.el.text; + }); + } + + // user defined functions + } + public class Xcls_Label42 : Object + { + public Gtk.Label el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_Label42(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Files to compile" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ScrolledWindow43 : Object + { + public Gtk.ScrolledWindow el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow43(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_files_tree( _this ); + child_0.ref(); + } + + // user defined functions + } + public class Xcls_files_tree : Object + { + public Gtk.TreeView el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_tree(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_files_tree_store( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn46( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + var child_2 = new Xcls_TreeViewColumn48( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + } + + // user defined functions + } + public class Xcls_files_tree_store : Object + { + public Gtk.ListStore el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_tree_store(ValaProjectSettings _owner ) + { + _this = _owner; + _this.files_tree_store = this; + this.el = new Gtk.ListStore( 2, typeof(string), // 0 file name + typeof(string), // type (dir orfile) + typeof(bool) // is checked. + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void load () { + + this.el.clear(); + + + var def = _this.project.compilegroups.get("_default_"); + var items = def.sources; + + + Gtk.TreeIter citer; + + for(var i =0 ; i < items.size; i++) { + this.el.append(out citer); + + this.el.set_value(citer, 0, items.get(i) ); // title + this.el.set_value(citer, 1, "dir"); // type + this.el.set_value(citer, 2, false ); // checked + /* + var files = def.files(items.get(i)); + + for(var j =0 ; j < files.size; j++) { + this.el.append(out citer); + + this.el.set_value(citer, 0, files.get(j) ); // title + this.el.set_value(citer, 1, "file"); // type + this.el.set_value(citer, 2, false ); // checked + + } + */ + + //this.el.set_value(citer, 1, items.get(i) ); + } + this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + } + public class Xcls_TreeViewColumn46 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn46(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "name"; + this.el.resizable = true; + var child_0 = new Xcls_files_render( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + /* this.el.add_attribute(_this.files_render.el , "markup", 2 ); + // this.el.add_attribute(_this.files_render.el , "text", 1 ); */ } + + // user defined functions + } + public class Xcls_files_render : Object + { + public Gtk.CellRendererText el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_render(ValaProjectSettings _owner ) + { + _this = _owner; + _this.files_render = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_TreeViewColumn48 : Object + { + public Gtk.TreeViewColumn el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn48(ValaProjectSettings _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "use"; + this.el.resizable = false; + this.el.fixed_width = 50; + var child_0 = new Xcls_files_render_use( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + /* + + this.el.add_attribute(_this.packages_render_use.el , "active", 1 ); + + */ } + + // user defined functions + } + public class Xcls_files_render_use : Object + { + public Gtk.CellRendererToggle el; + private ValaProjectSettings _this; + + + // my vars (def) + + // ctor + public Xcls_files_render_use(ValaProjectSettings _owner ) + { + _this = _owner; + _this.files_render_use = this; + this.el = new Gtk.CellRendererToggle(); + + // my vars (dec) + + // set gobject values + this.el.activatable = true; + + // listeners + this.el.toggled.connect( ( path_string) => { + var m = _this.default_packages_tree_store.el; + Gtk.TreeIter iter; + Gtk.TreePath path = new Gtk.TreePath.from_string (path_string); + m.get_iter (out iter, path); + GLib.Value val; + m.get_value(iter, 1, out val); + m.set_value(iter, 1, ((bool) val) ? false :true); + GLib.Value fval; + m.get_value(iter, 0, out fval); + var fn = (string)fval; + + var def = _this.project.compilegroups.get("_default_"); + var items = def.packages; + if ((bool)val) { + // renive + items.remove(fn); + } else { + items.add(fn); + } + + }); + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/WindowAddProp.bjs b/old-javascript/Builder4/WindowAddProp.bjs new file mode 100644 index 000000000..6e334944d --- /dev/null +++ b/old-javascript/Builder4/WindowAddProp.bjs @@ -0,0 +1,61 @@ +{ + "id": "file-gtk-14", + "name": "WindowAddProp", + "parent": "", + "title": false, + "path": "/home/alan/gitlive/app.Builder.js/Builder4/WindowAddProp.bjs", + "items": [ + { + "|void:clear": "() {\n this.model.el.clear();\n\n}", + ".signal:void:select": "(string key, string type, string skel, string etype)", + "id": "WindowAddProp", + "xtype": "ScrolledWindow", + "|init": " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n ", + "|shadow_type": "Gtk.ShadowType.IN", + "|void:show": "(Palete.Palete pal, string etype, string xtype) {\n this.model.el.clear();\n\n Gtk.TreeIter iter;\n var elementList = pal.getPropertiesFor( xtype,etype);\n \n \n //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);\n // console.dump(elementList);\n \n var miter = elementList.map_iterator();\n while (miter.next()) {\n var p = miter.get_value();\n \n this.model.el.append(out iter);\n\n this.model.el.set(iter,\n 0, p.name, \n 1, p.type,\n 2, \"\" + p.name +\" \"+p.type+\"\\n\" + \n GLib.Markup.escape_text(p.doctxt),\n 3, p.sig,\n 4, \"\" + p.name +\" \"+p.type+\"\",\n 5, etype,\n -1\n );\n }\n this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n}\n", + "|xns": "Gtk", + "items": [ + { + "listeners": { + "row_activated": "(path, column) => {\n\n Gtk.TreeIter iter;\n\n\n var m = _this.model;\n \n m.el.get_iter(out iter,path);\n \n \n // var val = \"\";\n \n \n var key = m.getValue(iter, 0);\n \n var type = m.getValue(iter, 1);\n var skel = m.getValue(iter, 3);\n var etype = m.getValue(iter, 5);\n \n \n _this.select(key,etype == \"signals\" ? \"\" : type,skel, etype);\n \n}\n" + }, + "pack": "add", + "tooltip_column": 2, + "xtype": "TreeView", + "|enable_tree_lines": "true", + "|headers_visible": "false", + "|init": "{ \n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.modify_font(description); \n \n this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);\n \n\n \n \n \n}\n", + "|xns": "Gtk", + "items": [ + { + "id": "model", + "n_columns": 6, + "pack": "set_model", + "xtype": "ListStore", + "|columns": "typeof(string), // 0 real key\ntypeof(string), // 1 real type\ntypeof(string), // 2 docs ?\ntypeof(string), // 3 visable desc\ntypeof(string), // 4 function desc\ntypeof(string) // 5 element type (event|prop)\n ", + "|string:getValue": "(Gtk.TreeIter iter, int col)\n{\n\n GLib.Value value;\n this.el.get_value(iter, col, out value);\n\n return (string)value;\n \n}", + "|xns": "Gtk" + }, + { + "id": "namecol", + "pack": "append_column", + "xtype": "TreeViewColumn", + "|init": " this.el.add_attribute(_this.namerender.el , \"markup\", 4 );\n \n", + "|xns": "Gtk", + "items": [ + { + "id": "namerender", + "pack": "pack_start,true", + "xtype": "CellRendererText", + "|xns": "Gtk" + } + ] + } + ] + } + ] + } + ], + "permname": "", + "modOrder": "" +} \ No newline at end of file diff --git a/old-javascript/Builder4/WindowAddProp.vala b/old-javascript/Builder4/WindowAddProp.vala new file mode 100644 index 000000000..8eba9eeee --- /dev/null +++ b/old-javascript/Builder4/WindowAddProp.vala @@ -0,0 +1,255 @@ +/* -- to compile +valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \ + /tmp/WindowAddProp.vala -o /tmp/WindowAddProp +*/ + + +/* -- to test class +static int main (string[] args) { + Gtk.init (ref args); + new Xcls_WindowAddProp(); + WindowAddProp.show_all(); + Gtk.main (); + return 0; +} +*/ + + +public static Xcls_WindowAddProp WindowAddProp; + +public class Xcls_WindowAddProp : Object +{ + public Gtk.ScrolledWindow el; + private Xcls_WindowAddProp _this; + + public Xcls_model model; + public Xcls_namecol namecol; + public Xcls_namerender namerender; + + // my vars + public signal void select(string key, string type, string skel, string etype); + + // ctor + public Xcls_WindowAddProp() + { + _this = this; + WindowAddProp = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_TreeView2( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + + } + + // userdefined functions + public void clear() { + this.model.el.clear(); + + } + public void show(Palete.Palete pal, string etype, string xtype) { + this.model.el.clear(); + + Gtk.TreeIter iter; + var elementList = pal.getPropertiesFor( xtype,etype); + + + //print ("GOT " + elementList.length + " items for " + fullpath + "|" + type); + // console.dump(elementList); + + var miter = elementList.map_iterator(); + while (miter.next()) { + var p = miter.get_value(); + + this.model.el.append(out iter); + + this.model.el.set(iter, + 0, p.name, + 1, p.type, + 2, "" + p.name +" "+p.type+"\n" + + GLib.Markup.escape_text(p.doctxt), + 3, p.sig, + 4, "" + p.name +" "+p.type+"", + 5, etype, + -1 + ); + } + this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + + // skip |xns - no return type + public class Xcls_TreeView2 : Object + { + public Gtk.TreeView el; + private Xcls_WindowAddProp _this; + + + // my vars + + // ctor + public Xcls_TreeView2(Xcls_WindowAddProp _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars + + // set gobject values + this.el.enable_tree_lines = true; + this.el.headers_visible = false; + this.el.tooltip_column = 2; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_namecol( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + { + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.modify_font(description); + + this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE); + + + + + + } + + // listeners + this.el.row_activated.connect( (path, column) => { + + Gtk.TreeIter iter; + + + var m = _this.model; + + m.el.get_iter(out iter,path); + + + // var val = ""; + + + var key = m.getValue(iter, 0); + + var type = m.getValue(iter, 1); + var skel = m.getValue(iter, 3); + var etype = m.getValue(iter, 5); + + + _this.select(key,etype == "signals" ? "" : type,skel, etype); + + } + ); + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_WindowAddProp _this; + + + // my vars + + // ctor + public Xcls_model(Xcls_WindowAddProp _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 6, typeof(string), // 0 real key +typeof(string), // 1 real type +typeof(string), // 2 docs ? +typeof(string), // 3 visable desc +typeof(string), // 4 function desc +typeof(string) // 5 element type (event|prop) + ); + + // my vars + + // set gobject values + } + + // userdefined functions + public string getValue(Gtk.TreeIter iter, int col) + { + + GLib.Value value; + this.el.get_value(iter, col, out value); + + return (string)value; + + } + + // skip |xns - no return type + } + public class Xcls_namecol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_WindowAddProp _this; + + + // my vars + + // ctor + public Xcls_namecol(Xcls_WindowAddProp _owner ) + { + _this = _owner; + _this.namecol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars + + // set gobject values + var child_0 = new Xcls_namerender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + this.el.add_attribute(_this.namerender.el , "markup", 4 ); + + } + + // userdefined functions + + // skip |xns - no return type + } + public class Xcls_namerender : Object + { + public Gtk.CellRendererText el; + private Xcls_WindowAddProp _this; + + + // my vars + + // ctor + public Xcls_namerender(Xcls_WindowAddProp _owner ) + { + _this = _owner; + _this.namerender = this; + this.el = new Gtk.CellRendererText(); + + // my vars + + // set gobject values + } + + // userdefined functions + + // skip |xns - no return type + } +} diff --git a/old-javascript/Builder4/WindowLeftProjects.bjs b/old-javascript/Builder4/WindowLeftProjects.bjs new file mode 100644 index 000000000..61f0c255d --- /dev/null +++ b/old-javascript/Builder4/WindowLeftProjects.bjs @@ -0,0 +1,75 @@ +{ + "name" : "WindowLeftProjects", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/WindowLeftProjects.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "listeners" : { + "show" : " ( ) => {\n this.load();\n}" + }, + "@ void project_selected" : "(Project.Project project)", + "id" : "WindowLeftProjects", + "| void load" : "() {\n // clear list...\n \n if (_this.is_loaded) {\n return;\n }\n _this.is_loading = true;\n \n _this.is_loaded = true;\n \n Project.Project.loadAll();\n var projects = Project.Project.allProjectsByName();\n \n Gtk.TreeIter iter;\n var m = this.model.el;\n m.clear();\n \n for (var i = 0; i < projects.size; i++) {\n m.append(out iter);\n m.set(iter, 0,projects.get(i).name );\n \n var o = new GLib.Value(typeof(Object));\n o.set_object((Object)projects.get(i));\n \n m.set_value(iter, 1, o);\n \n }\n m.set_sort_column_id(0, Gtk.SortType.ASCENDING);\n _this.is_loading = false; \n}\n", + "# bool is_loaded" : false, + "* pack" : "add", + "xtype" : "VBox", + "| Project.Project? getSelectedProject" : "() { \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n var s = this.view.el.get_selection();\n if (!s.get_selected(out mod, out iter)) {\n return null;\n }\n \n GLib.Value gval;\n\n mod.get_value(iter, 1 , out gval);\n var project = (Project.Project)gval.get_object();\n \n return project;\n}", + "| void selectProject" : "(Project.Project project) {\n \n var sel = _this.view.el.get_selection();\n \n sel.unselect_all();\n \n var found = false;\n _this.model.el.foreach((mod, path, iter) => {\n GLib.Value val;\n \n mod.get_value(iter, 1, out val);\n if ( ( (Project.Project)val.get_object()).fn != project.fn) {\n print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);\n return false;//continue\n }\n sel.select_iter(iter);\n this.project_selected(project);\n found = true;\n return true;\n \n \n });\n if (!found) {\n\t print(\"tried to select %s, could not find it\", project.name);\n }\n}\n", + "# bool is_loading" : false, + "$ xns" : "Gtk", + "$ homogeneous" : false, + "@ void show_new_project" : "()", + "items" : [ + { + "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "cursor_changed" : " () => {\n if (_this.is_loading) {\n return;\n }\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n var s = this.el.get_selection();\n if (!s.get_selected(out mod, out iter)) {\n return;\n }\n \n GLib.Value gval;\n\n mod.get_value(iter, 1 , out gval);\n var project = (Project.Project)gval.get_object();\n \n _this.project_selected(project);\n \n}" + }, + "id" : "view", + "* init" : " var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.modify_font(description); \n \n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n \n\n \n \n", + "xtype" : "TreeView", + "* pack" : "add", + "$ enable_tree_lines" : true, + "$ headers_visible" : false, + "$ xns" : "Gtk", + "items" : [ + { + "id" : "model", + "* init" : "{\n this.el.set_sort_func(0, (mod,a,b) => {\n GLib.Value ga, gb;\n mod.get_value(a,0, out ga);\n mod.get_value(b,0, out gb);\n \n if ((string)ga == (string)gb) {\n return 0;\n }\n return (string)ga > (string)gb ? 1 : -1;\n }); \n\n\n}\n", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string), typeof(Object)", + "n_columns" : 2, + "$ xns" : "Gtk" + }, + { + "* init" : "\n this.el.add_attribute(_this.namecol.el , \"markup\", 0 );\n ", + "xtype" : "TreeViewColumn", + "* pack" : "append_column", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "namecol", + "* pack" : "pack_start,true", + "xtype" : "CellRendererText", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/WindowLeftProjects.vala b/old-javascript/Builder4/WindowLeftProjects.vala new file mode 100644 index 000000000..4c45eda84 --- /dev/null +++ b/old-javascript/Builder4/WindowLeftProjects.vala @@ -0,0 +1,295 @@ +static Xcls_WindowLeftProjects _WindowLeftProjects; + +public class Xcls_WindowLeftProjects : Object +{ + public Gtk.VBox el; + private Xcls_WindowLeftProjects _this; + + public static Xcls_WindowLeftProjects singleton() + { + if (_WindowLeftProjects == null) { + _WindowLeftProjects= new Xcls_WindowLeftProjects(); + } + return _WindowLeftProjects; + } + public Xcls_view view; + public Xcls_model model; + public Xcls_namecol namecol; + + // my vars (def) + public signal void project_selected (Project.Project project); + public bool is_loaded; + public bool is_loading; + public signal void show_new_project (); + + // ctor + public Xcls_WindowLeftProjects() + { + _this = this; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + this.is_loaded = false; + this.is_loading = false; + + // set gobject values + var child_0 = new Xcls_ScrolledWindow2( _this ); + child_0.ref(); + this.el.pack_end ( child_0.el , true,true,0 ); + + // listeners + this.el.show.connect( ( ) => { + this.load(); + }); + } + + // user defined functions + public void load () { + // clear list... + + if (_this.is_loaded) { + return; + } + _this.is_loading = true; + + _this.is_loaded = true; + + Project.Project.loadAll(); + var projects = Project.Project.allProjectsByName(); + + Gtk.TreeIter iter; + var m = this.model.el; + m.clear(); + + for (var i = 0; i < projects.size; i++) { + m.append(out iter); + m.set(iter, 0,projects.get(i).name ); + + var o = new GLib.Value(typeof(Object)); + o.set_object((Object)projects.get(i)); + + m.set_value(iter, 1, o); + + } + m.set_sort_column_id(0, Gtk.SortType.ASCENDING); + _this.is_loading = false; + } + public Project.Project? getSelectedProject () { + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.view.el.get_selection(); + if (!s.get_selected(out mod, out iter)) { + return null; + } + + GLib.Value gval; + + mod.get_value(iter, 1 , out gval); + var project = (Project.Project)gval.get_object(); + + return project; + } + public void selectProject (Project.Project project) { + + var sel = _this.view.el.get_selection(); + + sel.unselect_all(); + + var found = false; + _this.model.el.foreach((mod, path, iter) => { + GLib.Value val; + + mod.get_value(iter, 1, out val); + if ( ( (Project.Project)val.get_object()).fn != project.fn) { + print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name); + return false;//continue + } + sel.select_iter(iter); + this.project_selected(project); + found = true; + return true; + + + }); + if (!found) { + print("tried to select %s, could not find it", project.name); + } + } + public class Xcls_ScrolledWindow2 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow2(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.TreeView el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_view(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.enable_tree_lines = true; + this.el.headers_visible = false; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn5( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.modify_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + // listeners + this.el.cursor_changed.connect( () => { + if (_this.is_loading) { + return; + } + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.el.get_selection(); + if (!s.get_selected(out mod, out iter)) { + return; + } + + GLib.Value gval; + + mod.get_value(iter, 1 , out gval); + var project = (Project.Project)gval.get_object(); + + _this.project_selected(project); + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string), typeof(Object) ); + + // my vars (dec) + + // set gobject values + + // init method + + { + this.el.set_sort_func(0, (mod,a,b) => { + GLib.Value ga, gb; + mod.get_value(a,0, out ga); + mod.get_value(b,0, out gb); + + if ((string)ga == (string)gb) { + return 0; + } + return (string)ga > (string)gb ? 1 : -1; + }); + + + } } + + // user defined functions + } + public class Xcls_TreeViewColumn5 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn5(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_namecol( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.namecol.el , "markup", 0 ); } + + // user defined functions + } + public class Xcls_namecol : Object + { + public Gtk.CellRendererText el; + private Xcls_WindowLeftProjects _this; + + + // my vars (def) + + // ctor + public Xcls_namecol(Xcls_WindowLeftProjects _owner ) + { + _this = _owner; + _this.namecol = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/WindowLeftProps.bjs b/old-javascript/Builder4/WindowLeftProps.bjs new file mode 100644 index 000000000..d9176bfc3 --- /dev/null +++ b/old-javascript/Builder4/WindowLeftProps.bjs @@ -0,0 +1,305 @@ +{ + "name" : "WindowLeftProps", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/WindowLeftProps.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "# bool allow_edit" : false, + "| void before_edit" : "()\n{\n\n print(\"before edit - stop editing\\n\");\n \n // these do not appear to trigger save...\n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n\n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false; \n \n \n// technicall stop the popup editor..\n\n}\n", + "id" : "LeftProps", + "| string keySortFormat" : "(string key) {\n // listeners first - with 0\n // specials\n if (key[0] == '*') {\n return \"1 \" + key;\n }\n // functions\n \n var bits = key.split(\" \");\n \n if (key[0] == '|') {\n return \"2 \" + bits[bits.length -1];\n }\n // signals\n if (key[0] == '@') {\n return \"3 \" + bits[bits.length -1];\n }\n \n // props\n if (key[0] == '#') {\n return \"4 \" + bits[bits.length -1];\n }\n // the rest..\n return \"5 \" + bits[bits.length -1]; \n\n\n\n}", + "| void finish_editing" : "() {\n // \n this.before_edit();\n}", + "| bool startEditingValue" : "( Gtk.TreePath path) {\n\n // ONLY return true if editing is allowed - eg. combo..\n \n print(\"start editing?\\n\");\n if (!this.stop_editor()) {\n print(\"stop editor failed\\n\");\n return false;\n }\n \n Gtk.TreeIter iter;\n\n var mod = this.model.el;\n mod.get_iter (out iter, path);\n \n /*\n m.set(iter, \n 0, \"listener\",\n 1, miter.get_key(),\n 2, \"\" + miter.get_key() + \"\",\n 3, miter.get_value()\n ); \n \n */\n GLib.Value gval;\n mod.get_value(iter, 3 , out gval);\n var val = (string)gval;\n \n mod.get_value(iter, 1 , out gval);\n var key = (string)gval;\n var type_ar = key.split(\" \");\n \n \n \n mod.get_value(iter, 0 , out gval);\n var type = (string)gval;\n \n \n \n var use_textarea = false;\n\n //------------ things that require the text editor...\n \n if (type == \"listener\") {\n use_textarea = true;\n }\n if (key.length > 0 && key[0] == '|') { // user defined method\n use_textarea = true;\n }\n if (key.length > 0 && key[0] == '$') { // raw string\n use_textarea = true;\n }\n if (key.length > 0 && key == \"* init\") {\n use_textarea = true;\n }\n if (val.length > 40) { // long value...\n use_textarea = true;\n }\n \n \n \n if (use_textarea) {\n print(\"Call show editor\\n\");\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.view.el.get_selection().select_path(path);\n \n this.show_editor(file, node, type, key);\n \n return false;\n });\n \n \n return false;\n }\n // others... - fill in options for true/false?\n print(\"turn on editing %s \\n\" , mod.get_path(iter).to_string());\n \n print (type_ar[0].up());\n if (type_ar.length > 1 && (\n type_ar[0].up() == \"BOOLEAN\"\n ||\n type_ar[0].up() == \"BOOL\" \n )) {\n print(\"start editing try/false)???\");\n this.valrender.el.has_entry = false;\n string[] opts = { \"true\", \"false\" };\n this.valrender.setOptions(opts);\n \n this.valrender.el.has_entry = false;\n this.valrender.el.editable = true;\n this.allow_edit = true;\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n this.view.el.set_cursor_on_cell(\n path,\n this.valcol.el,\n this.valrender.el,\n true\n );\n return false;\n });\n return true;\n }\n \n \n \n string[] opts = { };\n this.valrender.setOptions(opts);\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n // at this point - work out the type...\n // if its' a combo... then show the options..\n this.valrender.el.has_entry = true;\n \n this.valrender.el.editable = true; \n \n \n this.allow_edit = true;\n \n \n \n \n\n this.view.el.set_cursor_on_cell(\n path,\n this.valcol.el,\n this.valrender.el,\n true\n );\n return false;\n });\n return false;\n }\n", + "| void load" : "(JsRender.JsRender file, JsRender.Node? node) \n{\n print(\"load leftprops\\n\");\n this.before_edit();\n this.node = node;\n this.file = file;\n \n \n this.model.el.clear();\n \n //this.get('/RightEditor').el.hide();\n if (node ==null) {\n return ;\n }\n \n \n\n //var provider = this.get('/LeftTree').getPaleteProvider();\n Gtk.TreeIter iter;\n \n //typeof(string), // 0 key type\n //typeof(string), // 1 key\n //typeof(string), // 2 key (display)\n //typeof(string), // 3 value\n //typeof(string), // 4 value (display)\n //typeof(string), // 5 both (tooltip)\n \n \n \n \n // really need a way to sort the hashmap...\n var m = this.model.el;\n \n var miter = node.listeners.map_iterator();\n var i = 0;\n \n while(miter.next()) {\n i++;\n m.append(out iter,null);\n \n this.updateIter(iter, \"listener\", miter.get_key(), miter.get_value());\n \n \n }\n \n \n miter = node.props.map_iterator();\n \n \n while(miter.next()) {\n i++;\n m.append(out iter,null);\n this.updateIter(iter, \"prop\", miter.get_key(), miter.get_value());\n \n }\n print(\"clear selection\\n\");\n // clear selection?\n this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..\n \n this.view.el.get_selection().unselect_all();\n \n var pane = _this.main_window.editpane.el;\n var try_size = (i * 25) + 60; // est. 20px per line + 40px header\n \n // max 80%...\n pane.set_position( \n ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ? \n (int) (pane.max_position * 0.2f) :\n pane.max_position-try_size);\n \n \n}\n", + "xtype" : "VBox", + "| string keyFormat" : "(string val, string type) {\n \n // Glib.markup_escape_text(val);\n\n if (type == \"listener\") {\n return \"\" + \n GLib.Markup.escape_text(val) +\n \"\";\n }\n // property..\n if (val.length < 1) {\n return \"--empty--\";\n }\n \n //@ = signal\n //$ = property with \n //# - object properties\n //* = special\n // all of these... - display value is last element..\n var ar = val.strip().split(\" \");\n \n \n var dval = GLib.Markup.escape_text(ar[ar.length-1]);\n \n \n \n \n switch(val[0]) {\n case '@': // signal // just bold balck?\n if (dval[0] == '@') {\n dval = dval.substring(1);\n }\n \n return @\"@ $dval\"; \n case '#': // object properties?\n if (dval[0] == '#') {\n dval = dval.substring(1);\n }\n return @\"$dval\";\n case '*': // special\n if (dval[0] == '*') {\n dval = dval.substring(1);\n }\n return @\"$dval\"; \n case '$':\n if (dval[0] == '$') {\n dval = dval.substring(1);\n }\n return @\"$dval\";\n case '|': // user defined methods\n if (dval[0] == '|') {\n dval = dval.substring(1);\n }\n return @\"$dval\";\n \n \n \n default:\n return dval;\n }\n \n \n\n}", + "# JsRender.JsRender file" : "", + "@ bool stop_editor" : "()", + "@ void show_editor" : "(JsRender.JsRender file, JsRender.Node node, string type, string key)", + "@ void changed" : "()", + "| void deleteSelected" : " () {\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n var s = this.view.el.get_selection();\n s.get_selected(out mod, out iter);\n \n \n GLib.Value gval;\n mod.get_value(iter, 0 , out gval);\n var type = (string)gval;\n \n mod.get_value(iter, 1 , out gval);\n var key = (string)gval;\n \n switch(type) {\n case \"listener\":\n this.node.listeners.remove(key);\n break;\n \n case \"props\":\n this.node.props.remove(key);\n break;\n }\n this.load(this.file, this.node);\n \n _this.changed();\n}", + "$ xns" : "Gtk", + "| void startEditingKey" : "( Gtk.TreePath path) {\n \n if (!this.stop_editor()) {\n return;\n }\n \n // others... - fill in options for true/false?\n \n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.allow_edit = true;\n this.keyrender.el.editable = true;\n \n this.view.el.set_cursor_on_cell(\n path,\n this.keycol.el,\n this.keyrender.el,\n true\n );\n \n return false;\n });\n \n \n}\n", + "@ void show_add_props" : "(string type)", + "$ homogeneous" : "false ", + "# Xcls_MainWindow main_window" : "null", + "| void addProp" : " (string in_type, string key, string value, string value_type) {\n // info includes key, val, skel, etype..\n //console.dump(info);\n //type = info.type.toLowerCase();\n //var data = this.toJS();\n \n var type = in_type == \"signals\" ? \"listener\" : in_type;\n \n var fkey = (value_type.length > 0 ? value_type + \" \" : \"\") + key;\n \n if (type == \"listener\") {\n if (this.node.listeners.has_key(key)) {\n return;\n }\n this.node.listeners.set(key,value);\n } else {\n \n if (this.node.props.has_key(fkey)) {\n return;\n }\n this.node.props.set(fkey,value);\n }\n \n \n // add a row???\n this.load(this.file, this.node);\n \n \n \n /// need to find the row which I've just added..\n \n \n var s = this.view.el.get_selection();\n s.unselect_all();\n \n print(\"trying to find new iter\");\n \n this.model.el.foreach((model, path, iter) => {\n GLib.Value gval;\n \n this.model.el.get_value(iter, 0 , out gval);\n if ((string)gval != type) {\n print(\"not type: %s = %s\\n\", (string)gval , type);\n return false;\n }\n this.model.el.get_value(iter, 1 , out gval);\n if ((string)gval != fkey) {\n print(\"not key: %s = %s\\n\", (string)gval , fkey);\n return false;\n }\n // delay this?\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {\n \n this.startEditingValue(this.model.el.get_path(iter));\n return false;\n });\n //s.select_iter(iter);\n return true; \n });\n \n \n \n \n}\n", + "| void updateIter" : "(Gtk.TreeIter iter, string type, string key, string value) {\n\n print(\"update Iter %s, %s\\n\", key,value);\n //typeof(string), // 0 key type\n //typeof(string), // 1 key\n //typeof(string), // 2 key (display)\n //typeof(string), // 3 value\n //typeof(string), // 4 value (display)\n //typeof(string), // 5 both (tooltip)\n //typeof(string), // 6 key (sort)\n \n var dl = value.strip().split(\"\\n\");\n\n var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];\n \n if (type == \"listener\") {\n \n \n \n this.model.el.set(iter, \n 0, type,\n 1, key,\n 2, this.keyFormat(key ,type),\n 3, value,\n 4, dis_val,\n 5, \"\" + GLib.Markup.escape_text(key + \" \" +value) + \"\",\n 6, \"0 \" + key\n ); \n return;\n }\n \n\n\n this.model.el.set(iter, \n 0, \"props\",\n 1, key,\n 2, this.keyFormat(key , \"prop\"),\n 3, value,\n 4, dis_val,\n 5, \"\" + GLib.Markup.escape_text(key + \" \" + value) + \"\",\n 6, this.keySortFormat(key)\n ); \n}", + "# JsRender.Node node" : "", + "items" : [ + { + "* pack" : "pack_start,false,true,0", + "xtype" : "HBox", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " (self, ev) => {\n _this.before_edit();\n \n \n var p = _this.AddPropertyPopup;\n p.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, ev.button, ev.time);\n return true;\n}" + }, + "* pack" : "add", + "xtype" : "Button", + "$ xns" : "Gtk", + "items" : [ + { + "* pack" : "add", + "xtype" : "HBox", + "$ xns" : "Gtk", + "items" : [ + { + "xtype" : "Image", + "$ stock" : "Gtk.STOCK_ADD", + "* pack" : "add", + "$ xns" : "Gtk", + "$ icon_size" : "Gtk.IconSize.MENU" + }, + { + "label" : "Other", + "* pack" : "add", + "xtype" : "Label", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "AddPropertyPopup", + "* pack" : false, + "xtype" : "Menu", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : " () => {\n _this.addProp( \"prop\", \"id\", \"\", \"\");\n}" + }, + "label" : "id: _this.{ID} (Vala)", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Using _this.{ID} will map to this element", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"pack\",\"add\", \"*\");\n}" + }, + "label" : "pack: Pack method (Vala)", + "xtype" : "MenuItem", + "* pack" : "append", + "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"ctor\",\"\", \"*\");\n}" + }, + "label" : "ctor: Alterative to default contructor", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "eg. \n\nnew Clutter.Image.from_file(.....)", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) => {\n\n _this.addProp( \"prop\", \"init\", \"{\\n\\n}\\n\", \"*\" );\n}" + }, + "label" : "init: initialziation code (vala)", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "This code is called after the ctor", + "$ xns" : "Gtk" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " (self) => {\n\n _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");\n\n}" + }, + "label" : "String", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a user defined string property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"XXX\", \"0\", \"int\");\n}" + }, + "label" : "Number", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a user defined number property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXX\", \"true\", \"bool\");\n}" + }, + "label" : "Boolean", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a user defined boolean property", + "$ xns" : "Gtk" + }, + { + "* pack" : "add", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp(\"prop\", \"XXXX\", \"function() { }\", \"| function\");\n}" + }, + "label" : "Javascript Function", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a user function boolean property", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\n _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| return_type\");\n}" + }, + "label" : "Vala Method", + "* pack" : "append", + "xtype" : "MenuItem", + "tooltip_markup" : "Add a user function boolean property", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + }, + { + "# bool editing" : false, + "id" : "EditProps", + "* init" : " {\n \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n \n Gtk.TreeViewColumn col;\n int cell_x;\n int cell_y;\n Gtk.TreePath path;\n if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {\n print(\"nothing selected on click\");\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.el.get_selection().unselect_all();\n\n return false;\n });\n _this.before_edit();\n return false; //not on a element.\n }\n \n \n // right click.\n if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == \"Name\") { \n // show popup!. \n \n \n _this.before_edit();\n \n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n \n _this.valrender.el.stop_editing(false);\n _this.valrender.el.editable =false;\n \n _this.startEditingKey(path); \n \n return false;\n }\n \n \n \n \n // right click.\n if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) { \n // show popup!. \n //if (col.title == \"Value\") {\n // _this.before_edit();\n // return false;\n //}\n\n var p = _this.ContextMenu;\n\n p.el.set_screen(Gdk.Screen.get_default());\n p.el.show_all();\n p.el.popup(null, null, null, ev.button, ev.time);\n //Seed.print(\"click:\" + res.column.title);\n // select the \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n this.el.get_selection().select_path(path);\n return false;\n });\n _this.before_edit();\n return false;\n }\n \n \n if (col.title != \"Value\") {\n print(\"col title != Value\");\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n this.el.get_selection().select_path(path);\n return false;\n });\n \n _this.before_edit();\n // XObject.error(\"column is not value?\");\n return false; // ignore.. - key click.. ??? should we do this??\n }\n \n \n // if the cell can be edited with a pulldown\n // then we should return true... - and let the start_editing handle it?\n \n \n \n \n \n \n // _this.before_edit(); <<< we really need to stop the other editor..\n _this.keyrender.el.stop_editing(false);\n _this.keyrender.el.editable =false;\n \n \n return _this.startEditingValue(path); // assumes selected row..\n \n \n\n \n \n}" + }, + "id" : "view", + "* init" : "{\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.modify_font(description);\n}\n", + "tooltip_column" : 5, + "xtype" : "TreeView", + "$ enable_tree_lines" : true, + "$ headers_visible" : true, + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "model", + "$ 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", + "* pack" : "set_model", + "xtype" : "TreeStore", + "$ columns" : " typeof(string), // 0 key type\n typeof(string), // 1 key\n typeof(string), // 2 key (display)\n typeof(string), // 3 value\n typeof(string), // 4 value (display)\n typeof(string), // 5 both (tooltip) \n typeof(string) // 6 key (for sorting)\n", + "n_columns" : 7, + "$ xns" : "Gtk", + "$ toShort" : "function(str) {\n var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];\n return a.length > 1 ? a[0] + '....' : '' + str;\n}\n" + }, + { + "id" : "keycol", + "* init" : " this.el.add_attribute(_this.keyrender.el , \"markup\", 2 );\n this.el.add_attribute(_this.keyrender.el , \"text\", 1 );\n ", + "title" : "Name", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "$ resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "editing_started" : "( editable, path) => {\n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n\n\n // this.get('/LeftPanel.model').activePath = path;\n _this.model.el.get_value(iter,1, out gval);\n var val = (string)gval;\n \n ((Gtk.Entry)editable).set_text(val); \n}", + "edited" : " (path, newtext) => {\n print(\"Keyrender - signal:edited\\n\");\n \n this.el.editable = false;\n \n \n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n _this.model.el.get_value(iter,1, out gval);\n var oldval = (string)gval;\n \n _this.model.el.get_value(iter,0, out gval);\n var ktype = (string)gval;\n \n _this.model.el.set_value(iter, 1, newtext);\n \n if (oldval == newtext) {\n return;\n }\n \n \n print(\"ktype: %s\\n\",ktype);\n switch(ktype) {\n case \"listener\":\n var ov = _this.node.listeners.get(oldval);\n _this.node.listeners.set(newtext, ov);\n _this.node.listeners.remove(oldval);\n \n _this.updateIter(iter, ktype, newtext, ov);\n \n break;\n case \"props\":\n var ov = _this.node.props.get(oldval);\n _this.node.props.set(newtext, ov);\n _this.node.props.remove(oldval);\n _this.updateIter(iter, ktype, newtext, ov);\n break;\n }\n _this.changed();\n \n}" + }, + "id" : "keyrender", + "xtype" : "CellRendererText", + "* pack" : "pack_start,false", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "valcol", + "* init" : "{\n\t\n\t// typeof(string), // 0 key type\n // typeof(string), // 1 key\n // typeof(string), // 2 key (display)\n // typeof(string), // 3 value\n // typeof(string) // 4 value (display)\n\n\t\n\tthis.el.add_attribute(_this.valrender.el , \"text\", 4 );\n\t//this.el.add_attribute(_this.valrender.el , \"sensitive\", 4 );\n\t//this.el.add_attribute(this.items[0].el , 'editable', 3 );\n // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);\n\n //\tthis.get('/LeftPanel').editableColumn= this;\n}\n", + "* pack" : "append_column", + "title" : "Value", + "xtype" : "TreeViewColumn", + "$ resizable" : true, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "editing_started" : "( editable, path) => {\n //_this.editing = true;\n print(\"editing started called\\n\");\n if (!_this.allow_edit) {\n \n print(\"val - editing_Started\\n\");\n this.el.editable = false; // make sure it's not editor...\n \n \n return;\n }\n _this.allow_edit =false;\n \n \n if ( this.el.has_entry ) {\n \n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n\n \n // this.get('/LeftPanel.model').activePath = path;\n _this.model.el.get_value(iter,3, out gval);\n \n\n var val = (string)gval;\n var combo = (Gtk.ComboBox)editable;\n\n var entry = (Gtk.Entry) combo.get_child(); \n entry.set_text(val);\n }\n \n}", + "edited" : " (path, newtext) => {\n print(\"Valrender - signal:edited\\n\");\n \n this.el.editable = false;\n/* \n m.set(iter, \n 0, \"listener\",\n 1, miter.get_key(),\n 2, \"\" + miter.get_key() + \"\",\n 3, miter.get_value(),\n 4, display_value(short);\n ); \n\n */ \n\n Gtk.TreeIter iter;\n _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n GLib.Value gval;\n \n _this.model.el.get_value(iter,0, out gval);\n var ktype = (string)gval;\n \n \n _this.model.el.get_value(iter,3, out gval);\n var oldval = (string)gval;\n \n _this.model.el.get_value(iter,1, out gval);\n var key = (string)gval;\n \n \n \n switch(ktype) {\n case \"listener\":\n _this.node.listeners.set(key, newtext);\n _this.updateIter(iter,ktype,key,newtext);\n break;\n case \"props\":\n _this.node.props.set(key,newtext);\n _this.updateIter(iter,ktype, key,newtext); \n break;\n }\n// _this.load(_this.file,_this.node);\n _this.changed();\n \n}" + }, + "id" : "valrender", + "* pack" : "pack_start,true", + "xtype" : "CellRendererCombo", + "$ editable" : false, + "$ has_entry" : true, + "$ xns" : "Gtk", + "| void setOptions" : "(string[] ar) {\n var m = _this.valrendermodel.el;\n m.clear();\n Gtk.TreeIter iret;\n for (var i =0; i < ar.length; i++) {\n m.append(out iret);\n m.set_value(iret, 0, ar[i]);\n }\n\n}", + "text_column" : 0, + "items" : [ + { + "id" : "valrendermodel", + "* pack" : false, + "xtype" : "ListStore", + "$ columns" : "typeof(string)", + "n_columns" : 1, + "$ xns" : "Gtk", + "* prop" : "model" + } + ] + } + ] + }, + { + "id" : "ContextMenu", + "xtype" : "Menu", + "* pack" : false, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : " ( ) =>{\n \n var s = _this.view.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel model;\n s.get_selected (out model, out iter);\n _this.startEditingKey(model.get_path(iter));\n}" + }, + "label" : "Edit", + "xtype" : "MenuItem", + "* pack" : "append", + "$ xns" : "Gtk" + }, + { + "* pack" : "append", + "xtype" : "SeparatorMenuItem", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " ( ) =>{\n\t_this.deleteSelected();\n}" + }, + "label" : "Delete", + "xtype" : "MenuItem", + "* pack" : "append", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/WindowLeftProps.vala b/old-javascript/Builder4/WindowLeftProps.vala new file mode 100644 index 000000000..de5ecaae6 --- /dev/null +++ b/old-javascript/Builder4/WindowLeftProps.vala @@ -0,0 +1,1645 @@ +static Xcls_LeftProps _LeftProps; + +public class Xcls_LeftProps : Object +{ + public Gtk.VBox el; + private Xcls_LeftProps _this; + + public static Xcls_LeftProps singleton() + { + if (_LeftProps == null) { + _LeftProps= new Xcls_LeftProps(); + } + return _LeftProps; + } + public Xcls_AddPropertyPopup AddPropertyPopup; + public Xcls_EditProps EditProps; + public Xcls_view view; + public Xcls_model model; + public Xcls_keycol keycol; + public Xcls_keyrender keyrender; + public Xcls_valcol valcol; + public Xcls_valrender valrender; + public Xcls_valrendermodel valrendermodel; + public Xcls_ContextMenu ContextMenu; + + // my vars (def) + public bool allow_edit; + public JsRender.JsRender file; + public signal bool stop_editor (); + public signal void show_editor (JsRender.JsRender file, JsRender.Node node, string type, string key); + public signal void changed (); + public signal void show_add_props (string type); + public Xcls_MainWindow main_window; + public JsRender.Node node; + + // ctor + public Xcls_LeftProps() + { + _this = this; + this.el = new Gtk.VBox( false , 0 ); + + // my vars (dec) + this.allow_edit = false; + this.main_window = null; + + // set gobject values + var child_0 = new Xcls_HBox2( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + var child_1 = new Xcls_EditProps( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + public void before_edit () + { + + print("before edit - stop editing\n"); + + // these do not appear to trigger save... + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + _this.valrender.el.stop_editing(false); + _this.valrender.el.editable =false; + + + // technicall stop the popup editor.. + + } + public string keySortFormat (string key) { + // listeners first - with 0 + // specials + if (key[0] == '*') { + return "1 " + key; + } + // functions + + var bits = key.split(" "); + + if (key[0] == '|') { + return "2 " + bits[bits.length -1]; + } + // signals + if (key[0] == '@') { + return "3 " + bits[bits.length -1]; + } + + // props + if (key[0] == '#') { + return "4 " + bits[bits.length -1]; + } + // the rest.. + return "5 " + bits[bits.length -1]; + + + + } + public void finish_editing () { + // + this.before_edit(); + } + public bool startEditingValue ( Gtk.TreePath path) { + + // ONLY return true if editing is allowed - eg. combo.. + + print("start editing?\n"); + if (!this.stop_editor()) { + print("stop editor failed\n"); + return false; + } + + Gtk.TreeIter iter; + + var mod = this.model.el; + mod.get_iter (out iter, path); + + /* + m.set(iter, + 0, "listener", + 1, miter.get_key(), + 2, "" + miter.get_key() + "", + 3, miter.get_value() + ); + + */ + GLib.Value gval; + mod.get_value(iter, 3 , out gval); + var val = (string)gval; + + mod.get_value(iter, 1 , out gval); + var key = (string)gval; + var type_ar = key.split(" "); + + + + mod.get_value(iter, 0 , out gval); + var type = (string)gval; + + + + var use_textarea = false; + + //------------ things that require the text editor... + + if (type == "listener") { + use_textarea = true; + } + if (key.length > 0 && key[0] == '|') { // user defined method + use_textarea = true; + } + if (key.length > 0 && key[0] == '$') { // raw string + use_textarea = true; + } + if (key.length > 0 && key == "* init") { + use_textarea = true; + } + if (val.length > 40) { // long value... + use_textarea = true; + } + + + + if (use_textarea) { + print("Call show editor\n"); + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.view.el.get_selection().select_path(path); + + this.show_editor(file, node, type, key); + + return false; + }); + + + return false; + } + // others... - fill in options for true/false? + print("turn on editing %s \n" , mod.get_path(iter).to_string()); + + print (type_ar[0].up()); + if (type_ar.length > 1 && ( + type_ar[0].up() == "BOOLEAN" + || + type_ar[0].up() == "BOOL" + )) { + print("start editing try/false)???"); + this.valrender.el.has_entry = false; + string[] opts = { "true", "false" }; + this.valrender.setOptions(opts); + + this.valrender.el.has_entry = false; + this.valrender.el.editable = true; + this.allow_edit = true; + GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + this.view.el.set_cursor_on_cell( + path, + this.valcol.el, + this.valrender.el, + true + ); + return false; + }); + return true; + } + + + + string[] opts = { }; + this.valrender.setOptions(opts); + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + // at this point - work out the type... + // if its' a combo... then show the options.. + this.valrender.el.has_entry = true; + + this.valrender.el.editable = true; + + + this.allow_edit = true; + + + + + + this.view.el.set_cursor_on_cell( + path, + this.valcol.el, + this.valrender.el, + true + ); + return false; + }); + return false; + } + public void load (JsRender.JsRender file, JsRender.Node? node) + { + print("load leftprops\n"); + this.before_edit(); + this.node = node; + this.file = file; + + + this.model.el.clear(); + + //this.get('/RightEditor').el.hide(); + if (node ==null) { + return ; + } + + + + //var provider = this.get('/LeftTree').getPaleteProvider(); + Gtk.TreeIter iter; + + //typeof(string), // 0 key type + //typeof(string), // 1 key + //typeof(string), // 2 key (display) + //typeof(string), // 3 value + //typeof(string), // 4 value (display) + //typeof(string), // 5 both (tooltip) + + + + + // really need a way to sort the hashmap... + var m = this.model.el; + + var miter = node.listeners.map_iterator(); + var i = 0; + + while(miter.next()) { + i++; + m.append(out iter,null); + + this.updateIter(iter, "listener", miter.get_key(), miter.get_value()); + + + } + + + miter = node.props.map_iterator(); + + + while(miter.next()) { + i++; + m.append(out iter,null); + this.updateIter(iter, "prop", miter.get_key(), miter.get_value()); + + } + print("clear selection\n"); + // clear selection? + this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key.. + + this.view.el.get_selection().unselect_all(); + + var pane = _this.main_window.editpane.el; + var try_size = (i * 25) + 60; // est. 20px per line + 40px header + + // max 80%... + pane.set_position( + ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ? + (int) (pane.max_position * 0.2f) : + pane.max_position-try_size); + + + } + public string keyFormat (string val, string type) { + + // Glib.markup_escape_text(val); + + if (type == "listener") { + return "" + + GLib.Markup.escape_text(val) + + ""; + } + // property.. + if (val.length < 1) { + return "--empty--"; + } + + //@ = signal + //$ = property with + //# - object properties + //* = special + // all of these... - display value is last element.. + var ar = val.strip().split(" "); + + + var dval = GLib.Markup.escape_text(ar[ar.length-1]); + + + + + switch(val[0]) { + case '@': // signal // just bold balck? + if (dval[0] == '@') { + dval = dval.substring(1); + } + + return @"@ $dval"; + case '#': // object properties? + if (dval[0] == '#') { + dval = dval.substring(1); + } + return @"$dval"; + case '*': // special + if (dval[0] == '*') { + dval = dval.substring(1); + } + return @"$dval"; + case '$': + if (dval[0] == '$') { + dval = dval.substring(1); + } + return @"$dval"; + case '|': // user defined methods + if (dval[0] == '|') { + dval = dval.substring(1); + } + return @"$dval"; + + + + default: + return dval; + } + + + + } + public void deleteSelected () { + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + var s = this.view.el.get_selection(); + s.get_selected(out mod, out iter); + + + GLib.Value gval; + mod.get_value(iter, 0 , out gval); + var type = (string)gval; + + mod.get_value(iter, 1 , out gval); + var key = (string)gval; + + switch(type) { + case "listener": + this.node.listeners.remove(key); + break; + + case "props": + this.node.props.remove(key); + break; + } + this.load(this.file, this.node); + + _this.changed(); + } + public void startEditingKey ( Gtk.TreePath path) { + + if (!this.stop_editor()) { + return; + } + + // others... - fill in options for true/false? + + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.allow_edit = true; + this.keyrender.el.editable = true; + + this.view.el.set_cursor_on_cell( + path, + this.keycol.el, + this.keyrender.el, + true + ); + + return false; + }); + + + } + public void addProp (string in_type, string key, string value, string value_type) { + // info includes key, val, skel, etype.. + //console.dump(info); + //type = info.type.toLowerCase(); + //var data = this.toJS(); + + var type = in_type == "signals" ? "listener" : in_type; + + var fkey = (value_type.length > 0 ? value_type + " " : "") + key; + + if (type == "listener") { + if (this.node.listeners.has_key(key)) { + return; + } + this.node.listeners.set(key,value); + } else { + + if (this.node.props.has_key(fkey)) { + return; + } + this.node.props.set(fkey,value); + } + + + // add a row??? + this.load(this.file, this.node); + + + + /// need to find the row which I've just added.. + + + var s = this.view.el.get_selection(); + s.unselect_all(); + + print("trying to find new iter"); + + this.model.el.foreach((model, path, iter) => { + GLib.Value gval; + + this.model.el.get_value(iter, 0 , out gval); + if ((string)gval != type) { + print("not type: %s = %s\n", (string)gval , type); + return false; + } + this.model.el.get_value(iter, 1 , out gval); + if ((string)gval != fkey) { + print("not key: %s = %s\n", (string)gval , fkey); + return false; + } + // delay this? + GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => { + + this.startEditingValue(this.model.el.get_path(iter)); + return false; + }); + //s.select_iter(iter); + return true; + }); + + + + + } + public void updateIter (Gtk.TreeIter iter, string type, string key, string value) { + + print("update Iter %s, %s\n", key,value); + //typeof(string), // 0 key type + //typeof(string), // 1 key + //typeof(string), // 2 key (display) + //typeof(string), // 3 value + //typeof(string), // 4 value (display) + //typeof(string), // 5 both (tooltip) + //typeof(string), // 6 key (sort) + + var dl = value.strip().split("\n"); + + var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0]; + + if (type == "listener") { + + + + this.model.el.set(iter, + 0, type, + 1, key, + 2, this.keyFormat(key ,type), + 3, value, + 4, dis_val, + 5, "" + GLib.Markup.escape_text(key + " " +value) + "", + 6, "0 " + key + ); + return; + } + + + + this.model.el.set(iter, + 0, "props", + 1, key, + 2, this.keyFormat(key , "prop"), + 3, value, + 4, dis_val, + 5, "" + GLib.Markup.escape_text(key + " " + value) + "", + 6, this.keySortFormat(key) + ); + } + public class Xcls_HBox2 : Object + { + public Gtk.HBox el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_HBox2(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Button3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_Button3 : Object + { + public Gtk.Button el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Button3(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_HBox4( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_AddPropertyPopup( _this ); + child_1.ref(); + + // listeners + this.el.button_press_event.connect( (self, ev) => { + _this.before_edit(); + + + var p = _this.AddPropertyPopup; + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, ev.button, ev.time); + return true; + }); + } + + // user defined functions + } + public class Xcls_HBox4 : Object + { + public Gtk.HBox el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_HBox4(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_Image5( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_Label6( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + } + + // user defined functions + } + public class Xcls_Image5 : Object + { + public Gtk.Image el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Image5(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.stock = Gtk.STOCK_ADD; + this.el.icon_size = Gtk.IconSize.MENU; + } + + // user defined functions + } + public class Xcls_Label6 : Object + { + public Gtk.Label el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_Label6(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Other" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_AddPropertyPopup : Object + { + public Gtk.Menu el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_AddPropertyPopup(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.AddPropertyPopup = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem8( _this ); + child_0.ref(); + this.el.append ( child_0.el ); + var child_1 = new Xcls_MenuItem9( _this ); + child_1.ref(); + this.el.append ( child_1.el ); + var child_2 = new Xcls_MenuItem10( _this ); + child_2.ref(); + this.el.append ( child_2.el ); + var child_3 = new Xcls_MenuItem11( _this ); + child_3.ref(); + this.el.append ( child_3.el ); + var child_4 = new Xcls_SeparatorMenuItem12( _this ); + child_4.ref(); + this.el.add ( child_4.el ); + var child_5 = new Xcls_MenuItem13( _this ); + child_5.ref(); + this.el.append ( child_5.el ); + var child_6 = new Xcls_MenuItem14( _this ); + child_6.ref(); + this.el.append ( child_6.el ); + var child_7 = new Xcls_MenuItem15( _this ); + child_7.ref(); + this.el.append ( child_7.el ); + var child_8 = new Xcls_SeparatorMenuItem16( _this ); + child_8.ref(); + this.el.add ( child_8.el ); + var child_9 = new Xcls_MenuItem17( _this ); + child_9.ref(); + this.el.append ( child_9.el ); + var child_10 = new Xcls_MenuItem18( _this ); + child_10.ref(); + this.el.append ( child_10.el ); + } + + // user defined functions + } + public class Xcls_MenuItem8 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem8(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Using _this.{ID} will map to this element"; + this.el.label = "id: _this.{ID} (Vala)"; + + // listeners + this.el.activate.connect( () => { + _this.addProp( "prop", "id", "", ""); + }); + } + + // user defined functions + } + public class Xcls_MenuItem9 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem9(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element"; + this.el.label = "pack: Pack method (Vala)"; + + // listeners + this.el.activate.connect( ( ) => { + + _this.addProp( "prop", "pack","add", "*"); + }); + } + + // user defined functions + } + public class Xcls_MenuItem10 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem10(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)"; + this.el.label = "ctor: Alterative to default contructor"; + + // listeners + this.el.activate.connect( ( ) => { + + _this.addProp( "prop", "ctor","", "*"); + }); + } + + // user defined functions + } + public class Xcls_MenuItem11 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem11(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "This code is called after the ctor"; + this.el.label = "init: initialziation code (vala)"; + + // listeners + this.el.activate.connect( ( ) => { + + _this.addProp( "prop", "init", "{\n\n}\n", "*" ); + }); + } + + // user defined functions + } + public class Xcls_SeparatorMenuItem12 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem12(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_MenuItem13 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem13(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined string property"; + this.el.label = "String"; + + // listeners + this.el.activate.connect( (self) => { + + _this.addProp( "prop", "XXXX", "","string"); + + }); + } + + // user defined functions + } + public class Xcls_MenuItem14 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem14(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined number property"; + this.el.label = "Number"; + + // listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "XXX", "0", "int"); + }); + } + + // user defined functions + } + public class Xcls_MenuItem15 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem15(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user defined boolean property"; + this.el.label = "Boolean"; + + // listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp( "prop", "XXX", "true", "bool"); + }); + } + + // user defined functions + } + public class Xcls_SeparatorMenuItem16 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem16(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_MenuItem17 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem17(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user function boolean property"; + this.el.label = "Javascript Function"; + + // listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp("prop", "XXXX", "function() { }", "| function"); + }); + } + + // user defined functions + } + public class Xcls_MenuItem18 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem18(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_markup = "Add a user function boolean property"; + this.el.label = "Vala Method"; + + // listeners + this.el.activate.connect( ( ) =>{ + + _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type"); + }); + } + + // user defined functions + } + public class Xcls_EditProps : Object + { + public Gtk.ScrolledWindow el; + private Xcls_LeftProps _this; + + + // my vars (def) + public bool editing; + + // ctor + public Xcls_EditProps(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.EditProps = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + this.editing = false; + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + { + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } } + + // user defined functions + } + public class Xcls_view : Object + { + public Gtk.TreeView el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_view(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.tooltip_column = 5; + this.el.enable_tree_lines = true; + this.el.headers_visible = true; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_keycol( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + var child_2 = new Xcls_valcol( _this ); + child_2.ref(); + this.el.append_column ( child_2.el ); + var child_3 = new Xcls_ContextMenu( _this ); + child_3.ref(); + + // init method + + { + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + + + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.modify_font(description); + } + // listeners + this.el.button_press_event.connect( ( ev) => { + + Gtk.TreeViewColumn col; + int cell_x; + int cell_y; + Gtk.TreePath path; + if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) { + print("nothing selected on click"); + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.el.get_selection().unselect_all(); + + return false; + }); + _this.before_edit(); + return false; //not on a element. + } + + + // right click. + if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") { + // show popup!. + + + _this.before_edit(); + + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + _this.valrender.el.stop_editing(false); + _this.valrender.el.editable =false; + + _this.startEditingKey(path); + + return false; + } + + + + + // right click. + if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) { + // show popup!. + //if (col.title == "Value") { + // _this.before_edit(); + // return false; + //} + + var p = _this.ContextMenu; + + p.el.set_screen(Gdk.Screen.get_default()); + p.el.show_all(); + p.el.popup(null, null, null, ev.button, ev.time); + //Seed.print("click:" + res.column.title); + // select the + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + this.el.get_selection().select_path(path); + return false; + }); + _this.before_edit(); + return false; + } + + + if (col.title != "Value") { + print("col title != Value"); + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.el.get_selection().select_path(path); + return false; + }); + + _this.before_edit(); + // XObject.error("column is not value?"); + return false; // ignore.. - key click.. ??? should we do this?? + } + + + // if the cell can be edited with a pulldown + // then we should return true... - and let the start_editing handle it? + + + + + + + // _this.before_edit(); <<< we really need to stop the other editor.. + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + + return _this.startEditingValue(path); // assumes selected row.. + + + + + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.TreeStore el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.TreeStore( 7, typeof(string), // 0 key type + typeof(string), // 1 key + typeof(string), // 2 key (display) + typeof(string), // 3 value + typeof(string), // 4 value (display) + typeof(string), // 5 both (tooltip) + typeof(string) // 6 key (for sorting) + ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_keycol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_keycol(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.keycol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Name"; + this.el.resizable = true; + var child_0 = new Xcls_keyrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false ); + + // init method + + this.el.add_attribute(_this.keyrender.el , "markup", 2 ); + this.el.add_attribute(_this.keyrender.el , "text", 1 ); } + + // user defined functions + } + public class Xcls_keyrender : Object + { + public Gtk.CellRendererText el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_keyrender(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.keyrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + + // listeners + this.el.editing_started.connect( ( editable, path) => { + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + + + // this.get('/LeftPanel.model').activePath = path; + _this.model.el.get_value(iter,1, out gval); + var val = (string)gval; + + ((Gtk.Entry)editable).set_text(val); + }); + this.el.edited.connect( (path, newtext) => { + print("Keyrender - signal:edited\n"); + + this.el.editable = false; + + + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + _this.model.el.get_value(iter,1, out gval); + var oldval = (string)gval; + + _this.model.el.get_value(iter,0, out gval); + var ktype = (string)gval; + + _this.model.el.set_value(iter, 1, newtext); + + if (oldval == newtext) { + return; + } + + + print("ktype: %s\n",ktype); + switch(ktype) { + case "listener": + var ov = _this.node.listeners.get(oldval); + _this.node.listeners.set(newtext, ov); + _this.node.listeners.remove(oldval); + + _this.updateIter(iter, ktype, newtext, ov); + + break; + case "props": + var ov = _this.node.props.get(oldval); + _this.node.props.set(newtext, ov); + _this.node.props.remove(oldval); + _this.updateIter(iter, ktype, newtext, ov); + break; + } + _this.changed(); + + }); + } + + // user defined functions + } + public class Xcls_valcol : Object + { + public Gtk.TreeViewColumn el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valcol(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valcol = this; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "Value"; + this.el.resizable = true; + var child_0 = new Xcls_valrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + { + + // typeof(string), // 0 key type + // typeof(string), // 1 key + // typeof(string), // 2 key (display) + // typeof(string), // 3 value + // typeof(string) // 4 value (display) + + + this.el.add_attribute(_this.valrender.el , "text", 4 ); + //this.el.add_attribute(_this.valrender.el , "sensitive", 4 ); + //this.el.add_attribute(this.items[0].el , 'editable', 3 ); + // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL); + + // this.get('/LeftPanel').editableColumn= this; + } } + + // user defined functions + } + public class Xcls_valrender : Object + { + public Gtk.CellRendererCombo el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valrender(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valrender = this; + this.el = new Gtk.CellRendererCombo(); + + // my vars (dec) + + // set gobject values + this.el.editable = false; + this.el.text_column = 0; + this.el.has_entry = true; + var child_0 = new Xcls_valrendermodel( _this ); + child_0.ref(); + this.el.model = child_0.el; + + // listeners + this.el.editing_started.connect( ( editable, path) => { + //_this.editing = true; + print("editing started called\n"); + if (!_this.allow_edit) { + + print("val - editing_Started\n"); + this.el.editable = false; // make sure it's not editor... + + + return; + } + _this.allow_edit =false; + + + if ( this.el.has_entry ) { + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + + + // this.get('/LeftPanel.model').activePath = path; + _this.model.el.get_value(iter,3, out gval); + + + var val = (string)gval; + var combo = (Gtk.ComboBox)editable; + + var entry = (Gtk.Entry) combo.get_child(); + entry.set_text(val); + } + + }); + this.el.edited.connect( (path, newtext) => { + print("Valrender - signal:edited\n"); + + this.el.editable = false; + /* + m.set(iter, + 0, "listener", + 1, miter.get_key(), + 2, "" + miter.get_key() + "", + 3, miter.get_value(), + 4, display_value(short); + ); + + */ + + Gtk.TreeIter iter; + _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path)); + GLib.Value gval; + + _this.model.el.get_value(iter,0, out gval); + var ktype = (string)gval; + + + _this.model.el.get_value(iter,3, out gval); + var oldval = (string)gval; + + _this.model.el.get_value(iter,1, out gval); + var key = (string)gval; + + + + switch(ktype) { + case "listener": + _this.node.listeners.set(key, newtext); + _this.updateIter(iter,ktype,key,newtext); + break; + case "props": + _this.node.props.set(key,newtext); + _this.updateIter(iter,ktype, key,newtext); + break; + } + // _this.load(_this.file,_this.node); + _this.changed(); + + }); + } + + // user defined functions + public void setOptions (string[] ar) { + var m = _this.valrendermodel.el; + m.clear(); + Gtk.TreeIter iret; + for (var i =0; i < ar.length; i++) { + m.append(out iret); + m.set_value(iret, 0, ar[i]); + } + + } + } + public class Xcls_valrendermodel : Object + { + public Gtk.ListStore el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_valrendermodel(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.valrendermodel = this; + this.el = new Gtk.ListStore( 1, typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_ContextMenu : Object + { + public Gtk.Menu el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_ContextMenu(Xcls_LeftProps _owner ) + { + _this = _owner; + _this.ContextMenu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem28( _this ); + child_0.ref(); + this.el.append ( child_0.el ); + var child_1 = new Xcls_SeparatorMenuItem29( _this ); + child_1.ref(); + this.el.append ( child_1.el ); + var child_2 = new Xcls_MenuItem30( _this ); + child_2.ref(); + this.el.append ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuItem28 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem28(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Edit"; + + // listeners + this.el.activate.connect( ( ) =>{ + + var s = _this.view.el.get_selection(); + Gtk.TreeIter iter; + Gtk.TreeModel model; + s.get_selected (out model, out iter); + _this.startEditingKey(model.get_path(iter)); + }); + } + + // user defined functions + } + public class Xcls_SeparatorMenuItem29 : Object + { + public Gtk.SeparatorMenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_SeparatorMenuItem29(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.SeparatorMenuItem(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_MenuItem30 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem30(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete"; + + // listeners + this.el.activate.connect( ( ) =>{ + _this.deleteSelected(); + }); + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/WindowLeftTree.bjs b/old-javascript/Builder4/WindowLeftTree.bjs new file mode 100644 index 000000000..77fb761ab --- /dev/null +++ b/old-javascript/Builder4/WindowLeftTree.bjs @@ -0,0 +1,132 @@ +{ + "name" : "WindowLeftTree", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/WindowLeftTree.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "| JsRender.Node? getActiveElement" : " () { // return path to actie node.\n\n var path = this.getActivePath();\n if (path.length < 1) {\n return null;\n }\n return _this.model.pathToNode(path);\n \n}\n", + "id" : "WindowLeftTree", + "@ bool before_node_change" : "(JsRender.Node? node)", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "| JsRender.JsRender getActiveFile" : "() {\n return this.model.file;\n}\n", + "* pack" : "add", + "xtype" : "ScrolledWindow", + "@ void changed" : "()", + "$ xns" : "Gtk", + "@ void node_selected" : "(JsRender.Node? node)", + "# Xcls_MainWindow main_window" : "null", + "| string getActivePath" : " () {\n var model = this.model;\n var view = this.view.el;\n if (view.get_selection().count_selected_rows() < 1) {\n return \"\";\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n view.get_selection().get_selected(out mod, out iter);\n return mod.get_path(iter).to_string();\n}\n", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( ev) => {\n //console.log(\"button press?\");\n if (! _this.before_node_change(null) ) {\n return true;\n }\n\n \n if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {\n //print(\"click\" + ev.type);\n return false;\n }\n Gtk.TreePath res;\n if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n return true;\n }\n \n this.el.get_selection().select_path(res);\n \n //if (!this.get('/LeftTreeMenu').el) { \n // this.get('/LeftTreeMenu').init(); \n // }\n \n _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());\n _this.LeftTreeMenu.el.show_all();\n _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);\n // print(\"click:\" + res.path.to_string());\n return true;\n}", + "drag_begin" : "( ctx) => {\n\t//print('SOURCE: drag-begin');\n \n \n //this.targetData = \"\";\n \n // find what is selected in our tree...\n \n var s = _this.view.el.get_selection();\n if (s.count_selected_rows() < 1) {\n return;\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n\n \n\n // set some properties of the tree for use by the dropped element.\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n var tp = mod.get_path(iter).to_string();\n var data = (JsRender.Node)(value.dup_object());\n var xname = data.fqn();\n print (\"XNAME IS \" + xname+ \"\\n\");\n this.dragData = tp;\n this.dropList = _this.model.file.palete().getDropList(xname);\n \n print (\"DROP LIST IS \" + string.joinv(\", \", this.dropList) + \"\\n\");\n \n\n // make the drag icon a picture of the node that was selected\n \n \n // by default returns the path..\n var path = _this.model.el.get_path(iter);\n\n \n var pix = this.el.create_row_drag_icon ( path);\n \n Gtk.drag_set_icon_surface (ctx, pix) ;\n \n return;\n}", + "cursor_changed" : " ( ) => {\n\n\n if (this.blockChanges) { // probably not needed.. \n return ;\n }\n if (!_this.before_node_change(null) ) {\n\t this.blockChanges = true;\n\t this.el.get_selection().unselect_all();\n\t this.blockChanges = false;\n\t return;\n }\n if (_this.model.file == null) {\n return;\n } \n \n //var render = this.get('/LeftTree').getRenderer(); \n print(\"LEFT TREE -> view -> selection changed called\\n\");\n \n \n // -- it appears that the selection is not updated.\n \n GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n \n\n if (this.el.get_selection().count_selected_rows() < 1) {\n\n print(\"selected rows < 1\\n\");\n //??this.model.load( false);\n _this.node_selected(null);\n \n return false ;\n }\n \n //console.log('changed');\n var s = this.el.get_selection();\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n \n \n // var val = \"\";\n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n _this.model.activePath = mod.get_path(iter).to_string();\n \n var node = (JsRender.Node)value.dup_object();\n _this.node_selected(node);\n return false;\n }); \n //_this.after_node_change(node);\n\n// _this.model.file.changed(node, \"tree\");\n \n //Seed.print( value.get_string());\n return ;\n \n}", + "drag_end" : " (drag_context) => {\n\t//Seed.print('LEFT-TREE: drag-end');\n this.dragData = \"\";\n this.dropList = null;\n// this.targetData = \"\";\n this.highlightDropPath(\"\",0);\n// return true;\n}", + "drag_motion" : " ( ctx, x, y, time) => {\n print(\"got drag motion\\n\");\n var src = Gtk.drag_get_source_widget(ctx);\n this.drag_x = x;\n this.drag_y = y; \n\n if (src != this.el) {\n \n \n \n // the point of this is to detect where an item could be dropped..\n print(\"requesting drag data\\n\");\n this.drag_in_motion = true;\n \n // request data that will be recieved by the recieve... \n Gtk.drag_get_data\n (\n this.el, // will receive 'drag-data-received' signal \n ctx, // represents the current state of the DnD \n Gdk.Atom.intern(\"STRING\",true), // the target type we want \n time // time stamp \n );\n return true;\n } \n\n\n print(\"action: %d\\n\", ctx.get_actions());\n //print(\"GETTING POS\");\n var targetData = \"\";\n\n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n\n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n\n\n // ------------- a drag from self..\n\n\n //var action = Gdk.DragAction.COPY;\n // unless we are copying!!! ctl button..\n \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n\n\n if (_this.model.el.iter_n_children(null) < 1) {\n // no children.. -- asume it's ok..\n \n targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n \n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); \n Gdk.drag_status(ctx, action ,time);\n return true;\n \n // continue through to allow drop...\n\n } \n \n \n\n \n \n //print(\"ISOVER? \" + isOver);\n if (!isOver) {\n \n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); \n return false;\n\n }\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 // locally dragged items to not really use the \n var selection_text = this.dragData;\n \n \n \n if (selection_text == null || selection_text.length < 1) {\n //print(\"Error - drag selection text returned NULL\");\n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n }\n \n \n // see if we are dragging into ourself?\n var target_path = path.to_string(); \n print (\"Drag %s onto %s--%d\\n \", selection_text, target_path, pos);\n \n // pos : 3 = ontop - 0 = after, 1 = before\n //print(\"target_path=\"+target_path);\n\n // \n if (selection_text == target_path) {\n print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n \n Gdk.drag_status(ctx, 0 ,time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n// -- fixme -- this is not really correct..\n\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 \n // dropList is a list of xtypes that this node could be dropped on.\n // it is set up when we start to drag..\n \n \n targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n //print(\"Can not find drop node path\");\n \n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return false;\n }\n \n var td_ar = targetData.split(\"|\");\n \n \n\n Gdk.drag_status(ctx, action ,time);\n this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n return true;\n \n \n}", + "drag_data_get" : "( drag_context, data, info, time) => {\n \n \n //print(\"drag-data-get\");\n var s = this.el.get_selection();\n if (s.count_selected_rows() < 1) {\n data.set_text(\"\",0); \n print(\"return empty string - no selection..\");\n return;\n }\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n s.get_selected(out mod, out iter);\n \n \n \n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n var ndata = (JsRender.Node)(value.dup_object());\n var xname = ndata.fqn();\n \n \n var tp = mod.get_path(iter).to_string();\n // by default returns the path..\n \n if ( info != Gdk.Atom.intern(\"STRING\",true) ) {\n tp = ndata.toJsonString();\n } \n \n //data.set_text(tp,tp.length); \n \n data.set (data.get_target (), 8, (uchar[]) tp.to_utf8 ());\n \n \n // print(\"return \" + tp);\n }", + "drag_data_received" : " (ctx, x, y, sel, info, time) => {\n \n // THIS CODE ONLY RELATES TO drag or drop of \"NEW\" elements or \"FROM another tree..\"\n \n \n // print(\"Tree: drag-data-received\\n\");\n var selection_text = (string)sel.get_data();\n //print(\"selection_text= %s\\n\",selection_text);\n\n var is_drag = this.drag_in_motion;\n \n \n\n print(\"Is Drag %s\\n\", is_drag ? \"Y\": \"N\");\n var targetData = \"\";\n \n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n \n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n \n \n //console.log(\"LEFT-TREE: drag-motion\");\n var src = Gtk.drag_get_source_widget(ctx);\n \n // a drag from self - this should be handled by drop and motion.\n if (src == this.el) {\n print(\"Source == this element should not happen.. ? \\n\");\n return;\n }\n //print(\"drag_data_recieved from another element\");\n \n \n \n \n if (selection_text == null || selection_text.length < 1 || !isOver) {\n // nothing valid foudn to drop...\n print(\"empty sel text or not over\");\n if (is_drag) {\n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return;\n }\n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n // no drop action...\n return; \n \n }\n var dropNode = new JsRender.Node(); \n \n var dropNodeType = selection_text;\n var show_templates = true;\n // for drop\n if (dropNodeType[0] == '{') {\n var pa = new Json.Parser();\n pa.load_from_data(dropNodeType);\n \n dropNode.loadFromJson( pa.get_root().get_object(), 2);\n dropNodeType = dropNode.fqn();\n show_templates = false;\n \n \n } else {\n\n dropNode.setFqn(selection_text);\n }\n\n \n // dropList --- need to gather this ... \n print(\"get dropList for : %s\\n\",dropNodeType); \n var dropList = _this.model.file.palete().getDropList(dropNodeType);\n \n print(\"dropList: %s\\n\", string.joinv(\" , \", dropList));\n \n // if drag action is link ... then we can drop it anywahere...\n if ((ctx.get_actions() & Gdk.DragAction.LINK) > 0) {\n targetData = path.to_string() + \"|%d\".printf((int)pos);\n } else {\n \n \n targetData = _this.model.findDropNodeByPath( isEmpty ? \"\" : path.to_string(), dropList, pos);\n }\n \n \n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n \n // invalid drop path..\n if (this.drag_in_motion) {\n Gdk.drag_status(ctx, 0, time);\n this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n return;\n }\n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n // no drop action...\n return;\n }\n // valid drop path..\n \n var td_ar = targetData.split(\"|\");\n \n \n if (this.drag_in_motion) { \n Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);\n\n this.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n return;\n }\n // continue on to allow drop..\n \n\n // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n \n\n _this.model.dropNode(targetData, dropNode, show_templates);\n print(\"ADD new node!!!\\n\");\n \n ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);\n \n Gtk.drag_finish (ctx, false, false,time);\n \n \n \n \n \n}", + "drag_drop" : " ( ctx, x, y, time) => {\n //Seed.print(\"TARGET: drag-drop\");\n \n \n var src = Gtk.drag_get_source_widget(ctx);\n \n if (src != this.el) {\n \n \n \n this.drag_in_motion = false; \n // request data that will be recieved by the recieve... \n Gtk.drag_get_data\n (\n this.el, // will receive 'drag-data-received' signal \n ctx, // represents the current state of the DnD \n Gdk.Atom.intern(\"application/json\",true), // the target type we want \n time // time stamp \n );\n\n \n // No target offered by source => error\n \n\n return false;\n }\n \n // handle drop around self..\n \n \n \n //print(\"GETTING POS\");\n var targetData = \"\";\n \n Gtk.TreePath path;\n Gtk.TreeViewDropPosition pos;\n var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n \n // if there are not items in the tree.. the we have to set isOver to true for anything..\n var isEmpty = false;\n if (_this.model.el.iter_n_children(null) < 1) {\n print(\"got NO children?\\n\");\n isOver = true; //??? \n isEmpty = true;\n pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n }\n \n \n \n //var action = Gdk.DragAction.COPY;\n // unless we are copying!!! ctl button..\n \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n\n \n if (_this.model.el.iter_n_children(null) < 1) {\n // no children.. -- asume it's ok..\n \n targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n \n // continue through to allow drop...\n\n } else {\n \n \n \n \n \n //print(\"ISOVER? \" + isOver);\n if (!isOver) {\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n return true; // not over apoint!?! - no action on drop or motion..\n }\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 // locally dragged items to not really use the \n var selection_text = this.dragData;\n \n \n \n if (selection_text == null || selection_text.length < 1) {\n //print(\"Error - drag selection text returned NULL\");\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n return true; /// -- fixme -- this is not really correct..\n } \n \n // see if we are dragging into ourself?\n print (\"got selection text of \" + selection_text);\n \n var target_path = path.to_string();\n //print(\"target_path=\"+target_path);\n\n // \n if (selection_text == target_path) {\n print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n\n return true; /// -- fixme -- this is not really correct..\n\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 \n // dropList is a list of xtypes that this node could be dropped on.\n // it is set up when we start to drag..\n \n \n targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n \n print(\"targetDAta: \" + targetData +\"\\n\");\n \n if (targetData.length < 1) {\n //print(\"Can not find drop node path\");\n \n Gtk.drag_finish (ctx, false, false, time); // drop failed..\n return true;\n }\n \n var td_ar = targetData.split(\"|\");\n \n \n \n // continue on to allow drop..\n }\n // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n\n\n var delete_selection_data = false;\n \n if (action == Gdk.DragAction.ASK) {\n /* Ask the user to move or copy, then set the ctx action. */\n }\n\n if (action == Gdk.DragAction.MOVE) {\n delete_selection_data = true;\n }\n \n // drag around.. - reorder..\n _this.model.moveNode(targetData, action);\n \n \n \n \n \n // we can send stuff to souce here...\n\n\n// do we always say failure, so we handle the reall drop?\n Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);\n\n return true;\n \n \n \n \n \n \n}" + }, + "# string dragData" : "", + "# int drag_x" : "", + "# string[] dropList" : "", + "id" : "view", + "gboolean headers_visible" : true, + "# int drag_y" : "", + "* init" : "{\n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.modify_font(description);\n\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n // is this really needed??\n /*\n this.selection.signal['changed'].connect(function() {\n\t _this.get('/LeftTree.view').listeners.cursor_changed.apply(\n\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n\t );\n });\n */\n Gtk.drag_source_set (\n\t this.el, /* widget will be drag-able */\n\t Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n\t Builder4.Application.targetList, /* lists of target to support */\n\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */\n );\n\n // ?? needed??\n //Gtk.drag_source_add_text_targets(this.el); \n\n Gtk.drag_dest_set\n (\n this.el, /* widget that will accept a drop */\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n Builder4.Application.targetList, /* lists of target to support */\n Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */\n );\n\n //Gtk.drag_dest_set_target_list(this.el, Builder.Application.targetList);\n //Gtk.drag_dest_add_text_targets(this.el);\n}\n", + "tooltip_column" : 1, + "* pack" : "add", + "xtype" : "TreeView", + "$ enable_tree_lines" : true, + "$ headers_visible" : false, + "| void highlightDropPath" : " ( string treepath, Gtk.TreeViewDropPosition pos) {\n\n // highlighting for drag/drop\n if (treepath.length > 0) {\n this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos);\n } else {\n this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n \n}", + "# bool drag_in_motion" : "", + "# bool blockChanges" : false, + "$ xns" : "Gtk", + "| void selectNode" : "(string 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 \n this.el.set_cursor(tp, null, false); \n this.el.scroll_to_cell(tp, null, false, 0,0);\n}\n", + "items" : [ + { + "| string findDropNode" : " (string treepath_str, string[] targets) {\n\n // this is used by the dragdrop code in the roo version AFAIR..\n\n //var 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) < 1) {\n //print(\"NO KEYS\");\n return \"|%d\".printf((int)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.length > 0 && targets[0] == \"*\") {\n return treepath_str;\n }\n return this.findDropNodeByPath(treepath_str,targets, -1);\n}\n", + "currentTree" : false, + "id" : "model", + "# DialogTemplateSelect template_select" : "null", + "* init" : "print(\"model initialized\");\n\n", + "| void loadFile" : "(JsRender.JsRender f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n \n// if (!f) {\n// console.log('missing file');\n// return;\n// }\n \n // load the file if not loaded..\n if (f.tree == null) {\n f.loadItems( );\n }\n // if it's still null?\n if (f.tree == null) {\n return;\n }\n \n /// this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);\n \n //if (f.items.length && typeof(f.items[0]) == 'string') {\n \n //this.get('/RightEditor').el.show();\n //this.get('/RightEditor.view').load( f.items[0]);\n // return;\n //}\n //print(\"LOAD\");\n //print(JSON.stringify(f.items, null,4));\n //console.dump(f.items);\n var o = new Gee.ArrayList();\n o.add(f.tree);\n this.load(o,null);\n \n _this.view.el.expand_all();\n\n if (f.tree.items.size < 1) {\n // single item..\n \n //this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n _this.view.el.set_cursor( \n new Gtk.TreePath.from_string(\"0\"), null, false);\n \n \n } else {\n //this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n return;\n /* \n \n //print(\"hide right editior\");\n //this.get('/RightEditor').el.hide();\n //this.get('/Editor').el.hide();\n //print(\"set current tree\");\n //this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n //this.currentTree = this.currentTree || { items: [] };\n //_this.renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n \n \n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n */\n \n}\n", + "# JsRender.JsRender? file" : "null", + "| void updateSelected" : "() {\n \n \n var s = _this.view.el.get_selection();\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n \n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n \n GLib.Value value;\n this.el.get_value(iter, 2, out value);\n var node = (JsRender.Node)(value.get_object());\n \n this.el.set(iter, 0, node.nodeTitle(),\n 1, node.nodeTip(), -1\n );\n}\n", + "* pack" : "set_model", + "xtype" : "TreeStore", + "| string findDropNodeByPath" : " (string treepath_str, string[] targets, int in_pref = -1) {\n\n var path = treepath_str; // dupe it..\n \n \n // pref : 3 = ontop - 0 = after, 1 = before\n int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;\n \n var last = \"\";\n \n //console.dump(this.treemap);\n \n print(\"findDropNodeByPath : got path length %d / %s\\n\", path.length, path);\n \n if (path.length == 0) {\n // top drop. // just return empty..\n return \"|%d\".printf((int)pref) ;\n \n }\n \n \n while (path.length > 0) {\n \n if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) {\n if (path.last_index_of(\":\") < 0 ) {\n return \"\";\n }\n path = path.substring(0, path.last_index_of(\":\"));\n last = treepath_str;\n print(\"DROP before or after : using %s\\n\",path);\n continue;\n }\n \n //print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.pathToNode(path);\n \n if (node_data == null) {\n print(\"node not found\");\n return \"\";\n }\n \n var xname = node_data.fqn();\n var match = \"\";\n var prop = \"\";\n \n for (var i =0; i < targets.length; i++) {\n var tg = targets[i];\n if ((tg == xname) ) {\n match = tg;\n break;\n }\n // if target is \"xxxx:name\"\n if (tg.contains(xname +\":\")) {\n match = tg;\n var ar = tg.split(\":\");\n prop = ar[1];\n break;\n }\n }\n \n if (match.length > 0) {\n if (last.length > 0) { // pref is after/before..\n // then it's after last\n //if (pref > 1) {\n // return \"\";\n //}\n return last + \"|%d\".printf((int)pref) + \"|\" + prop;\n\n \n }\n return path + \"|%d\".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER);// + \"|\" + prop;\n }\n /*\n last = \"\" + path;\n var par = path.split(\":\");\n string [] ppar = {};\n for (var i = 0; i < par.length-1; i++) {\n ppar += par[i];\n }\n \n path = string.joinv(\":\", ppar);\n */\n break;\n\n }\n \n return \"\";\n \n}\n", + "| void moveNode" : "(string target_data, Gdk.DragAction action) \n{\n \n /// target_data = \"path|pos\");\n \n \n //print(\"MOVE NODE\");\n // console.dump(target_data);\n Gtk.TreeIter old_iter;\n Gtk.TreeModel mod;\n \n var s = _this.view.el.get_selection();\n s.get_selected(out mod , out old_iter);\n mod.get_path(old_iter);\n \n var node = this.pathToNode(mod.get_path(old_iter).to_string());\n //console.dump(node);\n if (node == null) {\n print(\"moveNode: ERROR - node is null?\");\n }\n \n \n\n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n\n \n if ((action & Gdk.DragAction.MOVE) > 0) {\n print(\"REMOVING OLD NODE : \" + target_data + \"\\n\");\n node.remove();\n this.dropNode(target_data, node, false);\n this.el.remove(ref old_iter);\n \n \n \n } else {\n print(\"DROPPING NODE // copy: \" + target_data + \"\\n\");\n node = node.deepClone();\n this.dropNode(target_data, node, false);\n }\n _this.changed();\n this.activePath= \"\";\n //this.updateNode(false,true);\n}\n", + "# string activePath" : "\"\"", + "$ columns" : "typeof(string),typeof(string),typeof(Object)", + "| void load" : "(Gee.ArrayList tr, Gtk.TreeIter? iter) \n{\n Gtk.TreeIter citer;\n //this.insert(citer,iter,0);\n for(var i =0 ; i < tr.size; i++) {\n if (iter != null) {\n this.el.insert(out citer,iter,-1); // why not append?\n } else {\n this.el.append(out citer,null);\n }\n \n this.el.set(citer, 0, tr.get(i).nodeTitle(),\n 1, tr.get(i).nodeTip(), -1\n );\n var o = new GLib.Value(typeof(Object));\n o.set_object((Object)tr.get(i));\n \n this.el.set_value(citer, 2, o);\n \n if (tr.get(i).items.size > 0) {\n this.load(tr.get(i).items, citer);\n }\n \n }\n\n \n}", + "| void deleteSelected" : "() {\n \n print(\"DELETE SELECTED?\");\n //_this.view.blockChanges = true;\n print(\"GET SELECTION?\");\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n \n\n\n this.activePath= \"\"; \n print(\"GET vnode value?\");\n\n GLib.Value value;\n this.el.get_value(iter, 2, out value);\n var data = (JsRender.Node)(value.get_object());\n print(\"removing node from Render\\n\");\n if (data.parent == null) {\n this.file.tree = null;\n } else {\n data.remove();\n }\n print(\"removing node from Tree\\n\"); \n s.unselect_all();\n this.el.remove(ref iter);\n\n \n \n \n // \n \n \n\n\n this.activePath= \"\"; // again!?!? \n //this.changed(null,true);\n \n _this.changed();\n \n _this.view.blockChanges = false;\n}\n", + "# Project.Project? project" : "null", + "n_columns" : 3, + "$ xns" : "Gtk", + "| JsRender.Node pathToNode" : "(string path) {\n \n \n Gtk.TreeIter iter;\n _this.model.el.get_iter_from_string(out iter, path);\n \n GLib.Value value;\n _this.model.el.get_value(iter, 2, out value);\n \n return (JsRender.Node)value.dup_object();\n\n}", + "| void dropNode" : "(string target_data_str, JsRender.Node node, bool show_templates) {\n// print(\"drop Node\");\n // console.dump(node);\n // console.dump(target_data);\n \n \n // 0 = before , 1=after 2/3 onto\n \n \n var target_data= target_data_str.split(\"|\");\n \n var parent_str = target_data[0].length > 0 ? target_data[0] : \"\";\n var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop..\n \n \n Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null;\n \n \n \n //print(\"add \" + tp + \"@\" + target_data[1] );\n \n JsRender.Node parentNode = null;\n \n Gtk.TreeIter iter_after;\n Gtk.TreeIter iter_par ;\n \n \n if (target_data.length == 3 && target_data[2].length > 0) {\n node.props.set(\"* prop\", target_data[2]);\n }\n\n Gtk.TreePath expand_parent = null;\n \n // we only need to show the template if it's come from else where?\n if (show_templates) {\n \n if (this.template_select == null) {\n this.template_select = new DialogTemplateSelect();\n }\n \n var new_node = this.template_select.show(\n (Gtk.Window) _this.el.get_toplevel (),\n this.file.palete(),\n node);\n \n if (new_node != null) {\n node = new_node;\n }\n } \n \n //print(\"pos is %d \\n\".printf(pos));\n \n Gtk.TreeIter n_iter; \n \n if ( parent_str.length < 1) {\n this.el.append(out n_iter, null); // drop at top level..\n node.parent = null;\n this.file.tree = node;\n \n \n } else if (pos < 2) {\n //print(target_data[1] > 0 ? 'insert_after' : 'insert_before');\n \n this.el.get_iter(out iter_after, tree_path ); \n this.el.iter_parent(out iter_par, iter_after);\n expand_parent = this.el.get_path(iter_par);\n \n GLib.Value value;\n this.el.get_value( iter_par, 2, out value);\n parentNode = (JsRender.Node)value.dup_object();\n \n \n this.el.get_value( iter_after, 2, out value);\n var relNode = (JsRender.Node)value.dup_object();\n \n if ( pos > 0 ) {\n \n this.el.insert_after(out n_iter, iter_par , iter_after);\n var ix = parentNode.items.index_of(relNode);\n parentNode.items.insert(ix+1, node);\n \n } else {\n this.el.insert_before(out n_iter, iter_par , iter_after);\n var ix = parentNode.items.index_of(relNode);\n parentNode.items.insert(ix, node);\n \n }\n node.parent = parentNode;\n \n \n \n } else {\n // print(\"appending to \" + parent_str);\n this.el.get_iter(out iter_par, tree_path);\n this.el.append(out n_iter, iter_par );\n expand_parent = this.el.get_path(iter_par);\n \n GLib.Value value;\n this.el.get_value( iter_par, 2, out value);\n parentNode = (JsRender.Node)value.dup_object();\n node.parent = parentNode;\n parentNode.items.add(node);\n }\n \n // reparent node in tree...\n \n \n // why only on no parent???\n \n //if (node.parent = null) {\n \n \n \n //}\n \n \n // work out what kind of packing to use.. -- should be in \n if (!node.has(\"pack\") && parent_str.length > 1) {\n \n this.file.palete().fillPack(node,parentNode);\n \n \n }\n \n // add the node...\n \n this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 );\n var o = new GLib.Value(typeof(Object));\n o.set_object((Object)node);\n \n this.el.set_value(n_iter, 2, o);\n \n \n \n \n// load children - if it has any..\n \n if (node.items.size > 0) {\n this.load(node.items, n_iter);\n _this.view.el.expand_row(this.el.get_path(n_iter), true);\n } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) {\n _this.view.el.expand_row(expand_parent,true);\n }\n\n //if (tp != null && (node.items.length() > 0 || pos > 1)) {\n // _this.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\n \n \n _this.view.el.set_cursor(this.el.get_path(n_iter), null, false);\n _this.changed();\n \n \n \n}\n", + "$ listAllTypes" : "function() {\n var s = this.get('/LeftTree.view').selection;\n print (\"LIST ALL TYPES: \" + s.count_selected_rows() );\n \n if (s.count_selected_rows() > 0) {\n var iter = new Gtk.TreeIter(); \n s.get_selected(this.el, iter);\n\n // set some properties of the tree for use by the dropped element.\n var value = new GObject.Value('');\n this.el.get_value(iter, 2, value);\n var data = JSON.parse(value.value);\n \n \n var xname = this.get('/LeftTree.model').file.guessName(data);\n console.log('selected:' + xname);\n if (xname.length) {\n return [ xname ];\n }\n return []; // could not find it..\n }\n \n var ret = [ ];\n \n var _this = this;\n function addall(li)\n {\n li.forEach(function(el) {\n // this is specific to roo!!!?\n if (!el) { // skip empty?\n return;\n }\n var fullpath = _this.file.guessName(el);\n if (fullpath.length && ret.indexOf(fullpath) < 0) {\n ret.push(fullpath);\n }\n \n \n if (el.items && el.items.length) {\n addall(el.items);\n }\n \n });\n \n \n }\n \n addall([this.currentTree]);\n \n // only if we have nothing, should we add '*top'\n if (!ret.length) {\n ret = [ '*top' ];\n }\n //console.log('all types in tree');\n //console.dump(ret);\n \n return ret;\n \n}\n" + }, + { + "utf8 title" : "test", + "* init" : " this.el.add_attribute(_this.renderer.el , \"markup\", 0 );\n ", + "xtype" : "TreeViewColumn", + "* pack" : "append_column", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "renderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + } + ] + } + ] + }, + { + "id" : "LeftTreeMenu", + "xtype" : "Menu", + "* pack" : false, + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "activate" : " ( ) => {\n \n print(\"ACTIVATE?\");\n \n \n _this.model.deleteSelected();\n}" + }, + "label" : "Delete Element", + "xtype" : "MenuItem", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " () => {\n\n DialogSaveTemplate.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.model.file.palete(), \n _this.getActiveElement()\n );\n \n \n}" + }, + "label" : "Save as Template", + "xtype" : "MenuItem", + "* pack" : "add", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "activate" : " () => {\n var node = _this.getActiveElement();\n var name = DialogSaveModule.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.model.file.project, \n node\n );\n if (name.length < 1) {\n return;\n \n }\n node.props.set(\"* xinclude\", name);\n node.items.clear();\n\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n Gtk.TreeIter citer;\n var n_cn = mod.iter_n_children(iter) -1;\n for (var i = n_cn; i > -1; i--) {\n mod.iter_nth_child(out citer, iter, i);\n \n\n print(\"removing node from Tree\\n\"); \n \n _this.model.el.remove(ref citer);\n }\n _this.changed();\n _this.node_selected(node);\n \n \n}" + }, + "label" : "Save as Module", + "xtype" : "MenuItem", + "* pack" : "add", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/WindowLeftTree.vala b/old-javascript/Builder4/WindowLeftTree.vala new file mode 100644 index 000000000..8018e8eeb --- /dev/null +++ b/old-javascript/Builder4/WindowLeftTree.vala @@ -0,0 +1,1566 @@ +static Xcls_WindowLeftTree _WindowLeftTree; + +public class Xcls_WindowLeftTree : Object +{ + public Gtk.ScrolledWindow el; + private Xcls_WindowLeftTree _this; + + public static Xcls_WindowLeftTree singleton() + { + if (_WindowLeftTree == null) { + _WindowLeftTree= new Xcls_WindowLeftTree(); + } + return _WindowLeftTree; + } + public Xcls_view view; + public Xcls_model model; + public Xcls_renderer renderer; + public Xcls_LeftTreeMenu LeftTreeMenu; + + // my vars (def) + public signal bool before_node_change (JsRender.Node? node); + public signal void changed (); + public signal void node_selected (JsRender.Node? node); + public Xcls_MainWindow main_window; + + // ctor + public Xcls_WindowLeftTree() + { + _this = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + this.main_window = null; + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_LeftTreeMenu( _this ); + child_1.ref(); + + // init method + + this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); } + + // user defined functions + public JsRender.Node? getActiveElement () { // return path to actie node. + + var path = this.getActivePath(); + if (path.length < 1) { + return null; + } + return _this.model.pathToNode(path); + + } + public JsRender.JsRender getActiveFile () { + return this.model.file; + } + public string getActivePath () { + var model = this.model; + var view = this.view.el; + if (view.get_selection().count_selected_rows() < 1) { + return ""; + } + Gtk.TreeIter iter; + Gtk.TreeModel mod; + view.get_selection().get_selected(out mod, out iter); + return mod.get_path(iter).to_string(); + } + public class Xcls_view : Object + { + public Gtk.TreeView el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + public string dragData; + public int drag_x; + public string[] dropList; + public int drag_y; + public bool drag_in_motion; + public bool blockChanges; + + // ctor + public Xcls_view(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.view = this; + this.el = new Gtk.TreeView(); + + // my vars (dec) + this.blockChanges = false; + + // set gobject values + this.el.tooltip_column = 1; + this.el.enable_tree_lines = true; + this.el.headers_visible = false; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn4( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.modify_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + + + // 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 */ + Builder4.Application.targetList, /* lists of target to support */ + Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */ + ); + + // ?? needed?? + //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, + Builder4.Application.targetList, /* lists of target to support */ + Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */ + ); + + //Gtk.drag_dest_set_target_list(this.el, Builder.Application.targetList); + //Gtk.drag_dest_add_text_targets(this.el); + } + // listeners + this.el.button_press_event.connect( ( ev) => { + //console.log("button press?"); + if (! _this.before_node_change(null) ) { + return true; + } + + + if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) { + //print("click" + ev.type); + return false; + } + Gtk.TreePath res; + if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) { + return true; + } + + this.el.get_selection().select_path(res); + + //if (!this.get('/LeftTreeMenu').el) { + // this.get('/LeftTreeMenu').init(); + // } + + _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default()); + _this.LeftTreeMenu.el.show_all(); + _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time); + // print("click:" + res.path.to_string()); + return true; + }); + this.el.drag_begin.connect( ( ctx) => { + //print('SOURCE: drag-begin'); + + + //this.targetData = ""; + + // find what is selected in our tree... + + var s = _this.view.el.get_selection(); + if (s.count_selected_rows() < 1) { + return; + } + Gtk.TreeIter iter; + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + + + + // set some properties of the tree for use by the dropped element. + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + var tp = mod.get_path(iter).to_string(); + var data = (JsRender.Node)(value.dup_object()); + var xname = data.fqn(); + print ("XNAME IS " + xname+ "\n"); + this.dragData = tp; + this.dropList = _this.model.file.palete().getDropList(xname); + + print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n"); + + + // make the drag icon a picture of the node that was selected + + + // by default returns the path.. + var path = _this.model.el.get_path(iter); + + + var pix = this.el.create_row_drag_icon ( path); + + Gtk.drag_set_icon_surface (ctx, pix) ; + + return; + }); + this.el.cursor_changed.connect( ( ) => { + + + if (this.blockChanges) { // probably not needed.. + return ; + } + if (!_this.before_node_change(null) ) { + this.blockChanges = true; + this.el.get_selection().unselect_all(); + this.blockChanges = false; + return; + } + if (_this.model.file == null) { + return; + } + + //var render = this.get('/LeftTree').getRenderer(); + print("LEFT TREE -> view -> selection changed called\n"); + + + // -- it appears that the selection is not updated. + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + + if (this.el.get_selection().count_selected_rows() < 1) { + + print("selected rows < 1\n"); + //??this.model.load( false); + _this.node_selected(null); + + return false ; + } + + //console.log('changed'); + var s = this.el.get_selection(); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + + + // var val = ""; + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + _this.model.activePath = mod.get_path(iter).to_string(); + + var node = (JsRender.Node)value.dup_object(); + _this.node_selected(node); + return false; + }); + //_this.after_node_change(node); + + // _this.model.file.changed(node, "tree"); + + //Seed.print( value.get_string()); + return ; + + }); + this.el.drag_end.connect( (drag_context) => { + //Seed.print('LEFT-TREE: drag-end'); + this.dragData = ""; + this.dropList = null; + // this.targetData = ""; + this.highlightDropPath("",0); + // return true; + }); + this.el.drag_motion.connect( ( ctx, x, y, time) => { + print("got drag motion\n"); + var src = Gtk.drag_get_source_widget(ctx); + this.drag_x = x; + this.drag_y = y; + + if (src != this.el) { + + + + // the point of this is to detect where an item could be dropped.. + print("requesting drag data\n"); + this.drag_in_motion = true; + + // request data that will be recieved by the recieve... + Gtk.drag_get_data + ( + this.el, // will receive 'drag-data-received' signal + ctx, // represents the current state of the DnD + Gdk.Atom.intern("STRING",true), // the target type we want + time // time stamp + ); + return true; + } + + + print("action: %d\n", ctx.get_actions()); + //print("GETTING POS"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + // ------------- a drag from self.. + + + //var action = Gdk.DragAction.COPY; + // unless we are copying!!! ctl button.. + + var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? + Gdk.DragAction.COPY : Gdk.DragAction.MOVE ; + // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; + + + if (_this.model.el.iter_n_children(null) < 1) { + // no children.. -- asume it's ok.. + + targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + Gdk.drag_status(ctx, action ,time); + return true; + + // continue through to allow drop... + + } + + + + + + //print("ISOVER? " + isOver); + if (!isOver) { + + Gdk.drag_status(ctx, 0 ,time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + + } + + // drag node is parent of child.. + //console.log("SRC TREEPATH: " + src.treepath); + //console.log("TARGET TREEPATH: " + data.path.to_string()); + + // nned to check a few here.. + //Gtk.TreeViewDropPosition.INTO_OR_AFTER + //Gtk.TreeViewDropPosition.INTO_OR_BEFORE + //Gtk.TreeViewDropPosition.AFTER + //Gtk.TreeViewDropPosition.BEFORE + + // locally dragged items to not really use the + var selection_text = this.dragData; + + + + if (selection_text == null || selection_text.length < 1) { + //print("Error - drag selection text returned NULL"); + Gdk.drag_status(ctx, 0 ,time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + } + + + // see if we are dragging into ourself? + var target_path = path.to_string(); + print ("Drag %s onto %s--%d\n ", selection_text, target_path, pos); + + // pos : 3 = ontop - 0 = after, 1 = before + //print("target_path="+target_path); + + // + if (selection_text == target_path) { + print("self drag ?? == we should perhaps allow copy onto self..\n"); + + Gdk.drag_status(ctx, 0 ,time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + // -- fixme -- this is not really correct.. + + } + + // check that + //print("DUMPING DATA"); + //console.dump(data); + // path, pos + + //print(data.path.to_string() +' => '+ data.pos); + + // dropList is a list of xtypes that this node could be dropped on. + // it is set up when we start to drag.. + + + targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos); + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + //print("Can not find drop node path"); + + Gdk.drag_status(ctx, 0, time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return false; + } + + var td_ar = targetData.split("|"); + + + + Gdk.drag_status(ctx, action ,time); + this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1])); + return true; + + + }); + this.el.drag_data_get.connect( ( drag_context, data, info, time) => { + + + //print("drag-data-get"); + var s = this.el.get_selection(); + if (s.count_selected_rows() < 1) { + data.set_text("",0); + print("return empty string - no selection.."); + return; + } + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + s.get_selected(out mod, out iter); + + + + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + var ndata = (JsRender.Node)(value.dup_object()); + var xname = ndata.fqn(); + + + var tp = mod.get_path(iter).to_string(); + // by default returns the path.. + + if ( info != Gdk.Atom.intern("STRING",true) ) { + tp = ndata.toJsonString(); + } + + //data.set_text(tp,tp.length); + + data.set (data.get_target (), 8, (uchar[]) tp.to_utf8 ()); + + + // print("return " + tp); + }); + this.el.drag_data_received.connect( (ctx, x, y, sel, info, time) => { + + // THIS CODE ONLY RELATES TO drag or drop of "NEW" elements or "FROM another tree.." + + + // print("Tree: drag-data-received\n"); + var selection_text = (string)sel.get_data(); + //print("selection_text= %s\n",selection_text); + + var is_drag = this.drag_in_motion; + + + + print("Is Drag %s\n", is_drag ? "Y": "N"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + //console.log("LEFT-TREE: drag-motion"); + var src = Gtk.drag_get_source_widget(ctx); + + // a drag from self - this should be handled by drop and motion. + if (src == this.el) { + print("Source == this element should not happen.. ? \n"); + return; + } + //print("drag_data_recieved from another element"); + + + + + if (selection_text == null || selection_text.length < 1 || !isOver) { + // nothing valid foudn to drop... + print("empty sel text or not over"); + if (is_drag) { + Gdk.drag_status(ctx, 0, time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return; + } + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + // no drop action... + return; + + } + var dropNode = new JsRender.Node(); + + var dropNodeType = selection_text; + var show_templates = true; + // for drop + if (dropNodeType[0] == '{') { + var pa = new Json.Parser(); + pa.load_from_data(dropNodeType); + + dropNode.loadFromJson( pa.get_root().get_object(), 2); + dropNodeType = dropNode.fqn(); + show_templates = false; + + + } else { + + dropNode.setFqn(selection_text); + } + + + // dropList --- need to gather this ... + print("get dropList for : %s\n",dropNodeType); + var dropList = _this.model.file.palete().getDropList(dropNodeType); + + print("dropList: %s\n", string.joinv(" , ", dropList)); + + // if drag action is link ... then we can drop it anywahere... + if ((ctx.get_actions() & Gdk.DragAction.LINK) > 0) { + targetData = path.to_string() + "|%d".printf((int)pos); + } else { + + + targetData = _this.model.findDropNodeByPath( isEmpty ? "" : path.to_string(), dropList, pos); + } + + + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + + // invalid drop path.. + if (this.drag_in_motion) { + Gdk.drag_status(ctx, 0, time); + this.highlightDropPath("", (Gtk.TreeViewDropPosition)0); + return; + } + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + // no drop action... + return; + } + // valid drop path.. + + var td_ar = targetData.split("|"); + + + if (this.drag_in_motion) { + Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time); + + this.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1])); + return; + } + // continue on to allow drop.. + + + // at this point, drag is not in motion... -- as checked above... - so it's a real drop event.. + + + _this.model.dropNode(targetData, dropNode, show_templates); + print("ADD new node!!!\n"); + + ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node); + + Gtk.drag_finish (ctx, false, false,time); + + + + + + }); + this.el.drag_drop.connect( ( ctx, x, y, time) => { + //Seed.print("TARGET: drag-drop"); + + + var src = Gtk.drag_get_source_widget(ctx); + + if (src != this.el) { + + + + this.drag_in_motion = false; + // request data that will be recieved by the recieve... + Gtk.drag_get_data + ( + this.el, // will receive 'drag-data-received' signal + ctx, // represents the current state of the DnD + Gdk.Atom.intern("application/json",true), // the target type we want + time // time stamp + ); + + + // No target offered by source => error + + + return false; + } + + // handle drop around self.. + + + + //print("GETTING POS"); + var targetData = ""; + + Gtk.TreePath path; + Gtk.TreeViewDropPosition pos; + var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos); + + // if there are not items in the tree.. the we have to set isOver to true for anything.. + var isEmpty = false; + if (_this.model.el.iter_n_children(null) < 1) { + print("got NO children?\n"); + isOver = true; //??? + isEmpty = true; + pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER; + } + + + + //var action = Gdk.DragAction.COPY; + // unless we are copying!!! ctl button.. + + var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? + Gdk.DragAction.COPY : Gdk.DragAction.MOVE ; + // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ; + + + if (_this.model.el.iter_n_children(null) < 1) { + // no children.. -- asume it's ok.. + + targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + + // continue through to allow drop... + + } else { + + + + + + //print("ISOVER? " + isOver); + if (!isOver) { + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; // not over apoint!?! - no action on drop or motion.. + } + + // drag node is parent of child.. + //console.log("SRC TREEPATH: " + src.treepath); + //console.log("TARGET TREEPATH: " + data.path.to_string()); + + // nned to check a few here.. + //Gtk.TreeViewDropPosition.INTO_OR_AFTER + //Gtk.TreeViewDropPosition.INTO_OR_BEFORE + //Gtk.TreeViewDropPosition.AFTER + //Gtk.TreeViewDropPosition.BEFORE + + // locally dragged items to not really use the + var selection_text = this.dragData; + + + + if (selection_text == null || selection_text.length < 1) { + //print("Error - drag selection text returned NULL"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; /// -- fixme -- this is not really correct.. + } + + // see if we are dragging into ourself? + print ("got selection text of " + selection_text); + + var target_path = path.to_string(); + //print("target_path="+target_path); + + // + if (selection_text == target_path) { + print("self drag ?? == we should perhaps allow copy onto self..\n"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + + return true; /// -- fixme -- this is not really correct.. + + } + + // check that + //print("DUMPING DATA"); + //console.dump(data); + // path, pos + + //print(data.path.to_string() +' => '+ data.pos); + + // dropList is a list of xtypes that this node could be dropped on. + // it is set up when we start to drag.. + + + targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos); + + print("targetDAta: " + targetData +"\n"); + + if (targetData.length < 1) { + //print("Can not find drop node path"); + + Gtk.drag_finish (ctx, false, false, time); // drop failed.. + return true; + } + + var td_ar = targetData.split("|"); + + + + // continue on to allow drop.. + } + // at this point, drag is not in motion... -- as checked above... - so it's a real drop event.. + + + var delete_selection_data = false; + + if (action == Gdk.DragAction.ASK) { + /* Ask the user to move or copy, then set the ctx action. */ + } + + if (action == Gdk.DragAction.MOVE) { + delete_selection_data = true; + } + + // drag around.. - reorder.. + _this.model.moveNode(targetData, action); + + + + + + // we can send stuff to souce here... + + + // do we always say failure, so we handle the reall drop? + Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time); + + return true; + + + + + + + }); + } + + // user defined functions + public void highlightDropPath ( string treepath, Gtk.TreeViewDropPosition pos) { + + // highlighting for drag/drop + if (treepath.length > 0) { + this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos); + } else { + this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER); + } + + } + public void selectNode (string 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); + } + } + public class Xcls_model : Object + { + public Gtk.TreeStore el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + public DialogTemplateSelect template_select; + public JsRender.JsRender? file; + public string activePath; + public Project.Project? project; + + // ctor + public Xcls_model(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.TreeStore( 3, typeof(string),typeof(string),typeof(Object) ); + + // my vars (dec) + this.template_select = null; + this.file = null; + this.activePath = ""; + this.project = null; + + // set gobject values + + // init method + + print("model initialized"); } + + // user defined functions + public string findDropNode (string treepath_str, string[] targets) { + + // this is used by the dragdrop code in the roo version AFAIR.. + + //var path = treepath_str.replace(/^builder-/, ''); + // treemap is depreciated... - should really check if model has any entries.. + + if (this.el.iter_n_children(null) < 1) { + //print("NO KEYS"); + return "|%d".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER); + } + //print("FIND treepath: " + path); + //console.dump(this.treemap); + + //if (!treepath_str.match(/^builder-/)) { + // return []; // nothing! + //} + if (targets.length > 0 && targets[0] == "*") { + return treepath_str; + } + return this.findDropNodeByPath(treepath_str,targets, -1); + } + public void loadFile (JsRender.JsRender f) { + //console.dump(f); + this.el.clear(); + this.file = f; + + + // if (!f) { + // console.log('missing file'); + // return; + // } + + // load the file if not loaded.. + if (f.tree == null) { + f.loadItems( ); + } + // if it's still null? + if (f.tree == null) { + return; + } + + /// this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name); + + //if (f.items.length && typeof(f.items[0]) == 'string') { + + //this.get('/RightEditor').el.show(); + //this.get('/RightEditor.view').load( f.items[0]); + // return; + //} + //print("LOAD"); + //print(JSON.stringify(f.items, null,4)); + //console.dump(f.items); + var o = new Gee.ArrayList(); + o.add(f.tree); + this.load(o,null); + + _this.view.el.expand_all(); + + if (f.tree.items.size < 1) { + // single item.. + + //this.get('/Window.leftvpaned').el.set_position(80); + // select first... + _this.view.el.set_cursor( + new Gtk.TreePath.from_string("0"), null, false); + + + } else { + //this.get('/Window.leftvpaned').el.set_position(200); + } + + return; + /* + + //print("hide right editior"); + //this.get('/RightEditor').el.hide(); + //this.get('/Editor').el.hide(); + //print("set current tree"); + //this.currentTree = this.toJS(false, false)[0]; + //console.dump(this.currentTree); + //this.currentTree = this.currentTree || { items: [] }; + //_this.renderView(); + //console.dump(this.map); + //var RightPalete = imports.Builder.RightPalete.RightPalete; + + + var pm = this.get('/RightPalete.model'); + // set up provider.. + + this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider(); + + if (!this.get('/RightPalete').provider) { + print ("********* PALETE PROVIDER MISSING?!!"); + } + this.get('/LeftTree').renderView(); + + pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes())); + + + + this.get('/Window.view-notebook').el.set_current_page( + this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1); + */ + + } + public void updateSelected () { + + + var s = _this.view.el.get_selection(); + + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + + GLib.Value value; + this.el.get_value(iter, 2, out value); + var node = (JsRender.Node)(value.get_object()); + + this.el.set(iter, 0, node.nodeTitle(), + 1, node.nodeTip(), -1 + ); + } + public string findDropNodeByPath (string treepath_str, string[] targets, int in_pref = -1) { + + var path = treepath_str; // dupe it.. + + + // pref : 3 = ontop - 0 = after, 1 = before + int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref; + + var last = ""; + + //console.dump(this.treemap); + + print("findDropNodeByPath : got path length %d / %s\n", path.length, path); + + if (path.length == 0) { + // top drop. // just return empty.. + return "|%d".printf((int)pref) ; + + } + + + while (path.length > 0) { + + if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) { + if (path.last_index_of(":") < 0 ) { + return ""; + } + path = path.substring(0, path.last_index_of(":")); + last = treepath_str; + print("DROP before or after : using %s\n",path); + continue; + } + + //print("LOOKING FOR PATH: " + path); + var node_data = this.pathToNode(path); + + if (node_data == null) { + print("node not found"); + return ""; + } + + var xname = node_data.fqn(); + var match = ""; + var prop = ""; + + for (var i =0; i < targets.length; i++) { + var tg = targets[i]; + if ((tg == xname) ) { + match = tg; + break; + } + // if target is "xxxx:name" + if (tg.contains(xname +":")) { + match = tg; + var ar = tg.split(":"); + prop = ar[1]; + break; + } + } + + if (match.length > 0) { + if (last.length > 0) { // pref is after/before.. + // then it's after last + //if (pref > 1) { + // return ""; + //} + return last + "|%d".printf((int)pref) + "|" + prop; + + + } + return path + "|%d".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER);// + "|" + prop; + } + /* + last = "" + path; + var par = path.split(":"); + string [] ppar = {}; + for (var i = 0; i < par.length-1; i++) { + ppar += par[i]; + } + + path = string.joinv(":", ppar); + */ + break; + + } + + return ""; + + } + public void moveNode (string target_data, Gdk.DragAction action) + { + + /// target_data = "path|pos"); + + + //print("MOVE NODE"); + // console.dump(target_data); + Gtk.TreeIter old_iter; + Gtk.TreeModel mod; + + var s = _this.view.el.get_selection(); + s.get_selected(out mod , out old_iter); + mod.get_path(old_iter); + + var node = this.pathToNode(mod.get_path(old_iter).to_string()); + //console.dump(node); + if (node == null) { + print("moveNode: ERROR - node is null?"); + } + + + + // needs to drop first, otherwise the target_data + // treepath will be invalid. + + + if ((action & Gdk.DragAction.MOVE) > 0) { + print("REMOVING OLD NODE : " + target_data + "\n"); + node.remove(); + this.dropNode(target_data, node, false); + this.el.remove(ref old_iter); + + + + } else { + print("DROPPING NODE // copy: " + target_data + "\n"); + node = node.deepClone(); + this.dropNode(target_data, node, false); + } + _this.changed(); + this.activePath= ""; + //this.updateNode(false,true); + } + public void load (Gee.ArrayList tr, Gtk.TreeIter? iter) + { + Gtk.TreeIter citer; + //this.insert(citer,iter,0); + for(var i =0 ; i < tr.size; i++) { + if (iter != null) { + this.el.insert(out citer,iter,-1); // why not append? + } else { + this.el.append(out citer,null); + } + + this.el.set(citer, 0, tr.get(i).nodeTitle(), + 1, tr.get(i).nodeTip(), -1 + ); + var o = new GLib.Value(typeof(Object)); + o.set_object((Object)tr.get(i)); + + this.el.set_value(citer, 2, o); + + if (tr.get(i).items.size > 0) { + this.load(tr.get(i).items, citer); + } + + } + + + } + public void deleteSelected () { + + print("DELETE SELECTED?"); + //_this.view.blockChanges = true; + print("GET SELECTION?"); + + var s = _this.view.el.get_selection(); + + print("GET SELECTED?"); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + + + + this.activePath= ""; + print("GET vnode value?"); + + GLib.Value value; + this.el.get_value(iter, 2, out value); + var data = (JsRender.Node)(value.get_object()); + print("removing node from Render\n"); + if (data.parent == null) { + this.file.tree = null; + } else { + data.remove(); + } + print("removing node from Tree\n"); + s.unselect_all(); + this.el.remove(ref iter); + + + + + // + + + + + this.activePath= ""; // again!?!? + //this.changed(null,true); + + _this.changed(); + + _this.view.blockChanges = false; + } + public JsRender.Node pathToNode (string path) { + + + Gtk.TreeIter iter; + _this.model.el.get_iter_from_string(out iter, path); + + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + + return (JsRender.Node)value.dup_object(); + + } + public void dropNode (string target_data_str, JsRender.Node node, bool show_templates) { + // print("drop Node"); + // console.dump(node); + // console.dump(target_data); + + + // 0 = before , 1=after 2/3 onto + + + var target_data= target_data_str.split("|"); + + var parent_str = target_data[0].length > 0 ? target_data[0] : ""; + var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop.. + + + Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null; + + + + //print("add " + tp + "@" + target_data[1] ); + + JsRender.Node parentNode = null; + + Gtk.TreeIter iter_after; + Gtk.TreeIter iter_par ; + + + if (target_data.length == 3 && target_data[2].length > 0) { + node.props.set("* prop", target_data[2]); + } + + Gtk.TreePath expand_parent = null; + + // we only need to show the template if it's come from else where? + if (show_templates) { + + if (this.template_select == null) { + this.template_select = new DialogTemplateSelect(); + } + + var new_node = this.template_select.show( + (Gtk.Window) _this.el.get_toplevel (), + this.file.palete(), + node); + + if (new_node != null) { + node = new_node; + } + } + + //print("pos is %d \n".printf(pos)); + + Gtk.TreeIter n_iter; + + if ( parent_str.length < 1) { + this.el.append(out n_iter, null); // drop at top level.. + node.parent = null; + this.file.tree = node; + + + } else if (pos < 2) { + //print(target_data[1] > 0 ? 'insert_after' : 'insert_before'); + + this.el.get_iter(out iter_after, tree_path ); + this.el.iter_parent(out iter_par, iter_after); + expand_parent = this.el.get_path(iter_par); + + GLib.Value value; + this.el.get_value( iter_par, 2, out value); + parentNode = (JsRender.Node)value.dup_object(); + + + this.el.get_value( iter_after, 2, out value); + var relNode = (JsRender.Node)value.dup_object(); + + if ( pos > 0 ) { + + this.el.insert_after(out n_iter, iter_par , iter_after); + var ix = parentNode.items.index_of(relNode); + parentNode.items.insert(ix+1, node); + + } else { + this.el.insert_before(out n_iter, iter_par , iter_after); + var ix = parentNode.items.index_of(relNode); + parentNode.items.insert(ix, node); + + } + node.parent = parentNode; + + + + } else { + // print("appending to " + parent_str); + this.el.get_iter(out iter_par, tree_path); + this.el.append(out n_iter, iter_par ); + expand_parent = this.el.get_path(iter_par); + + GLib.Value value; + this.el.get_value( iter_par, 2, out value); + parentNode = (JsRender.Node)value.dup_object(); + node.parent = parentNode; + parentNode.items.add(node); + } + + // reparent node in tree... + + + // why only on no parent??? + + //if (node.parent = null) { + + + + //} + + + // work out what kind of packing to use.. -- should be in + if (!node.has("pack") && parent_str.length > 1) { + + this.file.palete().fillPack(node,parentNode); + + + } + + // add the node... + + this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 ); + var o = new GLib.Value(typeof(Object)); + o.set_object((Object)node); + + this.el.set_value(n_iter, 2, o); + + + + + // load children - if it has any.. + + if (node.items.size > 0) { + this.load(node.items, n_iter); + _this.view.el.expand_row(this.el.get_path(n_iter), true); + } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) { + _this.view.el.expand_row(expand_parent,true); + } + + //if (tp != null && (node.items.length() > 0 || pos > 1)) { + // _this.view.el.expand_row(this.el.get_path(iter_par), true); + // } + // wee need to get the empty proptypes from somewhere.. + + //var olditer = this.activeIter; + this.activePath = this.el.get_path(n_iter).to_string(); + + + + + _this.view.el.set_cursor(this.el.get_path(n_iter), null, false); + _this.changed(); + + + + } + } + public class Xcls_TreeViewColumn4 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn4(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + this.el.title = "test"; + var child_0 = new Xcls_renderer( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.renderer.el , "markup", 0 ); } + + // user defined functions + } + public class Xcls_renderer : Object + { + public Gtk.CellRendererText el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_renderer(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.renderer = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_LeftTreeMenu : Object + { + public Gtk.Menu el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + _this.LeftTreeMenu = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_MenuItem7( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + var child_1 = new Xcls_MenuItem8( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_MenuItem9( _this ); + child_2.ref(); + this.el.add ( child_2.el ); + } + + // user defined functions + } + public class Xcls_MenuItem7 : Object + { + public Gtk.MenuItem el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem7(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Delete Element"; + + // listeners + this.el.activate.connect( ( ) => { + + print("ACTIVATE?"); + + + _this.model.deleteSelected(); + }); + } + + // user defined functions + } + public class Xcls_MenuItem8 : Object + { + public Gtk.MenuItem el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem8(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save as Template"; + + // listeners + this.el.activate.connect( () => { + + DialogSaveTemplate.singleton().show( + (Gtk.Window) _this.el.get_toplevel (), + _this.model.file.palete(), + _this.getActiveElement() + ); + + + }); + } + + // user defined functions + } + public class Xcls_MenuItem9 : Object + { + public Gtk.MenuItem el; + private Xcls_WindowLeftTree _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem9(Xcls_WindowLeftTree _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Save as Module"; + + // listeners + this.el.activate.connect( () => { + var node = _this.getActiveElement(); + var name = DialogSaveModule.singleton().show( + (Gtk.Window) _this.el.get_toplevel (), + _this.model.file.project, + node + ); + if (name.length < 1) { + return; + + } + node.props.set("* xinclude", name); + node.items.clear(); + + + var s = _this.view.el.get_selection(); + + print("GET SELECTED?"); + Gtk.TreeIter iter; + Gtk.TreeModel mod; + + + if (!s.get_selected(out mod, out iter)) { + return; // nothing seleted.. + } + Gtk.TreeIter citer; + var n_cn = mod.iter_n_children(iter) -1; + for (var i = n_cn; i > -1; i--) { + mod.iter_nth_child(out citer, iter, i); + + + print("removing node from Tree\n"); + + _this.model.el.remove(ref citer); + } + _this.changed(); + _this.node_selected(node); + + + }); + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/WindowRightPalete.bjs b/old-javascript/Builder4/WindowRightPalete.bjs new file mode 100644 index 000000000..dadd55969 --- /dev/null +++ b/old-javascript/Builder4/WindowRightPalete.bjs @@ -0,0 +1,80 @@ +{ + "name" : "WindowRightPalete", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/WindowRightPalete.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "id" : "RightPalete", + "@ void after_node_change(JsRender.Node? node)" : "", + "* pack" : "add", + "xtype" : "VBox", + "@ void before_node_change(JsRender.Node? node)" : "", + "| void load" : " (Palete.Palete pal, string cls ) {\n \n // this.get('model').expanded();\n \n var tr = pal.getChildList(cls);\n this.model.el.clear();\n\n\n Gtk.TreeIter citer;\n\n for(var i =0 ; i < tr.length; i++) {\n this.model.el.append(out citer); \n \n this.model.el.set_value(citer, 0, tr[i] ); // title \n \n }\n this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n \n} \n\n", + "@ void drag_end()" : "", + "$ xns" : "Gtk", + "| void clear" : "() {\n this.model.el.clear();\n}", + "items" : [ + { + "id" : "viewbox", + "* pack" : "add", + "xtype" : "VBox", + "$ xns" : "Gtk", + "items" : [ + { + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n this.el.set_size_request(-1,200);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "add", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "button_press_event" : " ( event) => {\n\n //\tif (!this.get('/Editor').save()) {\n //\t // popup!! - click handled.. \n// \t return true;\n// }\n return false;\n}", + "drag_begin" : " ( ctx) => {\n // we could fill this in now...\n// Seed.print('SOURCE: drag-begin');\n \n \n \n Gtk.TreeIter iter;\n var s = this.el.get_selection();\n \n Gtk.TreeModel mod;\n s.get_selected(out mod, out iter);\n var path = mod.get_path(iter);\n \n /// pix is a surface..\n var pix = this.el.create_row_drag_icon ( path);\n \n \n Gtk.drag_set_icon_surface (ctx, pix);\n GLib.Value value;\n \n\n _this.model.el.get_value(iter, 0, out value);\n \n this.dragData = (string) value;\n \n \n return;\n}", + "drag_end" : "( drag_context) => {\n \t print(\"SOURCE: drag-end\\n\");\n\t\n\tthis.dragData = \"\";\n\t//this.dropList = null;\n\t_this.drag_end(); // call signal..\n\t//this.get('/LeftTree.view').highlight(false);\n\t \n}", + "drag_data_get" : "(drag_context, selection_data, info, time) => {\n \t//Seed.print('Palete: drag-data-get: ' + target_type);\n if (this.dragData.length < 1 ) {\n return; \n }\n \n print(\"setting drag data to %s\\n\", this.dragData);\n // selection_data.set_text(this.dragData ,this.dragData.length);\n selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ());\n\n //this.el.dragData = \"TEST from source widget\";\n \n \n}" + }, + "# string dragData" : "", + "* init" : " {\n this.el.set_size_request(150,-1);\n // set_reorderable: [1]\n \n var description = new Pango.FontDescription();\n description.set_size(8000);\n this.el.modify_font(description);\n \n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n // this.selection.signal['changed'].connect(function() {\n // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);\n //});\n // see: http://live.gnome.org/GnomeLove/DragNDropTutorial\n \n Gtk.drag_source_set (\n this.el, /* widget will be drag-able */\n Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */\n Builder4.Application.targetList, /* lists of target to support */\n Gdk.DragAction.COPY /* what to do with data after dropped */\n );\n //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);\n \n // Gtk.drag_source_set_target_list(this.el, Application.targetList);\n // Gtk.drag_source_add_text_targets(this.el); \n \n}\n", + "xtype" : "TreeView", + "* pack" : "add", + "$ enable_tree_lines" : true, + "$ headers_visible" : false, + "$ xns" : "Gtk", + "items" : [ + { + "| string getValue" : " (Gtk.TreeIter iter, int col) {\n GLib.Value gval;\n this.el.get_value(iter, col , out gval);\n return (string)gval;\n \n \n}", + "id" : "model", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk" + }, + { + "* init" : " this.el.add_attribute(_this.txtrender.el , \"markup\", 0 );\n \n", + "* pack" : "append_column", + "xtype" : "TreeViewColumn", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "txtrender", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/WindowRightPalete.vala b/old-javascript/Builder4/WindowRightPalete.vala new file mode 100644 index 000000000..6868f74fd --- /dev/null +++ b/old-javascript/Builder4/WindowRightPalete.vala @@ -0,0 +1,313 @@ +static Xcls_RightPalete _RightPalete; + +public class Xcls_RightPalete : Object +{ + public Gtk.VBox el; + private Xcls_RightPalete _this; + + public static Xcls_RightPalete singleton() + { + if (_RightPalete == null) { + _RightPalete= new Xcls_RightPalete(); + } + return _RightPalete; + } + public Xcls_viewbox viewbox; + public Xcls_model model; + public Xcls_txtrender txtrender; + + // my vars (def) + public signal void after_node_change(JsRender.Node? node) ; + public signal void before_node_change(JsRender.Node? node) ; + public signal void drag_end() ; + + // ctor + public Xcls_RightPalete() + { + _this = this; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_viewbox( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + public void load (Palete.Palete pal, string cls ) { + + // this.get('model').expanded(); + + var tr = pal.getChildList(cls); + this.model.el.clear(); + + + Gtk.TreeIter citer; + + for(var i =0 ; i < tr.length; i++) { + this.model.el.append(out citer); + + this.model.el.set_value(citer, 0, tr[i] ); // title + + } + this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING); + + } + public void clear () { + this.model.el.clear(); + } + public class Xcls_viewbox : Object + { + public Gtk.VBox el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_viewbox(Xcls_RightPalete _owner ) + { + _this = _owner; + _this.viewbox = this; + this.el = new Gtk.VBox( true, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_ScrolledWindow3( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow3 : Object + { + public Gtk.ScrolledWindow el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_ScrolledWindow3(Xcls_RightPalete _owner ) + { + _this = _owner; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_TreeView4( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + this.el.set_size_request(-1,200); } + + // user defined functions + } + public class Xcls_TreeView4 : Object + { + public Gtk.TreeView el; + private Xcls_RightPalete _this; + + + // my vars (def) + public string dragData; + + // ctor + public Xcls_TreeView4(Xcls_RightPalete _owner ) + { + _this = _owner; + this.el = new Gtk.TreeView(); + + // my vars (dec) + + // set gobject values + this.el.enable_tree_lines = true; + this.el.headers_visible = false; + var child_0 = new Xcls_model( _this ); + child_0.ref(); + this.el.set_model ( child_0.el ); + var child_1 = new Xcls_TreeViewColumn6( _this ); + child_1.ref(); + this.el.append_column ( child_1.el ); + + // init method + + { + this.el.set_size_request(150,-1); + // set_reorderable: [1] + + var description = new Pango.FontDescription(); + description.set_size(8000); + this.el.modify_font(description); + + var selection = this.el.get_selection(); + selection.set_mode( Gtk.SelectionMode.SINGLE); + // this.selection.signal['changed'].connect(function() { + // _view.listeners['cursor-changed'].apply(_view, [ _view, '']); + //}); + // see: http://live.gnome.org/GnomeLove/DragNDropTutorial + + Gtk.drag_source_set ( + this.el, /* widget will be drag-able */ + Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */ + Builder4.Application.targetList, /* lists of target to support */ + Gdk.DragAction.COPY /* what to do with data after dropped */ + ); + //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList); + + // Gtk.drag_source_set_target_list(this.el, Application.targetList); + // Gtk.drag_source_add_text_targets(this.el); + + } + // listeners + this.el.button_press_event.connect( ( event) => { + + // if (!this.get('/Editor').save()) { + // // popup!! - click handled.. + // return true; + // } + return false; + }); + this.el.drag_begin.connect( ( ctx) => { + // we could fill this in now... + // Seed.print('SOURCE: drag-begin'); + + + + Gtk.TreeIter iter; + var s = this.el.get_selection(); + + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + var path = mod.get_path(iter); + + /// pix is a surface.. + var pix = this.el.create_row_drag_icon ( path); + + + Gtk.drag_set_icon_surface (ctx, pix); + GLib.Value value; + + + _this.model.el.get_value(iter, 0, out value); + + this.dragData = (string) value; + + + return; + }); + this.el.drag_end.connect( ( drag_context) => { + print("SOURCE: drag-end\n"); + + this.dragData = ""; + //this.dropList = null; + _this.drag_end(); // call signal.. + //this.get('/LeftTree.view').highlight(false); + + }); + this.el.drag_data_get.connect( (drag_context, selection_data, info, time) => { + //Seed.print('Palete: drag-data-get: ' + target_type); + if (this.dragData.length < 1 ) { + return; + } + + print("setting drag data to %s\n", this.dragData); + // selection_data.set_text(this.dragData ,this.dragData.length); + selection_data.set (selection_data.get_target (), 8, (uchar[]) this.dragData.to_utf8 ()); + + //this.el.dragData = "TEST from source widget"; + + + }); + } + + // user defined functions + } + public class Xcls_model : Object + { + public Gtk.ListStore el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_model(Xcls_RightPalete _owner ) + { + _this = _owner; + _this.model = this; + this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public string getValue (Gtk.TreeIter iter, int col) { + GLib.Value gval; + this.el.get_value(iter, col , out gval); + return (string)gval; + + + } + } + public class Xcls_TreeViewColumn6 : Object + { + public Gtk.TreeViewColumn el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_TreeViewColumn6(Xcls_RightPalete _owner ) + { + _this = _owner; + this.el = new Gtk.TreeViewColumn(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_txtrender( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , true ); + + // init method + + this.el.add_attribute(_this.txtrender.el , "markup", 0 ); } + + // user defined functions + } + public class Xcls_txtrender : Object + { + public Gtk.CellRendererText el; + private Xcls_RightPalete _this; + + + // my vars (def) + + // ctor + public Xcls_txtrender(Xcls_RightPalete _owner ) + { + _this = _owner; + _this.txtrender = this; + this.el = new Gtk.CellRendererText(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/WindowRooView.bjs b/old-javascript/Builder4/WindowRooView.bjs new file mode 100644 index 000000000..5324a6f1e --- /dev/null +++ b/old-javascript/Builder4/WindowRooView.bjs @@ -0,0 +1,111 @@ +{ + "name" : "WindowRooView", + "parent" : "", + "title" : "", + "path" : "/home/alan/gitlive/app.Builder.js/Builder4/WindowRooView.bjs", + "permname" : "", + "modOrder" : "", + "items" : [ + { + "id" : "WindowRooView", + "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n var filename = this.file.getIconFileName(false);\n \n var win = this.el.get_parent_window();\n var width = win.get_width();\n var height = win.get_height();\n\n Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.el.position);\n\n screenshot.save(filename,\"png\");\n return;\n \n \n \n \n \n \n \n var p = new WebKit.PrintOperation(_this.view.el);\n \n var ps = new Gtk.PrintSettings();\n ps.set_printer(\"Print to File\");\n ps.set(\"output-file-format\", \"pdf\");\n ps.set(\"output-uri\", \"file://\" + filename + \".pdf\");\n\n // find the printer...\n \n /*\n var ar = Gtk.PaperSize.get_paper_sizes(false);\n var psetup = new Gtk.PageSetup();\n for(var i = 0; i < ar.length(); i++) {\n if (ar.nth_data(i).get_name() ==\"iso_a4\") {\n psetup.set_paper_size(ar.nth_data(i));\n }\n }\n psetup.set_orientation(Gtk.PageOrientation.LANDSCAPE);\n \n \n p.set_page_setup(psetup);\n */\n p.set_print_settings(ps);\n \n p.finished.connect(() => {\n print(\"creating thumbnail for \" + filename + \".pdf\\n\"); \n var s = new Cairo.PdfSurface(filename + \".pdf\", 400,400);\n \n s.write_to_png (filename);\n \n // var f = GLib.File.new_for_path (filename + \".pdf\");\n // f.delete();\n });\n \n \n p.print();\n \n // should we hold until it's printed...\n \n \n\n \n \n\n\n \n \n}\n", + "| void loadFile" : "(JsRender.JsRender file)\n{\n this.file = file;\n this.view.renderJS(true);\n}", + "* pack" : "add", + "xtype" : "VPaned", + "# JsRender.JsRender file" : "", + "| void requestRedraw" : "() {\n this.view.renderJS(false);\n}", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "viewbox", + "* pack" : "pack1,true,true", + "xtype" : "VBox", + "$ xns" : "Gtk", + "$ homogeneous" : false, + "items" : [ + { + "$ vexpand" : false, + "$ height_request" : 20, + "* pack" : "pack_start,false,true,0", + "xtype" : "HBox", + "$ xns" : "Gtk", + "$ homogeneous" : true, + "items" : [ + { + "listeners" : { + "clicked" : "( ) => {\n _this.view.renderJS( true);\n}" + }, + "label" : "Redraw", + "xtype" : "Button", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "toggled" : " (state) => {\n this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");\n}" + }, + "label" : "Auto Redraw On", + "id" : "AutoRedraw", + "$ active" : true, + "* pack" : "pack_start,false,false,0", + "xtype" : "CheckButton", + "$ xns" : "Gtk" + }, + { + "listeners" : { + "clicked" : " () => {\n _this.view.redraws = 99;\n _this.view.el.web_context.clear_cache(); \n _this.view.renderJS(true);\n\n}" + }, + "label" : "Full Redraw", + "xtype" : "Button", + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk" + } + ] + }, + { + "id" : "viewcontainer", + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "* pack" : "pack_end,true,true,0", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "items" : [ + { + "listeners" : { + "script_dialog" : " (dialog) => {\n if (this.el == null) {\n return true;\n }\n \n var msg = dialog.get_message();\n if (msg.length < 4) {\n return false;\n }\n if (msg.substring(0,4) != \"IPC:\") {\n return false;\n }\n var ar = msg.split(\":\", 3);\n if (ar.length < 3) {\n return false;\n }\n switch(ar[1]) {\n case \"SAVEHTML\":\n _this.file.saveHTML(ar[2]);\n return true;\n default:\n return false;\n }\n \n}", + "show" : " ( ) => {\n this.initInspector();;\n}", + "drag_drop" : " ( ctx, x, y,time, ud) => {\n return false;\n /*\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\t*/\n}" + }, + "# string renderedData" : "\"\"", + "id" : "view", + "# bool refreshRequired" : false, + "* init" : " {\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 \n \n \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( \"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, //\n Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,\n null, // list of targets\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(1, () =>{\n //print(\"run refresh?\");\n if (this.el == null) {\n return false;\n }\n this.runRefresh(); \n return true;\n });\n \n \n}\n", + "* pack" : "add", + "redraws" : 0, + "xtype" : "WebView", + "# WebKit.WebInspector inspector" : "", + "# int redraws" : 0, + "| void runRefresh" : " () \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 != null) {\n // do not redraw if last redraw was less that 5 seconds ago.\n if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {\n return;\n }\n }\n \n if (_this.file == null) {\n return;\n }\n \n \n this.refreshRequired = false;\n // print(\"HTML RENDERING\");\n \n \n //this.get('/BottomPane').el.show();\n //this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n _this.file.webkit_page_id = this.el.get_page_id();\n \n var js = _this.file.toSourcePreview();\n\n if (js.length < 1) {\n print(\"no data\");\n return;\n }\n// var data = js[0];\n this.redraws++;\n \n var project = _this.file.project; \n\n //print (project.fn);\n // set it to non-empty.\n \n// runhtml = runhtml.length ? runhtml : ''; \n\n\n// this.runhtml = this.runhtml || '';\n \n \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\n var runhtml = \"\\n\" ;\n\n // fix to make sure they are the same..\n this.runhtml = project.runhtml;\n // need to modify paths\n\n string inhtml;\n var base_template = _this.file.project.base_template;\n \n if (base_template.length > 0 && !FileUtils.test(\n Builder4.Application.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) \n ) {\n print(\"invalid base_template name - using default: %s\\n\", base_template);\n base_template = \"\";\n \n }\n \n GLib.FileUtils.get_contents(\n Builder4.Application.configDirectory() + \"/resources/\" + \n (base_template.length > 0 ? base_template : \"roo.builder.html\")\n , out inhtml);\n \n \n this.renderedData = js;\n\n\n string js_src = js + \"\\n\" +\n\t\"Roo.onReady(function() {\\n\" +\n\t\"if (\" + _this.file.name +\".show) \" + _this.file.name +\".show({});\\n\" +\n\t\"Roo.XComponent.build();\\n\" +\n\t\"});\\n\";\n\t\n // print(\"render js: \" + js);\n //if (!this.ready) {\n // console.log('not loaded yet');\n //}\n this.lastRedraw = new DateTime.now_local();\n\n var html = inhtml.replace(\"\", runhtml + this.runhtml + \n \n \"\" + \n \n \"\");\n //print(\"LOAD HTML \" + html);\n \n var rootURL = _this.file.project.rootURL;\n \n \n \n this.el.load_html( html , \n //fixme - should be a config option!\n (rootURL.length > 0 ? rootURL : \"http://localhost/app.Builder/\")\n );\n \n // force the inspector... \n this.initInspector();\n \n // - no need for this, the builder javascript will call it when build is complete\n //GLib.Timeout.add_seconds(1, () => {\n // this.el.run_javascript(\"Builder.saveHTML()\",null);\n // return false;\n //});\n// print( \"before render\" + this.lastRedraw);\n// print( \"after render\" + (new Date()));\n \n}\n", + "$ xns" : "WebKit", + "| void initInspector" : "() {\n \n if (this.inspector == this.el.get_inspector()) {\n this.inspector.show();\n this.inspector.open_window(); \n print(\"init inspecter called, and inspector is the same as existing\\n\");\n return;\n }\n print(\"new inspector?\\n\");\n\n this.inspector = this.el.get_inspector();\n this.inspector.ref();\n \n // got a new inspector...\n \n this.inspector.open_window.connect(() => {\n this.inspector = this.el.get_inspector();\n print(\"inspector attach\\n\");\n var wv = this.inspector.get_web_view();\n if (wv != null) {\n print(\"got inspector web view\\n\");\n _this.inspectorcontainer.el.add(wv);\n wv.show();\n } else {\n //this.inspector.close();\n \n //this.inspector = null;\n \n \n }\n return true;\n \n });\n this.inspector.closed.connect(() => {\n print(\"inspector closed?!?\");\n // if this happens destroy the webkit..\n // recreate it..\n this.el.stop_loading();\n \n if (_this.viewbox.el.get_parent() == null) {\n return;\n }\n \n \n _this.viewbox.el.remove(_this.viewcontainer.el);\n _this.el.remove(_this.inspectorcontainer.el); \n \n // destory seems to cause problems.\n //this.el.destroy();\n //_this.viewcontainer.el.destroy();\n //_this.inspectorcontainer.el.destroy();\n\n this.el = null; \n var nv =new Xcls_viewcontainer(_this);\n nv.ref();\n _this.viewbox.el.pack_end(nv.el,true,true,0);\n \n var inv =new Xcls_inspectorcontainer(_this);\n inv.ref();\n _this.el.pack2(inv.el,true,true);\n \n inv.el.show_all();\n nv.el.show_all();\n //while(Gtk.events_pending ()) Gtk.main_iteration ();\n //_this.view.renderJS(true); \n _this.view.refreshRequired = true;\n \n }); \n \n this.inspector.show();\n}\n", + "# GLib.DateTime lastRedraw" : "null", + "# string runhtml" : "\"\"", + "# bool pendingRedraw" : false, + "| void renderJS" : "(bool force) {\n\n // this is the public redraw call..\n // we refresh in a loop privately..\n var autodraw = _this.AutoRedraw.el.active;\n if (!autodraw && !force) {\n print(\"Skipping redraw - no force, and autodraw off\");\n return;\n }\n this.refreshRequired = true;\n}\n" + } + ] + } + ] + }, + { + "id" : "inspectorcontainer", + "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", + "xtype" : "ScrolledWindow", + "* pack" : "pack2,true,true", + "$ xns" : "Gtk" + } + ] + } + ] +} \ No newline at end of file diff --git a/old-javascript/Builder4/WindowRooView.vala b/old-javascript/Builder4/WindowRooView.vala new file mode 100644 index 000000000..b1ecb7707 --- /dev/null +++ b/old-javascript/Builder4/WindowRooView.vala @@ -0,0 +1,673 @@ +static Xcls_WindowRooView _WindowRooView; + +public class Xcls_WindowRooView : Object +{ + public Gtk.VPaned el; + private Xcls_WindowRooView _this; + + public static Xcls_WindowRooView singleton() + { + if (_WindowRooView == null) { + _WindowRooView= new Xcls_WindowRooView(); + } + return _WindowRooView; + } + public Xcls_viewbox viewbox; + public Xcls_AutoRedraw AutoRedraw; + public Xcls_viewcontainer viewcontainer; + public Xcls_view view; + public Xcls_inspectorcontainer inspectorcontainer; + + // my vars (def) + public JsRender.JsRender file; + + // ctor + public Xcls_WindowRooView() + { + _this = this; + this.el = new Gtk.VPaned(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_viewbox( _this ); + child_0.ref(); + this.el.pack1 ( child_0.el , true,true ); + var child_1 = new Xcls_inspectorcontainer( _this ); + child_1.ref(); + this.el.pack2 ( child_1.el , true,true ); + } + + // user defined functions + public void createThumb () { + + + if (this.file == null) { + return; + } + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + var height = win.get_height(); + + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.el.position); + + screenshot.save(filename,"png"); + return; + + + + + + + + var p = new WebKit.PrintOperation(_this.view.el); + + var ps = new Gtk.PrintSettings(); + ps.set_printer("Print to File"); + ps.set("output-file-format", "pdf"); + ps.set("output-uri", "file://" + filename + ".pdf"); + + // find the printer... + + /* + var ar = Gtk.PaperSize.get_paper_sizes(false); + var psetup = new Gtk.PageSetup(); + for(var i = 0; i < ar.length(); i++) { + if (ar.nth_data(i).get_name() =="iso_a4") { + psetup.set_paper_size(ar.nth_data(i)); + } + } + psetup.set_orientation(Gtk.PageOrientation.LANDSCAPE); + + + p.set_page_setup(psetup); + */ + p.set_print_settings(ps); + + p.finished.connect(() => { + print("creating thumbnail for " + filename + ".pdf\n"); + var s = new Cairo.PdfSurface(filename + ".pdf", 400,400); + + s.write_to_png (filename); + + // var f = GLib.File.new_for_path (filename + ".pdf"); + // f.delete(); + }); + + + p.print(); + + // should we hold until it's printed... + + + + + + + + + + } + public void loadFile (JsRender.JsRender file) + { + this.file = file; + this.view.renderJS(true); + } + public void requestRedraw () { + this.view.renderJS(false); + } + public class Xcls_viewbox : Object + { + public Gtk.VBox el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_viewbox(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.viewbox = this; + this.el = new Gtk.VBox( false, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_HBox3( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,true,0 ); + var child_1 = new Xcls_viewcontainer( _this ); + child_1.ref(); + this.el.pack_end ( child_1.el , true,true,0 ); + } + + // user defined functions + } + public class Xcls_HBox3 : Object + { + public Gtk.HBox el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_HBox3(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.HBox( true, 0 ); + + // my vars (dec) + + // set gobject values + this.el.height_request = 20; + this.el.vexpand = false; + var child_0 = new Xcls_Button4( _this ); + child_0.ref(); + this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_AutoRedraw( _this ); + child_1.ref(); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_Button6( _this ); + child_2.ref(); + this.el.pack_start ( child_2.el , false,false,0 ); + } + + // user defined functions + } + public class Xcls_Button4 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button4(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Redraw"; + + // listeners + this.el.clicked.connect( ( ) => { + _this.view.renderJS( true); + }); + } + + // user defined functions + } + public class Xcls_AutoRedraw : Object + { + public Gtk.CheckButton el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_AutoRedraw(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.AutoRedraw = this; + this.el = new Gtk.CheckButton(); + + // my vars (dec) + + // set gobject values + this.el.active = true; + this.el.label = "Auto Redraw On"; + + // listeners + this.el.toggled.connect( (state) => { + this.el.set_label(this.el.active ? "Auto Redraw On" : "Auto Redraw Off"); + }); + } + + // user defined functions + } + public class Xcls_Button6 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button6(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.label = "Full Redraw"; + + // listeners + this.el.clicked.connect( () => { + _this.view.redraws = 99; + _this.view.el.web_context.clear_cache(); + _this.view.renderJS(true); + + }); + } + + // user defined functions + } + public class Xcls_viewcontainer : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_viewcontainer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.viewcontainer = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); } + + // user defined functions + } + public class Xcls_view : Object + { + public WebKit.WebView el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public string renderedData; + public bool refreshRequired; + public WebKit.WebInspector inspector; + public int redraws; + public GLib.DateTime lastRedraw; + public string runhtml; + public bool pendingRedraw; + + // ctor + public Xcls_view(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.view = this; + this.el = new WebKit.WebView(); + + // my vars (dec) + this.renderedData = ""; + this.refreshRequired = false; + this.redraws = 0; + this.lastRedraw = null; + this.runhtml = ""; + this.pendingRedraw = false; + + // set gobject values + + // init method + + { + // this may not work!? + var settings = this.el.get_settings(); + settings.enable_developer_extras = 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; + + + + + + + // FIXME - base url of script.. + // we need it so some of the database features work. + this.el.load_html( "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 + ( + this.el, // + Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT, + null, // list of targets + Gdk.DragAction.COPY // what to do with data after dropped + ); + + // print("RB: TARGETS : " + LeftTree.atoms["STRING"]); + Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList); + */ + GLib.Timeout.add_seconds(1, () =>{ + //print("run refresh?"); + if (this.el == null) { + return false; + } + this.runRefresh(); + return true; + }); + + + } + // listeners + this.el.script_dialog.connect( (dialog) => { + if (this.el == null) { + return true; + } + + var msg = dialog.get_message(); + if (msg.length < 4) { + return false; + } + if (msg.substring(0,4) != "IPC:") { + return false; + } + var ar = msg.split(":", 3); + if (ar.length < 3) { + return false; + } + switch(ar[1]) { + case "SAVEHTML": + _this.file.saveHTML(ar[2]); + return true; + default: + return false; + } + + }); + this.el.show.connect( ( ) => { + this.initInspector();; + }); + this.el.drag_drop.connect( ( ctx, x, y,time, ud) => { + return false; + /* + print("TARGET: drag-drop"); + var is_valid_drop_site = true; + + + Gtk.drag_get_data + ( + w, // will receive 'drag-data-received' signal + ctx, /* represents the current state of the DnD + this.get('/Window').atoms["STRING"], /* the target type we want + time /* time stamp + ); + + + /* No target offered by source => error + + + return is_valid_drop_site; + */ + }); + } + + // user defined functions + public void runRefresh () + { + // this is run every 2 seconds from the init.. + + + + if (!this.refreshRequired) { + // print("no refresh required"); + return; + } + + if (this.lastRedraw != null) { + // do not redraw if last redraw was less that 5 seconds ago. + if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) { + return; + } + } + + if (_this.file == null) { + return; + } + + + this.refreshRequired = false; + // print("HTML RENDERING"); + + + //this.get('/BottomPane').el.show(); + //this.get('/BottomPane').el.set_current_page(2);// webkit inspector + _this.file.webkit_page_id = this.el.get_page_id(); + + var js = _this.file.toSourcePreview(); + + if (js.length < 1) { + print("no data"); + return; + } + // var data = js[0]; + this.redraws++; + + var project = _this.file.project; + + //print (project.fn); + // set it to non-empty. + + // runhtml = runhtml.length ? runhtml : ''; + + + // this.runhtml = this.runhtml || ''; + + + // then we need to reload the browser using + // load_html_string.. + + // then trigger a redraw once it's loaded.. + this.pendingRedraw = true; + + var runhtml = "\n" ; + + // fix to make sure they are the same.. + this.runhtml = project.runhtml; + // need to modify paths + + string inhtml; + var base_template = _this.file.project.base_template; + + if (base_template.length > 0 && !FileUtils.test( + Builder4.Application.configDirectory() + "/resources/" + base_template, FileTest.EXISTS) + ) { + print("invalid base_template name - using default: %s\n", base_template); + base_template = ""; + + } + + GLib.FileUtils.get_contents( + Builder4.Application.configDirectory() + "/resources/" + + (base_template.length > 0 ? base_template : "roo.builder.html") + , out inhtml); + + + this.renderedData = js; + + + string js_src = js + "\n" + + "Roo.onReady(function() {\n" + + "if (" + _this.file.name +".show) " + _this.file.name +".show({});\n" + + "Roo.XComponent.build();\n" + + "});\n"; + + // print("render js: " + js); + //if (!this.ready) { + // console.log('not loaded yet'); + //} + this.lastRedraw = new DateTime.now_local(); + + var html = inhtml.replace("", runhtml + this.runhtml + + + "" + + + ""); + //print("LOAD HTML " + html); + + var rootURL = _this.file.project.rootURL; + + + + this.el.load_html( html , + //fixme - should be a config option! + (rootURL.length > 0 ? rootURL : "http://localhost/app.Builder/") + ); + + // force the inspector... + this.initInspector(); + + // - no need for this, the builder javascript will call it when build is complete + //GLib.Timeout.add_seconds(1, () => { + // this.el.run_javascript("Builder.saveHTML()",null); + // return false; + //}); + // print( "before render" + this.lastRedraw); + // print( "after render" + (new Date())); + + } + public void initInspector () { + + if (this.inspector == this.el.get_inspector()) { + this.inspector.show(); + this.inspector.open_window(); + print("init inspecter called, and inspector is the same as existing\n"); + return; + } + print("new inspector?\n"); + + this.inspector = this.el.get_inspector(); + this.inspector.ref(); + + // got a new inspector... + + this.inspector.open_window.connect(() => { + this.inspector = this.el.get_inspector(); + print("inspector attach\n"); + var wv = this.inspector.get_web_view(); + if (wv != null) { + print("got inspector web view\n"); + _this.inspectorcontainer.el.add(wv); + wv.show(); + } else { + //this.inspector.close(); + + //this.inspector = null; + + + } + return true; + + }); + this.inspector.closed.connect(() => { + print("inspector closed?!?"); + // if this happens destroy the webkit.. + // recreate it.. + this.el.stop_loading(); + + if (_this.viewbox.el.get_parent() == null) { + return; + } + + + _this.viewbox.el.remove(_this.viewcontainer.el); + _this.el.remove(_this.inspectorcontainer.el); + + // destory seems to cause problems. + //this.el.destroy(); + //_this.viewcontainer.el.destroy(); + //_this.inspectorcontainer.el.destroy(); + + this.el = null; + var nv =new Xcls_viewcontainer(_this); + nv.ref(); + _this.viewbox.el.pack_end(nv.el,true,true,0); + + var inv =new Xcls_inspectorcontainer(_this); + inv.ref(); + _this.el.pack2(inv.el,true,true); + + inv.el.show_all(); + nv.el.show_all(); + //while(Gtk.events_pending ()) Gtk.main_iteration (); + //_this.view.renderJS(true); + _this.view.refreshRequired = true; + + }); + + this.inspector.show(); + } + public void renderJS (bool force) { + + // this is the public redraw call.. + // we refresh in a loop privately.. + var autodraw = _this.AutoRedraw.el.active; + if (!autodraw && !force) { + print("Skipping redraw - no force, and autodraw off"); + return; + } + this.refreshRequired = true; + } + } + public class Xcls_inspectorcontainer : Object + { + public Gtk.ScrolledWindow el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_inspectorcontainer(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.inspectorcontainer = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.shadow_type = Gtk.ShadowType.IN; + + // init method + + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); } + + // user defined functions + } +} diff --git a/old-javascript/Builder4/config1.builder b/old-javascript/Builder4/config1.builder new file mode 100644 index 000000000..55aa9ce6e --- /dev/null +++ b/old-javascript/Builder4/config1.builder @@ -0,0 +1,34 @@ +[ + { + "name" : "Builder4", + "compile_flags" : "-g", + "target_bin" : "/tmp/Builder5", + "sources" : [ + ], + "packages" : [ + ] + }, + { + "name" : "_default_", + "compile_flags" : "", + "target_bin" : "", + "sources" : [ + "../Builder4", + "../Palete", + "../Project", + "../JsRender" + ], + "packages" : [ + "clutter-gtk-1.0", + "gdk-3.0", + "gtk+-3.0", + "gtksourceview-3.0", + "libxml-2.0", + "json-glib-1.0", + "gobject-introspection-1.0", + "libsoup-2.4", + "posix", + "libvala-0.26" + ] + } +] \ No newline at end of file diff --git a/old-javascript/JSDOC/Collapse.js b/old-javascript/JSDOC/Collapse.js new file mode 100644 index 000000000..71a89fde9 --- /dev/null +++ b/old-javascript/JSDOC/Collapse.js @@ -0,0 +1,260 @@ +//