2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Gee.ArrayList<Gtk.Widget>? error_widgets" : "null",
7 "# Xcls_MainWindow? main_window" : "null",
8 "# int last_error_counter" : "-1",
10 "@ bool before_node_change" : "()",
11 "@ void changed" : "()",
12 "@ void node_selected" : "(JsRender.Node? node)",
13 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
14 "bool hexpand" : true,
15 "bool vexpand" : true,
16 "id" : "WindowLeftTree",
24 "xtype" : "SignalListItemFactory"
31 "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
32 "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
33 "bool has_frame" : true,
34 "bool hexpand" : true,
35 "bool vexpand" : true,
39 "# bool blockChanges" : false,
40 "$ JsRender.Node? dragNode" : "null",
41 "$ string lastEventSource" : "\"\"",
46 " this.css = new Gtk.CssProvider();",
48 "\t\tthis.css.load_from_string(\"",
49 "#left-tree-view { font-size: 12px;}\t",
50 ".drag-over { background-color:#88a3bc; }",
52 " border-bottom-width: 5px; ",
53 " border-bottom-style: solid;",
54 " border-bottom-color: #88a3bc;",
57 " border-top-width: 5px;",
58 " border-top-style: solid;",
59 " border-top-color: #88a3bc;",
62 " border-top-width: 5px;",
63 " border-top-style: solid;",
64 " border-top-color: red;",
65 " border-bottom-width: 5px; ",
66 " border-bottom-style: solid;",
67 " border-bottom-color: red;",
70 " border-top-width: 5px;",
71 " border-top-style: solid;",
72 " border-top-color: #ABF4EB;",
73 " border-bottom-width: 5px; ",
74 " border-bottom-style: solid;",
75 " border-bottom-color: #ABF4EB;",
78 " border-top-width: 5px;",
79 " border-top-style: solid;",
80 " border-top-color: #EEA9FF;",
81 " border-bottom-width: 5px; ",
82 " border-bottom-style: solid;",
83 " border-bottom-color: #EEA9FF;",
86 "#left-tree-view indent {",
87 "-gtk-icon-size : 2px;",
89 "#left-tree-view indent:nth-last-child(2) {",
94 "\tGtk.StyleContext.add_provider_for_display(",
95 "\t\tthis.el.get_display(),",
97 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
105 "Boolean id" : "view",
106 "Gtk.CssProvider css" : "",
107 "bool button_is_pressed" : false,
108 "bool headers_visible" : false,
109 "bool hexpand" : false,
110 "bool vexpand" : true,
116 "(n_press, x, y) => {",
118 " //console.log(\"button press?\");",
120 " //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
124 " _this.view.button_is_pressed = true;",
126 " _this.view.lastEventSource = \"tree\";",
127 " if (! _this.before_node_change() ) {",
128 " \tGLib.debug(\"before_node_change return false\");",
132 "\t // nothing there -show dialog",
133 " if (_this.model.el.get_n_items() < 1) {",
134 "\t _this.main_window.windowstate.showAddObject(_this.view.el, null);",
135 " GLib.debug(\"no items\");",
139 " var row = _this.view.getRowAt(x,y, out pos );",
141 "\t GLib.debug(\"no row selected items\");",
145 " var node = _this.selmodel.getNodeAt(row);",
146 " if (node == null) {",
147 " \tGLib.warning(\"No node found at row %d\", row);",
153 " if (_this.view.getColAt(x,y) > 0 ) {",
154 "\t GLib.debug(\"add colum clicked.\");",
155 " var fqn = node.fqn();",
156 " \tvar cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
157 " \t\tif (cn.size < 1) {",
161 "\t\t_this.main_window.windowstate.leftTreeBeforeChange();",
162 "\t\t//_this.view.el.get_selection().select_path(res);",
163 "\t\tGLib.debug(\"Button Pressed - start show window\");",
164 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, node);",
165 "\t\tGLib.debug(\"Button Pressed - finsihed show window\");",
175 "(n_press, x, y) => {",
177 " _this.view.button_is_pressed = false;",
184 "xtype" : "GestureClick"
190 "(n_press, x, y) => {",
195 " if (_this.model.el.get_n_items() < 1) {",
197 " GLib.debug(\"no items\");",
201 " var row = _this.view.getRowAt(x,y, out pos );",
203 "\t GLib.debug(\"no row selected items\");",
207 " var node = _this.selmodel.getNodeAt(row);",
208 " if (node == null) {",
209 " \tGLib.warning(\"No node found at row %d\", row);",
214 "\t_this.model.selectNode(node);",
218 "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());",
219 "\t//_this.deletemenu.el.set_parent(_this.view.el);",
220 "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
223 "\t//Gtk.Allocation rect;",
224 "\t//_this.view.el.get_allocation(out rect);",
225 " \t//_this.deletemenu.el.set_has_arrow(false);",
226 "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
229 "\t_this.LeftTreeMenu.el.set_offset( ",
231 "\t\t\t(int)y - (int)_this.view.el.get_height());",
233 " _this.LeftTreeMenu.el.popup();",
240 "xtype" : "GestureClick"
243 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
248 "\tGLib.debug(\"SOURCE: drag-begin\");",
250 " // find what is selected in our tree...",
251 " var data = _this.selmodel.getSelectedNode();",
252 "\tif (data == null) {",
255 "\t_this.view.dragNode = data;",
256 " var xname = data.fqn();",
257 " GLib.debug (\"XNAME IS %s\", xname);",
259 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
262 " var paintable = new Gtk.WidgetPaintable(widget);",
263 " this.el.set_icon(paintable, 0,0);",
269 "(drag, reason) => {",
271 "\t_this.view.dragNode = null;",
277 "(drag, delete_data) => {",
279 "_this.view.dragNode = null;",
288 "///\t( drag_context, data, info, time) => {",
291 "\t//print(\"drag-data-get\");",
292 " \tvar ndata = _this.selmodel.getSelectedNode();",
293 "\tif (ndata == null) {",
294 "\t \tGLib.debug(\"return empty string - no selection..\");",
300 "\t//data.set_text(tp,tp.length); ",
302 "\tvar \tstr = ndata.toJsonString();",
303 "\tGLib.debug(\"prepare store: %s\", str);",
304 "\tGLib.Value ov = GLib.Value(typeof(string));",
305 "\tov.set_string(str);",
306 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
308 "\tGLib.Value v = GLib.Value(typeof(string));",
309 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
311 "\t\tcont.get_value(ref v);",
314 "\tGLib.debug(\"set %s\", v.get_string());",
323 "xtype" : "DragSource"
329 "(keyval, keycode, state) => {",
333 "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) {",
337 "\t_this.model.deleteSelected();",
344 "xtype" : "EventControllerKey"
352 "(keyval, keycode, state) => {",
354 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
355 " \t\tthis.is_shift = 1;",
362 "(keyval, keycode, state) => {",
363 "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int) keycode, state);",
364 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
365 " \t\tthis.is_shift = 0;",
367 "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
374 "xtype" : "EventControllerKey"
379 "new Gtk.DropTarget ( typeof(string) ,",
380 "\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE )"
382 "Gtk.Widget? highlightWidget" : "null",
383 "JsRender.Node? lastDragNode" : "null",
389 "\tGLib.debug(\"got DropTarget:accept\");",
391 "// NOT REALLY NEEDED? = put stuff in drop?",
394 "/* ( ctx, x, y, time) => {",
395 " //Seed.print(\"TARGET: drag-drop\");",
398 " var src = Gtk.drag_get_source_widget(ctx);",
400 " if (src != this.el) {",
404 " this.drag_in_motion = false; ",
405 " // request data that will be recieved by the recieve... ",
406 " Gtk.drag_get_data",
408 " this.el, // will receive 'drag-data-received' signal ",
409 " ctx, // represents the current state of the DnD ",
410 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
411 " time // time stamp ",
415 " // No target offered by source => error",
421 " // handle drop around self..",
425 " //print(\"GETTING POS\");",
426 " var targetData = \"\";",
428 " Gtk.TreePath path;",
429 " Gtk.TreeViewDropPosition pos;",
430 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
432 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
433 " var isEmpty = false;",
434 " if (_this.model.el.iter_n_children(null) < 1) {",
435 " print(\"got NO children?\\n\");",
436 " isOver = true; //??? ",
438 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
443 " //var action = Gdk.DragAction.COPY;",
444 " // unless we are copying!!! ctl button..",
446 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
447 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
448 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
451 " if (_this.model.el.iter_n_children(null) < 1) {",
452 " // no children.. -- asume it's ok..",
454 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
456 " // continue through to allow drop...",
464 " //print(\"ISOVER? \" + isOver);",
467 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
468 " return true; // not over apoint!?! - no action on drop or motion..",
471 " // drag node is parent of child..",
472 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
473 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
475 " // nned to check a few here..",
476 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
477 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
478 " //Gtk.TreeViewDropPosition.AFTER",
479 " //Gtk.TreeViewDropPosition.BEFORE",
481 " // locally dragged items to not really use the ",
482 " var selection_text = this.dragData;",
486 " if (selection_text == null || selection_text.length < 1) {",
487 " //print(\"Error - drag selection text returned NULL\");",
489 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
490 " return true; /// -- fixme -- this is not really correct..",
493 " // see if we are dragging into ourself?",
494 " print (\"got selection text of \" + selection_text);",
496 " var target_path = path.to_string();",
497 " //print(\"target_path=\"+target_path);",
500 " if (selection_text == target_path) {",
501 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
503 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
505 " return true; /// -- fixme -- this is not really correct..",
510 " //print(\"DUMPING DATA\");",
511 " //console.dump(data);",
514 " //print(data.path.to_string() +' => '+ data.pos);",
516 " // dropList is a list of xtypes that this node could be dropped on.",
517 " // it is set up when we start to drag..",
520 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
522 " print(\"targetDAta: \" + targetData +\"\\n\");",
524 " if (targetData.length < 1) {",
525 " //print(\"Can not find drop node path\");",
527 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
533 " // continue on to allow drop..",
535 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
538 " var delete_selection_data = false;",
540 " if (action == Gdk.DragAction.ASK) {",
541 " // Ask the user to move or copy, then set the ctx action. ",
544 " if (action == Gdk.DragAction.MOVE) {",
545 " delete_selection_data = true;",
548 " // drag around.. - reorder..",
549 " _this.model.moveNode(targetData, action);",
555 " // we can send stuff to souce here...",
558 "// do we always say failure, so we handle the reall drop?",
559 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
577 "\tthis.addHighlight(null,\"\");",
579 " \tvar is_shift = _this.keystate.is_shift > 0;",
581 " \tvar pos = \"\";",
582 " \t// -- get position..",
583 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
584 "\t\t// still dragging same node",
586 "\t\tthis.lastDragNode = new JsRender.Node(); ",
587 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
592 " var dropNode = new JsRender.Node(); ",
593 "\tdropNode.loadFromJsonString(v.get_string(), 1);",
594 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
596 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
598 " if (_this.model.el.n_items < 1) {",
599 " \t// FIXME check valid drop types?",
600 " \tif (!drop_on_to.contains(\"*top\")) {",
601 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
602 "\t\t\treturn false;\t",
604 "\t\t// add new node to top..",
607 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
608 " \t_this.main_window.windowstate.file.tree = dropNode; ",
609 " \tdropNode.updated_count++;",
611 "\t\tm.append(dropNode);",
612 "\t\t_this.model.selectNode(dropNode); \t",
613 "\t\t_this.changed();",
614 "\t\treturn true; // no need to highlight?",
620 "\tvar row = _this.view.getRowAt(x,y, out pos);",
622 "\t\treturn false; //Gdk.DragAction.COPY;",
624 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
626 "\tvar node = (JsRender.Node)tr.get_item();",
628 " \tif (pos == \"above\" || pos == \"below\") {",
629 "\t\tif (node.parent == null) {",
630 "\t\t\tpos = \"over\";",
632 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
633 "\t\t\t\tpos = \"over\";",
635 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
636 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
637 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
638 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
639 " \t\t\t\t\t\treturn false;\t",
649 " \tif (pos == \"over\") {",
650 "\t \tif (!drop_on_to.contains(node.fqn())) {",
651 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
652 "\t\t\treturn false;",
655 "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
656 " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
657 "\t\t\treturn false;\t",
662 " \t\tcase \"over\":",
663 "\t \t\tnode.appendChild(dropNode);",
664 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
665 "\t\t \t\t_this.model.selectNode(null); ",
666 "\t\t \t\t_this.view.dragNode.remove();",
669 "\t \t\tdropNode.updated_count++;",
670 " \t\t\t_this.model.selectNode(dropNode); ",
672 " \t\t\t_this.changed();\t\t\t\t \t\t",
673 "\t \t\treturn true;",
675 " \t\tcase \"above\":",
676 " \t\t\tGLib.debug(\"Above - insertBefore\");",
678 "\t\t\tnode.parent.insertBefore(dropNode, node);",
679 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
680 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
681 "\t\t \t\t_this.view.dragNode.remove();",
683 "\t\t\tdropNode.updated_count++;",
684 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
685 " \t\t\t_this.changed();",
686 " \t\t\treturn true;",
688 " \t\tcase \"below\":",
689 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
690 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
691 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
692 "\t\t \t\t_this.view.dragNode.remove();",
696 " \t\t\tnode.parent.insertAfter(dropNode, node);",
697 " \t\t\tdropNode.updated_count++;",
698 " \t\t\t_this.model.selectNode(dropNode);\t",
699 " \t\t\t_this.changed();",
700 " \t\t\t// select it",
701 " \t\t\treturn true;",
704 " \t\t\t// should not happen",
705 " \t\t\treturn false;",
718 "\tthis.addHighlight(null,\"\");",
726 "\tvar is_shift = _this.keystate.is_shift > 0;",
728 "\tGLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
729 "\tstring pos; // over / before / after..",
731 " //GLib.debug(\"got drag motion\");",
733 " GLib.Value v = GLib.Value(typeof(string));",
734 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
735 " \tvar cont = this.el.current_drop.get_drag().content ;",
737 " \t\tcont.get_value(ref v);",
738 "\t} catch (GLib.Error e) {",
739 "\t GLib.debug(\"failed to get drag value\");",
740 "\t\treturn Gdk.DragAction.COPY;\t ",
744 "\t//GLib.debug(\"got %s\", v.get_string());",
746 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
747 "\t\t// still dragging same node",
749 "\t\tthis.lastDragNode = new JsRender.Node(); ",
750 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
754 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
755 "\t\t\t\tthis.lastDragNode.fqn());",
757 " string[] str = {};",
758 " foreach(var dp in drop_on_to) {",
761 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
764 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
766 " if (_this.model.el.n_items < 1) {",
767 " \t// FIXME check valid drop types?",
768 " \tif (drop_on_to.contains(\"*top\")) {",
769 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
771 "\t\t\tthis.addHighlight(null, \"\");\t\t",
774 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
779 " \tGLib.debug(\"check is over\");",
781 " // if path of source and dest are inside each other..",
782 " // need to add source info to drag?",
784 " \tvar row = _this.view.getRowAt(x,y, out pos);",
787 "\t\tthis.addHighlight(null, \"\");\t",
788 "\t \treturn Gdk.DragAction.COPY;",
790 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
792 "\tvar node = (JsRender.Node)tr.get_item();",
794 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
797 " \tif (pos == \"above\" || pos == \"below\") {",
798 "\t\tif (node.parent == null) {",
799 "\t\t\tGLib.debug(\"no parent try center\");",
800 "\t\t\tpos = \"over\";",
803 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
804 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
805 "\t \t\t\tpos = \"over\";",
807 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
808 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
809 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
810 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
811 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
812 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
825 " \tif (pos == \"over\") {",
826 "\t \tif (!drop_on_to.contains(node.fqn())) {",
827 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
828 "\t\t\tthis.addHighlight(null, \"\"); ",
829 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
831 "\t\tif (_this.view.dragNode != null && is_shift) {",
832 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
833 "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
834 " \t\t\t\tthis.addHighlight(null, \"\");",
835 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
842 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
843 "\tvar w = _this.view.getWidgetAt(x,y);",
844 "\tthis.addHighlight(w, pos); ",
845 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
849 "string lastDragString" : "\"\"",
850 "xtype" : "DropTarget",
851 "| void addHighlight" : [
852 "(Gtk.Widget? w, string hl) {",
853 "\tif (this.highlightWidget != null) {",
854 "\t\tvar ww = this.highlightWidget;",
855 "\t\tGLib.debug(\"clear drag from previous highlight\");",
856 "\t\tif (ww.has_css_class(\"drag-below\")) {",
857 "\t\t\t ww.remove_css_class(\"drag-below\");",
859 "\t\tif (ww.has_css_class(\"drag-above\")) {",
860 "\t\t\t ww.remove_css_class(\"drag-above\");",
862 "\t\tif (ww.has_css_class(\"drag-over\")) {",
863 "\t\t\t ww.remove_css_class(\"drag-over\");",
866 "\tif (w != null) {",
867 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
868 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
869 "\t\t\tw.add_css_class(\"drag-\" + hl);",
872 "\tthis.highlightWidget = w;",
883 "* ctor" : "this.updateModel(null)",
886 "xtype" : "TreeListModel",
887 "| Gtk.TreeListModel updateModel" : [
888 "(GLib.ListStore? m) {",
889 "\tthis.el = new Gtk.TreeListModel(",
890 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
891 "\t\tfalse, // passthru",
892 "\t\ttrue, // autexpand",
894 "\t\t\treturn ((JsRender.Node)item).childstore;",
898 "\tif (_this.selmodel.el == null) {",
899 "\t\treturn this.el;",
901 "\t_this.selmodel.el.set_model(this.el);",
905 "| int nodeToRow" : [
906 "(JsRender.Node node) ",
909 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
910 "\tfor (var i = 0; i < s.n_items; i++) {",
911 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
912 "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
913 "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
914 "\t\tvar nn = (lr.get_item() as JsRender.Node);",
915 "\t\tif (nn != null && nn.oid == node.oid) {",
920 "\treturn -1;\t\t\t",
925 "| void deleteSelected" : [
930 "\tvar node = _this.selmodel.getSelectedNode();",
933 " if (node == null) {",
934 " \tGLib.debug(\"delete Selected - no node slected?\");",
937 " _this.selmodel.el.unselect_all();",
940 " \tGLib.debug(\"delete Selected - done\");",
943 " print(\"DELETE SELECTED?\");",
944 " //_this.view.blockChanges = true;",
945 " print(\"GET SELECTION?\");",
947 " var s = _this.view.el.get_selection();",
949 " print(\"GET SELECTED?\");",
950 " Gtk.TreeIter iter;",
951 " Gtk.TreeModel mod;",
954 " if (!s.get_selected(out mod, out iter)) {",
955 " return; // nothing seleted..",
960 " this.activePath= \"\"; ",
961 " print(\"GET vnode value?\");",
963 " GLib.Value value;",
964 " this.el.get_value(iter, 2, out value);",
965 " var data = (JsRender.Node)(value.get_object());",
966 " print(\"removing node from Render\\n\");",
967 " if (data.parent == null) {",
968 " _this.main_window.windowstate.file.tree = null;",
972 " print(\"removing node from Tree\\n\"); ",
973 " s.unselect_all();",
974 " this.el.remove(ref iter);",
984 " this.activePath= \"\"; // again!?!? ",
985 " //this.changed(null,true);",
989 " _this.view.blockChanges = false;",
994 "| void loadFile" : [
995 "(JsRender.JsRender f) {",
996 " //console.dump(f);",
998 " _this.drop.highlightWidget = null;",
1000 " var m = (GLib.ListStore) this.el.model;",
1001 "\tm.remove_all();",
1002 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
1004 " _this.main_window.windowstate.file = f;",
1005 " _this.last_error_counter = -1;",
1007 " if (f.tree == null) {",
1009 "\t f.loadItems( );",
1010 " } catch (Error e) {",
1014 " // if it's still null?",
1015 " if (f.tree == null) {",
1016 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1017 " \t_this.updateErrors();",
1020 " \tm.append(f.tree);",
1021 "\t_this.updateErrors();",
1023 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1031 "| void selectNode" : [
1032 "(JsRender.Node? node) ",
1034 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1035 "\tif (node == null) {",
1036 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1039 "\tvar row = this.nodeToRow(node);",
1043 "\t\t// select none?",
1044 "\t\tGLib.debug(\"Could not find node\");",
1045 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1048 "\tGLib.debug(\"Select %d\", row);",
1049 "\ts.set_selected(row);",
1050 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1051 "\t//_this.node_selected(node);\t\t\t",
1059 "selection_changed" : [
1060 "(position, n_items) => {",
1064 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1065 "\t\t\t// then event was started by some other action",
1066 "\t\t\t// which should manually trigger all the events..",
1067 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1072 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1073 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1077 "\t\t if (!_this.before_node_change( ) ) {",
1078 "\t\t\t _this.view.blockChanges = true;",
1079 "\t\t\t _this.selmodel.el.unselect_all();",
1080 "\t\t\t _this.view.blockChanges = false;",
1084 "\t\t if (_this.main_window.windowstate.file == null) {",
1085 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1089 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1090 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1093 "\t\t// -- it appears that the selection is not updated.",
1094 "\t\t // select the node...",
1095 "\t\t //_this.selmodel.el.set_selected(row);",
1097 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1099 "\t var snode = _this.selmodel.getSelectedNode();",
1100 "\t if (snode == null) {",
1102 "\t GLib.debug(\"selected rows < 1\");",
1103 "\t //??this.model.load( false);",
1104 "\t _this.node_selected(null);",
1112 "\t GLib.debug (\"calling left_tree.node_selected\");",
1113 "\t _this.node_selected(snode);",
1118 "\t // no need to scroll. it's in the view as we clicked on it.",
1119 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1126 "xtype" : "SingleSelection",
1127 "| JsRender.Node getNodeAt" : [
1130 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1132 " var a = tr.get_item();; ",
1133 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1136 " return (JsRender.Node)tr.get_item();",
1140 "| JsRender.Node? getSelectedNode" : [
1142 " if (this.el.selected_item == null) {",
1145 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1146 " return (JsRender.Node)tr.get_item();",
1153 "* pack" : "append_column",
1154 "bool expand" : true,
1155 "bool resizable" : true,
1160 "* prop" : "factory",
1164 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1166 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1167 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1170 "\tvar hbox = (Gtk.Box) expand.child;",
1173 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1174 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1176 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1177 "\tvar node = (JsRender.Node) lr.get_item();",
1179 " GLib.debug(\"node is %s\", node.get_type().name());",
1180 "// was item (1) in old layout",
1185 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1186 " var clsname = node.fqn();",
1188 " var clsb = clsname.split(\".\");",
1189 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1191 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1195 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1196 "\t\t img.set_from_file(fn);",
1199 "\t \t\timg.set_from_paintable(",
1200 "\t\t\t \tic.lookup_icon (",
1201 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1202 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1206 " \t} catch (GLib.Error e) {}",
1208 " expand.set_hide_expander( !node.hasChildren() );",
1209 " \texpand.set_list_row(lr);",
1211 " \tnode.bind_property(\"iconResourceName\",",
1212 " img, \"resource\",",
1213 " GLib.BindingFlags.SYNC_CREATE);",
1215 " \tnode.bind_property(\"nodeTitleProp\",",
1217 " GLib.BindingFlags.SYNC_CREATE);",
1218 " \tnode.bind_property(\"nodeTipProp\",",
1219 " lbl, \"tooltip_markup\",",
1220 " GLib.BindingFlags.SYNC_CREATE);",
1221 " \t// bind image...",
1229 "\tvar expand = new Gtk.TreeExpander();",
1231 "\texpand.set_indent_for_depth(true);",
1232 "\texpand.set_indent_for_icon(true);",
1233 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1234 "\tvar icon = new Gtk.Image();",
1235 "\tvar lbl = new Gtk.Label(\"\");",
1236 "\tlbl.use_markup = true;",
1237 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1239 "\ticon.margin_end = 4;",
1240 " \tlbl.justify = Gtk.Justification.LEFT;",
1241 " \tlbl.xalign = 0;",
1243 "//\tlistitem.activatable = true; ??",
1245 "\thbox.append(icon);",
1246 "\thbox.append(lbl);",
1247 "\texpand.set_child(hbox);",
1248 "\t((Gtk.ListItem)listitem).set_child(expand);",
1254 "xtype" : "SignalListItemFactory"
1257 "title" : "Property",
1258 "xtype" : "ColumnViewColumn"
1262 "* pack" : "append_column",
1263 "int fixed_width" : 25,
1267 "* prop" : "factory",
1272 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1273 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1274 "\tvar node = (JsRender.Node) lr.get_item();",
1277 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1278 "\timg.set_from_paintable(",
1279 "\t \tic.lookup_icon (",
1280 "\t \t\t\"list-add\", null, 16,1, ",
1281 "\t\t\t Gtk.TextDirection.NONE, 0",
1285 " \tvar fqn = node.fqn();",
1286 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1288 "\timg.set_visible(cn.size > 0 ? true : false);",
1297 "\tvar icon = new Gtk.Image();",
1299 "\t((Gtk.ListItem)listitem).set_child(icon);",
1304 "xtype" : "SignalListItemFactory"
1307 "string title" : "Add",
1308 "xtype" : "ColumnViewColumn"
1311 "string name" : "left-tree-view",
1312 "xtype" : "ColumnView",
1313 "| Gtk.Widget? getWidgetAt" : [
1314 "(double x, double y) {",
1316 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1317 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1318 "\tif (w == null) {",
1322 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1323 "\tif (row == null) {",
1331 "| Gtk.Widget? getWidgetAtRow" : [
1335 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1336 " \tvar colview = gesture.widget;",
1337 " \tvar line_no = check_list_widget(colview, x,y);",
1338 " if (line_no > -1) {",
1339 " \t\tvar item = colview.model.get_item(line_no);",
1343 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1344 " var child = this.el.get_first_child(); ",
1345 " \tvar line_no = -1; ",
1346 " \tvar reading_header = true;",
1348 " \twhile (child != null) {",
1349 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1351 " \t if (reading_header) {",
1354 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1356 "\t\t\t\t\tchild = child.get_next_sibling();",
1357 "\t\t\t\t\tcontinue;",
1359 "\t\t\t\t// should be columnlistview",
1360 "\t\t\t\tchild = child.get_first_child(); ",
1364 "\t\t\t\treading_header = false;",
1365 "\t\t\t\tcontinue;",
1371 "\t\t\tif (line_no == row) {",
1372 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1373 "\t\t\t return (Gtk.Widget)child;",
1375 "\t child = child.get_next_sibling(); ",
1377 "\t\t//GLib.debug(\"Rturning null\");",
1382 "| int getColAt" : [
1383 "(double x, double y) {",
1386 "\tfrom \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1389 "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1390 "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1391 " var child = this.el.get_first_child(); ",
1395 "\twhile (child != null) {",
1397 "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1398 "\t\t\tchild = child.get_first_child();",
1402 "\t\t//child.get_allocation(out alloc);",
1403 "\t\tif (x < (child.get_width() + offx)) {",
1404 "\t\t\treturn col;",
1407 "\t\t//offx += child.get_width();",
1409 "\t\t//child = child.get_next_sibling();",
1417 "| int getRowAt" : [
1418 "(double x, double y, out string pos) {",
1421 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1422 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1423 "\tif (w == null) {",
1427 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1428 "\tif (row == null) {",
1432 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1437 "\twhile (cr.get_prev_sibling() != null) {",
1439 "\t\tcr = cr.get_prev_sibling();",
1442 "\t//GLib.debug(\"row number is %d\", rn);",
1443 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1444 "\t// above or belw",
1445 "\tGraphene.Rect bounds;",
1446 "\trow.compute_bounds(this.el, out bounds);",
1447 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1448 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1449 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1451 "\tvar ypos = y - bounds.get_y();",
1452 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1453 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1454 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1455 "\tpos = \"over\";",
1457 "\tif (rpos > 80) {",
1458 "\t\tpos = \"below\";",
1459 "\t} else if (rpos < 20) {",
1460 "\t\tpos = \"above\";",
1469 "id" : "LeftTreeMenu",
1474 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1479 "bool has_frame" : false,
1480 "label" : "Delete Element",
1484 "_this.LeftTreeMenu.el.hide();",
1485 " _this.model.deleteSelected();",
1494 "bool has_frame" : false,
1495 "label" : "Save as Template",
1499 "_this.LeftTreeMenu.el.hide();",
1500 " DialogSaveTemplate.singleton().showIt(",
1501 " (Gtk.Window) _this.el.get_root (), ",
1502 " _this.main_window.windowstate.file.palete(), ",
1503 " _this.getActiveElement()",
1514 "bool has_frame" : false,
1515 "label" : "Save as Module",
1520 " _this.LeftTreeMenu.el.hide();",
1521 " var node = _this.getActiveElement();",
1524 " var sm = DialogSaveModule.singleton();",
1528 " (Gtk.Window) _this.el.get_root (), ",
1529 " _this.main_window.windowstate.project, ",
1533 " gtk4 migration - disabled this part.. probably not used muchanyway",
1536 " if (name.length < 1) {",
1540 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1541 " node.items.clear();",
1544 " var s = _this.view.el.get_selection();",
1546 " print(\"GET SELECTED?\");",
1547 " Gtk.TreeIter iter;",
1548 " Gtk.TreeModel mod;",
1551 " if (!s.get_selected(out mod, out iter)) {",
1552 " return; // nothing seleted..",
1554 " Gtk.TreeIter citer;",
1555 " var n_cn = mod.iter_n_children(iter) -1;",
1556 " for (var i = n_cn; i > -1; i--) {",
1557 " mod.iter_nth_child(out citer, iter, i);",
1560 " print(\"removing node from Tree\\n\"); ",
1562 " _this.model.el.remove(ref citer);",
1564 " _this.changed();",
1565 " _this.node_selected(node, \"tree\");",
1580 "xtype" : "ScrolledWindow"
1584 "| JsRender.JsRender getActiveFile" : [
1586 " return this.main_window.windowstate.file;",
1591 "| JsRender.Node? getActiveElement" : [
1592 " () { // return path to actie node.",
1595 "\treturn _this.selmodel.getSelectedNode();",
1601 "| void onresize" : [
1605 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1606 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1611 "| void removeErrors" : [
1613 "\tif (this.error_widgets == null || this.error_widgets.size < 1) {",
1616 "\tforeach(var child in this.error_widgets) {",
1618 "\t\tif (child.has_css_class(\"node-err\")) {",
1619 "\t\t\tchild.remove_css_class(\"node-err\");",
1621 "\t\tif (child.has_css_class(\"node-warn\")) {",
1622 "\t\t\tchild.remove_css_class(\"node-warn\");",
1625 "\t\tif (child.has_css_class(\"node-depr\")) {",
1626 "\t\t\tchild.remove_css_class(\"node-depr\");",
1629 "\tthis.error_widgets = null;",
1633 "\tvar child = this.view.el.get_first_child(); ",
1635 "\tvar reading_header = true;",
1637 "\twhile (child != null) {",
1638 "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1640 "\t if (reading_header) {",
1643 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1645 "\t\t\t\tchild = child.get_next_sibling();",
1646 "\t\t\t\tcontinue;",
1648 "\t\t\t// should be columnlistview",
1649 "\t\t\tchild = child.get_first_child(); ",
1653 "\t\t\treading_header = false;",
1657 "\t \tif (child.has_css_class(\"node-err\")) {",
1658 "\t\t\tchild.remove_css_class(\"node-err\");",
1660 "\t\tif (child.has_css_class(\"node-warn\")) {",
1661 "\t\t\tchild.remove_css_class(\"node-warn\");",
1664 "\t\tif (child.has_css_class(\"node-depr\")) {",
1665 "\t\t\tchild.remove_css_class(\"node-depr\");",
1668 " child = child.get_next_sibling(); ",
1670 "\t//GLib.debug(\"Rturning null\");",
1675 "| void updateErrors" : [
1677 "\tvar file = this.getActiveFile();",
1678 "\tif (file == null) {",
1682 "\tvar ar = file.getErrors();",
1683 "\tif (ar == null || ar.size < 1) {",
1684 "\t\tif (this.last_error_counter != file.error_counter) {",
1685 "\t\t\tthis.removeErrors();",
1688 "\t\tthis.last_error_counter = file.error_counter ;",
1692 " \tif (this.last_error_counter == file.error_counter) {",
1695 "\tthis.removeErrors();",
1696 "\tthis.error_widgets = new Gee.ArrayList<Gtk.Widget>();",
1697 "\tforeach(var diag in ar) { ",
1700 "// print(\"get inter\\n\");",
1701 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1702 "\t if (node == null) {",
1705 " \tvar row = _this.model.nodeToRow(node);",
1706 " \tif (row < 0) {",
1709 " \tvar w = this.view.getWidgetAtRow(row);",
1710 " \tif (w == null) {",
1713 "\t\tthis.error_widgets.add(w);",
1714 "\t\t// always show errors.",
1715 "\t\tvar ed = diag.category.down();",
1716 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1719 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1720 "\t\t\tw.remove_css_class(\"node-warn\");",
1722 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1723 "\t\t\tw.remove_css_class(\"node-depr\");",
1725 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1726 "\t\t\tw.add_css_class(\"node-\" + ed);",
1735 "name" : "WindowLeftTree"