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 "\t// must get the pos before we clear the hightlihg.",
578 " \tvar pos = \"\";",
579 " \tvar row = _this.view.getRowAt(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?",
629 "\t\tGLib.debug(\"could not get row %d,%d, %s\", (int)x,(int)y,pos);",
630 "\t\treturn false; //Gdk.DragAction.COPY;",
632 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
634 "\tvar node = (JsRender.Node)tr.get_item();",
636 " \tif (pos == \"above\" || pos == \"below\") {",
637 "\t\tif (node.parent == null) {",
638 "\t\t\tpos = \"over\";",
640 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
641 "\t\t\t\tpos = \"over\";",
643 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
644 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
645 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
646 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
647 " \t\t\t\t\t\treturn false;\t",
657 " \tif (pos == \"over\") {",
658 "\t \tif (!drop_on_to.contains(node.fqn())) {",
659 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
660 "\t\t\treturn false;",
663 "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
664 " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
665 "\t\t\treturn false;\t",
670 " \t\tcase \"over\":",
672 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
673 "\t\t \t\t_this.model.selectNode(null); ",
674 "\t\t \t\t_this.view.dragNode.remove();",
676 " \t \t\tnode.appendChild(dropNode);\t\t\t",
677 "\t \t\tdropNode.updated_count++;",
678 " \t\t\t_this.model.selectNode(dropNode); ",
680 " \t\t\t_this.changed();\t\t\t\t \t\t",
681 "\t \t\treturn true;",
683 " \t\tcase \"above\":",
684 " \t\t\tGLib.debug(\"Above - insertBefore\");",
687 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
688 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
689 "\t\t \t\t_this.view.dragNode.remove();",
691 "\t\t\tnode.parent.insertBefore(dropNode, node);\t \t\t",
692 "\t\t\tdropNode.updated_count++;",
693 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
694 " \t\t\t_this.changed();",
695 " \t\t\treturn true;",
697 " \t\tcase \"below\":",
698 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
699 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
700 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
701 "\t\t \t\t_this.view.dragNode.remove();",
705 " \t\t\tnode.parent.insertAfter(dropNode, node);",
706 " \t\t\tdropNode.updated_count++;",
707 " \t\t\t_this.model.selectNode(dropNode);\t",
708 " \t\t\t_this.changed();",
709 " \t\t\t// select it",
710 " \t\t\treturn true;",
713 " \t\t\t// should not happen",
714 " \t\t\treturn false;",
727 "\tthis.addHighlight(null,\"\");",
735 "\tvar is_shift = _this.keystate.is_shift > 0;",
737 "\t//GLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
738 "\tstring pos; // over / before / after..",
740 " //GLib.debug(\"got drag motion\");",
742 " GLib.Value v = GLib.Value(typeof(string));",
743 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
744 " \tvar cont = this.el.current_drop.get_drag().content ;",
746 " \t\tcont.get_value(ref v);",
747 "\t} catch (GLib.Error e) {",
748 "\t // GLib.debug(\"failed to get drag value\");",
749 "\t\treturn Gdk.DragAction.COPY;\t ",
753 "\t//GLib.debug(\"got %s\", v.get_string());",
755 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
756 "\t\t// still dragging same node",
758 "\t\tthis.lastDragNode = new JsRender.Node(); ",
759 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
763 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
764 "\t\t\t\tthis.lastDragNode.fqn());",
766 " string[] str = {};",
767 " foreach(var dp in drop_on_to) {",
770 " \t//GLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
773 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
775 " if (_this.model.el.n_items < 1) {",
776 " \t// FIXME check valid drop types?",
777 " \tif (drop_on_to.contains(\"*top\")) {",
778 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
780 "\t\t\tthis.addHighlight(null, \"\");\t\t",
783 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
790 " // if path of source and dest are inside each other..",
791 " // need to add source info to drag?",
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);",
797 "\t\tthis.addHighlight(null, \"\");\t",
798 "\t \treturn Gdk.DragAction.COPY;",
800 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
802 "\tvar node = (JsRender.Node)tr.get_item();",
804 "\t//GLib.debug(\"Drop over node: %s\", node.fqn());",
807 " \tif (pos == \"above\" || pos == \"below\") {",
808 "\t\tif (node.parent == null) {",
809 "\t\t\t//GLib.debug(\"no parent try center\");",
810 "\t\t\tpos = \"over\";",
813 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
814 "\t\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
815 "\t \t\t\tpos = \"over\";",
817 "\t\t\t\t//GLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
818 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
819 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
820 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
821 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
822 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
835 " \tif (pos == \"over\") {",
836 "\t \tif (!drop_on_to.contains(node.fqn())) {",
837 "\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
838 "\t\t\tthis.addHighlight(null, \"\"); ",
839 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
841 "\t\tif (_this.view.dragNode != null && is_shift) {",
842 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
843 "\t \t\t\t//GLib.debug(\"shift drop not self not allowed\");",
844 " \t\t\t\tthis.addHighlight(null, \"\");",
845 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
852 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
853 "\tvar w = _this.view.getWidgetAt(x,y);",
854 "\tthis.addHighlight(w, pos); ",
855 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
859 "string lastDragString" : "\"\"",
860 "xtype" : "DropTarget",
861 "| void addHighlight" : [
862 "(Gtk.Widget? w, string hl) {",
863 "\tif (this.highlightWidget != null) {",
864 "\t\tvar ww = this.highlightWidget;",
865 "\t\t//GLib.debug(\"clear drag from previous highlight\");",
866 "\t\tif (ww.has_css_class(\"drag-below\")) {",
867 "\t\t\t ww.remove_css_class(\"drag-below\");",
869 "\t\tif (ww.has_css_class(\"drag-above\")) {",
870 "\t\t\t ww.remove_css_class(\"drag-above\");",
872 "\t\tif (ww.has_css_class(\"drag-over\")) {",
873 "\t\t\t ww.remove_css_class(\"drag-over\");",
876 "\tif (w != null) {",
877 "\t\t//GLib.debug(\"add drag=%s to widget\", hl);\t",
878 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
879 "\t\t\tw.add_css_class(\"drag-\" + hl);",
882 "\tthis.highlightWidget = w;",
889 "bool can_unselect" : true,
894 "* ctor" : "this.updateModel(null)",
897 "xtype" : "TreeListModel",
898 "| Gtk.TreeListModel updateModel" : [
899 "(GLib.ListStore? m) {",
900 "\tthis.el = new Gtk.TreeListModel(",
901 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
902 "\t\tfalse, // passthru",
903 "\t\ttrue, // autexpand",
905 "\t\t\treturn ((JsRender.Node)item).childstore;",
909 "\tif (_this.selmodel.el == null) {",
910 "\t\treturn this.el;",
912 "\t_this.selmodel.el.set_model(this.el);",
916 "| int nodeToRow" : [
917 "(JsRender.Node node) ",
920 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
921 "\tfor (var i = 0; i < s.n_items; i++) {",
922 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
923 "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
924 "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
925 "\t\tvar nn = (lr.get_item() as JsRender.Node);",
926 "\t\tif (nn != null && nn.oid == node.oid) {",
931 "\treturn -1;\t\t\t",
936 "| void deleteSelected" : [
941 "\tvar node = _this.selmodel.getSelectedNode();",
944 " if (node == null) {",
945 " \tGLib.debug(\"delete Selected - no node slected?\");",
948 " _this.selmodel.el.unselect_all();",
949 " if (node.parent != null) {",
950 "\t\tnode.remove();",
951 "\t \tGLib.debug(\"delete Selected - done\");",
952 "\t\t_this.changed();",
955 "\tthis.updateModel(null);",
956 "\t_this.main_window.windowstate.file.tree = null;",
957 "\t_this.changed();",
958 "\t_this.node_selected(null);",
960 " print(\"DELETE SELECTED?\");",
961 " //_this.view.blockChanges = true;",
962 " print(\"GET SELECTION?\");",
964 " var s = _this.view.el.get_selection();",
966 " print(\"GET SELECTED?\");",
967 " Gtk.TreeIter iter;",
968 " Gtk.TreeModel mod;",
971 " if (!s.get_selected(out mod, out iter)) {",
972 " return; // nothing seleted..",
977 " this.activePath= \"\"; ",
978 " print(\"GET vnode value?\");",
980 " GLib.Value value;",
981 " this.el.get_value(iter, 2, out value);",
982 " var data = (JsRender.Node)(value.get_object());",
983 " print(\"removing node from Render\\n\");",
984 " if (data.parent == null) {",
985 " _this.main_window.windowstate.file.tree = null;",
989 " print(\"removing node from Tree\\n\"); ",
990 " s.unselect_all();",
991 " this.el.remove(ref iter);",
1001 " this.activePath= \"\"; // again!?!? ",
1002 " //this.changed(null,true);",
1004 " _this.changed();",
1006 " _this.view.blockChanges = false;",
1011 "| void loadFile" : [
1012 "(JsRender.JsRender f) {",
1013 " //console.dump(f);",
1015 " _this.drop.highlightWidget = null;",
1017 " var m = (GLib.ListStore) this.el.model;",
1018 "\tm.remove_all();",
1019 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
1021 " _this.main_window.windowstate.file = f;",
1022 " _this.last_error_counter = -1;",
1024 " if (f.tree == null) {",
1026 "\t f.loadItems( );",
1027 " } catch (Error e) {",
1031 " // if it's still null?",
1032 " if (f.tree == null) {",
1033 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1034 " \t_this.updateErrors();",
1037 " \tm.append(f.tree);",
1038 "\t_this.updateErrors();",
1040 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1048 "| void selectNode" : [
1049 "(JsRender.Node? node) ",
1051 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1052 "\tif (node == null) {",
1053 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1056 "\tvar row = this.nodeToRow(node);",
1060 "\t\t// select none?",
1061 "\t\tGLib.debug(\"Could not find node\");",
1062 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1065 "\tGLib.debug(\"Select %d\", row);",
1066 "\ts.set_selected(row);",
1067 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1068 "\t//_this.node_selected(node);\t\t\t",
1076 "selection_changed" : [
1077 "(position, n_items) => {",
1081 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1082 "\t\t\t// then event was started by some other action",
1083 "\t\t\t// which should manually trigger all the events..",
1084 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1089 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1090 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1094 "\t\t if (!_this.before_node_change( ) ) {",
1095 "\t\t\t _this.view.blockChanges = true;",
1096 "\t\t\t _this.selmodel.el.unselect_all();",
1097 "\t\t\t _this.view.blockChanges = false;",
1101 "\t\t if (_this.main_window.windowstate.file == null) {",
1102 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1106 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1107 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1110 "\t\t// -- it appears that the selection is not updated.",
1111 "\t\t // select the node...",
1112 "\t\t //_this.selmodel.el.set_selected(row);",
1114 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1116 "\t var snode = _this.selmodel.getSelectedNode();",
1117 "\t if (snode == null) {",
1119 "\t GLib.debug(\"selected rows < 1\");",
1120 "\t //??this.model.load( false);",
1121 "\t _this.node_selected(null);",
1129 "\t GLib.debug (\"calling left_tree.node_selected %s\", snode.toJsonString());",
1130 "\t _this.node_selected(snode);",
1135 "\t // no need to scroll. it's in the view as we clicked on it.",
1136 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1143 "xtype" : "SingleSelection",
1144 "| JsRender.Node getNodeAt" : [
1147 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1149 " var a = tr.get_item();; ",
1150 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1153 " return (JsRender.Node)tr.get_item();",
1157 "| JsRender.Node? getSelectedNode" : [
1159 " if (this.el.selected_item == null) {",
1164 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1166 " return (JsRender.Node)tr.get_item();",
1173 "* pack" : "append_column",
1174 "bool expand" : true,
1175 "bool resizable" : true,
1180 "* prop" : "factory",
1184 "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1186 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1187 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1190 "\tvar hbox = (Gtk.Box) expand.child;",
1193 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1194 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1196 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1197 "\tvar node = (JsRender.Node) lr.get_item();",
1198 "\tif (node == null || node.fqn() == \"\") {",
1201 " //GLib.debug(\"node is %s\", node.get_type().name());",
1202 "// was item (1) in old layout",
1207 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1208 " var clsname = node.fqn();",
1210 " var clsb = clsname.split(\".\");",
1211 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1213 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1217 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1218 "\t\t img.set_from_file(fn);",
1221 "\t \t\timg.set_from_paintable(",
1222 "\t\t\t \tic.lookup_icon (",
1223 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1224 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1228 " \t} catch (GLib.Error e) {}",
1230 " expand.set_hide_expander( !node.hasChildren() );",
1231 " \texpand.set_list_row(lr);",
1233 " \tnode.bind_property(\"iconResourceName\",",
1234 " img, \"resource\",",
1235 " GLib.BindingFlags.SYNC_CREATE);",
1237 " \tnode.bind_property(\"nodeTitleProp\",",
1239 " GLib.BindingFlags.SYNC_CREATE);",
1240 " \tnode.bind_property(\"nodeTipProp\",",
1241 " lbl, \"tooltip_markup\",",
1242 " GLib.BindingFlags.SYNC_CREATE);",
1243 " \t// bind image...",
1251 "\tvar expand = new Gtk.TreeExpander();",
1253 "\texpand.set_indent_for_depth(true);",
1254 "\texpand.set_indent_for_icon(true);",
1255 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1256 "\tvar icon = new Gtk.Image();",
1257 "\tvar lbl = new Gtk.Label(\"\");",
1258 "\tlbl.use_markup = true;",
1259 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1261 "\ticon.margin_end = 4;",
1262 " \tlbl.justify = Gtk.Justification.LEFT;",
1263 " \tlbl.xalign = 0;",
1265 "//\tlistitem.activatable = true; ??",
1267 "\thbox.append(icon);",
1268 "\thbox.append(lbl);",
1269 "\texpand.set_child(hbox);",
1270 "\t((Gtk.ListItem)listitem).set_child(expand);",
1276 "xtype" : "SignalListItemFactory"
1279 "title" : "Property",
1280 "xtype" : "ColumnViewColumn"
1284 "* pack" : "append_column",
1285 "int fixed_width" : 25,
1289 "* prop" : "factory",
1294 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1295 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1296 "\tvar node = (JsRender.Node) lr.get_item();",
1299 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1300 "\timg.set_from_paintable(",
1301 "\t \tic.lookup_icon (",
1302 "\t \t\t\"list-add\", null, 16,1, ",
1303 "\t\t\t Gtk.TextDirection.NONE, 0",
1307 " \tvar fqn = node.fqn();",
1308 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1310 "\timg.set_visible(cn.size > 0 ? true : false);",
1319 "\tvar icon = new Gtk.Image();",
1321 "\t((Gtk.ListItem)listitem).set_child(icon);",
1326 "xtype" : "SignalListItemFactory"
1329 "string title" : "Add",
1330 "xtype" : "ColumnViewColumn"
1333 "string name" : "left-tree-view",
1334 "xtype" : "ColumnView",
1335 "| Gtk.Widget? getWidgetAt" : [
1336 "(double x, double y) {",
1338 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1339 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1340 "\tif (w == null) {",
1344 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1345 "\tif (row == null) {",
1353 "| Gtk.Widget? getWidgetAtRow" : [
1357 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1358 " \tvar colview = gesture.widget;",
1359 " \tvar line_no = check_list_widget(colview, x,y);",
1360 " if (line_no > -1) {",
1361 " \t\tvar item = colview.model.get_item(line_no);",
1365 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1366 " var child = this.el.get_first_child(); ",
1367 " \tvar line_no = -1; ",
1368 " \tvar reading_header = true;",
1370 " \twhile (child != null) {",
1371 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1373 " \t if (reading_header) {",
1376 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1378 "\t\t\t\t\tchild = child.get_next_sibling();",
1379 "\t\t\t\t\tcontinue;",
1381 "\t\t\t\t// should be columnlistview",
1382 "\t\t\t\tchild = child.get_first_child(); ",
1386 "\t\t\t\treading_header = false;",
1387 "\t\t\t\tcontinue;",
1393 "\t\t\tif (line_no == row) {",
1394 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1395 "\t\t\t return (Gtk.Widget)child;",
1397 "\t child = child.get_next_sibling(); ",
1399 "\t\t//GLib.debug(\"Rturning null\");",
1404 "| int getColAt" : [
1405 "(double x, double y) {",
1408 "\tfrom \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1411 "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1412 "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1413 " var child = this.el.get_first_child(); ",
1417 "\twhile (child != null) {",
1419 "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1420 "\t\t\tchild = child.get_first_child();",
1424 "\t\t//child.get_allocation(out alloc);",
1425 "\t\tif (x < (child.get_width() + offx)) {",
1426 "\t\t\treturn col;",
1429 "\t\t//offx += child.get_width();",
1431 "\t\t//child = child.get_next_sibling();",
1439 "| int getRowAt" : [
1440 "(double x, double y, out string pos) {",
1443 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1444 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1445 "\tif (w == null) {",
1449 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1450 "\tif (row == null) {",
1454 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1459 "\twhile (cr.get_prev_sibling() != null) {",
1461 "\t\tcr = cr.get_prev_sibling();",
1464 "\t//GLib.debug(\"row number is %d\", rn);",
1465 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1466 "\t// above or belw",
1467 "\tGraphene.Rect bounds;",
1468 "\trow.compute_bounds(this.el, out bounds);",
1469 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1470 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1471 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1473 "\tvar ypos = y - bounds.get_y();",
1474 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1475 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1476 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1477 "\tpos = \"over\";",
1479 "\tif (rpos > 80) {",
1480 "\t\tpos = \"below\";",
1481 "\t} else if (rpos < 20) {",
1482 "\t\tpos = \"above\";",
1491 "id" : "LeftTreeMenu",
1496 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1501 "bool has_frame" : false,
1502 "label" : "Delete Element",
1506 "_this.LeftTreeMenu.el.hide();",
1507 " _this.model.deleteSelected();",
1516 "bool has_frame" : false,
1517 "label" : "Save as Template",
1521 "_this.LeftTreeMenu.el.hide();",
1522 " DialogSaveTemplate.singleton().showIt(",
1523 " (Gtk.Window) _this.el.get_root (), ",
1524 " _this.main_window.windowstate.file.palete(), ",
1525 " _this.getActiveElement()",
1536 "bool has_frame" : false,
1537 "label" : "Save as Module",
1542 " _this.LeftTreeMenu.el.hide();",
1543 " var node = _this.getActiveElement();",
1546 " var sm = DialogSaveModule.singleton();",
1550 " (Gtk.Window) _this.el.get_root (), ",
1551 " _this.main_window.windowstate.project, ",
1555 " gtk4 migration - disabled this part.. probably not used muchanyway",
1558 " if (name.length < 1) {",
1562 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1563 " node.items.clear();",
1566 " var s = _this.view.el.get_selection();",
1568 " print(\"GET SELECTED?\");",
1569 " Gtk.TreeIter iter;",
1570 " Gtk.TreeModel mod;",
1573 " if (!s.get_selected(out mod, out iter)) {",
1574 " return; // nothing seleted..",
1576 " Gtk.TreeIter citer;",
1577 " var n_cn = mod.iter_n_children(iter) -1;",
1578 " for (var i = n_cn; i > -1; i--) {",
1579 " mod.iter_nth_child(out citer, iter, i);",
1582 " print(\"removing node from Tree\\n\"); ",
1584 " _this.model.el.remove(ref citer);",
1586 " _this.changed();",
1587 " _this.node_selected(node, \"tree\");",
1602 "xtype" : "ScrolledWindow"
1606 "| JsRender.JsRender getActiveFile" : [
1608 " return this.main_window.windowstate.file;",
1613 "| JsRender.Node? getActiveElement" : [
1614 " () { // return path to actie node.",
1617 "\treturn _this.selmodel.getSelectedNode();",
1623 "| void onresize" : [
1627 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1628 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1633 "| void removeErrors" : [
1635 "\tif (this.error_widgets == null || this.error_widgets.size < 1) {",
1638 "\tforeach(var child in this.error_widgets) {",
1640 "\t\tif (child.has_css_class(\"node-err\")) {",
1641 "\t\t\tchild.remove_css_class(\"node-err\");",
1643 "\t\tif (child.has_css_class(\"node-warn\")) {",
1644 "\t\t\tchild.remove_css_class(\"node-warn\");",
1647 "\t\tif (child.has_css_class(\"node-depr\")) {",
1648 "\t\t\tchild.remove_css_class(\"node-depr\");",
1651 "\tthis.error_widgets = null;",
1655 "\tvar child = this.view.el.get_first_child(); ",
1657 "\tvar reading_header = true;",
1659 "\twhile (child != null) {",
1660 "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1662 "\t if (reading_header) {",
1665 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1667 "\t\t\t\tchild = child.get_next_sibling();",
1668 "\t\t\t\tcontinue;",
1670 "\t\t\t// should be columnlistview",
1671 "\t\t\tchild = child.get_first_child(); ",
1675 "\t\t\treading_header = false;",
1679 "\t \tif (child.has_css_class(\"node-err\")) {",
1680 "\t\t\tchild.remove_css_class(\"node-err\");",
1682 "\t\tif (child.has_css_class(\"node-warn\")) {",
1683 "\t\t\tchild.remove_css_class(\"node-warn\");",
1686 "\t\tif (child.has_css_class(\"node-depr\")) {",
1687 "\t\t\tchild.remove_css_class(\"node-depr\");",
1690 " child = child.get_next_sibling(); ",
1692 "\t//GLib.debug(\"Rturning null\");",
1697 "| void updateErrors" : [
1699 "\tvar file = this.getActiveFile();",
1700 "\tif (file == null) {",
1704 "\tvar ar = file.getErrors();",
1705 "\tif (ar == null || ar.size < 1) {",
1706 "\t\tif (this.last_error_counter != file.error_counter) {",
1707 "\t\t\tthis.removeErrors();",
1710 "\t\tthis.last_error_counter = file.error_counter ;",
1714 " \tif (this.last_error_counter == file.error_counter) {",
1717 "\tthis.removeErrors();",
1718 "\tthis.error_widgets = new Gee.ArrayList<Gtk.Widget>();",
1719 "\tforeach(var diag in ar) { ",
1722 "// print(\"get inter\\n\");",
1723 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1724 "\t if (node == null) {",
1727 " \tvar row = _this.model.nodeToRow(node);",
1728 " \tif (row < 0) {",
1731 " \tvar w = this.view.getWidgetAtRow(row);",
1732 " \tif (w == null) {",
1735 "\t\tthis.error_widgets.add(w);",
1736 "\t\t// always show errors.",
1737 "\t\tvar ed = diag.category.down();",
1738 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1741 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1742 "\t\t\tw.remove_css_class(\"node-warn\");",
1744 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1745 "\t\t\tw.remove_css_class(\"node-depr\");",
1747 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1748 "\t\t\tw.add_css_class(\"node-\" + ed);",
1757 "name" : "WindowLeftTree"