2 "build_module" : "builder",
5 "# JsRender.JsRender file" : "",
6 "# JsRender.Node node" : "",
7 "# Xcls_MainWindow main_window" : "null",
8 "# bool allow_edit" : false,
9 "$ homogeneous" : "false ",
11 "@ bool stop_editor" : "()",
12 "@ void changed" : "()",
13 "@ void show_add_props" : "(string type)",
14 "@ void show_editor" : "(JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop)",
15 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
20 "* pack" : "pack_start,false,true,0",
21 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
27 "int margin_start" : 5,
28 "string label" : "Add:",
32 "$ tooltip_text" : "\"Add Property\"",
35 "bool always_show_image" : true,
36 "bool hexpand" : true,
40 "* pack" : "set_image",
41 "utf8 icon_name" : "format-justify-left",
49 " _this.main_window.windowstate.showProps(",
51 " \t\tJsRender.NodePropType.PROP",
57 "string label" : "Property",
61 "$ tooltip_text" : "\"Add Event Code\"",
64 "bool always_show_image" : true,
65 "bool hexpand" : true,
69 "* pack" : "set_image",
70 "utf8 icon_name" : "appointment-new",
79 " _this.main_window.windowstate.showProps(",
80 " \t\t_this.view.el, ",
81 " \t\tJsRender.NodePropType.LISTENER",
88 "string label" : "Event",
94 "bool always_show_image" : true,
95 "bool hexpand" : true,
100 "id" : "AddPropertyPopup",
105 "label" : "id: _this.{ID} (Vala)",
109 " \t// is this userdef or special??",
110 " _this.addProp( new JsRender.NodeProp.prop(\"id\") );",
114 "tooltip_markup" : "Using _this.{ID} will map to this element",
120 "label" : "pack: Pack method (Vala)",
124 "// is this userdef?",
125 " _this.addProp( new JsRender.NodeProp.special(\"pack\", \"add\") );",
129 "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
135 "label" : "ctor: Alterative to default contructor (Vala)",
140 " _this.addProp( new JsRender.NodeProp.special(\"ctor\") );",
147 "new Clutter.Image.from_file(.....)"
154 "label" : "init: initialziation code (vala)",
158 " _this.addProp( new JsRender.NodeProp.special(\"init\",\"{\\n\\n}\\n\" ) );",
163 "tooltip_markup" : "This code is called after the ctor",
169 "label" : "cms-id: (Roo JS/Pman library)",
174 " _this.addProp( new JsRender.NodeProp.prop(\"cms-id\",\"string\", \"\" ) );",
182 "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})",
190 "xtype" : "SeparatorMenuItem"
200 "\t_this.view.popover.show(",
201 "\t\t_this.view.el, ",
203 "\t\t new JsRender.NodeProp.prop(\"\", \"string\", \"\") ,",
211 "tooltip_markup" : "Add a user defined string property",
221 " _this.view.popover.show(",
222 "\t\t_this.view.el, ",
224 "\t\t new JsRender.NodeProp.prop(\"\", \"int\", \"0\") ,",
232 "tooltip_markup" : "Add a user defined number property",
244 " _this.view.popover.show(",
245 "\t\t_this.view.el, ",
247 "\t\t new JsRender.NodeProp.prop(\"\", \"bool\", \"true\") ,",
255 "tooltip_markup" : "Add a user defined boolean property",
261 "xtype" : "SeparatorMenuItem"
266 "label" : "Javascript Function",
271 " _this.view.popover.show(",
272 "\t\t_this.view.el, ",
274 "\t\t new JsRender.NodeProp.jsmethod(\"\") ,",
283 "tooltip_markup" : "Add a user function boolean property",
289 "label" : "Vala Method",
294 " _this.view.popover.show(",
295 "\t\t_this.view.el, ",
297 "\t\t new JsRender.NodeProp.valamethod(\"\") ,",
304 "tooltip_markup" : "Add a user function boolean property",
310 "label" : "Vala Signal",
314 " _this.view.popover.show(",
315 "\t\t_this.view.el, ",
317 "\t\t new JsRender.NodeProp.sig(\"\" ) ,",
324 "tooltip_markup" : "Add a vala signal",
330 "xtype" : "SeparatorMenuItem"
335 "label" : "Flexy - If",
339 " \t_this.view.popover.show(",
340 "\t\t_this.view.el, ",
342 "\t\t new JsRender.NodeProp.prop(\"flexy:if\", \"string\", \"value_or_condition\") ,",
351 "tooltip_markup" : "Add a flexy if (for HTML templates)",
357 "label" : "Flexy - Include",
361 " \t_this.view.popover.show(",
362 "\t\t_this.view.el, ",
364 "\t\t new JsRender.NodeProp.prop(\"flexy:include\", \"string\", \"name_of_file.html\") ,",
373 "tooltip_markup" : "Add a flexy include (for HTML templates)",
379 "label" : "Flexy - Foreach",
384 " \t_this.view.popover.show(",
385 "\t\t_this.view.el, ",
387 "\t\t new JsRender.NodeProp.prop(\"flexy:foreach\", \"string\", \"array,key,value\") ,",
396 "tooltip_markup" : "Add a flexy foreach (for HTML templates)",
403 "$ Gtk.Stock stock" : "Gtk.Stock.ADD",
404 "$ icon_size" : "Gtk.IconSize.MENU",
406 "* pack" : "set_image",
411 "button_press_event" : [
413 " _this.before_edit();",
416 " var p = _this.AddPropertyPopup;",
417 " p.el.set_screen(Gdk.Screen.get_default());",
419 " p.el.popup(null, null, null, ev.button, ev.time);",
424 "string label" : "Other",
431 "# bool editing" : false,
432 "$ shadow_type" : "Gtk.ShadowType.IN",
437 " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
441 "* pack" : "pack_end,true,true,0",
445 "$ enable_tree_lines" : true,
446 "$ headers_visible" : true,
450 " var selection = this.el.get_selection();",
451 " selection.set_mode( Gtk.SelectionMode.SINGLE);",
454 " var description = new Pango.FontDescription();",
455 " description.set_size(10000);",
456 " this.el.override_font(description);",
462 "Xcls_PopoverProperty popover" : "null",
467 "function(str, doRefresh) {",
468 " if (!this.activePath) {",
471 " var iter = new Gtk.TreeIter();",
473 " _this.setTreeIter(prop);",
474 " this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));",
476 " this.el.set_value(iter, 1, '' +str);",
477 " this.el.set_value(iter, 3, '' + this.toShort(str));",
478 " var type = this.getIterValue(iter, 4);",
480 " this.el.set_value(iter, 5, type + ' : ' + str);",
481 " // update the tree... ",
483 " this.get('/LeftTree.model').changed(this.toJS(), doRefresh); ",
488 " typeof(JsRender.NodeProp), // 0 key type",
489 " typeof(string), // 1 display_key",
490 " typeof(string), // 2 display_value",
491 " typeof(string), // 3 display_tooltip",
492 " \t\ttypeof(string) // 4 sortable value",
495 " \t1, prop.to_display_name(),",
497 " 3, \"<tt>\" + GLib.Markup.escape_text(key + \" \" +kvalue) + \"</tt>\",",
498 " 4, \"0 \" + prop.name",
504 "* pack" : "set_model",
507 "xtype" : "TreeStore"
510 "$ resizable" : true,
513 " this.el.add_attribute(_this.keyrender.el , \"markup\", 1 ); // 1 is the key.",
514 " //this.el.add_attribute(_this.keyrender.el , \"text\", 1 );",
517 "* pack" : "append_column",
522 "* pack" : "pack_start,false",
524 "xtype" : "CellRendererText"
527 "title" : "Property",
528 "xtype" : "TreeViewColumn"
531 "$ resizable" : true,
539 "\tthis.el.add_attribute(_this.valrender.el , \"text\", 2 );",
544 "* pack" : "append_column",
548 "$ editable" : false,
549 "$ has_entry" : true,
551 "* pack" : "pack_start,true",
555 "$ columns" : "typeof(string)",
559 "id" : "valrendermodel",
561 "xtype" : "ListStore"
566 " (path, newtext) => {",
567 " GLib.debug(\"Valrender - signal:edited\\n\");",
569 " this.el.editable = false;",
572 " Gtk.TreeIter iter;",
573 " _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
576 " _this.model.el.get_value(iter,0, out gval);",
577 " var prop = (JsRender.NodeProp)gval;",
578 " prop.val = newtext;",
579 " _this.updateIter(iter,prop);",
584 "editing_started" : [
585 "( editable, path) => {",
586 " //_this.editing = true;",
587 " GLib.debug(\"editing started called\\n\");",
588 " if (!_this.allow_edit) {",
590 " GLib.debug(\"val - editing_Started\\n\");",
591 " this.el.editable = false; // make sure it's not editor...",
596 " _this.allow_edit =false;",
599 " if ( this.el.has_entry ) {",
601 " Gtk.TreeIter iter;",
602 " _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
607 " // this.get('/LeftPanel.model').activePath = path;",
608 " _this.model.el.get_value(iter,0, out gval);",
611 " var prop = (JsRender.NodeProp)gval;",
612 " var combo = (Gtk.ComboBox)editable;",
614 " var entry = (Gtk.Entry) combo.get_child(); ",
615 " entry.set_text(prop.val);",
622 "xtype" : "CellRendererCombo",
623 "| void setOptions" : [
625 "\tvar m = _this.valrendermodel.el;",
627 "\tGtk.TreeIter iret;",
628 " for (var i =0; i < ar.length; i++) {",
629 " m.append(out iret);",
630 " m.set_value(iret, 0, ar[i]);",
638 "xtype" : "TreeViewColumn"
643 "id" : "ContextMenu",
652 "\t_this.deleteSelected();",
663 "button_press_event" : [
666 " Gtk.TreeViewColumn col;",
669 " Gtk.TreePath path;",
671 " // event x /y are relative to the widget..",
672 " if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {",
673 " GLib.debug(\"nothing selected on click\");",
674 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
675 " this.el.get_selection().unselect_all();",
679 " _this.before_edit();",
680 " return false; //not on a element.",
684 " // single click on name..",
685 " //if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == \"Name\") { ",
686 " if (ev.button == 1 && col.title == \"Property\") { ",
687 " \t// need to shift down, as ev.y does not inclucde header apparently..",
688 " \t// or popover might be trying to do a central?",
689 " this.editPropertyDetails(path, (int) ev.y + 12); ",
698 " if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) { ",
700 " //if (col.title == \"Value\") {",
701 " // _this.before_edit();",
705 " var p = _this.ContextMenu;",
707 " p.el.set_screen(Gdk.Screen.get_default());",
709 " p.el.popup(null, null, null, ev.button, ev.time);",
710 " //Seed.print(\"click:\" + res.column.title);",
712 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
714 " this.el.get_selection().select_path(path);",
717 " _this.before_edit();",
722 " if (col.title != \"Value\") {",
723 " GLib.debug(\"col title != Value\");",
725 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
726 " this.el.get_selection().select_path(path);",
730 " _this.before_edit();",
731 " // XObject.error(\"column is not value?\");",
732 " return false; // ignore.. - key click.. ??? should we do this??",
736 " // if the cell can be edited with a pulldown",
737 " // then we should return true... - and let the start_editing handle it?",
744 " // _this.before_edit(); <<< we really need to stop the other editor..",
745 " _this.keyrender.el.stop_editing(false);",
746 " _this.keyrender.el.editable =false;",
749 " return _this.startEditingValue(path); // assumes selected row..",
758 "tooltip_column" : 3,
759 "xtype" : "TreeView",
760 "| void editPropertyDetails" : [
761 "(Gtk.TreePath path, int y) {",
766 " _this.before_edit();",
767 " _this.stop_editor();",
769 " _this.keyrender.el.stop_editing(false);",
770 " _this.keyrender.el.editable =false;",
772 " _this.valrender.el.stop_editing(false);",
773 " _this.valrender.el.editable =false;",
774 " Gtk.TreeIter iter;",
775 " var mod = this.el.get_model();",
776 "\t mod.get_iter (out iter, path);",
779 "\tGLib.Value gval;",
781 " mod.get_value(iter,0, out gval);",
783 " this.popover.show(_this.view.el, _this.node, (JsRender.NodeProp)gval, y);",
791 "xtype" : "ScrolledWindow"
795 "| string keyFormat" : [
796 "(string val, string type) {",
798 " // Glib.markup_escape_text(val);",
800 " if (type == \"listener\") {",
801 " return \"<span font_weight=\\\"bold\\\" color=\\\"#660000\\\">\" + ",
802 " GLib.Markup.escape_text(val) +",
806 " if (val.length < 1) {",
807 " return \"<span color=\\\"#FF0000\\\">--empty--</span>\";",
811 " //$ = property with ",
812 " //# - object properties",
814 " // all of these... - display value is last element..",
815 " var ar = val.strip().split(\" \");",
818 " var dval = GLib.Markup.escape_text(ar[ar.length-1]);",
824 " case '@': // signal // just bold balck?",
825 " if (dval[0] == '@') {",
826 " dval = dval.substring(1);",
829 " return @\"<span font_weight=\\\"bold\\\">@ $dval</span>\"; ",
830 " case '#': // object properties?",
831 " if (dval[0] == '#') {",
832 " dval = dval.substring(1);",
834 " return @\"<span font_weight=\\\"bold\\\">$dval</span>\";",
835 " case '*': // special",
836 " if (dval[0] == '*') {",
837 " dval = dval.substring(1);",
839 " return @\"<span color=\\\"#0000CC\\\" font_weight=\\\"bold\\\">$dval</span>\"; ",
841 " if (dval[0] == '$') {",
842 " dval = dval.substring(1);",
844 " return @\"<span style=\\\"italic\\\">$dval</span>\";",
845 " case '|': // user defined methods",
846 " if (dval[0] == '|') {",
847 " dval = dval.substring(1);",
849 " return @\"<span color=\\\"#008000\\\" font_weight=\\\"bold\\\">$dval</span>\";",
861 "| string keySortFormat" : [
863 " // listeners first - with 0",
865 " if (key[0] == '*') {",
866 " return \"1 \" + key;",
870 " var bits = key.split(\" \");",
872 " if (key[0] == '|') {",
873 " return \"2 \" + bits[bits.length -1];",
876 " if (key[0] == '@') {",
877 " return \"3 \" + bits[bits.length -1];",
881 " if (key[0] == '#') {",
882 " return \"4 \" + bits[bits.length -1];",
885 " return \"5 \" + bits[bits.length -1]; ",
892 " (JsRender.NodeProp prop) {",
893 " // info includes key, val, skel, etype..",
894 " //console.dump(info);",
895 " //type = info.type.toLowerCase();",
896 " //var data = this.toJS();",
901 " if (prop.ptype == JsRender.NodePropType.LISTENER) {",
902 " if (this.node.listeners.has_key(prop.name)) {",
905 " this.node.listeners.set(prop.name,prop);",
907 " assert(this.node != null);",
908 " assert(this.node.props != null);",
909 " if (this.node.props.has_key(prop.to_index_key())) {",
912 " this.node.props.set(prop.to_index_key(),prop);",
917 " this.load(this.file, this.node);",
921 " /// need to find the row which I've just added..",
924 " var s = this.view.el.get_selection();",
925 " s.unselect_all();",
927 " GLib.debug(\"trying to find new iter\");",
929 " this.model.el.foreach((model, path, iter) => {",
931 " this.model.el.get_value(iter, 0 , out gval);",
933 " var iprop = (JsRender.NodeProp)gval;",
934 " if (iprop.to_index_key() != prop.to_index_key()) {",
935 " \treturn false; // continue?",
939 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {",
941 " \t\tif (prop.name == \"\") { // empty string for key name.",
942 " \t\t_this.view.editPropertyDetails(this.model.el.get_path(iter));",
943 " \t\treturn false;",
947 " this.startEditingValue(this.model.el.get_path(iter));",
950 " //s.select_iter(iter);",
960 "| void deleteSelected" : [
963 " this.stop_editor();",
965 " Gtk.TreeIter iter;",
966 " Gtk.TreeModel mod;",
968 " var s = this.view.el.get_selection();",
969 " s.get_selected(out mod, out iter);",
973 " mod.get_value(iter, 0 , out gval);",
974 " var prop = (JsRender.NodeProp)gval;",
976 " switch(prop.ptype) {",
977 " case JsRender.NodePropType.LISTENER:",
978 " this.node.listeners.unset(prop.to_index_key());",
982 " this.node.props.unset(prop.to_index_key());",
985 " this.load(this.file, this.node);",
990 "| void finish_editing" : [
993 " this.before_edit();",
997 "(JsRender.JsRender file, JsRender.Node? node) ",
999 "\t// not sure when to initialize this - we should do it on setting main window really. ",
1000 " if (this.view.popover == null) {",
1001 " \t\t this.view.popover = new Xcls_PopoverProperty();",
1002 " \t\t this.view.popover.mainwindow = _this.main_window;",
1008 " GLib.debug(\"load leftprops\\n\");",
1009 " this.before_edit();",
1010 " this.node = node;",
1011 " this.file = file;",
1014 " this.model.el.clear();",
1016 " //this.get('/RightEditor').el.hide();",
1017 " if (node ==null) {",
1023 " //var provider = this.get('/LeftTree').getPaleteProvider();",
1024 " Gtk.TreeIter iter;",
1030 " // really need a way to sort the hashmap...",
1031 " var m = this.model.el;",
1033 " var miter = node.listeners.map_iterator();",
1036 " while(miter.next()) {",
1038 " m.append(out iter,null);",
1040 " this.updateIter(iter, miter.get_value());",
1046 " miter = node.props.map_iterator();",
1049 " while(miter.next()) {",
1051 " m.append(out iter,null);",
1052 " this.updateIter(iter, miter.get_value());",
1055 " GLib.debug(\"clear selection\\n\");",
1056 " // clear selection?",
1057 " this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..",
1059 " this.view.el.get_selection().unselect_all();",
1067 "| void startEditingKey" : [
1068 "( Gtk.TreePath path) {",
1070 " if (!this.stop_editor()) {",
1074 " // others... - fill in options for true/false?",
1077 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1078 " this.allow_edit = true;",
1079 " this.keyrender.el.editable = true;",
1081 " this.view.el.set_cursor_on_cell(",
1084 " this.keyrender.el,",
1095 "| void updateIter" : [
1096 "(Gtk.TreeIter iter, JsRender.NodeProp prop) {",
1098 " //print(\"update Iter %s, %s\\n\", key,kvalue);",
1100 " var dl = prop.val.strip().split(\"\\n\");",
1102 " var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];",
1104 " if (prop.ptype == JsRender.NodePropType.LISTENER) {",
1108 " this.model.el.set(iter, ",
1110 " \t1, prop.to_display_name(),",
1112 " 3, \"<tt>\" + GLib.Markup.escape_text(prop.to_tooltip()) + \"</tt>\",",
1113 " 4, prop.to_sort_key(),",
1121 " this.model.el.set(iter, ",
1123 " \t1, prop.to_display_name(),",
1125 " 3, \"<tt>\" + GLib.Markup.escape_text(prop.to_tooltip()) + \"</tt>\",",
1126 " 4, prop.to_sort_key(),",
1132 "| bool startEditingValue" : [
1133 "( Gtk.TreePath path) {",
1135 " // ONLY return true if editing is allowed - eg. combo..",
1137 " GLib.debug(\"start editing?\\n\");",
1138 " if (!this.stop_editor()) {",
1139 " GLib.debug(\"stop editor failed\\n\");",
1143 " Gtk.TreeIter iter;",
1145 " var mod = this.model.el;",
1146 " mod.get_iter (out iter, path);",
1148 " GLib.Value gval;",
1149 " mod.get_value(iter, 0 , out gval);",
1150 " var prop = (JsRender.NodeProp)gval;",
1154 " var use_textarea = false;",
1156 " //------------ things that require the text editor...",
1158 " if (prop.ptype == JsRender.NodePropType.LISTENER) {",
1159 " use_textarea = true;",
1161 " if (prop.ptype == JsRender.NodePropType.METHOD) { ",
1162 " use_textarea = true;",
1164 " if (prop.ptype == JsRender.NodePropType.RAW) { // raw string",
1165 " use_textarea = true;",
1167 " if ( prop.name == \"init\" && prop.ptype == JsRender.NodePropType.SPECIAL) {",
1168 " use_textarea = true;",
1170 " if (prop.val.length > 40) { // long value...",
1171 " use_textarea = true;",
1176 " if (use_textarea) {",
1177 " GLib.debug(\"Call show editor\\n\");",
1178 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1179 " this.view.el.get_selection().select_path(path);",
1181 " this.show_editor(file, node, prop);",
1190 " var pal = this.file.project.palete;",
1193 " var has_opts = pal.typeOptions(this.node.fqn(), prop.name, prop.rtype, out opts);",
1197 " // others... - fill in options for true/false?",
1198 " GLib.debug(\"turn on editing %s \\n\" , mod.get_path(iter).to_string());",
1200 " // GLib.debug (ktype.up());",
1202 " GLib.debug(\"start editing try/false)???\");",
1203 " this.valrender.el.has_entry = false;",
1205 " this.valrender.setOptions(opts);",
1207 " this.valrender.el.has_entry = false;",
1208 " this.valrender.el.editable = true;",
1209 " this.allow_edit = true;",
1210 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1211 " this.view.el.set_cursor_on_cell(",
1213 "\t this.valcol.el,",
1214 "\t this.valrender.el,",
1222 " // see if type is a Enum.",
1229 " this.valrender.setOptions(opts);",
1231 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1233 " // at this point - work out the type...",
1234 " // if its' a combo... then show the options..",
1235 " this.valrender.el.has_entry = true;",
1237 " this.valrender.el.editable = true; ",
1240 " this.allow_edit = true;",
1246 " this.view.el.set_cursor_on_cell(",
1249 " this.valrender.el,",
1258 "| void before_edit" : [
1262 " GLib.debug(\"before edit - stop editing\\n\");",
1264 " // these do not appear to trigger save...",
1265 " _this.keyrender.el.stop_editing(false);",
1266 " _this.keyrender.el.editable =false;",
1268 " _this.valrender.el.stop_editing(false);",
1269 " _this.valrender.el.editable =false; ",
1272 "// technicall stop the popup editor..",
1279 "\tthis.load(this.file, this.node);",
1286 "name" : "WindowLeftProps",
1288 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowLeftProps.bjs",