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();",
899 " if (prop.ptype == JsRender.NodePropType.LISTENER) {",
900 " if (this.node.listeners.has_key(prop.name)) {",
903 " this.node.listeners.set(prop.name,prop);",
905 " assert(this.node != null);",
906 " assert(this.node.props != null);",
907 " if (this.node.props.has_key(prop.to_index_key())) {",
910 " this.node.props.set(prop.to_index_key(),prop);",
915 " this.load(this.file, this.node);",
919 " /// need to find the row which I've just added..",
922 " var s = this.view.el.get_selection();",
923 " s.unselect_all();",
925 " GLib.debug(\"trying to find new iter\");",
927 " this.model.el.foreach((model, path, iter) => {",
929 " this.model.el.get_value(iter, 0 , out gval);",
931 " var iprop = (JsRender.NodeProp)gval;",
932 " if (iprop.to_index_key() != prop.to_index_key()) {",
933 " \treturn false; // continue?",
937 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {",
939 " \t\tif (prop.name == \"\") { // empty string for key name.",
940 " \t\t_this.view.editPropertyDetails(this.model.el.get_path(iter));",
941 " \t\treturn false;",
945 " this.startEditingValue(this.model.el.get_path(iter));",
948 " //s.select_iter(iter);",
958 "| void deleteSelected" : [
961 " this.stop_editor();",
963 " Gtk.TreeIter iter;",
964 " Gtk.TreeModel mod;",
966 " var s = this.view.el.get_selection();",
967 " s.get_selected(out mod, out iter);",
971 " mod.get_value(iter, 0 , out gval);",
972 " var prop = (JsRender.NodeProp)gval;",
974 " switch(prop.ptype) {",
975 " case JsRender.NodePropType.LISTENER:",
976 " this.node.listeners.unset(prop.to_index_key());",
980 " this.node.props.unset(prop.to_index_key());",
983 " this.load(this.file, this.node);",
988 "| void finish_editing" : [
991 " this.before_edit();",
995 "(JsRender.JsRender file, JsRender.Node? node) ",
997 "\t// not sure when to initialize this - we should do it on setting main window really. ",
998 " if (this.view.popover == null) {",
999 " \t\t this.view.popover = new Xcls_PopoverProperty();",
1000 " \t\t this.view.popover.mainwindow = _this.main_window;",
1006 " GLib.debug(\"load leftprops\\n\");",
1007 " this.before_edit();",
1008 " this.node = node;",
1009 " this.file = file;",
1012 " this.model.el.clear();",
1014 " //this.get('/RightEditor').el.hide();",
1015 " if (node ==null) {",
1021 " //var provider = this.get('/LeftTree').getPaleteProvider();",
1022 " Gtk.TreeIter iter;",
1028 " // really need a way to sort the hashmap...",
1029 " var m = this.model.el;",
1031 " var miter = node.listeners.map_iterator();",
1034 " while(miter.next()) {",
1036 " m.append(out iter,null);",
1038 " this.updateIter(iter, miter.get_value());",
1044 " miter = node.props.map_iterator();",
1047 " while(miter.next()) {",
1049 " m.append(out iter,null);",
1050 " this.updateIter(iter, miter.get_value());",
1053 " GLib.debug(\"clear selection\\n\");",
1054 " // clear selection?",
1055 " this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..",
1057 " this.view.el.get_selection().unselect_all();",
1065 "| void startEditingKey" : [
1066 "( Gtk.TreePath path) {",
1068 " if (!this.stop_editor()) {",
1072 " // others... - fill in options for true/false?",
1075 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1076 " this.allow_edit = true;",
1077 " this.keyrender.el.editable = true;",
1079 " this.view.el.set_cursor_on_cell(",
1082 " this.keyrender.el,",
1093 "| void updateIter" : [
1094 "(Gtk.TreeIter iter, JsRender.NodeProp prop) {",
1096 " //print(\"update Iter %s, %s\\n\", key,kvalue);",
1098 " var dl = prop.val.strip().split(\"\\n\");",
1100 " var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];",
1102 " if (prop.ptype == JsRender.NodePropType.LISTENER) {",
1106 " this.model.el.set(iter, ",
1108 " \t1, prop.to_display_name(),",
1110 " 3, \"<tt>\" + GLib.Markup.escape_text(prop.to_tooltip()) + \"</tt>\",",
1111 " 4, prop.to_sort_key(),",
1119 " this.model.el.set(iter, ",
1121 " \t1, prop.to_display_name(),",
1123 " 3, \"<tt>\" + GLib.Markup.escape_text(prop.to_tooltip()) + \"</tt>\",",
1124 " 4, prop.to_sort_key(),",
1130 "| bool startEditingValue" : [
1131 "( Gtk.TreePath path) {",
1133 " // ONLY return true if editing is allowed - eg. combo..",
1135 " GLib.debug(\"start editing?\\n\");",
1136 " if (!this.stop_editor()) {",
1137 " GLib.debug(\"stop editor failed\\n\");",
1141 " Gtk.TreeIter iter;",
1143 " var mod = this.model.el;",
1144 " mod.get_iter (out iter, path);",
1146 " GLib.Value gval;",
1147 " mod.get_value(iter, 0 , out gval);",
1148 " var prop = (JsRender.NodeProp)gval;",
1152 " var use_textarea = false;",
1154 " //------------ things that require the text editor...",
1156 " if (prop.ptype == JsRender.NodePropType.LISTENER) {",
1157 " use_textarea = true;",
1159 " if (prop.ptype == JsRender.NodePropType.METHOD) { ",
1160 " use_textarea = true;",
1162 " if (prop.ptype == JsRender.NodePropType.RAW) { // raw string",
1163 " use_textarea = true;",
1165 " if ( prop.name == \"init\" && prop.ptype == JsRender.NodePropType.SPECIAL) {",
1166 " use_textarea = true;",
1168 " if (prop.val.length > 40) { // long value...",
1169 " use_textarea = true;",
1174 " if (use_textarea) {",
1175 " GLib.debug(\"Call show editor\\n\");",
1176 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1177 " this.view.el.get_selection().select_path(path);",
1179 " this.show_editor(file, node, prop);",
1188 " var pal = this.file.project.palete;",
1191 " var has_opts = pal.typeOptions(this.node.fqn(), prop.name, prop.rtype, out opts);",
1195 " // others... - fill in options for true/false?",
1196 " GLib.debug(\"turn on editing %s \\n\" , mod.get_path(iter).to_string());",
1198 " // GLib.debug (ktype.up());",
1200 " GLib.debug(\"start editing try/false)???\");",
1201 " this.valrender.el.has_entry = false;",
1203 " this.valrender.setOptions(opts);",
1205 " this.valrender.el.has_entry = false;",
1206 " this.valrender.el.editable = true;",
1207 " this.allow_edit = true;",
1208 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1209 " this.view.el.set_cursor_on_cell(",
1211 "\t this.valcol.el,",
1212 "\t this.valrender.el,",
1220 " // see if type is a Enum.",
1227 " this.valrender.setOptions(opts);",
1229 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1231 " // at this point - work out the type...",
1232 " // if its' a combo... then show the options..",
1233 " this.valrender.el.has_entry = true;",
1235 " this.valrender.el.editable = true; ",
1238 " this.allow_edit = true;",
1244 " this.view.el.set_cursor_on_cell(",
1247 " this.valrender.el,",
1256 "| void before_edit" : [
1260 " GLib.debug(\"before edit - stop editing\\n\");",
1262 " // these do not appear to trigger save...",
1263 " _this.keyrender.el.stop_editing(false);",
1264 " _this.keyrender.el.editable =false;",
1266 " _this.valrender.el.stop_editing(false);",
1267 " _this.valrender.el.editable =false; ",
1270 "// technicall stop the popup editor..",
1277 "\tthis.load(this.file, this.node);",
1284 "name" : "WindowLeftProps",
1286 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowLeftProps.bjs",