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);",
211 "\t_this.model.selectNode(node);",
215 "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());",
216 "\t//_this.deletemenu.el.set_parent(_this.view.el);",
217 "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
220 "\t//Gtk.Allocation rect;",
221 "\t//_this.view.el.get_allocation(out rect);",
222 " \t//_this.deletemenu.el.set_has_arrow(false);",
223 "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
226 "\t_this.LeftTreeMenu.el.set_offset( ",
228 "\t\t\t(int)y - (int)_this.view.el.get_height());",
230 " _this.LeftTreeMenu.el.popup();",
237 "xtype" : "GestureClick"
240 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
245 "\tGLib.debug(\"SOURCE: drag-begin\");",
247 " // find what is selected in our tree...",
248 " var data = _this.selmodel.getSelectedNode();",
249 "\tif (data == null) {",
252 "\t_this.view.dragNode = data;",
253 " var xname = data.fqn();",
254 " GLib.debug (\"XNAME IS %s\", xname);",
256 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
259 " var paintable = new Gtk.WidgetPaintable(widget);",
260 " this.el.set_icon(paintable, 0,0);",
266 "(drag, reason) => {",
268 "\t_this.view.dragNode = null;",
274 "(drag, delete_data) => {",
276 "_this.view.dragNode = null;",
285 "///\t( drag_context, data, info, time) => {",
288 "\t//print(\"drag-data-get\");",
289 " \tvar ndata = _this.selmodel.getSelectedNode();",
290 "\tif (ndata == null) {",
291 "\t \tGLib.debug(\"return empty string - no selection..\");",
297 "\t//data.set_text(tp,tp.length); ",
299 "\tvar \tstr = ndata.toJsonString();",
300 "\tGLib.debug(\"prepare store: %s\", str);",
301 "\tGLib.Value ov = GLib.Value(typeof(string));",
302 "\tov.set_string(str);",
303 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
305 "\tGLib.Value v = GLib.Value(typeof(string));",
306 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
308 "\t\tcont.get_value(ref v);",
311 "\tGLib.debug(\"set %s\", v.get_string());",
320 "xtype" : "DragSource"
326 "(keyval, keycode, state) => {",
330 "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) {",
334 "\t_this.model.deleteSelected();",
341 "xtype" : "EventControllerKey"
346 "new Gtk.DropTarget ( typeof(string) ,",
347 "\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE )"
349 "Gtk.Widget? highlightWidget" : "null",
350 "JsRender.Node? lastDragNode" : "null",
356 "\tGLib.debug(\"got DropTarget:accept\");",
358 "// NOT REALLY NEEDED? = put stuff in drop?",
361 "/* ( ctx, x, y, time) => {",
362 " //Seed.print(\"TARGET: drag-drop\");",
365 " var src = Gtk.drag_get_source_widget(ctx);",
367 " if (src != this.el) {",
371 " this.drag_in_motion = false; ",
372 " // request data that will be recieved by the recieve... ",
373 " Gtk.drag_get_data",
375 " this.el, // will receive 'drag-data-received' signal ",
376 " ctx, // represents the current state of the DnD ",
377 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
378 " time // time stamp ",
382 " // No target offered by source => error",
388 " // handle drop around self..",
392 " //print(\"GETTING POS\");",
393 " var targetData = \"\";",
395 " Gtk.TreePath path;",
396 " Gtk.TreeViewDropPosition pos;",
397 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
399 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
400 " var isEmpty = false;",
401 " if (_this.model.el.iter_n_children(null) < 1) {",
402 " print(\"got NO children?\\n\");",
403 " isOver = true; //??? ",
405 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
410 " //var action = Gdk.DragAction.COPY;",
411 " // unless we are copying!!! ctl button..",
413 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
414 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
415 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
418 " if (_this.model.el.iter_n_children(null) < 1) {",
419 " // no children.. -- asume it's ok..",
421 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
423 " // continue through to allow drop...",
431 " //print(\"ISOVER? \" + isOver);",
434 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
435 " return true; // not over apoint!?! - no action on drop or motion..",
438 " // drag node is parent of child..",
439 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
440 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
442 " // nned to check a few here..",
443 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
444 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
445 " //Gtk.TreeViewDropPosition.AFTER",
446 " //Gtk.TreeViewDropPosition.BEFORE",
448 " // locally dragged items to not really use the ",
449 " var selection_text = this.dragData;",
453 " if (selection_text == null || selection_text.length < 1) {",
454 " //print(\"Error - drag selection text returned NULL\");",
456 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
457 " return true; /// -- fixme -- this is not really correct..",
460 " // see if we are dragging into ourself?",
461 " print (\"got selection text of \" + selection_text);",
463 " var target_path = path.to_string();",
464 " //print(\"target_path=\"+target_path);",
467 " if (selection_text == target_path) {",
468 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
470 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
472 " return true; /// -- fixme -- this is not really correct..",
477 " //print(\"DUMPING DATA\");",
478 " //console.dump(data);",
481 " //print(data.path.to_string() +' => '+ data.pos);",
483 " // dropList is a list of xtypes that this node could be dropped on.",
484 " // it is set up when we start to drag..",
487 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
489 " print(\"targetDAta: \" + targetData +\"\\n\");",
491 " if (targetData.length < 1) {",
492 " //print(\"Can not find drop node path\");",
494 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
500 " // continue on to allow drop..",
502 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
505 " var delete_selection_data = false;",
507 " if (action == Gdk.DragAction.ASK) {",
508 " // Ask the user to move or copy, then set the ctx action. ",
511 " if (action == Gdk.DragAction.MOVE) {",
512 " delete_selection_data = true;",
515 " // drag around.. - reorder..",
516 " _this.model.moveNode(targetData, action);",
522 " // we can send stuff to souce here...",
525 "// do we always say failure, so we handle the reall drop?",
526 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
544 "\tthis.addHighlight(null,\"\");",
546 " \tvar is_shift = _this.keystate.is_shift > 0;",
548 " \tvar pos = \"\";",
549 " \t// -- get position..",
550 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
551 "\t\t// still dragging same node",
553 "\t\tthis.lastDragNode = new JsRender.Node(); ",
554 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
559 " var dropNode = new JsRender.Node(); ",
560 "\tdropNode.loadFromJsonString(v.get_string(), 1);",
561 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
563 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
565 " if (_this.model.el.n_items < 1) {",
566 " \t// FIXME check valid drop types?",
567 " \tif (!drop_on_to.contains(\"*top\")) {",
568 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
569 "\t\t\treturn false;\t",
571 "\t\t// add new node to top..",
574 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
575 " \t_this.main_window.windowstate.file.tree = dropNode; ",
578 "\t\tm.append(dropNode);",
579 "\t\t_this.model.selectNode(dropNode); \t",
580 "\t\t_this.changed();",
581 "\t\treturn true; // no need to highlight?",
587 "\tvar row = _this.view.getRowAt(x,y, out pos);",
589 "\t\treturn false; //Gdk.DragAction.COPY;",
591 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
593 "\tvar node = (JsRender.Node)tr.get_item();",
595 " \tif (pos == \"above\" || pos == \"below\") {",
596 "\t\tif (node.parent == null) {",
597 "\t\t\tpos = \"over\";",
599 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
600 "\t\t\t\tpos = \"over\";",
602 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
603 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
604 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
605 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
606 " \t\t\t\t\t\treturn false;\t",
616 " \tif (pos == \"over\") {",
617 "\t \tif (!drop_on_to.contains(node.fqn())) {",
618 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
619 "\t\t\treturn false;",
622 "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
623 " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
624 "\t\t\treturn false;\t",
629 " \t\tcase \"over\":",
630 "\t \t\tnode.appendChild(dropNode);",
631 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
632 "\t\t \t\t_this.model.selectNode(null); ",
633 "\t\t \t\t_this.view.dragNode.remove();",
637 " \t\t\t_this.model.selectNode(dropNode); ",
639 " \t\t\t_this.changed();\t\t\t\t \t\t",
640 "\t \t\treturn true;",
642 " \t\tcase \"above\":",
643 " \t\t\tGLib.debug(\"Above - insertBefore\");",
645 "\t\t\tnode.parent.insertBefore(dropNode, node);",
646 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
647 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
648 "\t\t \t\t_this.view.dragNode.remove();",
651 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
652 " \t\t\t_this.changed();",
653 " \t\t\treturn true;",
655 " \t\tcase \"below\":",
656 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
657 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
658 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
659 "\t\t \t\t_this.view.dragNode.remove();",
663 " \t\t\tnode.parent.insertAfter(dropNode, node);",
664 " \t\t\t_this.model.selectNode(dropNode);\t",
665 " \t\t\t_this.changed();",
666 " \t\t\t// select it",
667 " \t\t\treturn true;",
670 " \t\t\t// should not happen",
671 " \t\t\treturn false;",
684 "\tthis.addHighlight(null,\"\");",
692 "\tvar is_shift = _this.keystate.is_shift > 0;",
694 "\tGLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
695 "\tstring pos; // over / before / after..",
697 " //GLib.debug(\"got drag motion\");",
699 " GLib.Value v = GLib.Value(typeof(string));",
700 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
701 " \tvar cont = this.el.current_drop.get_drag().content ;",
703 " \t\tcont.get_value(ref v);",
704 "\t} catch (GLib.Error e) {",
705 "\t GLib.debug(\"failed to get drag value\");",
706 "\t\treturn Gdk.DragAction.COPY;\t ",
710 "\t//GLib.debug(\"got %s\", v.get_string());",
712 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
713 "\t\t// still dragging same node",
715 "\t\tthis.lastDragNode = new JsRender.Node(); ",
716 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
720 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
721 "\t\t\t\tthis.lastDragNode.fqn());",
723 " string[] str = {};",
724 " foreach(var dp in drop_on_to) {",
727 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
730 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
732 " if (_this.model.el.n_items < 1) {",
733 " \t// FIXME check valid drop types?",
734 " \tif (drop_on_to.contains(\"*top\")) {",
735 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
737 "\t\t\tthis.addHighlight(null, \"\");\t\t",
740 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
745 " \tGLib.debug(\"check is over\");",
747 " // if path of source and dest are inside each other..",
748 " // need to add source info to drag?",
750 " \tvar row = _this.view.getRowAt(x,y, out pos);",
753 "\t\tthis.addHighlight(null, \"\");\t",
754 "\t \treturn Gdk.DragAction.COPY;",
756 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
758 "\tvar node = (JsRender.Node)tr.get_item();",
760 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
763 " \tif (pos == \"above\" || pos == \"below\") {",
764 "\t\tif (node.parent == null) {",
765 "\t\t\tGLib.debug(\"no parent try center\");",
766 "\t\t\tpos = \"over\";",
769 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
770 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
771 "\t \t\t\tpos = \"over\";",
773 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
774 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
775 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
776 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
777 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
778 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
791 " \tif (pos == \"over\") {",
792 "\t \tif (!drop_on_to.contains(node.fqn())) {",
793 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
794 "\t\t\tthis.addHighlight(null, \"\"); ",
795 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
797 "\t\tif (_this.view.dragNode != null && is_shift) {",
798 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
799 "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
800 " \t\t\t\tthis.addHighlight(null, \"\");",
801 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
808 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
809 "\tvar w = _this.view.getWidgetAt(x,y);",
810 "\tthis.addHighlight(w, pos); ",
811 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
815 "string lastDragString" : "\"\"",
816 "xtype" : "DropTarget",
817 "| void addHighlight" : [
818 "(Gtk.Widget? w, string hl) {",
819 "\tif (this.highlightWidget != null) {",
820 "\t\tvar ww = this.highlightWidget;",
821 "\t\tGLib.debug(\"clear drag from previous highlight\");",
822 "\t\tif (ww.has_css_class(\"drag-below\")) {",
823 "\t\t\t ww.remove_css_class(\"drag-below\");",
825 "\t\tif (ww.has_css_class(\"drag-above\")) {",
826 "\t\t\t ww.remove_css_class(\"drag-above\");",
828 "\t\tif (ww.has_css_class(\"drag-over\")) {",
829 "\t\t\t ww.remove_css_class(\"drag-over\");",
832 "\tif (w != null) {",
833 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
834 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
835 "\t\t\tw.add_css_class(\"drag-\" + hl);",
838 "\tthis.highlightWidget = w;",
849 "* ctor" : "this.updateModel(null)",
852 "xtype" : "TreeListModel",
853 "| Gtk.TreeListModel updateModel" : [
854 "(GLib.ListStore? m) {",
855 "\tthis.el = new Gtk.TreeListModel(",
856 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
857 "\t\tfalse, // passthru",
858 "\t\ttrue, // autexpand",
860 "\t\t\treturn ((JsRender.Node)item).childstore;",
864 "\tif (_this.selmodel.el == null) {",
865 "\t\treturn this.el;",
867 "\t_this.selmodel.el.set_model(this.el);",
871 "| int nodeToRow" : [
872 "(JsRender.Node node) ",
875 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
876 "\tfor (var i = 0; i < s.n_items; i++) {",
877 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
878 "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
879 "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
880 "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {",
885 "\treturn -1;\t\t\t",
890 "| void deleteSelected" : [
895 "\tvar node = _this.selmodel.getSelectedNode();",
898 " if (node == null) {",
899 " \tGLib.debug(\"delete Selected - no node slected?\");",
902 " _this.selmodel.el.unselect_all();",
905 " \tGLib.debug(\"delete Selected - done\");",
908 " print(\"DELETE SELECTED?\");",
909 " //_this.view.blockChanges = true;",
910 " print(\"GET SELECTION?\");",
912 " var s = _this.view.el.get_selection();",
914 " print(\"GET SELECTED?\");",
915 " Gtk.TreeIter iter;",
916 " Gtk.TreeModel mod;",
919 " if (!s.get_selected(out mod, out iter)) {",
920 " return; // nothing seleted..",
925 " this.activePath= \"\"; ",
926 " print(\"GET vnode value?\");",
928 " GLib.Value value;",
929 " this.el.get_value(iter, 2, out value);",
930 " var data = (JsRender.Node)(value.get_object());",
931 " print(\"removing node from Render\\n\");",
932 " if (data.parent == null) {",
933 " _this.main_window.windowstate.file.tree = null;",
937 " print(\"removing node from Tree\\n\"); ",
938 " s.unselect_all();",
939 " this.el.remove(ref iter);",
949 " this.activePath= \"\"; // again!?!? ",
950 " //this.changed(null,true);",
954 " _this.view.blockChanges = false;",
959 "| void loadFile" : [
960 "(JsRender.JsRender f) {",
961 " //console.dump(f);",
963 " _this.drop.highlightWidget = null;",
965 " var m = (GLib.ListStore) this.el.model;",
967 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
969 " _this.main_window.windowstate.file = f;",
970 " _this.last_error_counter = -1;",
972 " if (f.tree == null) {",
974 "\t f.loadItems( );",
975 " } catch (Error e) {",
979 " // if it's still null?",
980 " if (f.tree == null) {",
981 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
982 " \t_this.updateErrors();",
985 " \tm.append(f.tree);",
986 "\t_this.updateErrors();",
988 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
996 "| void selectNode" : [
997 "(JsRender.Node node) ",
999 "\tvar row = this.nodeToRow(node);",
1000 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1003 "\t\t// select none?",
1004 "\t\tGLib.debug(\"Could not find node\");",
1007 "\tGLib.debug(\"Select %d\", row);",
1008 "\ts.set_selected(row);",
1009 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1010 "\t//_this.node_selected(node);\t\t\t",
1018 "selection_changed" : [
1019 "(position, n_items) => {",
1023 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1024 "\t\t\t// then event was started by some other action",
1025 "\t\t\t// which should manually trigger all the events..",
1026 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1031 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1032 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1036 "\t\t if (!_this.before_node_change( ) ) {",
1037 "\t\t\t _this.view.blockChanges = true;",
1038 "\t\t\t _this.selmodel.el.unselect_all();",
1039 "\t\t\t _this.view.blockChanges = false;",
1043 "\t\t if (_this.main_window.windowstate.file == null) {",
1044 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1048 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1049 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1052 "\t\t// -- it appears that the selection is not updated.",
1053 "\t\t // select the node...",
1054 "\t\t //_this.selmodel.el.set_selected(row);",
1056 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1058 "\t var snode = _this.selmodel.getSelectedNode();",
1059 "\t if (snode == null) {",
1061 "\t GLib.debug(\"selected rows < 1\");",
1062 "\t //??this.model.load( false);",
1063 "\t _this.node_selected(null);",
1071 "\t GLib.debug (\"calling left_tree.node_selected\");",
1072 "\t _this.node_selected(snode);",
1077 "\t // no need to scroll. it's in the view as we clicked on it.",
1078 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1085 "xtype" : "SingleSelection",
1086 "| JsRender.Node getNodeAt" : [
1089 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1091 " var a = tr.get_item();; ",
1092 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1095 " return (JsRender.Node)tr.get_item();",
1099 "| JsRender.Node? getSelectedNode" : [
1101 " if (this.el.selected_item == null) {",
1104 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1105 " return (JsRender.Node)tr.get_item();",
1112 "* pack" : "append_column",
1113 "bool expand" : true,
1114 "bool resizable" : true,
1119 "* prop" : "factory",
1123 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1125 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1126 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1129 "\tvar hbox = (Gtk.Box) expand.child;",
1132 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1133 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1135 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1136 "\tvar node = (JsRender.Node) lr.get_item();",
1138 " GLib.debug(\"node is %s\", node.get_type().name());",
1139 "// was item (1) in old layout",
1144 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1145 " var clsname = node.fqn();",
1147 " var clsb = clsname.split(\".\");",
1148 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1150 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1154 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1155 "\t\t img.set_from_file(fn);",
1158 "\t \t\timg.set_from_paintable(",
1159 "\t\t\t \tic.lookup_icon (",
1160 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1161 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1165 " \t} catch (GLib.Error e) {}",
1167 " expand.set_hide_expander( !node.hasChildren() );",
1168 " \texpand.set_list_row(lr);",
1170 " \tnode.bind_property(\"iconFilename\",",
1172 " GLib.BindingFlags.SYNC_CREATE);",
1174 " \tnode.bind_property(\"nodeTitleProp\",",
1176 " GLib.BindingFlags.SYNC_CREATE);",
1177 " \tnode.bind_property(\"nodeTipProp\",",
1178 " lbl, \"tooltip_markup\",",
1179 " GLib.BindingFlags.SYNC_CREATE);",
1180 " \t// bind image...",
1188 "\tvar expand = new Gtk.TreeExpander();",
1190 "\texpand.set_indent_for_depth(true);",
1191 "\texpand.set_indent_for_icon(true);",
1192 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1193 "\tvar icon = new Gtk.Image();",
1194 "\tvar lbl = new Gtk.Label(\"\");",
1195 "\tlbl.use_markup = true;",
1196 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1198 "\ticon.margin_end = 4;",
1199 " \tlbl.justify = Gtk.Justification.LEFT;",
1200 " \tlbl.xalign = 0;",
1202 "//\tlistitem.activatable = true; ??",
1204 "\thbox.append(icon);",
1205 "\thbox.append(lbl);",
1206 "\texpand.set_child(hbox);",
1207 "\t((Gtk.ListItem)listitem).set_child(expand);",
1213 "xtype" : "SignalListItemFactory"
1216 "title" : "Property",
1217 "xtype" : "ColumnViewColumn"
1221 "* pack" : "append_column",
1222 "int fixed_width" : 25,
1226 "* prop" : "factory",
1231 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1232 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1233 "\tvar node = (JsRender.Node) lr.get_item();",
1236 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1237 "\timg.set_from_paintable(",
1238 "\t \tic.lookup_icon (",
1239 "\t \t\t\"list-add\", null, 16,1, ",
1240 "\t\t\t Gtk.TextDirection.NONE, 0",
1244 " \tvar fqn = node.fqn();",
1245 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1247 "\timg.set_visible(cn.size > 0 ? true : false);",
1256 "\tvar icon = new Gtk.Image();",
1258 "\t((Gtk.ListItem)listitem).set_child(icon);",
1263 "xtype" : "SignalListItemFactory"
1266 "string title" : "Add",
1267 "xtype" : "ColumnViewColumn"
1275 "(keyval, keycode, state) => {",
1277 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
1278 " \t\tthis.is_shift = 1;",
1285 "(keyval, keycode, state) => {",
1286 "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int) keycode, state);",
1287 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
1288 " \t\tthis.is_shift = 0;",
1290 "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
1297 "xtype" : "EventControllerKey"
1300 "string name" : "left-tree-view",
1301 "xtype" : "ColumnView",
1302 "| Gtk.Widget? getWidgetAt" : [
1303 "(double x, double in_y) {",
1306 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1307 " \tvar colview = gesture.widget;",
1308 " \tvar line_no = check_list_widget(colview, x,y);",
1309 " if (line_no > -1) {",
1310 " \t\tvar item = colview.model.get_item(line_no);",
1314 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1315 " var child = this.el.get_first_child(); ",
1316 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1317 " \tvar line_no = -1; ",
1318 " \tvar reading_header = true;",
1319 " \tvar curr_y = 0;",
1320 " \tvar header_height = 0;",
1322 " \twhile (child != null) {",
1323 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1324 "\t if (reading_header) {",
1327 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1328 "\t\t\t h += child.get_height();",
1329 "\t\t\t\t\tchild = child.get_next_sibling();",
1330 "\t\t\t\t\tcontinue;",
1332 "\t\t\t\t// should be columnlistview",
1333 "\t\t\t\tchild = child.get_first_child(); ",
1334 "\t\t\t GLib.debug(\"header height=%d\", h);",
1335 "\t\t\t\theader_height = h;",
1337 "\t\t\t\treading_header = false;",
1342 "\t\t\tif (y < header_height) {",
1343 "\t\t \treturn null;",
1346 "\t\t\tvar hh = child.get_height();",
1347 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1349 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1350 "\t\t\t return (Gtk.Widget)child;",
1352 "\t\t curr_y += hh ;",
1354 "\t\t if (curr_y > y) {",
1355 "\t\t return null;",
1357 "\t child = child.get_next_sibling(); ",
1363 "| Gtk.Widget? getWidgetAtRow" : [
1367 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1368 " \tvar colview = gesture.widget;",
1369 " \tvar line_no = check_list_widget(colview, x,y);",
1370 " if (line_no > -1) {",
1371 " \t\tvar item = colview.model.get_item(line_no);",
1375 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1376 " var child = this.el.get_first_child(); ",
1377 " \tvar line_no = -1; ",
1378 " \tvar reading_header = true;",
1380 " \twhile (child != null) {",
1381 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1383 " \t if (reading_header) {",
1386 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1388 "\t\t\t\t\tchild = child.get_next_sibling();",
1389 "\t\t\t\t\tcontinue;",
1391 "\t\t\t\t// should be columnlistview",
1392 "\t\t\t\tchild = child.get_first_child(); ",
1396 "\t\t\t\treading_header = false;",
1403 "\t\t\tif (line_no == row) {",
1404 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1405 "\t\t\t return (Gtk.Widget)child;",
1407 "\t child = child.get_next_sibling(); ",
1409 "\t\t//GLib.debug(\"Rturning null\");",
1414 "| int getColAt" : [
1415 "(double x, double y) {",
1418 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1421 "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1422 "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1423 " var child = this.el.get_first_child(); ",
1427 " \twhile (child != null) {",
1429 "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1430 "\t\t\t\tchild = child.get_first_child();",
1431 "\t\t\t\tcontinue;",
1434 "\t\t\t//child.get_allocation(out alloc);",
1435 "\t\t\tif (x < (child.get_width() + offx)) {",
1436 "\t\t\t\treturn col;",
1439 "\t\t\t//offx += child.get_width();",
1441 "\t\t\t//child = child.get_next_sibling();",
1449 "| int getRowAt" : [
1450 "(double x, double in_y, out string pos) {",
1457 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1458 " \tvar colview = gesture.widget;",
1459 " \tvar line_no = check_list_widget(colview, x,y);",
1460 " if (line_no > -1) {",
1461 " \t\tvar item = colview.model.get_item(line_no);",
1467 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
1468 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1469 " var child = this.el.get_first_child(); ",
1470 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1471 " \tvar line_no = -1; ",
1472 " \tvar reading_header = true;",
1473 " \tvar real_y = 0;",
1474 " \tvar header_height = 0;",
1475 " \tpos = \"none\";",
1477 " \twhile (child != null) {",
1478 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1479 " \t if (reading_header) {",
1482 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1483 "\t\t\t h += child.get_height();",
1484 "\t\t\t\t\tchild = child.get_next_sibling();",
1485 "\t\t\t\t\tcontinue;",
1487 "\t\t\t\t// should be columnlistview",
1488 "\t\t\t\tchild = child.get_first_child(); ",
1489 "\t\t\t GLib.debug(\"header height=%d\", h);",
1490 "\t\t\t\theader_height = h;",
1492 "\t\t\t\treading_header = false;",
1496 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1497 " \t\t child = child.get_next_sibling();",
1501 "\t\t \tif (y < header_height) {",
1502 "\t\t \treturn -1;",
1506 "\t\t\tvar hh = child.get_height();",
1507 "\t\t\t//child.get_allocation(out alloc);",
1508 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1509 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1511 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1513 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1514 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1515 "\t\t \t\tpos = \"below\";",
1516 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1517 "\t \t\t\tpos = \"over\";",
1519 " \t\t\t\tpos = \"above\";",
1521 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1522 "\t\t\t return line_no;",
1526 "\t\t if (real_y + hh > y) {",
1530 "\t child = child.get_next_sibling(); ",
1540 "id" : "LeftTreeMenu",
1545 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1550 "label" : "Delete Element",
1554 "_this.LeftTreeMenu.el.hide();",
1555 " _this.model.deleteSelected();",
1564 "label" : "Save as Template",
1568 "_this.LeftTreeMenu.el.hide();",
1569 " DialogSaveTemplate.singleton().showIt(",
1570 " (Gtk.Window) _this.el.get_root (), ",
1571 " _this.main_window.windowstate.file.palete(), ",
1572 " _this.getActiveElement()",
1583 "label" : "Save as Module",
1588 " _this.LeftTreeMenu.el.hide();",
1589 " var node = _this.getActiveElement();",
1592 " var sm = DialogSaveModule.singleton();",
1596 " (Gtk.Window) _this.el.get_root (), ",
1597 " _this.main_window.windowstate.project, ",
1601 " gtk4 migration - disabled this part.. probably not used muchanyway",
1604 " if (name.length < 1) {",
1608 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1609 " node.items.clear();",
1612 " var s = _this.view.el.get_selection();",
1614 " print(\"GET SELECTED?\");",
1615 " Gtk.TreeIter iter;",
1616 " Gtk.TreeModel mod;",
1619 " if (!s.get_selected(out mod, out iter)) {",
1620 " return; // nothing seleted..",
1622 " Gtk.TreeIter citer;",
1623 " var n_cn = mod.iter_n_children(iter) -1;",
1624 " for (var i = n_cn; i > -1; i--) {",
1625 " mod.iter_nth_child(out citer, iter, i);",
1628 " print(\"removing node from Tree\\n\"); ",
1630 " _this.model.el.remove(ref citer);",
1632 " _this.changed();",
1633 " _this.node_selected(node, \"tree\");",
1648 "xtype" : "ScrolledWindow"
1652 "| JsRender.JsRender getActiveFile" : [
1654 " return this.main_window.windowstate.file;",
1658 "| JsRender.Node? getActiveElement" : [
1659 " () { // return path to actie node.",
1662 "\treturn _this.selmodel.getSelectedNode();",
1668 "| void onresize" : [
1672 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1673 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1678 "| void removeErrors" : [
1680 "\tvar child = this.view.el.get_first_child(); ",
1682 "\tvar reading_header = true;",
1684 "\twhile (child != null) {",
1685 "\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1687 "\t if (reading_header) {",
1690 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1692 "\t\t\t\tchild = child.get_next_sibling();",
1693 "\t\t\t\tcontinue;",
1695 "\t\t\t// should be columnlistview",
1696 "\t\t\tchild = child.get_first_child(); ",
1700 "\t\t\treading_header = false;",
1704 "\t \tif (child.has_css_class(\"node-err\")) {",
1705 "\t\t\tchild.remove_css_class(\"node-err\");",
1707 "\t\tif (child.has_css_class(\"node-warn\")) {",
1708 "\t\t\tchild.remove_css_class(\"node-warn\");",
1711 "\t\tif (child.has_css_class(\"node-depr\")) {",
1712 "\t\t\tchild.remove_css_class(\"node-depr\");",
1715 " child = child.get_next_sibling(); ",
1717 "\t//GLib.debug(\"Rturning null\");",
1721 "| void updateErrors" : [
1723 "\tvar file = this.getActiveFile();",
1724 "\tvar ar = file.getErrors();",
1725 "\tif (ar.size < 1) {",
1726 "\t\tthis.removeErrors();",
1727 "\t\tthis.last_error_counter = file.error_counter ;",
1731 " \tif (this.last_error_counter == file.error_counter) {",
1734 "\tthis.removeErrors();",
1736 "\tforeach(var diag in ar) { ",
1739 "// print(\"get inter\\n\");",
1740 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1741 "\t if (node == null) {",
1744 " \tvar row = _this.model.nodeToRow(node);",
1745 " \tif (row < 0) {",
1748 " \tvar w = this.view.getWidgetAtRow(row);",
1749 " \tif (w == null) {",
1752 "\t\t// always show errors.",
1753 "\t\tvar ed = diag.category.down();",
1754 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1757 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1758 "\t\t\tw.remove_css_class(\"node-warn\");",
1760 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1761 "\t\t\tw.remove_css_class(\"node-depr\");",
1763 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1764 "\t\t\tw.add_css_class(\"node-\" + ed);",
1773 "name" : "WindowLeftTree"