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\treturn true; // no need to highlight?",
628 "\t\tGLib.debug(\"could not get row %d,%d, %s\", (int)x,(int)y,pos);",
629 "\t\treturn false; //Gdk.DragAction.COPY;",
631 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
633 "\tvar node = (JsRender.Node)tr.get_item();",
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 " \tvar row = _this.view.getRowAt(x,y, out pos);",
793 " \t//GLib.debug(\"check is over %d, %d, %s\", (int)x,(int)y, pos);",
796 "\t\tthis.addHighlight(null, \"\");\t",
797 "\t \treturn Gdk.DragAction.COPY;",
799 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
801 "\tvar node = (JsRender.Node)tr.get_item();",
803 "\t//GLib.debug(\"Drop over node: %s\", node.fqn());",
806 " \tif (pos == \"above\" || pos == \"below\") {",
807 "\t\tif (node.parent == null) {",
808 "\t\t\t//GLib.debug(\"no parent try center\");",
809 "\t\t\tpos = \"over\";",
812 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
813 "\t\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
814 "\t \t\t\tpos = \"over\";",
816 "\t\t\t\t//GLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
817 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
818 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
819 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
820 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
821 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
834 " \tif (pos == \"over\") {",
835 "\t \tif (!drop_on_to.contains(node.fqn())) {",
836 "\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
837 "\t\t\tthis.addHighlight(null, \"\"); ",
838 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
840 "\t\tif (_this.view.dragNode != null && is_shift) {",
841 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
842 "\t \t\t\t//GLib.debug(\"shift drop not self not allowed\");",
843 " \t\t\t\tthis.addHighlight(null, \"\");",
844 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
851 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
852 "\tvar w = _this.view.getWidgetAt(x,y);",
853 "\tthis.addHighlight(w, pos); ",
854 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
858 "string lastDragString" : "\"\"",
859 "xtype" : "DropTarget",
860 "| void addHighlight" : [
861 "(Gtk.Widget? w, string hl) {",
862 "\tif (this.highlightWidget != null) {",
863 "\t\tvar ww = this.highlightWidget;",
864 "\t\t//GLib.debug(\"clear drag from previous highlight\");",
865 "\t\tif (ww.has_css_class(\"drag-below\")) {",
866 "\t\t\t ww.remove_css_class(\"drag-below\");",
868 "\t\tif (ww.has_css_class(\"drag-above\")) {",
869 "\t\t\t ww.remove_css_class(\"drag-above\");",
871 "\t\tif (ww.has_css_class(\"drag-over\")) {",
872 "\t\t\t ww.remove_css_class(\"drag-over\");",
875 "\tif (w != null) {",
876 "\t\t//GLib.debug(\"add drag=%s to widget\", hl);\t",
877 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
878 "\t\t\tw.add_css_class(\"drag-\" + hl);",
881 "\tthis.highlightWidget = w;",
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();",
949 " \tGLib.debug(\"delete Selected - done\");",
952 " print(\"DELETE SELECTED?\");",
953 " //_this.view.blockChanges = true;",
954 " print(\"GET SELECTION?\");",
956 " var s = _this.view.el.get_selection();",
958 " print(\"GET SELECTED?\");",
959 " Gtk.TreeIter iter;",
960 " Gtk.TreeModel mod;",
963 " if (!s.get_selected(out mod, out iter)) {",
964 " return; // nothing seleted..",
969 " this.activePath= \"\"; ",
970 " print(\"GET vnode value?\");",
972 " GLib.Value value;",
973 " this.el.get_value(iter, 2, out value);",
974 " var data = (JsRender.Node)(value.get_object());",
975 " print(\"removing node from Render\\n\");",
976 " if (data.parent == null) {",
977 " _this.main_window.windowstate.file.tree = null;",
981 " print(\"removing node from Tree\\n\"); ",
982 " s.unselect_all();",
983 " this.el.remove(ref iter);",
993 " this.activePath= \"\"; // again!?!? ",
994 " //this.changed(null,true);",
998 " _this.view.blockChanges = false;",
1003 "| void loadFile" : [
1004 "(JsRender.JsRender f) {",
1005 " //console.dump(f);",
1007 " _this.drop.highlightWidget = null;",
1009 " var m = (GLib.ListStore) this.el.model;",
1010 "\tm.remove_all();",
1011 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
1013 " _this.main_window.windowstate.file = f;",
1014 " _this.last_error_counter = -1;",
1016 " if (f.tree == null) {",
1018 "\t f.loadItems( );",
1019 " } catch (Error e) {",
1023 " // if it's still null?",
1024 " if (f.tree == null) {",
1025 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1026 " \t_this.updateErrors();",
1029 " \tm.append(f.tree);",
1030 "\t_this.updateErrors();",
1032 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1040 "| void selectNode" : [
1041 "(JsRender.Node? node) ",
1043 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1044 "\tif (node == null) {",
1045 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1048 "\tvar row = this.nodeToRow(node);",
1052 "\t\t// select none?",
1053 "\t\tGLib.debug(\"Could not find node\");",
1054 "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1057 "\tGLib.debug(\"Select %d\", row);",
1058 "\ts.set_selected(row);",
1059 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1060 "\t//_this.node_selected(node);\t\t\t",
1068 "selection_changed" : [
1069 "(position, n_items) => {",
1073 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1074 "\t\t\t// then event was started by some other action",
1075 "\t\t\t// which should manually trigger all the events..",
1076 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1081 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1082 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1086 "\t\t if (!_this.before_node_change( ) ) {",
1087 "\t\t\t _this.view.blockChanges = true;",
1088 "\t\t\t _this.selmodel.el.unselect_all();",
1089 "\t\t\t _this.view.blockChanges = false;",
1093 "\t\t if (_this.main_window.windowstate.file == null) {",
1094 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1098 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1099 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1102 "\t\t// -- it appears that the selection is not updated.",
1103 "\t\t // select the node...",
1104 "\t\t //_this.selmodel.el.set_selected(row);",
1106 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1108 "\t var snode = _this.selmodel.getSelectedNode();",
1109 "\t if (snode == null) {",
1111 "\t GLib.debug(\"selected rows < 1\");",
1112 "\t //??this.model.load( false);",
1113 "\t _this.node_selected(null);",
1121 "\t GLib.debug (\"calling left_tree.node_selected %s\", snode.toJsonString());",
1122 "\t _this.node_selected(snode);",
1127 "\t // no need to scroll. it's in the view as we clicked on it.",
1128 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1135 "xtype" : "SingleSelection",
1136 "| JsRender.Node getNodeAt" : [
1139 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1141 " var a = tr.get_item();; ",
1142 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1145 " return (JsRender.Node)tr.get_item();",
1149 "| JsRender.Node? getSelectedNode" : [
1151 " if (this.el.selected_item == null) {",
1156 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1158 " return (JsRender.Node)tr.get_item();",
1165 "* pack" : "append_column",
1166 "bool expand" : true,
1167 "bool resizable" : true,
1172 "* prop" : "factory",
1176 "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1178 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1179 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1182 "\tvar hbox = (Gtk.Box) expand.child;",
1185 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1186 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1188 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1189 "\tvar node = (JsRender.Node) lr.get_item();",
1190 "\tif (node == null || node.fqn() == \"\") {",
1193 " //GLib.debug(\"node is %s\", node.get_type().name());",
1194 "// was item (1) in old layout",
1199 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1200 " var clsname = node.fqn();",
1202 " var clsb = clsname.split(\".\");",
1203 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1205 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1209 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1210 "\t\t img.set_from_file(fn);",
1213 "\t \t\timg.set_from_paintable(",
1214 "\t\t\t \tic.lookup_icon (",
1215 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1216 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1220 " \t} catch (GLib.Error e) {}",
1222 " expand.set_hide_expander( !node.hasChildren() );",
1223 " \texpand.set_list_row(lr);",
1225 " \tnode.bind_property(\"iconResourceName\",",
1226 " img, \"resource\",",
1227 " GLib.BindingFlags.SYNC_CREATE);",
1229 " \tnode.bind_property(\"nodeTitleProp\",",
1231 " GLib.BindingFlags.SYNC_CREATE);",
1232 " \tnode.bind_property(\"nodeTipProp\",",
1233 " lbl, \"tooltip_markup\",",
1234 " GLib.BindingFlags.SYNC_CREATE);",
1235 " \t// bind image...",
1243 "\tvar expand = new Gtk.TreeExpander();",
1245 "\texpand.set_indent_for_depth(true);",
1246 "\texpand.set_indent_for_icon(true);",
1247 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1248 "\tvar icon = new Gtk.Image();",
1249 "\tvar lbl = new Gtk.Label(\"\");",
1250 "\tlbl.use_markup = true;",
1251 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1253 "\ticon.margin_end = 4;",
1254 " \tlbl.justify = Gtk.Justification.LEFT;",
1255 " \tlbl.xalign = 0;",
1257 "//\tlistitem.activatable = true; ??",
1259 "\thbox.append(icon);",
1260 "\thbox.append(lbl);",
1261 "\texpand.set_child(hbox);",
1262 "\t((Gtk.ListItem)listitem).set_child(expand);",
1268 "xtype" : "SignalListItemFactory"
1271 "title" : "Property",
1272 "xtype" : "ColumnViewColumn"
1276 "* pack" : "append_column",
1277 "int fixed_width" : 25,
1281 "* prop" : "factory",
1286 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1287 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1288 "\tvar node = (JsRender.Node) lr.get_item();",
1291 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1292 "\timg.set_from_paintable(",
1293 "\t \tic.lookup_icon (",
1294 "\t \t\t\"list-add\", null, 16,1, ",
1295 "\t\t\t Gtk.TextDirection.NONE, 0",
1299 " \tvar fqn = node.fqn();",
1300 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1302 "\timg.set_visible(cn.size > 0 ? true : false);",
1311 "\tvar icon = new Gtk.Image();",
1313 "\t((Gtk.ListItem)listitem).set_child(icon);",
1318 "xtype" : "SignalListItemFactory"
1321 "string title" : "Add",
1322 "xtype" : "ColumnViewColumn"
1325 "string name" : "left-tree-view",
1326 "xtype" : "ColumnView",
1327 "| Gtk.Widget? getWidgetAt" : [
1328 "(double x, double y) {",
1330 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1331 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1332 "\tif (w == null) {",
1336 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1337 "\tif (row == null) {",
1345 "| Gtk.Widget? getWidgetAtRow" : [
1349 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1350 " \tvar colview = gesture.widget;",
1351 " \tvar line_no = check_list_widget(colview, x,y);",
1352 " if (line_no > -1) {",
1353 " \t\tvar item = colview.model.get_item(line_no);",
1357 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1358 " var child = this.el.get_first_child(); ",
1359 " \tvar line_no = -1; ",
1360 " \tvar reading_header = true;",
1362 " \twhile (child != null) {",
1363 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1365 " \t if (reading_header) {",
1368 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1370 "\t\t\t\t\tchild = child.get_next_sibling();",
1371 "\t\t\t\t\tcontinue;",
1373 "\t\t\t\t// should be columnlistview",
1374 "\t\t\t\tchild = child.get_first_child(); ",
1378 "\t\t\t\treading_header = false;",
1379 "\t\t\t\tcontinue;",
1385 "\t\t\tif (line_no == row) {",
1386 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1387 "\t\t\t return (Gtk.Widget)child;",
1389 "\t child = child.get_next_sibling(); ",
1391 "\t\t//GLib.debug(\"Rturning null\");",
1396 "| int getColAt" : [
1397 "(double x, double y) {",
1400 "\tfrom \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1403 "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1404 "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1405 " var child = this.el.get_first_child(); ",
1409 "\twhile (child != null) {",
1411 "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1412 "\t\t\tchild = child.get_first_child();",
1416 "\t\t//child.get_allocation(out alloc);",
1417 "\t\tif (x < (child.get_width() + offx)) {",
1418 "\t\t\treturn col;",
1421 "\t\t//offx += child.get_width();",
1423 "\t\t//child = child.get_next_sibling();",
1431 "| int getRowAt" : [
1432 "(double x, double y, out string pos) {",
1435 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1436 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1437 "\tif (w == null) {",
1441 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1442 "\tif (row == null) {",
1446 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1451 "\twhile (cr.get_prev_sibling() != null) {",
1453 "\t\tcr = cr.get_prev_sibling();",
1456 "\t//GLib.debug(\"row number is %d\", rn);",
1457 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1458 "\t// above or belw",
1459 "\tGraphene.Rect bounds;",
1460 "\trow.compute_bounds(this.el, out bounds);",
1461 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1462 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1463 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1465 "\tvar ypos = y - bounds.get_y();",
1466 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1467 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1468 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1469 "\tpos = \"over\";",
1471 "\tif (rpos > 80) {",
1472 "\t\tpos = \"below\";",
1473 "\t} else if (rpos < 20) {",
1474 "\t\tpos = \"above\";",
1483 "id" : "LeftTreeMenu",
1488 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1493 "bool has_frame" : false,
1494 "label" : "Delete Element",
1498 "_this.LeftTreeMenu.el.hide();",
1499 " _this.model.deleteSelected();",
1508 "bool has_frame" : false,
1509 "label" : "Save as Template",
1513 "_this.LeftTreeMenu.el.hide();",
1514 " DialogSaveTemplate.singleton().showIt(",
1515 " (Gtk.Window) _this.el.get_root (), ",
1516 " _this.main_window.windowstate.file.palete(), ",
1517 " _this.getActiveElement()",
1528 "bool has_frame" : false,
1529 "label" : "Save as Module",
1534 " _this.LeftTreeMenu.el.hide();",
1535 " var node = _this.getActiveElement();",
1538 " var sm = DialogSaveModule.singleton();",
1542 " (Gtk.Window) _this.el.get_root (), ",
1543 " _this.main_window.windowstate.project, ",
1547 " gtk4 migration - disabled this part.. probably not used muchanyway",
1550 " if (name.length < 1) {",
1554 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1555 " node.items.clear();",
1558 " var s = _this.view.el.get_selection();",
1560 " print(\"GET SELECTED?\");",
1561 " Gtk.TreeIter iter;",
1562 " Gtk.TreeModel mod;",
1565 " if (!s.get_selected(out mod, out iter)) {",
1566 " return; // nothing seleted..",
1568 " Gtk.TreeIter citer;",
1569 " var n_cn = mod.iter_n_children(iter) -1;",
1570 " for (var i = n_cn; i > -1; i--) {",
1571 " mod.iter_nth_child(out citer, iter, i);",
1574 " print(\"removing node from Tree\\n\"); ",
1576 " _this.model.el.remove(ref citer);",
1578 " _this.changed();",
1579 " _this.node_selected(node, \"tree\");",
1594 "xtype" : "ScrolledWindow"
1598 "| JsRender.JsRender getActiveFile" : [
1600 " return this.main_window.windowstate.file;",
1605 "| JsRender.Node? getActiveElement" : [
1606 " () { // return path to actie node.",
1609 "\treturn _this.selmodel.getSelectedNode();",
1615 "| void onresize" : [
1619 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1620 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1625 "| void removeErrors" : [
1627 "\tif (this.error_widgets == null || this.error_widgets.size < 1) {",
1630 "\tforeach(var child in this.error_widgets) {",
1632 "\t\tif (child.has_css_class(\"node-err\")) {",
1633 "\t\t\tchild.remove_css_class(\"node-err\");",
1635 "\t\tif (child.has_css_class(\"node-warn\")) {",
1636 "\t\t\tchild.remove_css_class(\"node-warn\");",
1639 "\t\tif (child.has_css_class(\"node-depr\")) {",
1640 "\t\t\tchild.remove_css_class(\"node-depr\");",
1643 "\tthis.error_widgets = null;",
1647 "\tvar child = this.view.el.get_first_child(); ",
1649 "\tvar reading_header = true;",
1651 "\twhile (child != null) {",
1652 "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1654 "\t if (reading_header) {",
1657 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1659 "\t\t\t\tchild = child.get_next_sibling();",
1660 "\t\t\t\tcontinue;",
1662 "\t\t\t// should be columnlistview",
1663 "\t\t\tchild = child.get_first_child(); ",
1667 "\t\t\treading_header = false;",
1671 "\t \tif (child.has_css_class(\"node-err\")) {",
1672 "\t\t\tchild.remove_css_class(\"node-err\");",
1674 "\t\tif (child.has_css_class(\"node-warn\")) {",
1675 "\t\t\tchild.remove_css_class(\"node-warn\");",
1678 "\t\tif (child.has_css_class(\"node-depr\")) {",
1679 "\t\t\tchild.remove_css_class(\"node-depr\");",
1682 " child = child.get_next_sibling(); ",
1684 "\t//GLib.debug(\"Rturning null\");",
1689 "| void updateErrors" : [
1691 "\tvar file = this.getActiveFile();",
1692 "\tif (file == null) {",
1696 "\tvar ar = file.getErrors();",
1697 "\tif (ar == null || ar.size < 1) {",
1698 "\t\tif (this.last_error_counter != file.error_counter) {",
1699 "\t\t\tthis.removeErrors();",
1702 "\t\tthis.last_error_counter = file.error_counter ;",
1706 " \tif (this.last_error_counter == file.error_counter) {",
1709 "\tthis.removeErrors();",
1710 "\tthis.error_widgets = new Gee.ArrayList<Gtk.Widget>();",
1711 "\tforeach(var diag in ar) { ",
1714 "// print(\"get inter\\n\");",
1715 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1716 "\t if (node == null) {",
1719 " \tvar row = _this.model.nodeToRow(node);",
1720 " \tif (row < 0) {",
1723 " \tvar w = this.view.getWidgetAtRow(row);",
1724 " \tif (w == null) {",
1727 "\t\tthis.error_widgets.add(w);",
1728 "\t\t// always show errors.",
1729 "\t\tvar ed = diag.category.down();",
1730 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1733 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1734 "\t\t\tw.remove_css_class(\"node-warn\");",
1736 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1737 "\t\t\tw.remove_css_class(\"node-depr\");",
1739 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1740 "\t\t\tw.add_css_class(\"node-\" + ed);",
1749 "name" : "WindowLeftTree"