2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Xcls_MainWindow? main_window" : "null",
7 "# int last_error_counter" : "-1",
9 "@ bool before_node_change" : "()",
10 "@ void changed" : "()",
11 "@ void node_selected" : "(JsRender.Node? node)",
12 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
13 "bool hexpand" : true,
14 "bool vexpand" : true,
15 "id" : "WindowLeftTree",
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; ",
608 " \tdropNode.updated_count++;",
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();",
668 "\t \t\tdropNode.updated_count++;",
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();",
682 "\t\t\tdropNode.updated_count++;",
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\tdropNode.updated_count++;",
697 " \t\t\t_this.model.selectNode(dropNode);\t",
698 " \t\t\t_this.changed();",
699 " \t\t\t// select it",
700 " \t\t\treturn true;",
703 " \t\t\t// should not happen",
704 " \t\t\treturn false;",
717 "\tthis.addHighlight(null,\"\");",
725 "\tvar is_shift = _this.keystate.is_shift > 0;",
727 "\tGLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
728 "\tstring pos; // over / before / after..",
730 " //GLib.debug(\"got drag motion\");",
732 " GLib.Value v = GLib.Value(typeof(string));",
733 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
734 " \tvar cont = this.el.current_drop.get_drag().content ;",
736 " \t\tcont.get_value(ref v);",
737 "\t} catch (GLib.Error e) {",
738 "\t GLib.debug(\"failed to get drag value\");",
739 "\t\treturn Gdk.DragAction.COPY;\t ",
743 "\t//GLib.debug(\"got %s\", v.get_string());",
745 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
746 "\t\t// still dragging same node",
748 "\t\tthis.lastDragNode = new JsRender.Node(); ",
749 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
753 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
754 "\t\t\t\tthis.lastDragNode.fqn());",
756 " string[] str = {};",
757 " foreach(var dp in drop_on_to) {",
760 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
763 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
765 " if (_this.model.el.n_items < 1) {",
766 " \t// FIXME check valid drop types?",
767 " \tif (drop_on_to.contains(\"*top\")) {",
768 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
770 "\t\t\tthis.addHighlight(null, \"\");\t\t",
773 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
778 " \tGLib.debug(\"check is over\");",
780 " // if path of source and dest are inside each other..",
781 " // need to add source info to drag?",
783 " \tvar row = _this.view.getRowAt(x,y, out pos);",
786 "\t\tthis.addHighlight(null, \"\");\t",
787 "\t \treturn Gdk.DragAction.COPY;",
789 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
791 "\tvar node = (JsRender.Node)tr.get_item();",
793 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
796 " \tif (pos == \"above\" || pos == \"below\") {",
797 "\t\tif (node.parent == null) {",
798 "\t\t\tGLib.debug(\"no parent try center\");",
799 "\t\t\tpos = \"over\";",
802 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
803 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
804 "\t \t\t\tpos = \"over\";",
806 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
807 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
808 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
809 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
810 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
811 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
824 " \tif (pos == \"over\") {",
825 "\t \tif (!drop_on_to.contains(node.fqn())) {",
826 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
827 "\t\t\tthis.addHighlight(null, \"\"); ",
828 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
830 "\t\tif (_this.view.dragNode != null && is_shift) {",
831 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
832 "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
833 " \t\t\t\tthis.addHighlight(null, \"\");",
834 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
841 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
842 "\tvar w = _this.view.getWidgetAt(x,y);",
843 "\tthis.addHighlight(w, pos); ",
844 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
848 "string lastDragString" : "\"\"",
849 "xtype" : "DropTarget",
850 "| void addHighlight" : [
851 "(Gtk.Widget? w, string hl) {",
852 "\tif (this.highlightWidget != null) {",
853 "\t\tvar ww = this.highlightWidget;",
854 "\t\tGLib.debug(\"clear drag from previous highlight\");",
855 "\t\tif (ww.has_css_class(\"drag-below\")) {",
856 "\t\t\t ww.remove_css_class(\"drag-below\");",
858 "\t\tif (ww.has_css_class(\"drag-above\")) {",
859 "\t\t\t ww.remove_css_class(\"drag-above\");",
861 "\t\tif (ww.has_css_class(\"drag-over\")) {",
862 "\t\t\t ww.remove_css_class(\"drag-over\");",
865 "\tif (w != null) {",
866 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
867 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
868 "\t\t\tw.add_css_class(\"drag-\" + hl);",
871 "\tthis.highlightWidget = w;",
882 "* ctor" : "this.updateModel(null)",
885 "xtype" : "TreeListModel",
886 "| Gtk.TreeListModel updateModel" : [
887 "(GLib.ListStore? m) {",
888 "\tthis.el = new Gtk.TreeListModel(",
889 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
890 "\t\tfalse, // passthru",
891 "\t\ttrue, // autexpand",
893 "\t\t\treturn ((JsRender.Node)item).childstore;",
897 "\tif (_this.selmodel.el == null) {",
898 "\t\treturn this.el;",
900 "\t_this.selmodel.el.set_model(this.el);",
904 "| int nodeToRow" : [
905 "(JsRender.Node node) ",
908 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
909 "\tfor (var i = 0; i < s.n_items; i++) {",
910 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
911 "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
912 "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
913 "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {",
918 "\treturn -1;\t\t\t",
923 "| void deleteSelected" : [
928 "\tvar node = _this.selmodel.getSelectedNode();",
931 " if (node == null) {",
932 " \tGLib.debug(\"delete Selected - no node slected?\");",
935 " _this.selmodel.el.unselect_all();",
938 " \tGLib.debug(\"delete Selected - done\");",
941 " print(\"DELETE SELECTED?\");",
942 " //_this.view.blockChanges = true;",
943 " print(\"GET SELECTION?\");",
945 " var s = _this.view.el.get_selection();",
947 " print(\"GET SELECTED?\");",
948 " Gtk.TreeIter iter;",
949 " Gtk.TreeModel mod;",
952 " if (!s.get_selected(out mod, out iter)) {",
953 " return; // nothing seleted..",
958 " this.activePath= \"\"; ",
959 " print(\"GET vnode value?\");",
961 " GLib.Value value;",
962 " this.el.get_value(iter, 2, out value);",
963 " var data = (JsRender.Node)(value.get_object());",
964 " print(\"removing node from Render\\n\");",
965 " if (data.parent == null) {",
966 " _this.main_window.windowstate.file.tree = null;",
970 " print(\"removing node from Tree\\n\"); ",
971 " s.unselect_all();",
972 " this.el.remove(ref iter);",
982 " this.activePath= \"\"; // again!?!? ",
983 " //this.changed(null,true);",
987 " _this.view.blockChanges = false;",
992 "| void loadFile" : [
993 "(JsRender.JsRender f) {",
994 " //console.dump(f);",
996 " _this.drop.highlightWidget = null;",
998 " var m = (GLib.ListStore) this.el.model;",
1000 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
1002 " _this.main_window.windowstate.file = f;",
1003 " _this.last_error_counter = -1;",
1005 " if (f.tree == null) {",
1007 "\t f.loadItems( );",
1008 " } catch (Error e) {",
1012 " // if it's still null?",
1013 " if (f.tree == null) {",
1014 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1015 " \t_this.updateErrors();",
1018 " \tm.append(f.tree);",
1019 "\t_this.updateErrors();",
1021 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1029 "| void selectNode" : [
1030 "(JsRender.Node node) ",
1032 "\tvar row = this.nodeToRow(node);",
1033 "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1036 "\t\t// select none?",
1037 "\t\tGLib.debug(\"Could not find node\");",
1040 "\tGLib.debug(\"Select %d\", row);",
1041 "\ts.set_selected(row);",
1042 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1043 "\t//_this.node_selected(node);\t\t\t",
1051 "selection_changed" : [
1052 "(position, n_items) => {",
1056 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1057 "\t\t\t// then event was started by some other action",
1058 "\t\t\t// which should manually trigger all the events..",
1059 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1064 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1065 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1069 "\t\t if (!_this.before_node_change( ) ) {",
1070 "\t\t\t _this.view.blockChanges = true;",
1071 "\t\t\t _this.selmodel.el.unselect_all();",
1072 "\t\t\t _this.view.blockChanges = false;",
1076 "\t\t if (_this.main_window.windowstate.file == null) {",
1077 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1081 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1082 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1085 "\t\t// -- it appears that the selection is not updated.",
1086 "\t\t // select the node...",
1087 "\t\t //_this.selmodel.el.set_selected(row);",
1089 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1091 "\t var snode = _this.selmodel.getSelectedNode();",
1092 "\t if (snode == null) {",
1094 "\t GLib.debug(\"selected rows < 1\");",
1095 "\t //??this.model.load( false);",
1096 "\t _this.node_selected(null);",
1104 "\t GLib.debug (\"calling left_tree.node_selected\");",
1105 "\t _this.node_selected(snode);",
1110 "\t // no need to scroll. it's in the view as we clicked on it.",
1111 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1118 "xtype" : "SingleSelection",
1119 "| JsRender.Node getNodeAt" : [
1122 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1124 " var a = tr.get_item();; ",
1125 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1128 " return (JsRender.Node)tr.get_item();",
1132 "| JsRender.Node? getSelectedNode" : [
1134 " if (this.el.selected_item == null) {",
1137 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1138 " return (JsRender.Node)tr.get_item();",
1145 "* pack" : "append_column",
1146 "bool expand" : true,
1147 "bool resizable" : true,
1152 "* prop" : "factory",
1156 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1158 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1159 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1162 "\tvar hbox = (Gtk.Box) expand.child;",
1165 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1166 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1168 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1169 "\tvar node = (JsRender.Node) lr.get_item();",
1171 " GLib.debug(\"node is %s\", node.get_type().name());",
1172 "// was item (1) in old layout",
1177 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1178 " var clsname = node.fqn();",
1180 " var clsb = clsname.split(\".\");",
1181 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1183 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1187 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1188 "\t\t img.set_from_file(fn);",
1191 "\t \t\timg.set_from_paintable(",
1192 "\t\t\t \tic.lookup_icon (",
1193 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1194 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1198 " \t} catch (GLib.Error e) {}",
1200 " expand.set_hide_expander( !node.hasChildren() );",
1201 " \texpand.set_list_row(lr);",
1203 " \tnode.bind_property(\"iconResourceName\",",
1204 " img, \"resource\",",
1205 " GLib.BindingFlags.SYNC_CREATE);",
1207 " \tnode.bind_property(\"nodeTitleProp\",",
1209 " GLib.BindingFlags.SYNC_CREATE);",
1210 " \tnode.bind_property(\"nodeTipProp\",",
1211 " lbl, \"tooltip_markup\",",
1212 " GLib.BindingFlags.SYNC_CREATE);",
1213 " \t// bind image...",
1221 "\tvar expand = new Gtk.TreeExpander();",
1223 "\texpand.set_indent_for_depth(true);",
1224 "\texpand.set_indent_for_icon(true);",
1225 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1226 "\tvar icon = new Gtk.Image();",
1227 "\tvar lbl = new Gtk.Label(\"\");",
1228 "\tlbl.use_markup = true;",
1229 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1231 "\ticon.margin_end = 4;",
1232 " \tlbl.justify = Gtk.Justification.LEFT;",
1233 " \tlbl.xalign = 0;",
1235 "//\tlistitem.activatable = true; ??",
1237 "\thbox.append(icon);",
1238 "\thbox.append(lbl);",
1239 "\texpand.set_child(hbox);",
1240 "\t((Gtk.ListItem)listitem).set_child(expand);",
1246 "xtype" : "SignalListItemFactory"
1249 "title" : "Property",
1250 "xtype" : "ColumnViewColumn"
1254 "* pack" : "append_column",
1255 "int fixed_width" : 25,
1259 "* prop" : "factory",
1264 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1265 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1266 "\tvar node = (JsRender.Node) lr.get_item();",
1269 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1270 "\timg.set_from_paintable(",
1271 "\t \tic.lookup_icon (",
1272 "\t \t\t\"list-add\", null, 16,1, ",
1273 "\t\t\t Gtk.TextDirection.NONE, 0",
1277 " \tvar fqn = node.fqn();",
1278 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1280 "\timg.set_visible(cn.size > 0 ? true : false);",
1289 "\tvar icon = new Gtk.Image();",
1291 "\t((Gtk.ListItem)listitem).set_child(icon);",
1296 "xtype" : "SignalListItemFactory"
1299 "string title" : "Add",
1300 "xtype" : "ColumnViewColumn"
1303 "string name" : "left-tree-view",
1304 "xtype" : "ColumnView",
1305 "| Gtk.Widget? getWidgetAt" : [
1306 "(double x, double in_y) {",
1309 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1310 " \tvar colview = gesture.widget;",
1311 " \tvar line_no = check_list_widget(colview, x,y);",
1312 " if (line_no > -1) {",
1313 " \t\tvar item = colview.model.get_item(line_no);",
1317 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1318 " var child = this.el.get_first_child(); ",
1319 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1320 " \tvar line_no = -1; ",
1321 " \tvar reading_header = true;",
1322 " \tvar curr_y = 0;",
1323 " \tvar header_height = 0;",
1325 " \twhile (child != null) {",
1326 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1327 "\t if (reading_header) {",
1330 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1331 "\t\t\t h += child.get_height();",
1332 "\t\t\t\t\tchild = child.get_next_sibling();",
1333 "\t\t\t\t\tcontinue;",
1335 "\t\t\t\t// should be columnlistview",
1336 "\t\t\t\tchild = child.get_first_child(); ",
1337 "\t\t\t GLib.debug(\"header height=%d\", h);",
1338 "\t\t\t\theader_height = h;",
1340 "\t\t\t\treading_header = false;",
1341 "\t\t\t\tcontinue;",
1345 "\t\t\tif (y < header_height) {",
1346 "\t\t \treturn null;",
1349 "\t\t\tvar hh = child.get_height();",
1350 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1351 "\t\t\tif (child.has_css_class(\"node-err\") || ",
1352 "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
1353 "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
1354 "\t\t\t\thh += 10;",
1357 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1358 "\t\t\t return (Gtk.Widget)child;",
1360 "\t\t curr_y += hh ;",
1362 "\t\t if (curr_y > y) {",
1363 "\t\t return null;",
1365 "\t child = child.get_next_sibling(); ",
1371 "| Gtk.Widget? getWidgetAtRow" : [
1375 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1376 " \tvar colview = gesture.widget;",
1377 " \tvar line_no = check_list_widget(colview, x,y);",
1378 " if (line_no > -1) {",
1379 " \t\tvar item = colview.model.get_item(line_no);",
1383 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1384 " var child = this.el.get_first_child(); ",
1385 " \tvar line_no = -1; ",
1386 " \tvar reading_header = true;",
1388 " \twhile (child != null) {",
1389 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1391 " \t if (reading_header) {",
1394 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1396 "\t\t\t\t\tchild = child.get_next_sibling();",
1397 "\t\t\t\t\tcontinue;",
1399 "\t\t\t\t// should be columnlistview",
1400 "\t\t\t\tchild = child.get_first_child(); ",
1404 "\t\t\t\treading_header = false;",
1405 "\t\t\t\tcontinue;",
1411 "\t\t\tif (line_no == row) {",
1412 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1413 "\t\t\t return (Gtk.Widget)child;",
1415 "\t child = child.get_next_sibling(); ",
1417 "\t\t//GLib.debug(\"Rturning null\");",
1422 "| int getColAt" : [
1423 "(double x, double y) {",
1426 "\tfrom \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1429 "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1430 "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1431 " var child = this.el.get_first_child(); ",
1435 "\twhile (child != null) {",
1437 "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1438 "\t\t\tchild = child.get_first_child();",
1442 "\t\t//child.get_allocation(out alloc);",
1443 "\t\tif (x < (child.get_width() + offx)) {",
1444 "\t\t\treturn col;",
1447 "\t\t//offx += child.get_width();",
1449 "\t\t//child = child.get_next_sibling();",
1457 "| int getRowAt" : [
1458 "(double x, double in_y, out string pos) {",
1465 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1466 " \tvar colview = gesture.widget;",
1467 " \tvar line_no = check_list_widget(colview, x,y);",
1468 " if (line_no > -1) {",
1469 " \t\tvar item = colview.model.get_item(line_no);",
1475 " \t\tGLib.debug(\"get Widget At Row x = %d y = %d\", (int) x, (int) in_y);",
1476 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1477 " var child = this.el.get_first_child(); ",
1478 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1479 " \tvar line_no = -1; ",
1480 " \tvar reading_header = true;",
1481 " \tvar real_y = 0;",
1482 " \tvar header_height = 0;",
1483 " \tpos = \"none\";",
1485 " \twhile (child != null) {",
1486 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1487 " \t if (reading_header) {",
1490 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1491 "\t\t\t h += child.get_height();",
1492 "\t\t\t\t\tchild = child.get_next_sibling();",
1493 "\t\t\t\t\tcontinue;",
1495 "\t\t\t\t// should be columnlistview",
1496 "\t\t\t\tchild = child.get_first_child(); ",
1497 "\t\t\t //GLib.debug(\"header height=%d\", h);",
1498 "\t\t\t\theader_height = h;",
1500 "\t\t\t\treading_header = false;",
1501 "\t\t\t\tcontinue;",
1505 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1506 " \t\t child = child.get_next_sibling();",
1510 "\t\t \tif (y < header_height) {",
1511 "\t\t \treturn -1;",
1515 "\t\t\tvar hh = child.get_height();",
1517 "\t\t\tif (child.has_css_class(\"node-err\") || ",
1518 "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
1519 "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
1520 "\t\t\t\thh += 10;",
1523 "\t\t\t//child.get_allocation(out alloc);",
1524 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1525 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1527 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1529 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1530 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1531 "\t\t \t\tpos = \"below\";",
1532 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1533 "\t \t\t\tpos = \"over\";",
1535 " \t\t\t\tpos = \"above\";",
1537 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1538 "\t\t\t return line_no;",
1542 "\t\t if (real_y + hh > y) {",
1546 "\t child = child.get_next_sibling(); ",
1556 "id" : "LeftTreeMenu",
1561 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1566 "bool has_frame" : false,
1567 "label" : "Delete Element",
1571 "_this.LeftTreeMenu.el.hide();",
1572 " _this.model.deleteSelected();",
1581 "bool has_frame" : false,
1582 "label" : "Save as Template",
1586 "_this.LeftTreeMenu.el.hide();",
1587 " DialogSaveTemplate.singleton().showIt(",
1588 " (Gtk.Window) _this.el.get_root (), ",
1589 " _this.main_window.windowstate.file.palete(), ",
1590 " _this.getActiveElement()",
1601 "bool has_frame" : false,
1602 "label" : "Save as Module",
1607 " _this.LeftTreeMenu.el.hide();",
1608 " var node = _this.getActiveElement();",
1611 " var sm = DialogSaveModule.singleton();",
1615 " (Gtk.Window) _this.el.get_root (), ",
1616 " _this.main_window.windowstate.project, ",
1620 " gtk4 migration - disabled this part.. probably not used muchanyway",
1623 " if (name.length < 1) {",
1627 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1628 " node.items.clear();",
1631 " var s = _this.view.el.get_selection();",
1633 " print(\"GET SELECTED?\");",
1634 " Gtk.TreeIter iter;",
1635 " Gtk.TreeModel mod;",
1638 " if (!s.get_selected(out mod, out iter)) {",
1639 " return; // nothing seleted..",
1641 " Gtk.TreeIter citer;",
1642 " var n_cn = mod.iter_n_children(iter) -1;",
1643 " for (var i = n_cn; i > -1; i--) {",
1644 " mod.iter_nth_child(out citer, iter, i);",
1647 " print(\"removing node from Tree\\n\"); ",
1649 " _this.model.el.remove(ref citer);",
1651 " _this.changed();",
1652 " _this.node_selected(node, \"tree\");",
1667 "xtype" : "ScrolledWindow"
1671 "| JsRender.JsRender getActiveFile" : [
1673 " return this.main_window.windowstate.file;",
1678 "| JsRender.Node? getActiveElement" : [
1679 " () { // return path to actie node.",
1682 "\treturn _this.selmodel.getSelectedNode();",
1688 "| void onresize" : [
1692 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1693 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1698 "| void removeErrors" : [
1700 "\tvar child = this.view.el.get_first_child(); ",
1702 "\tvar reading_header = true;",
1704 "\twhile (child != null) {",
1705 "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1707 "\t if (reading_header) {",
1710 "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1712 "\t\t\t\tchild = child.get_next_sibling();",
1713 "\t\t\t\tcontinue;",
1715 "\t\t\t// should be columnlistview",
1716 "\t\t\tchild = child.get_first_child(); ",
1720 "\t\t\treading_header = false;",
1724 "\t \tif (child.has_css_class(\"node-err\")) {",
1725 "\t\t\tchild.remove_css_class(\"node-err\");",
1727 "\t\tif (child.has_css_class(\"node-warn\")) {",
1728 "\t\t\tchild.remove_css_class(\"node-warn\");",
1731 "\t\tif (child.has_css_class(\"node-depr\")) {",
1732 "\t\t\tchild.remove_css_class(\"node-depr\");",
1735 " child = child.get_next_sibling(); ",
1737 "\t//GLib.debug(\"Rturning null\");",
1741 "| void updateErrors" : [
1743 "\tvar file = this.getActiveFile();",
1744 "\tif (file == null) {",
1748 "\tvar ar = file.getErrors();",
1749 "\tif (ar == null || ar.size < 1) {",
1750 "\t\tif (this.last_error_counter != file.error_counter) {",
1751 "\t\t\tthis.removeErrors();",
1754 "\t\tthis.last_error_counter = file.error_counter ;",
1758 " \tif (this.last_error_counter == file.error_counter) {",
1761 "\tthis.removeErrors();",
1763 "\tforeach(var diag in ar) { ",
1766 "// print(\"get inter\\n\");",
1767 "\t var node= file.lineToNode( (int)diag.range.start.line) ;",
1768 "\t if (node == null) {",
1771 " \tvar row = _this.model.nodeToRow(node);",
1772 " \tif (row < 0) {",
1775 " \tvar w = this.view.getWidgetAtRow(row);",
1776 " \tif (w == null) {",
1779 "\t\t// always show errors.",
1780 "\t\tvar ed = diag.category.down();",
1781 "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1784 "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1785 "\t\t\tw.remove_css_class(\"node-warn\");",
1787 "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1788 "\t\t\tw.remove_css_class(\"node-depr\");",
1790 "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1791 "\t\t\tw.add_css_class(\"node-\" + ed);",
1800 "name" : "WindowLeftTree"