2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Xcls_MainWindow? main_window" : "null",
8 "@ bool before_node_change" : "()",
9 "@ void changed" : "()",
10 "@ void node_selected" : "(JsRender.Node? node)",
11 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
12 "bool hexpand" : true,
13 "bool vexpand" : true,
14 "id" : "WindowLeftTree",
15 "int last_error_counter" : "-1",
23 "xtype" : "SignalListItemFactory"
30 "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
31 "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
32 "bool has_frame" : true,
33 "bool hexpand" : true,
34 "bool vexpand" : true,
38 "# bool blockChanges" : false,
39 "$ JsRender.Node? dragNode" : "null",
40 "$ string lastEventSource" : "\"\"",
45 " this.css = new Gtk.CssProvider();",
47 "\t\tthis.css.load_from_string(\"",
48 "#left-tree-view { font-size: 12px;}\t",
49 ".drag-over { background-color:#88a3bc; }",
51 " border-bottom-width: 5px; ",
52 " border-bottom-style: solid;",
53 " border-bottom-color: #88a3bc;",
56 " border-top-width: 5px;",
57 " border-top-style: solid;",
58 " border-top-color: #88a3bc;",
61 " border-top-width: 5px;",
62 " border-top-style: solid;",
63 " border-top-color: red;",
64 " border-bottom-width: 5px; ",
65 " border-bottom-style: solid;",
66 " border-bottom-color: red;",
69 " border-top-width: 5px;",
70 " border-top-style: solid;",
71 " border-top-color: #ABF4EB;",
72 " border-bottom-width: 5px; ",
73 " border-bottom-style: solid;",
74 " border-bottom-color: #ABF4EB;",
77 " border-top-width: 5px;",
78 " border-top-style: solid;",
79 " border-top-color: #EEA9FF;",
80 " border-bottom-width: 5px; ",
81 " border-bottom-style: solid;",
82 " border-bottom-color: #EEA9FF;",
85 "#left-tree-view indent {",
86 "-gtk-icon-size : 2px;",
88 "#left-tree-view indent:nth-last-child(2) {",
93 "\tGtk.StyleContext.add_provider_for_display(",
94 "\t\tthis.el.get_display(),",
96 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
104 "Boolean id" : "view",
105 "Gtk.CssProvider css" : "",
106 "bool button_is_pressed" : false,
107 "bool headers_visible" : false,
108 "bool hexpand" : false,
109 "bool vexpand" : true,
115 "(n_press, x, y) => {",
117 " //console.log(\"button press?\");",
119 " //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
123 " _this.view.button_is_pressed = true;",
125 " _this.view.lastEventSource = \"tree\";",
126 " if (! _this.before_node_change() ) {",
127 " \tGLib.debug(\"before_node_change return false\");",
131 "\t // nothing there -show dialog",
132 " if (_this.model.el.get_n_items() < 1) {",
133 "\t _this.main_window.windowstate.showAddObject(_this.view.el, null);",
134 " GLib.debug(\"no items\");",
138 " var row = _this.view.getRowAt(x,y, out pos );",
140 "\t GLib.debug(\"no row selected items\");",
144 " var node = _this.selmodel.getNodeAt(row);",
145 " if (node == null) {",
146 " \tGLib.warning(\"No node found at row %d\", row);",
152 " if (_this.view.getColAt(x,y) > 0 ) {",
153 "\t GLib.debug(\"add colum clicked.\");",
154 " var fqn = node.fqn();",
155 " \tvar cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
156 " \t\tif (cn.size < 1) {",
160 "\t\t_this.main_window.windowstate.leftTreeBeforeChange();",
161 "\t\t//_this.view.el.get_selection().select_path(res);",
162 "\t\tGLib.debug(\"Button Pressed - start show window\");",
163 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, node);",
164 "\t\tGLib.debug(\"Button Pressed - finsihed show window\");",
174 "(n_press, x, y) => {",
176 " _this.view.button_is_pressed = false;",
183 "xtype" : "GestureClick"
189 "(n_press, x, y) => {",
194 " if (_this.model.el.get_n_items() < 1) {",
196 " GLib.debug(\"no items\");",
200 " var row = _this.view.getRowAt(x,y, out pos );",
202 "\t GLib.debug(\"no row selected items\");",
206 " var node = _this.selmodel.getNodeAt(row);",
207 " if (node == null) {",
208 " \tGLib.warning(\"No node found at row %d\", row);",
213 "\t_this.model.selectNode(node);",
217 "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());",
218 "\t//_this.deletemenu.el.set_parent(_this.view.el);",
219 "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
222 "\t//Gtk.Allocation rect;",
223 "\t//_this.view.el.get_allocation(out rect);",
224 " \t//_this.deletemenu.el.set_has_arrow(false);",
225 "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
228 "\t_this.LeftTreeMenu.el.set_offset( ",
230 "\t\t\t(int)y - (int)_this.view.el.get_height());",
232 " _this.LeftTreeMenu.el.popup();",
239 "xtype" : "GestureClick"
242 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
247 "\tGLib.debug(\"SOURCE: drag-begin\");",
249 " // find what is selected in our tree...",
250 " var data = _this.selmodel.getSelectedNode();",
251 "\tif (data == null) {",
254 "\t_this.view.dragNode = data;",
255 " var xname = data.fqn();",
256 " GLib.debug (\"XNAME IS %s\", xname);",
258 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
261 " var paintable = new Gtk.WidgetPaintable(widget);",
262 " this.el.set_icon(paintable, 0,0);",
268 "(drag, reason) => {",
270 "\t_this.view.dragNode = null;",
276 "(drag, delete_data) => {",
278 "_this.view.dragNode = null;",
287 "///\t( drag_context, data, info, time) => {",
290 "\t//print(\"drag-data-get\");",
291 " \tvar ndata = _this.selmodel.getSelectedNode();",
292 "\tif (ndata == null) {",
293 "\t \tGLib.debug(\"return empty string - no selection..\");",
299 "\t//data.set_text(tp,tp.length); ",
301 "\tvar \tstr = ndata.toJsonString();",
302 "\tGLib.debug(\"prepare store: %s\", str);",
303 "\tGLib.Value ov = GLib.Value(typeof(string));",
304 "\tov.set_string(str);",
305 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
307 "\tGLib.Value v = GLib.Value(typeof(string));",
308 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
310 "\t\tcont.get_value(ref v);",
313 "\tGLib.debug(\"set %s\", v.get_string());",
322 "xtype" : "DragSource"
328 "(keyval, keycode, state) => {",
332 "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) {",
336 "\t_this.model.deleteSelected();",
343 "xtype" : "EventControllerKey"
351 "(keyval, keycode, state) => {",
353 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
354 " \t\tthis.is_shift = 1;",
361 "(keyval, keycode, state) => {",
362 "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int) keycode, state);",
363 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
364 " \t\tthis.is_shift = 0;",
366 "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
373 "xtype" : "EventControllerKey"
378 "new Gtk.DropTarget ( typeof(string) ,",
379 "\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE )"
381 "Gtk.Widget? highlightWidget" : "null",
382 "JsRender.Node? lastDragNode" : "null",
388 "\tGLib.debug(\"got DropTarget:accept\");",
390 "// NOT REALLY NEEDED? = put stuff in drop?",
393 "/* ( ctx, x, y, time) => {",
394 " //Seed.print(\"TARGET: drag-drop\");",
397 " var src = Gtk.drag_get_source_widget(ctx);",
399 " if (src != this.el) {",
403 " this.drag_in_motion = false; ",
404 " // request data that will be recieved by the recieve... ",
405 " Gtk.drag_get_data",
407 " this.el, // will receive 'drag-data-received' signal ",
408 " ctx, // represents the current state of the DnD ",
409 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
410 " time // time stamp ",
414 " // No target offered by source => error",
420 " // handle drop around self..",
424 " //print(\"GETTING POS\");",
425 " var targetData = \"\";",
427 " Gtk.TreePath path;",
428 " Gtk.TreeViewDropPosition pos;",
429 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
431 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
432 " var isEmpty = false;",
433 " if (_this.model.el.iter_n_children(null) < 1) {",
434 " print(\"got NO children?\\n\");",
435 " isOver = true; //??? ",
437 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
442 " //var action = Gdk.DragAction.COPY;",
443 " // unless we are copying!!! ctl button..",
445 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
446 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
447 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
450 " if (_this.model.el.iter_n_children(null) < 1) {",
451 " // no children.. -- asume it's ok..",
453 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
455 " // continue through to allow drop...",
463 " //print(\"ISOVER? \" + isOver);",
466 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
467 " return true; // not over apoint!?! - no action on drop or motion..",
470 " // drag node is parent of child..",
471 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
472 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
474 " // nned to check a few here..",
475 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
476 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
477 " //Gtk.TreeViewDropPosition.AFTER",
478 " //Gtk.TreeViewDropPosition.BEFORE",
480 " // locally dragged items to not really use the ",
481 " var selection_text = this.dragData;",
485 " if (selection_text == null || selection_text.length < 1) {",
486 " //print(\"Error - drag selection text returned NULL\");",
488 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
489 " return true; /// -- fixme -- this is not really correct..",
492 " // see if we are dragging into ourself?",
493 " print (\"got selection text of \" + selection_text);",
495 " var target_path = path.to_string();",
496 " //print(\"target_path=\"+target_path);",
499 " if (selection_text == target_path) {",
500 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
502 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
504 " return true; /// -- fixme -- this is not really correct..",
509 " //print(\"DUMPING DATA\");",
510 " //console.dump(data);",
513 " //print(data.path.to_string() +' => '+ data.pos);",
515 " // dropList is a list of xtypes that this node could be dropped on.",
516 " // it is set up when we start to drag..",
519 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
521 " print(\"targetDAta: \" + targetData +\"\\n\");",
523 " if (targetData.length < 1) {",
524 " //print(\"Can not find drop node path\");",
526 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
532 " // continue on to allow drop..",
534 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
537 " var delete_selection_data = false;",
539 " if (action == Gdk.DragAction.ASK) {",
540 " // Ask the user to move or copy, then set the ctx action. ",
543 " if (action == Gdk.DragAction.MOVE) {",
544 " delete_selection_data = true;",
547 " // drag around.. - reorder..",
548 " _this.model.moveNode(targetData, action);",
554 " // we can send stuff to souce here...",
557 "// do we always say failure, so we handle the reall drop?",
558 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
576 "\tthis.addHighlight(null,\"\");",
578 " \tvar is_shift = _this.keystate.is_shift > 0;",
580 " \tvar pos = \"\";",
581 " \t// -- get position..",
582 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
583 "\t\t// still dragging same node",
585 "\t\tthis.lastDragNode = new JsRender.Node(); ",
586 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
591 " var dropNode = new JsRender.Node(); ",
592 "\tdropNode.loadFromJsonString(v.get_string(), 1);",
593 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
595 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
597 " if (_this.model.el.n_items < 1) {",
598 " \t// FIXME check valid drop types?",
599 " \tif (!drop_on_to.contains(\"*top\")) {",
600 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
601 "\t\t\treturn false;\t",
603 "\t\t// add new node to top..",
606 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
607 " \t_this.main_window.windowstate.file.tree = dropNode; ",
610 "\t\tm.append(dropNode);",
611 "\t\t_this.model.selectNode(dropNode); \t",
612 "\t\t_this.changed();",
613 "\t\treturn true; // no need to highlight?",
619 "\tvar row = _this.view.getRowAt(x,y, out pos);",
621 "\t\treturn false; //Gdk.DragAction.COPY;",
623 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
625 "\tvar node = (JsRender.Node)tr.get_item();",
627 " \tif (pos == \"above\" || pos == \"below\") {",
628 "\t\tif (node.parent == null) {",
629 "\t\t\tpos = \"over\";",
631 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
632 "\t\t\t\tpos = \"over\";",
634 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
635 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
636 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
637 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
638 " \t\t\t\t\t\treturn false;\t",
648 " \tif (pos == \"over\") {",
649 "\t \tif (!drop_on_to.contains(node.fqn())) {",
650 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
651 "\t\t\treturn false;",
654 "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
655 " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
656 "\t\t\treturn false;\t",
661 " \t\tcase \"over\":",
662 "\t \t\tnode.appendChild(dropNode);",
663 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
664 "\t\t \t\t_this.model.selectNode(null); ",
665 "\t\t \t\t_this.view.dragNode.remove();",
669 " \t\t\t_this.model.selectNode(dropNode); ",
671 " \t\t\t_this.changed();\t\t\t\t \t\t",
672 "\t \t\treturn true;",
674 " \t\tcase \"above\":",
675 " \t\t\tGLib.debug(\"Above - insertBefore\");",
677 "\t\t\tnode.parent.insertBefore(dropNode, node);",
678 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
679 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
680 "\t\t \t\t_this.view.dragNode.remove();",
683 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
684 " \t\t\t_this.changed();",
685 " \t\t\treturn true;",
687 " \t\tcase \"below\":",
688 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
689 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
690 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
691 "\t\t \t\t_this.view.dragNode.remove();",
695 " \t\t\tnode.parent.insertAfter(dropNode, node);",
696 " \t\t\t_this.model.selectNode(dropNode);\t",
697 " \t\t\t_this.changed();",
698 " \t\t\t// select it",
699 " \t\t\treturn true;",
702 " \t\t\t// should not happen",
703 " \t\t\treturn false;",
716 "\tthis.addHighlight(null,\"\");",
724 "\tvar is_shift = _this.keystate.is_shift > 0;",
726 "\tGLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
727 "\tstring pos; // over / before / after..",
729 " //GLib.debug(\"got drag motion\");",
731 " GLib.Value v = GLib.Value(typeof(string));",
732 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
733 " \tvar cont = this.el.current_drop.get_drag().content ;",
735 " \t\tcont.get_value(ref v);",
736 "\t} catch (GLib.Error e) {",
737 "\t GLib.debug(\"failed to get drag value\");",
738 "\t\treturn Gdk.DragAction.COPY;\t ",
742 "\t//GLib.debug(\"got %s\", v.get_string());",
744 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
745 "\t\t// still dragging same node",
747 "\t\tthis.lastDragNode = new JsRender.Node(); ",
748 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
752 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
753 "\t\t\t\tthis.lastDragNode.fqn());",
755 " string[] str = {};",
756 " foreach(var dp in drop_on_to) {",
759 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
762 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
764 " if (_this.model.el.n_items < 1) {",
765 " \t// FIXME check valid drop types?",
766 " \tif (drop_on_to.contains(\"*top\")) {",
767 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
769 "\t\t\tthis.addHighlight(null, \"\");\t\t",
772 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
777 " \tGLib.debug(\"check is over\");",
779 " // if path of source and dest are inside each other..",
780 " // need to add source info to drag?",
782 " \tvar row = _this.view.getRowAt(x,y, out pos);",
785 "\t\tthis.addHighlight(null, \"\");\t",
786 "\t \treturn Gdk.DragAction.COPY;",
788 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
790 "\tvar node = (JsRender.Node)tr.get_item();",
792 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
795 " \tif (pos == \"above\" || pos == \"below\") {",
796 "\t\tif (node.parent == null) {",
797 "\t\t\tGLib.debug(\"no parent try center\");",
798 "\t\t\tpos = \"over\";",
801 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
802 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
803 "\t \t\t\tpos = \"over\";",
805 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
806 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
807 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
808 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
809 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
810 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
823 " \tif (pos == \"over\") {",
824 "\t \tif (!drop_on_to.contains(node.fqn())) {",
825 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
826 "\t\t\tthis.addHighlight(null, \"\"); ",
827 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
829 "\t\tif (_this.view.dragNode != null && is_shift) {",
830 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
831 "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
832 " \t\t\t\tthis.addHighlight(null, \"\");",
833 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
840 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
841 "\tvar w = _this.view.getWidgetAt(x,y);",
842 "\tthis.addHighlight(w, pos); ",
843 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
847 "string lastDragString" : "\"\"",
848 "xtype" : "DropTarget",
849 "| void addHighlight" : [
850 "(Gtk.Widget? w, string hl) {",
851 "\tif (this.highlightWidget != null) {",
852 "\t\tvar ww = this.highlightWidget;",
853 "\t\tGLib.debug(\"clear drag from previous highlight\");",
854 "\t\tif (ww.has_css_class(\"drag-below\")) {",
855 "\t\t\t ww.remove_css_class(\"drag-below\");",
857 "\t\tif (ww.has_css_class(\"drag-above\")) {",
858 "\t\t\t ww.remove_css_class(\"drag-above\");",
860 "\t\tif (ww.has_css_class(\"drag-over\")) {",
861 "\t\t\t ww.remove_css_class(\"drag-over\");",
864 "\tif (w != null) {",
865 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
866 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
867 "\t\t\tw.add_css_class(\"drag-\" + hl);",
870 "\tthis.highlightWidget = w;",
881 "* ctor" : "this.updateModel(null)",
884 "xtype" : "TreeListModel",
885 "| Gtk.TreeListModel updateModel" : [
886 "(GLib.ListStore? m) {",
887 "\tthis.el = new Gtk.TreeListModel(",
888 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
889 "\t\tfalse, // passthru",
890 "\t\ttrue, // autexpand",
892 "\t\t\treturn ((JsRender.Node)item).childstore;",
896 "\tif (_this.selmodel.el == null) {",
897 "\t\treturn this.el;",
899 "\t_this.selmodel.el.set_model(this.el);",
903 "| int nodeToRow" : [
904 "(JsRender.Node node) ",
907 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
908 "\tfor (var i = 0; i < s.n_items; i++) {",
909 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
910 "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
911 "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
912 "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {",
917 "\treturn -1;\t\t\t",
922 "| void deleteSelected" : [
927 "\tvar node = _this.selmodel.getSelectedNode();",
930 " if (node == null) {",
931 " \tGLib.debug(\"delete Selected - no node slected?\");",
934 " _this.selmodel.el.unselect_all();",
937 " \tGLib.debug(\"delete Selected - done\");",
940 " print(\"DELETE SELECTED?\");",
941 " //_this.view.blockChanges = true;",
942 " print(\"GET SELECTION?\");",
944 " var s = _this.view.el.get_selection();",
946 " print(\"GET SELECTED?\");",
947 " Gtk.TreeIter iter;",
948 " Gtk.TreeModel mod;",
951 " if (!s.get_selected(out mod, out iter)) {",
952 " return; // nothing seleted..",
957 " this.activePath= \"\"; ",
958 " print(\"GET vnode value?\");",
960 " GLib.Value value;",
961 " this.el.get_value(iter, 2, out value);",
962 " var data = (JsRender.Node)(value.get_object());",
963 " print(\"removing node from Render\\n\");",
964 " if (data.parent == null) {",
965 " _this.main_window.windowstate.file.tree = null;",
969 " print(\"removing node from Tree\\n\"); ",
970 " s.unselect_all();",
971 " this.el.remove(ref iter);",
981 " this.activePath= \"\"; // again!?!? ",
982 " //this.changed(null,true);",
986 " _this.view.blockChanges = false;",
991 "| void loadFile" : [
992 "(JsRender.JsRender f) {",
993 " //console.dump(f);",
995 " _this.drop.highlightWidget = null;",
997 " var m = (GLib.ListStore) this.el.model;",
999 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
1001 " _this.main_window.windowstate.file = f;",
1002 " _this.last_error_counter = -1;",
1004 " if (f.tree == null) {",
1006 "\t f.loadItems( );",
1007 " } catch (Error e) {",
1011 " // if it's still null?",
1012 " if (f.tree == null) {",
1013 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1014 " \t_this.updateErrors();",
1017 " \tm.append(f.tree);",
1018 "\t_this.updateErrors();",
1020 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1028 "| void selectNode" : [
1029 "(JsRender.Node node) ",
1031 "\tvar row = this.nodeToRow(node);",
1032 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1035 "\t\t// select none?",
1036 "\t\tGLib.debug(\"Could not find node\");",
1039 "\tGLib.debug(\"Select %d\", row);",
1040 "\ts.set_selected(row);",
1041 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1042 "\t//_this.node_selected(node);\t\t\t",
1050 "selection_changed" : [
1051 "(position, n_items) => {",
1055 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1056 "\t\t\t// then event was started by some other action",
1057 "\t\t\t// which should manually trigger all the events..",
1058 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1063 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1064 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1068 "\t\t if (!_this.before_node_change( ) ) {",
1069 "\t\t\t _this.view.blockChanges = true;",
1070 "\t\t\t _this.selmodel.el.unselect_all();",
1071 "\t\t\t _this.view.blockChanges = false;",
1075 "\t\t if (_this.main_window.windowstate.file == null) {",
1076 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1080 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1081 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1084 "\t\t// -- it appears that the selection is not updated.",
1085 "\t\t // select the node...",
1086 "\t\t //_this.selmodel.el.set_selected(row);",
1088 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1090 "\t var snode = _this.selmodel.getSelectedNode();",
1091 "\t if (snode == null) {",
1093 "\t GLib.debug(\"selected rows < 1\");",
1094 "\t //??this.model.load( false);",
1095 "\t _this.node_selected(null);",
1103 "\t GLib.debug (\"calling left_tree.node_selected\");",
1104 "\t _this.node_selected(snode);",
1109 "\t // no need to scroll. it's in the view as we clicked on it.",
1110 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1117 "xtype" : "SingleSelection",
1118 "| JsRender.Node getNodeAt" : [
1121 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1123 " var a = tr.get_item();; ",
1124 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1127 " return (JsRender.Node)tr.get_item();",
1131 "| JsRender.Node? getSelectedNode" : [
1133 " if (this.el.selected_item == null) {",
1136 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1137 " return (JsRender.Node)tr.get_item();",
1144 "* pack" : "append_column",
1145 "bool expand" : true,
1146 "bool resizable" : true,
1151 "* prop" : "factory",
1155 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1157 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1158 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1161 "\tvar hbox = (Gtk.Box) expand.child;",
1164 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1165 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1167 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1168 "\tvar node = (JsRender.Node) lr.get_item();",
1170 " GLib.debug(\"node is %s\", node.get_type().name());",
1171 "// was item (1) in old layout",
1176 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1177 " var clsname = node.fqn();",
1179 " var clsb = clsname.split(\".\");",
1180 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1182 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1186 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1187 "\t\t img.set_from_file(fn);",
1190 "\t \t\timg.set_from_paintable(",
1191 "\t\t\t \tic.lookup_icon (",
1192 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1193 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1197 " \t} catch (GLib.Error e) {}",
1199 " expand.set_hide_expander( !node.hasChildren() );",
1200 " \texpand.set_list_row(lr);",
1202 " \tnode.bind_property(\"iconFilename\",",
1204 " GLib.BindingFlags.SYNC_CREATE);",
1206 " \tnode.bind_property(\"nodeTitleProp\",",
1208 " GLib.BindingFlags.SYNC_CREATE);",
1209 " \tnode.bind_property(\"nodeTipProp\",",
1210 " lbl, \"tooltip_markup\",",
1211 " GLib.BindingFlags.SYNC_CREATE);",
1212 " \t// bind image...",
1220 "\tvar expand = new Gtk.TreeExpander();",
1222 "\texpand.set_indent_for_depth(true);",
1223 "\texpand.set_indent_for_icon(true);",
1224 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1225 "\tvar icon = new Gtk.Image();",
1226 "\tvar lbl = new Gtk.Label(\"\");",
1227 "\tlbl.use_markup = true;",
1228 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1230 "\ticon.margin_end = 4;",
1231 " \tlbl.justify = Gtk.Justification.LEFT;",
1232 " \tlbl.xalign = 0;",
1234 "//\tlistitem.activatable = true; ??",
1236 "\thbox.append(icon);",
1237 "\thbox.append(lbl);",
1238 "\texpand.set_child(hbox);",
1239 "\t((Gtk.ListItem)listitem).set_child(expand);",
1245 "xtype" : "SignalListItemFactory"
1248 "title" : "Property",
1249 "xtype" : "ColumnViewColumn"
1253 "* pack" : "append_column",
1254 "int fixed_width" : 25,
1258 "* prop" : "factory",
1263 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1264 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1265 "\tvar node = (JsRender.Node) lr.get_item();",
1268 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1269 "\timg.set_from_paintable(",
1270 "\t \tic.lookup_icon (",
1271 "\t \t\t\"list-add\", null, 16,1, ",
1272 "\t\t\t Gtk.TextDirection.NONE, 0",
1276 " \tvar fqn = node.fqn();",
1277 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1279 "\timg.set_visible(cn.size > 0 ? true : false);",
1288 "\tvar icon = new Gtk.Image();",
1290 "\t((Gtk.ListItem)listitem).set_child(icon);",
1295 "xtype" : "SignalListItemFactory"
1298 "string title" : "Add",
1299 "xtype" : "ColumnViewColumn"
1302 "string name" : "left-tree-view",
1303 "xtype" : "ColumnView",
1304 "| Gtk.Widget? getWidgetAt" : [
1305 "(double x, double in_y) {",
1308 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1309 " \tvar colview = gesture.widget;",
1310 " \tvar line_no = check_list_widget(colview, x,y);",
1311 " if (line_no > -1) {",
1312 " \t\tvar item = colview.model.get_item(line_no);",
1316 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1317 " var child = this.el.get_first_child(); ",
1318 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1319 " \tvar line_no = -1; ",
1320 " \tvar reading_header = true;",
1321 " \tvar curr_y = 0;",
1322 " \tvar header_height = 0;",
1324 " \twhile (child != null) {",
1325 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1326 "\t if (reading_header) {",
1329 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1330 "\t\t\t h += child.get_height();",
1331 "\t\t\t\t\tchild = child.get_next_sibling();",
1332 "\t\t\t\t\tcontinue;",
1334 "\t\t\t\t// should be columnlistview",
1335 "\t\t\t\tchild = child.get_first_child(); ",
1336 "\t\t\t GLib.debug(\"header height=%d\", h);",
1337 "\t\t\t\theader_height = h;",
1339 "\t\t\t\treading_header = false;",
1340 "\t\t\t\tcontinue;",
1344 "\t\t\tif (y < header_height) {",
1345 "\t\t \treturn null;",
1348 "\t\t\tvar hh = child.get_height();",
1349 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1350 "\t\t\tif (child.has_css_class(\"node-err\") || ",
1351 "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
1352 "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
1353 "\t\t\t\thh += 10;",
1356 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1357 "\t\t\t return (Gtk.Widget)child;",
1359 "\t\t curr_y += hh ;",
1361 "\t\t if (curr_y > y) {",
1362 "\t\t return null;",
1364 "\t child = child.get_next_sibling(); ",
1370 "| Gtk.Widget? getWidgetAtRow" : [
1374 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1375 " \tvar colview = gesture.widget;",
1376 " \tvar line_no = check_list_widget(colview, x,y);",
1377 " if (line_no > -1) {",
1378 " \t\tvar item = colview.model.get_item(line_no);",
1382 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1383 " var child = this.el.get_first_child(); ",
1384 " \tvar line_no = -1; ",
1385 " \tvar reading_header = true;",
1387 " \twhile (child != null) {",
1388 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1390 " \t if (reading_header) {",
1393 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1395 "\t\t\t\t\tchild = child.get_next_sibling();",
1396 "\t\t\t\t\tcontinue;",
1398 "\t\t\t\t// should be columnlistview",
1399 "\t\t\t\tchild = child.get_first_child(); ",
1403 "\t\t\t\treading_header = false;",
1404 "\t\t\t\tcontinue;",
1410 "\t\t\tif (line_no == row) {",
1411 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1412 "\t\t\t return (Gtk.Widget)child;",
1414 "\t child = child.get_next_sibling(); ",
1416 "\t\t//GLib.debug(\"Rturning null\");",
1421 "| int getColAt" : [
1422 "(double x, double y) {",
1425 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1428 "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1429 "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1430 " var child = this.el.get_first_child(); ",
1434 " \twhile (child != null) {",
1436 "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1437 "\t\t\t\tchild = child.get_first_child();",
1438 "\t\t\t\tcontinue;",
1441 "\t\t\t//child.get_allocation(out alloc);",
1442 "\t\t\tif (x < (child.get_width() + offx)) {",
1443 "\t\t\t\treturn col;",
1446 "\t\t\t//offx += child.get_width();",
1448 "\t\t\t//child = child.get_next_sibling();",
1456 "| int getRowAt" : [
1457 "(double x, double in_y, out string pos) {",
1464 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1465 " \tvar colview = gesture.widget;",
1466 " \tvar line_no = check_list_widget(colview, x,y);",
1467 " if (line_no > -1) {",
1468 " \t\tvar item = colview.model.get_item(line_no);",
1474 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
1475 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1476 " var child = this.el.get_first_child(); ",
1477 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1478 " \tvar line_no = -1; ",
1479 " \tvar reading_header = true;",
1480 " \tvar real_y = 0;",
1481 " \tvar header_height = 0;",
1482 " \tpos = \"none\";",
1484 " \twhile (child != null) {",
1485 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1486 " \t if (reading_header) {",
1489 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1490 "\t\t\t h += child.get_height();",
1491 "\t\t\t\t\tchild = child.get_next_sibling();",
1492 "\t\t\t\t\tcontinue;",
1494 "\t\t\t\t// should be columnlistview",
1495 "\t\t\t\tchild = child.get_first_child(); ",
1496 "\t\t\t //GLib.debug(\"header height=%d\", h);",
1497 "\t\t\t\theader_height = h;",
1499 "\t\t\t\treading_header = false;",
1500 "\t\t\t\tcontinue;",
1504 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1505 " \t\t child = child.get_next_sibling();",
1509 "\t\t \tif (y < header_height) {",
1510 "\t\t \treturn -1;",
1514 "\t\t\tvar hh = child.get_height();",
1516 "\t\t\tif (child.has_css_class(\"node-err\") || ",
1517 "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
1518 "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
1519 "\t\t\t\thh += 10;",
1522 "\t\t\t//child.get_allocation(out alloc);",
1523 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1524 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1526 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1528 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1529 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1530 "\t\t \t\tpos = \"below\";",
1531 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1532 "\t \t\t\tpos = \"over\";",
1534 " \t\t\t\tpos = \"above\";",
1536 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1537 "\t\t\t return line_no;",
1541 "\t\t if (real_y + hh > y) {",
1545 "\t child = child.get_next_sibling(); ",
1555 "id" : "LeftTreeMenu",
1560 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1565 "label" : "Delete Element",
1569 "_this.LeftTreeMenu.el.hide();",
1570 " _this.model.deleteSelected();",
1579 "label" : "Save as Template",
1583 "_this.LeftTreeMenu.el.hide();",
1584 " DialogSaveTemplate.singleton().showIt(",
1585 " (Gtk.Window) _this.el.get_root (), ",
1586 " _this.main_window.windowstate.file.palete(), ",
1587 " _this.getActiveElement()",
1598 "label" : "Save as Module",
1603 " _this.LeftTreeMenu.el.hide();",
1604 " var node = _this.getActiveElement();",
1607 " var sm = DialogSaveModule.singleton();",
1611 " (Gtk.Window) _this.el.get_root (), ",
1612 " _this.main_window.windowstate.project, ",
1616 " gtk4 migration - disabled this part.. probably not used muchanyway",
1619 " if (name.length < 1) {",
1623 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1624 " node.items.clear();",
1627 " var s = _this.view.el.get_selection();",
1629 " print(\"GET SELECTED?\");",
1630 " Gtk.TreeIter iter;",
1631 " Gtk.TreeModel mod;",
1634 " if (!s.get_selected(out mod, out iter)) {",
1635 " return; // nothing seleted..",
1637 " Gtk.TreeIter citer;",
1638 " var n_cn = mod.iter_n_children(iter) -1;",
1639 " for (var i = n_cn; i > -1; i--) {",
1640 " mod.iter_nth_child(out citer, iter, i);",
1643 " print(\"removing node from Tree\\n\"); ",
1645 " _this.model.el.remove(ref citer);",
1647 " _this.changed();",
1648 " _this.node_selected(node, \"tree\");",
1663 "xtype" : "ScrolledWindow"
1667 "| JsRender.JsRender getActiveFile" : [
1669 " return this.main_window.windowstate.file;",
1673 "| JsRender.Node? getActiveElement" : [
1674 " () { // return path to actie node.",
1677 "\treturn _this.selmodel.getSelectedNode();",
1683 "| void onresize" : [
1687 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1688 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1693 "| void removeErrors" : [
1695 "\tvar child = this.view.el.get_first_child(); ",
1697 "\tvar reading_header = true;",
1699 "\twhile (child != null) {",
1700 "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1702 "\t if (reading_header) {",
1705 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1707 "\t\t\t\tchild = child.get_next_sibling();",
1708 "\t\t\t\tcontinue;",
1710 "\t\t\t// should be columnlistview",
1711 "\t\t\tchild = child.get_first_child(); ",
1715 "\t\t\treading_header = false;",
1719 "\t \tif (child.has_css_class(\"node-err\")) {",
1720 "\t\t\tchild.remove_css_class(\"node-err\");",
1722 "\t\tif (child.has_css_class(\"node-warn\")) {",
1723 "\t\t\tchild.remove_css_class(\"node-warn\");",
1726 "\t\tif (child.has_css_class(\"node-depr\")) {",
1727 "\t\t\tchild.remove_css_class(\"node-depr\");",
1730 " child = child.get_next_sibling(); ",
1732 "\t//GLib.debug(\"Rturning null\");",
1736 "| void updateErrors" : [
1738 "\tvar file = this.getActiveFile();",
1739 "\tvar ar = file.getErrors();",
1740 "\t\tif (ar.size < 1) {",
1741 "\t\tif (this.last_error_counter != file.error_counter) {",
1742 "\t\t\tthis.removeErrors();",
1745 "\t\tthis.last_error_counter = file.error_counter ;",
1749 " \tif (this.last_error_counter == file.error_counter) {",
1752 "\tthis.removeErrors();",
1754 "\tforeach(var diag in ar) { ",
1757 "// print(\"get inter\\n\");",
1758 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1759 "\t if (node == null) {",
1762 " \tvar row = _this.model.nodeToRow(node);",
1763 " \tif (row < 0) {",
1766 " \tvar w = this.view.getWidgetAtRow(row);",
1767 " \tif (w == null) {",
1770 "\t\t// always show errors.",
1771 "\t\tvar ed = diag.category.down();",
1772 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1775 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1776 "\t\t\tw.remove_css_class(\"node-warn\");",
1778 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1779 "\t\t\tw.remove_css_class(\"node-depr\");",
1781 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1782 "\t\t\tw.add_css_class(\"node-\" + ed);",
1791 "name" : "WindowLeftTree"