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_widget = _this.view.getRowWidgetAt(x,y, out pos );",
140 " if (row_widget == null) {",
141 "\t GLib.debug(\"no row selected items\");",
145 " var node = row_widget.get_data<JsRender.Node>(\"node\");",
146 " if (node == null) {",
147 " \tGLib.warning(\"No node found bound to widget\");",
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_widget = _this.view.getRowWidgetAt(x,y, out pos );",
202 " if (row_widget == null) {",
203 "\t GLib.debug(\"no row selected items\");",
207 " var node = row_widget.get_data<JsRender.Node>(\"node\");",
208 " if (node == null) {",
209 " \tGLib.warning(\"No node found from widget\");",
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 = data.get_data<Gtk.Widget>(\"tree-row\");",
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 "\t// must get the pos before we clear the hightlihg.",
578 " \tvar pos = \"\";",
579 " \tvar row_widget = _this.view.getRowWidgetAt(x,y, out pos);",
580 "\tthis.addHighlight(null,\"\");",
582 " \tvar is_shift = _this.keystate.is_shift > 0;",
585 " \t// -- get position..",
586 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
587 "\t\t// still dragging same node",
589 "\t\tthis.lastDragNode = new JsRender.Node(); ",
590 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
595 " var dropNode = new JsRender.Node(); ",
596 "\tdropNode.loadFromJsonString(v.get_string(), 2);",
597 "\tGLib.debug(\"dropped node %s\", dropNode.toJsonString());",
600 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
602 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
604 " if (_this.model.el.n_items < 1) {",
605 " \t// FIXME check valid drop types?",
606 " \tif (!drop_on_to.contains(\"*top\")) {",
607 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
608 "\t\t\treturn false;\t",
610 "\t\t// add new node to top..",
611 "\t\tGLib.debug(\"adding to top\");",
613 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
614 " \t_this.main_window.windowstate.file.tree = dropNode; ",
615 " \tdropNode.updated_count++;",
617 "\t\tm.append(dropNode);",
618 "\t\t_this.model.selectNode(dropNode); \t",
619 "\t\t_this.changed();",
620 "\t\t_this.node_selected(dropNode);",
621 "\t\treturn true; // no need to highlight?",
628 "\tif (row_widget == null) {",
629 "\t\tGLib.debug(\"could not get row %d,%d, %s\", (int)x,(int)y,pos);",
630 "\t\treturn false; //Gdk.DragAction.COPY;",
633 "\tvar node = row_widget.get_data<JsRender.Node>(\"node\");",
635 " \tif (pos == \"above\" || pos == \"below\") {",
636 "\t\tif (node.parent == null) {",
637 "\t\t\tpos = \"over\";",
639 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
640 "\t\t\t\tpos = \"over\";",
642 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
643 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
644 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
645 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
646 " \t\t\t\t\t\treturn false;\t",
656 " \tif (pos == \"over\") {",
657 "\t \tif (!drop_on_to.contains(node.fqn())) {",
658 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
659 "\t\t\treturn false;",
662 "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
663 " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
664 "\t\t\treturn false;\t",
669 " \t\tcase \"over\":",
671 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
672 "\t\t \t\t_this.model.selectNode(null); ",
673 "\t\t \t\t_this.view.dragNode.remove();",
675 " \t \t\tnode.appendChild(dropNode);\t\t\t",
676 "\t \t\tdropNode.updated_count++;",
677 " \t\t\t_this.model.selectNode(dropNode); ",
679 " \t\t\t_this.changed();\t\t\t\t \t\t",
680 "\t \t\treturn true;",
682 " \t\tcase \"above\":",
683 " \t\t\tGLib.debug(\"Above - insertBefore\");",
686 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
687 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
688 "\t\t \t\t_this.view.dragNode.remove();",
690 "\t\t\tnode.parent.insertBefore(dropNode, node);\t \t\t",
691 "\t\t\tdropNode.updated_count++;",
692 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
693 " \t\t\t_this.changed();",
694 " \t\t\treturn true;",
696 " \t\tcase \"below\":",
697 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
698 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
699 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
700 "\t\t \t\t_this.view.dragNode.remove();",
704 " \t\t\tnode.parent.insertAfter(dropNode, node);",
705 " \t\t\tdropNode.updated_count++;",
706 " \t\t\t_this.model.selectNode(dropNode);\t",
707 " \t\t\t_this.changed();",
708 " \t\t\t// select it",
709 " \t\t\treturn true;",
712 " \t\t\t// should not happen",
713 " \t\t\treturn false;",
726 "\tthis.addHighlight(null,\"\");",
734 "\tvar is_shift = _this.keystate.is_shift > 0;",
736 "\t//GLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
737 "\tstring pos; // over / before / after..",
739 " //GLib.debug(\"got drag motion\");",
741 " GLib.Value v = GLib.Value(typeof(string));",
742 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
743 " \tvar cont = this.el.current_drop.get_drag().content ;",
745 " \t\tcont.get_value(ref v);",
746 "\t} catch (GLib.Error e) {",
747 "\t // GLib.debug(\"failed to get drag value\");",
748 "\t\treturn Gdk.DragAction.COPY;\t ",
752 "\t//GLib.debug(\"got %s\", v.get_string());",
754 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
755 "\t\t// still dragging same node",
757 "\t\tthis.lastDragNode = new JsRender.Node(); ",
758 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
762 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
763 "\t\t\t\tthis.lastDragNode.fqn());",
765 " string[] str = {};",
766 " foreach(var dp in drop_on_to) {",
769 " \t//GLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
772 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
774 " if (_this.model.el.n_items < 1) {",
775 " \t// FIXME check valid drop types?",
776 " \tif (drop_on_to.contains(\"*top\")) {",
777 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
779 "\t\t\tthis.addHighlight(null, \"\");\t\t",
782 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
789 " // if path of source and dest are inside each other..",
790 " // need to add source info to drag?",
792 " \t var row_widget = _this.view.getRowWidgetAt( x,y, out pos); ",
793 "// \tvar row = _this.view.getRowAt(x,y, out pos);",
794 " \t//GLib.debug(\"check is over %d, %d, %s\", (int)x,(int)y, pos);",
796 " \tif (row_widget == null) {",
797 "\t\tthis.addHighlight(null, \"\");\t",
798 "\t \treturn Gdk.DragAction.COPY;",
800 " \tvar node = row_widget.get_data<JsRender.Node>(\"node\");",
802 "\t//GLib.debug(\"Drop over node: %s\", node.fqn());",
805 " \tif (pos == \"above\" || pos == \"below\") {",
806 "\t\tif (node.parent == null) {",
807 "\t\t\t//GLib.debug(\"no parent try center\");",
808 "\t\t\tpos = \"over\";",
811 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
812 "\t\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
813 "\t \t\t\tpos = \"over\";",
815 "\t\t\t\t//GLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
816 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
817 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
818 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
819 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
820 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
833 " \tif (pos == \"over\") {",
834 "\t \tif (!drop_on_to.contains(node.fqn())) {",
835 "\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
836 "\t\t\tthis.addHighlight(null, \"\"); ",
837 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
839 "\t\tif (_this.view.dragNode != null && is_shift) {",
840 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
841 "\t \t\t\t//GLib.debug(\"shift drop not self not allowed\");",
842 " \t\t\t\tthis.addHighlight(null, \"\");",
843 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
850 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
852 "\tthis.addHighlight(row_widget, pos); ",
853 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
857 "string lastDragString" : "\"\"",
858 "xtype" : "DropTarget",
859 "| void addHighlight" : [
860 "(Gtk.Widget? w, string hl) {",
861 "\tif (this.highlightWidget != null) {",
862 "\t\tvar ww = this.highlightWidget;",
863 "\t\t//GLib.debug(\"clear drag from previous highlight\");",
864 "\t\tif (ww.has_css_class(\"drag-below\")) {",
865 "\t\t\t ww.remove_css_class(\"drag-below\");",
867 "\t\tif (ww.has_css_class(\"drag-above\")) {",
868 "\t\t\t ww.remove_css_class(\"drag-above\");",
870 "\t\tif (ww.has_css_class(\"drag-over\")) {",
871 "\t\t\t ww.remove_css_class(\"drag-over\");",
874 "\tif (w != null) {",
875 "\t\t//GLib.debug(\"add drag=%s to widget\", hl);\t",
876 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
877 "\t\t\tw.add_css_class(\"drag-\" + hl);",
880 "\tthis.highlightWidget = w;",
887 "bool can_unselect" : true,
892 "* ctor" : "this.updateModel(null)",
895 "xtype" : "TreeListModel",
896 "| Gtk.TreeListModel updateModel" : [
897 "(GLib.ListStore? m) {",
898 "\tthis.el = new Gtk.TreeListModel(",
899 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
900 "\t\tfalse, // passthru",
901 "\t\ttrue, // autexpand",
903 "\t\t\treturn ((JsRender.Node)item).childstore;",
907 "\tif (_this.selmodel.el == null) {",
908 "\t\treturn this.el;",
910 "\t_this.selmodel.el.set_model(this.el);",
914 "| int nodeToRow" : [
915 "(JsRender.Node node) ",
918 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
919 "\tfor (var i = 0; i < s.n_items; i++) {",
920 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
921 "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
922 "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
923 "\t\tvar nn = (lr.get_item() as JsRender.Node);",
924 "\t\tif (nn != null && nn.oid == node.oid) {",
929 "\treturn -1;\t\t\t",
934 "| void deleteSelected" : [
939 "\tvar node = _this.selmodel.getSelectedNode();",
942 " if (node == null) {",
943 " \tGLib.debug(\"delete Selected - no node slected?\");",
946 " _this.selmodel.el.unselect_all();",
947 " if (node.parent != null) {",
948 "\t\tnode.remove();",
949 "\t \tGLib.debug(\"delete Selected - done\");",
950 "\t\t_this.changed();",
953 "\tthis.updateModel(null);",
954 "\t_this.main_window.windowstate.file.tree = null;",
955 "\t_this.changed();",
956 "\t_this.node_selected(null);",
958 " print(\"DELETE SELECTED?\");",
959 " //_this.view.blockChanges = true;",
960 " print(\"GET SELECTION?\");",
962 " var s = _this.view.el.get_selection();",
964 " print(\"GET SELECTED?\");",
965 " Gtk.TreeIter iter;",
966 " Gtk.TreeModel mod;",
969 " if (!s.get_selected(out mod, out iter)) {",
970 " return; // nothing seleted..",
975 " this.activePath= \"\"; ",
976 " print(\"GET vnode value?\");",
978 " GLib.Value value;",
979 " this.el.get_value(iter, 2, out value);",
980 " var data = (JsRender.Node)(value.get_object());",
981 " print(\"removing node from Render\\n\");",
982 " if (data.parent == null) {",
983 " _this.main_window.windowstate.file.tree = null;",
987 " print(\"removing node from Tree\\n\"); ",
988 " s.unselect_all();",
989 " this.el.remove(ref iter);",
999 " this.activePath= \"\"; // again!?!? ",
1000 " //this.changed(null,true);",
1002 " _this.changed();",
1004 " _this.view.blockChanges = false;",
1009 "| void loadFile" : [
1010 "(JsRender.JsRender f) {",
1011 " //console.dump(f);",
1013 " _this.drop.highlightWidget = null;",
1015 " var m = (GLib.ListStore) this.el.model;",
1016 "\tm.remove_all();",
1017 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
1019 " _this.main_window.windowstate.file = f;",
1020 " _this.last_error_counter = -1;",
1022 " if (f.tree == null) {",
1024 "\t f.loadItems( );",
1025 " } catch (Error e) {",
1029 " // if it's still null?",
1030 " if (f.tree == null) {",
1031 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1032 " \t_this.updateErrors();",
1035 " \tm.append(f.tree);",
1036 "\t_this.updateErrors();",
1038 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1046 "| void selectNode" : [
1047 "(JsRender.Node? node) ",
1049 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1050 "\tif (node == null) {",
1051 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1054 "\tvar row = this.nodeToRow(node);",
1058 "\t\t// select none?",
1059 "\t\tGLib.debug(\"Could not find node\");",
1060 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1063 "\tGLib.debug(\"Select %d\", row);",
1064 "\ts.set_selected(row);",
1065 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1066 "\t//_this.node_selected(node);\t\t\t",
1074 "selection_changed" : [
1075 "(position, n_items) => {",
1079 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1080 "\t\t\t// then event was started by some other action",
1081 "\t\t\t// which should manually trigger all the events..",
1082 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1087 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1088 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1092 "\t\t if (!_this.before_node_change( ) ) {",
1093 "\t\t\t _this.view.blockChanges = true;",
1094 "\t\t\t _this.selmodel.el.unselect_all();",
1095 "\t\t\t _this.view.blockChanges = false;",
1099 "\t\t if (_this.main_window.windowstate.file == null) {",
1100 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1104 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1105 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1108 "\t\t// -- it appears that the selection is not updated.",
1109 "\t\t // select the node...",
1110 "\t\t //_this.selmodel.el.set_selected(row);",
1112 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1114 "\t var snode = _this.selmodel.getSelectedNode();",
1115 "\t if (snode == null) {",
1117 "\t GLib.debug(\"selected rows < 1\");",
1118 "\t //??this.model.load( false);",
1119 "\t _this.node_selected(null);",
1127 "\t GLib.debug (\"calling left_tree.node_selected %s\", snode.toJsonString());",
1128 "\t _this.node_selected(snode);",
1133 "\t // no need to scroll. it's in the view as we clicked on it.",
1134 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1141 "xtype" : "SingleSelection",
1142 "| JsRender.Node getNodeAt" : [
1145 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1147 " var a = tr.get_item();; ",
1148 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1151 " return (JsRender.Node)tr.get_item();",
1155 "| JsRender.Node? getSelectedNode" : [
1157 " if (this.el.selected_item == null) {",
1162 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1164 " return (JsRender.Node)tr.get_item();",
1171 "* pack" : "append_column",
1172 "bool expand" : true,
1173 "bool resizable" : true,
1178 "* prop" : "factory",
1182 "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1184 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1185 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1188 "\tvar hbox = (Gtk.Box) expand.child;",
1191 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1192 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1194 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1195 "\tvar node = (JsRender.Node) lr.get_item();",
1196 "\tif (node == null || node.fqn() == \"\") {",
1200 "\tnode.set_data<Gtk.Widget>(\"tree-row\", expand.get_parent().get_parent());",
1201 "\texpand.get_parent().get_parent().set_data<JsRender.Node>(\"node\", node);",
1203 " //GLib.debug(\"node is %s\", node.get_type().name());",
1204 "// was item (1) in old layout",
1209 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1210 " var clsname = node.fqn();",
1212 " var clsb = clsname.split(\".\");",
1213 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1215 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1219 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1220 "\t\t img.set_from_file(fn);",
1223 "\t \t\timg.set_from_paintable(",
1224 "\t\t\t \tic.lookup_icon (",
1225 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1226 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1230 " \t} catch (GLib.Error e) {}",
1232 " expand.set_hide_expander( !node.hasChildren() );",
1233 " \texpand.set_list_row(lr);",
1235 " \tnode.bind_property(\"iconResourceName\",",
1236 " img, \"resource\",",
1237 " GLib.BindingFlags.SYNC_CREATE);",
1239 " \tnode.bind_property(\"nodeTitleProp\",",
1241 " GLib.BindingFlags.SYNC_CREATE);",
1242 " \tnode.bind_property(\"nodeTipProp\",",
1243 " lbl, \"tooltip_markup\",",
1244 " GLib.BindingFlags.SYNC_CREATE);",
1245 " \t// bind image...",
1253 "\tvar expand = new Gtk.TreeExpander();",
1255 "\texpand.set_indent_for_depth(true);",
1256 "\texpand.set_indent_for_icon(true);",
1257 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1258 "\tvar icon = new Gtk.Image();",
1259 "\tvar lbl = new Gtk.Label(\"\");",
1260 "\tlbl.use_markup = true;",
1261 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1263 "\ticon.margin_end = 4;",
1264 " \tlbl.justify = Gtk.Justification.LEFT;",
1265 " \tlbl.xalign = 0;",
1267 "//\tlistitem.activatable = true; ??",
1269 "\thbox.append(icon);",
1270 "\thbox.append(lbl);",
1271 "\texpand.set_child(hbox);",
1272 "\t((Gtk.ListItem)listitem).set_child(expand);",
1278 "xtype" : "SignalListItemFactory"
1281 "title" : "Property",
1282 "xtype" : "ColumnViewColumn"
1286 "* pack" : "append_column",
1287 "int fixed_width" : 25,
1291 "* prop" : "factory",
1296 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1297 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1298 "\tvar node = (JsRender.Node) lr.get_item();",
1301 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1302 "\timg.set_from_paintable(",
1303 "\t \tic.lookup_icon (",
1304 "\t \t\t\"list-add\", null, 16,1, ",
1305 "\t\t\t Gtk.TextDirection.NONE, 0",
1309 " \tvar fqn = node.fqn();",
1310 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1312 "\timg.set_visible(cn.size > 0 ? true : false);",
1321 "\tvar icon = new Gtk.Image();",
1323 "\t((Gtk.ListItem)listitem).set_child(icon);",
1328 "xtype" : "SignalListItemFactory"
1331 "string title" : "Add",
1332 "xtype" : "ColumnViewColumn"
1335 "string name" : "left-tree-view",
1336 "xtype" : "ColumnView",
1337 "| Gtk.Widget? getRowWidgetAt" : [
1338 "(double x, double y, out string pos) {",
1341 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1342 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1343 "\tif (w == null) {",
1347 "\tvar row = w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1348 "\tif (row == null) {",
1352 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1356 "\t//GLib.debug(\"row number is %d\", rn);",
1357 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1358 "\t// above or belw",
1359 "\tGraphene.Rect bounds;",
1360 "\trow.compute_bounds(this.el, out bounds);",
1361 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1362 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1363 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1365 "\tvar ypos = y - bounds.get_y();",
1366 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1367 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1368 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1369 "\tpos = \"over\";",
1371 "\tif (rpos > 80) {",
1372 "\t\tpos = \"below\";",
1373 "\t} else if (rpos < 20) {",
1374 "\t\tpos = \"above\";",
1379 "| Gtk.Widget? getWidgetAtRowBROKE" : [
1383 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1384 " \tvar colview = gesture.widget;",
1385 " \tvar line_no = check_list_widget(colview, x,y);",
1386 " if (line_no > -1) {",
1387 " \t\tvar item = colview.model.get_item(line_no);",
1391 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1392 " var child = this.el.get_first_child(); ",
1393 " \tvar line_no = -1; ",
1394 " \tvar reading_header = true;",
1396 " \twhile (child != null) {",
1397 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1399 " \t if (reading_header) {",
1402 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1404 "\t\t\t\t\tchild = child.get_next_sibling();",
1405 "\t\t\t\t\tcontinue;",
1407 "\t\t\t\t// should be columnlistview",
1408 "\t\t\t\tchild = child.get_first_child(); ",
1412 "\t\t\t\treading_header = false;",
1413 "\t\t\t\tcontinue;",
1419 "\t\t\tif (line_no == row) {",
1420 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1421 "\t\t\t return (Gtk.Widget)child;",
1423 "\t child = child.get_next_sibling(); ",
1425 "\t\t//GLib.debug(\"Rturning null\");",
1430 "| int getColAt" : [
1431 "(double x, double y) {",
1434 "\tfrom \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1437 "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1438 "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1439 " var child = this.el.get_first_child(); ",
1443 "\twhile (child != null) {",
1445 "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1446 "\t\t\tchild = child.get_first_child();",
1450 "\t\t//child.get_allocation(out alloc);",
1451 "\t\tif (x < (child.get_width() + offx)) {",
1452 "\t\t\treturn col;",
1455 "\t\t//offx += child.get_width();",
1457 "\t\t//child = child.get_next_sibling();",
1465 "| int getRowAtOLD" : [
1466 "(double x, double y, out string pos) {",
1469 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1470 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1471 "\tif (w == null) {",
1475 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1476 "\tif (row == null) {",
1480 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1485 "\twhile (cr.get_prev_sibling() != null) {",
1487 "\t\tcr = cr.get_prev_sibling();",
1490 "\t//GLib.debug(\"row number is %d\", rn);",
1491 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1492 "\t// above or belw",
1493 "\tGraphene.Rect bounds;",
1494 "\trow.compute_bounds(this.el, out bounds);",
1495 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1496 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1497 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1499 "\tvar ypos = y - bounds.get_y();",
1500 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1501 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1502 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1503 "\tpos = \"over\";",
1505 "\tif (rpos > 80) {",
1506 "\t\tpos = \"below\";",
1507 "\t} else if (rpos < 20) {",
1508 "\t\tpos = \"above\";",
1517 "id" : "LeftTreeMenu",
1522 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1527 "bool has_frame" : false,
1528 "label" : "Delete Element",
1532 "_this.LeftTreeMenu.el.hide();",
1533 " _this.model.deleteSelected();",
1542 "bool has_frame" : false,
1543 "label" : "Save as Template",
1547 "_this.LeftTreeMenu.el.hide();",
1548 " DialogSaveTemplate.singleton().showIt(",
1549 " (Gtk.Window) _this.el.get_root (), ",
1550 " _this.main_window.windowstate.file.palete(), ",
1551 " _this.getActiveElement()",
1562 "bool has_frame" : false,
1563 "label" : "Save as Module",
1568 " _this.LeftTreeMenu.el.hide();",
1569 " var node = _this.getActiveElement();",
1572 " var sm = DialogSaveModule.singleton();",
1576 " (Gtk.Window) _this.el.get_root (), ",
1577 " _this.main_window.windowstate.project, ",
1581 " gtk4 migration - disabled this part.. probably not used muchanyway",
1584 " if (name.length < 1) {",
1588 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1589 " node.items.clear();",
1592 " var s = _this.view.el.get_selection();",
1594 " print(\"GET SELECTED?\");",
1595 " Gtk.TreeIter iter;",
1596 " Gtk.TreeModel mod;",
1599 " if (!s.get_selected(out mod, out iter)) {",
1600 " return; // nothing seleted..",
1602 " Gtk.TreeIter citer;",
1603 " var n_cn = mod.iter_n_children(iter) -1;",
1604 " for (var i = n_cn; i > -1; i--) {",
1605 " mod.iter_nth_child(out citer, iter, i);",
1608 " print(\"removing node from Tree\\n\"); ",
1610 " _this.model.el.remove(ref citer);",
1612 " _this.changed();",
1613 " _this.node_selected(node, \"tree\");",
1628 "xtype" : "ScrolledWindow"
1632 "| JsRender.JsRender getActiveFile" : [
1634 " return this.main_window.windowstate.file;",
1639 "| JsRender.Node? getActiveElement" : [
1640 " () { // return path to actie node.",
1643 "\treturn _this.selmodel.getSelectedNode();",
1649 "| void onresize" : [
1653 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1654 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1659 "| void removeErrors" : [
1661 "\tif (this.error_widgets == null || this.error_widgets.size < 1) {",
1664 "\tforeach(var child in this.error_widgets) {",
1666 "\t\tif (child.has_css_class(\"node-err\")) {",
1667 "\t\t\tchild.remove_css_class(\"node-err\");",
1669 "\t\tif (child.has_css_class(\"node-warn\")) {",
1670 "\t\t\tchild.remove_css_class(\"node-warn\");",
1673 "\t\tif (child.has_css_class(\"node-depr\")) {",
1674 "\t\t\tchild.remove_css_class(\"node-depr\");",
1677 "\tthis.error_widgets = null;",
1681 "\tvar child = this.view.el.get_first_child(); ",
1683 "\tvar reading_header = true;",
1685 "\twhile (child != null) {",
1686 "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1688 "\t if (reading_header) {",
1691 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1693 "\t\t\t\tchild = child.get_next_sibling();",
1694 "\t\t\t\tcontinue;",
1696 "\t\t\t// should be columnlistview",
1697 "\t\t\tchild = child.get_first_child(); ",
1701 "\t\t\treading_header = false;",
1705 "\t \tif (child.has_css_class(\"node-err\")) {",
1706 "\t\t\tchild.remove_css_class(\"node-err\");",
1708 "\t\tif (child.has_css_class(\"node-warn\")) {",
1709 "\t\t\tchild.remove_css_class(\"node-warn\");",
1712 "\t\tif (child.has_css_class(\"node-depr\")) {",
1713 "\t\t\tchild.remove_css_class(\"node-depr\");",
1716 " child = child.get_next_sibling(); ",
1718 "\t//GLib.debug(\"Rturning null\");",
1723 "| void updateErrors" : [
1725 "\tvar file = this.getActiveFile();",
1726 "\tif (file == null) {",
1730 "\tvar ar = file.getErrors();",
1731 "\tif (ar == null || ar.size < 1) {",
1732 "\t\tif (this.last_error_counter != file.error_counter) {",
1733 "\t\t\tthis.removeErrors();",
1736 "\t\tthis.last_error_counter = file.error_counter ;",
1740 " \tif (this.last_error_counter == file.error_counter) {",
1743 "\tthis.removeErrors();",
1744 "\tthis.error_widgets = new Gee.ArrayList<Gtk.Widget>();",
1745 "\tforeach(var diag in ar) { ",
1747 "// print(\"get inter\\n\");",
1748 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1749 "\t if (node == null) {",
1752 " \tvar w = node.get_data<Gtk.Widget>(\"tree-row\");",
1753 " \tif (w == null) {",
1756 "\t\tthis.error_widgets.add(w);",
1757 "\t\t// always show errors.",
1758 "\t\tvar ed = diag.category.down();",
1759 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1762 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1763 "\t\t\tw.remove_css_class(\"node-warn\");",
1765 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1766 "\t\t\tw.remove_css_class(\"node-depr\");",
1768 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1769 "\t\t\tw.add_css_class(\"node-\" + ed);",
1778 "name" : "WindowLeftTree"