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",
22 "xtype" : "SignalListItemFactory"
29 "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
30 "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
31 "bool has_frame" : true,
32 "bool hexpand" : true,
33 "bool vexpand" : true,
37 "# bool blockChanges" : false,
38 "$ JsRender.Node? dragNode" : "null",
39 "$ string lastEventSource" : "\"\"",
44 " this.css = new Gtk.CssProvider();",
46 "\t\tthis.css.load_from_string(\"",
47 "#left-tree-view { font-size: 12px;}\t",
48 ".drag-over { background-color:#88a3bc; }",
50 " border-bottom-width: 5px; ",
51 " border-bottom-style: solid;",
52 " border-bottom-color: #88a3bc;",
55 " border-top-width: 5px;",
56 " border-top-style: solid;",
57 " border-top-color: #88a3bc;",
59 "#left-tree-view indent {",
60 "-gtk-icon-size : 2px;",
62 "#left-tree-view indent:nth-last-child(2) {",
67 "\tGtk.StyleContext.add_provider_for_display(",
68 "\t\tthis.el.get_display(),",
70 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
78 "Boolean id" : "view",
79 "Gtk.CssProvider css" : "",
80 "bool button_is_pressed" : false,
81 "bool headers_visible" : false,
82 "bool hexpand" : false,
83 "bool vexpand" : true,
89 "(n_press, x, y) => {",
91 " //console.log(\"button press?\");",
93 " //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
97 " _this.view.button_is_pressed = true;",
99 " _this.view.lastEventSource = \"tree\";",
100 " if (! _this.before_node_change() ) {",
101 " \tGLib.debug(\"before_node_change return false\");",
105 "\t // nothing there -show dialog",
106 " if (_this.model.el.get_n_items() < 1) {",
107 "\t _this.main_window.windowstate.showAddObject(_this.view.el, null);",
108 " GLib.debug(\"no items\");",
112 " var row = _this.view.getRowAt(x,y, out pos );",
114 "\t GLib.debug(\"no row selected items\");",
118 " var node = _this.selmodel.getNodeAt(row);",
119 " if (node == null) {",
120 " \tGLib.warning(\"No node found at row %d\", row);",
126 " if (_this.view.getColAt(x,y) > 0 ) {",
127 "\t GLib.debug(\"add colum clicked.\");",
128 " var fqn = node.fqn();",
129 " \tvar cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
130 " \t\tif (cn.size < 1) {",
134 "\t\t_this.main_window.windowstate.leftTreeBeforeChange();",
135 "\t\t//_this.view.el.get_selection().select_path(res);",
136 "\t\tGLib.debug(\"Button Pressed - start show window\");",
137 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, node);",
138 "\t\tGLib.debug(\"Button Pressed - finsihed show window\");",
148 "(n_press, x, y) => {",
150 " _this.view.button_is_pressed = false;",
157 "xtype" : "GestureClick"
163 "(n_press, x, y) => {",
168 " if (_this.model.el.get_n_items() < 1) {",
170 " GLib.debug(\"no items\");",
174 " var row = _this.view.getRowAt(x,y, out pos );",
176 "\t GLib.debug(\"no row selected items\");",
180 " var node = _this.selmodel.getNodeAt(row);",
181 " if (node == null) {",
182 " \tGLib.warning(\"No node found at row %d\", row);",
185 "\t_this.model.selectNode(node);",
189 "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());",
190 "\t//_this.deletemenu.el.set_parent(_this.view.el);",
191 "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
194 "\t//Gtk.Allocation rect;",
195 "\t//_this.view.el.get_allocation(out rect);",
196 " \t//_this.deletemenu.el.set_has_arrow(false);",
197 "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
200 "\t_this.LeftTreeMenu.el.set_offset( ",
202 "\t\t\t(int)y - (int)_this.view.el.get_height());",
204 " _this.LeftTreeMenu.el.popup();",
211 "xtype" : "GestureClick"
214 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
219 "\tGLib.debug(\"SOURCE: drag-begin\");",
221 " // find what is selected in our tree...",
222 " var data = _this.selmodel.getSelectedNode();",
223 "\tif (data == null) {",
226 "\t_this.view.dragNode = data;",
227 " var xname = data.fqn();",
228 " GLib.debug (\"XNAME IS %s\", xname);",
230 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
233 " var paintable = new Gtk.WidgetPaintable(widget);",
234 " this.el.set_icon(paintable, 0,0);",
240 "(drag, reason) => {",
242 "\t_this.view.dragNode = null;",
248 "(drag, delete_data) => {",
250 "_this.view.dragNode = null;",
259 "///\t( drag_context, data, info, time) => {",
262 "\t//print(\"drag-data-get\");",
263 " \tvar ndata = _this.selmodel.getSelectedNode();",
264 "\tif (ndata == null) {",
265 "\t \tGLib.debug(\"return empty string - no selection..\");",
271 "\t//data.set_text(tp,tp.length); ",
273 "\tvar \tstr = ndata.toJsonString();",
274 "\tGLib.debug(\"prepare store: %s\", str);",
275 "\tGLib.Value ov = GLib.Value(typeof(string));",
276 "\tov.set_string(str);",
277 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
279 "\tGLib.Value v = GLib.Value(typeof(string));",
280 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
282 "\t\tcont.get_value(ref v);",
285 "\tGLib.debug(\"set %s\", v.get_string());",
294 "xtype" : "DragSource"
300 "(keyval, keycode, state) => {",
304 "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) {",
308 "\t_this.model.deleteSelected();",
315 "xtype" : "EventControllerKey"
320 "new Gtk.DropTarget ( typeof(string) ,",
321 "\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE )"
323 "Gtk.Widget? highlightWidget" : "null",
324 "JsRender.Node? lastDragNode" : "null",
330 "\tGLib.debug(\"got DropTarget:accept\");",
332 "// NOT REALLY NEEDED? = put stuff in drop?",
335 "/* ( ctx, x, y, time) => {",
336 " //Seed.print(\"TARGET: drag-drop\");",
339 " var src = Gtk.drag_get_source_widget(ctx);",
341 " if (src != this.el) {",
345 " this.drag_in_motion = false; ",
346 " // request data that will be recieved by the recieve... ",
347 " Gtk.drag_get_data",
349 " this.el, // will receive 'drag-data-received' signal ",
350 " ctx, // represents the current state of the DnD ",
351 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
352 " time // time stamp ",
356 " // No target offered by source => error",
362 " // handle drop around self..",
366 " //print(\"GETTING POS\");",
367 " var targetData = \"\";",
369 " Gtk.TreePath path;",
370 " Gtk.TreeViewDropPosition pos;",
371 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
373 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
374 " var isEmpty = false;",
375 " if (_this.model.el.iter_n_children(null) < 1) {",
376 " print(\"got NO children?\\n\");",
377 " isOver = true; //??? ",
379 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
384 " //var action = Gdk.DragAction.COPY;",
385 " // unless we are copying!!! ctl button..",
387 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
388 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
389 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
392 " if (_this.model.el.iter_n_children(null) < 1) {",
393 " // no children.. -- asume it's ok..",
395 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
397 " // continue through to allow drop...",
405 " //print(\"ISOVER? \" + isOver);",
408 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
409 " return true; // not over apoint!?! - no action on drop or motion..",
412 " // drag node is parent of child..",
413 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
414 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
416 " // nned to check a few here..",
417 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
418 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
419 " //Gtk.TreeViewDropPosition.AFTER",
420 " //Gtk.TreeViewDropPosition.BEFORE",
422 " // locally dragged items to not really use the ",
423 " var selection_text = this.dragData;",
427 " if (selection_text == null || selection_text.length < 1) {",
428 " //print(\"Error - drag selection text returned NULL\");",
430 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
431 " return true; /// -- fixme -- this is not really correct..",
434 " // see if we are dragging into ourself?",
435 " print (\"got selection text of \" + selection_text);",
437 " var target_path = path.to_string();",
438 " //print(\"target_path=\"+target_path);",
441 " if (selection_text == target_path) {",
442 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
444 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
446 " return true; /// -- fixme -- this is not really correct..",
451 " //print(\"DUMPING DATA\");",
452 " //console.dump(data);",
455 " //print(data.path.to_string() +' => '+ data.pos);",
457 " // dropList is a list of xtypes that this node could be dropped on.",
458 " // it is set up when we start to drag..",
461 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
463 " print(\"targetDAta: \" + targetData +\"\\n\");",
465 " if (targetData.length < 1) {",
466 " //print(\"Can not find drop node path\");",
468 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
474 " // continue on to allow drop..",
476 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
479 " var delete_selection_data = false;",
481 " if (action == Gdk.DragAction.ASK) {",
482 " // Ask the user to move or copy, then set the ctx action. ",
485 " if (action == Gdk.DragAction.MOVE) {",
486 " delete_selection_data = true;",
489 " // drag around.. - reorder..",
490 " _this.model.moveNode(targetData, action);",
496 " // we can send stuff to souce here...",
499 "// do we always say failure, so we handle the reall drop?",
500 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
518 "\tthis.addHighlight(null,\"\");",
520 " \tvar is_shift = _this.keystate.is_shift > 0;",
522 " \tvar pos = \"\";",
523 " \t// -- get position..",
524 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
525 "\t\t// still dragging same node",
527 "\t\tthis.lastDragNode = new JsRender.Node(); ",
528 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
533 " var dropNode = new JsRender.Node(); ",
534 "\tdropNode.loadFromJsonString(v.get_string(), 1);",
535 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
537 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
539 " if (_this.model.el.n_items < 1) {",
540 " \t// FIXME check valid drop types?",
541 " \tif (!drop_on_to.contains(\"*top\")) {",
542 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
543 "\t\t\treturn false;\t",
545 "\t\t// add new node to top..",
548 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
549 " \t_this.main_window.windowstate.file.tree = dropNode; ",
552 "\t\tm.append(dropNode);",
553 "\t\t_this.model.selectNode(dropNode); \t",
554 "\t\t_this.changed();",
555 "\t\treturn true; // no need to highlight?",
561 "\tvar row = _this.view.getRowAt(x,y, out pos);",
563 "\t\treturn false; //Gdk.DragAction.COPY;",
565 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
567 "\tvar node = (JsRender.Node)tr.get_item();",
569 " \tif (pos == \"above\" || pos == \"below\") {",
570 "\t\tif (node.parent == null) {",
571 "\t\t\tpos = \"over\";",
573 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
574 "\t\t\t\tpos = \"over\";",
576 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
577 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
578 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
579 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
580 " \t\t\t\t\t\treturn false;\t",
590 " \tif (pos == \"over\") {",
591 "\t \tif (!drop_on_to.contains(node.fqn())) {",
592 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
593 "\t\t\treturn false;",
596 "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
597 " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
598 "\t\t\treturn false;\t",
603 " \t\tcase \"over\":",
604 "\t \t\tnode.appendChild(dropNode);",
605 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
606 "\t\t \t\t_this.model.selectNode(null); ",
607 "\t\t \t\t_this.view.dragNode.remove();",
611 " \t\t\t_this.model.selectNode(dropNode); ",
613 " \t\t\t_this.changed();\t\t\t\t \t\t",
614 "\t \t\treturn true;",
616 " \t\tcase \"above\":",
617 " \t\t\tGLib.debug(\"Above - insertBefore\");",
619 "\t\t\tnode.parent.insertBefore(dropNode, node);",
620 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
621 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
622 "\t\t \t\t_this.view.dragNode.remove();",
625 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
626 " \t\t\t_this.changed();",
627 " \t\t\treturn true;",
629 " \t\tcase \"below\":",
630 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
631 "\t \t\tif (is_shift && _this.view.dragNode != null) {",
632 "\t\t \t\t_this.model.selectNode(null); \t \t\t",
633 "\t\t \t\t_this.view.dragNode.remove();",
637 " \t\t\tnode.parent.insertAfter(dropNode, node);",
638 " \t\t\t_this.model.selectNode(dropNode);\t",
639 " \t\t\t_this.changed();",
640 " \t\t\t// select it",
641 " \t\t\treturn true;",
644 " \t\t\t// should not happen",
645 " \t\t\treturn false;",
658 "\tthis.addHighlight(null,\"\");",
666 "\tvar is_shift = _this.keystate.is_shift > 0;",
668 "\tGLib.debug(\"shift is %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
669 "\tstring pos; // over / before / after..",
671 " //GLib.debug(\"got drag motion\");",
673 " GLib.Value v = GLib.Value(typeof(string));",
674 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
675 " \tvar cont = this.el.current_drop.get_drag().content ;",
677 " \t\tcont.get_value(ref v);",
678 "\t} catch (GLib.Error e) {",
679 "\t GLib.debug(\"failed to get drag value\");",
680 "\t\treturn Gdk.DragAction.COPY;\t ",
684 "\t//GLib.debug(\"got %s\", v.get_string());",
686 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
687 "\t\t// still dragging same node",
689 "\t\tthis.lastDragNode = new JsRender.Node(); ",
690 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
694 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
695 "\t\t\t\tthis.lastDragNode.fqn());",
697 " string[] str = {};",
698 " foreach(var dp in drop_on_to) {",
701 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
704 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
706 " if (_this.model.el.n_items < 1) {",
707 " \t// FIXME check valid drop types?",
708 " \tif (drop_on_to.contains(\"*top\")) {",
709 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
711 "\t\t\tthis.addHighlight(null, \"\");\t\t",
714 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
719 " \tGLib.debug(\"check is over\");",
721 " // if path of source and dest are inside each other..",
722 " // need to add source info to drag?",
724 " \tvar row = _this.view.getRowAt(x,y, out pos);",
727 "\t\tthis.addHighlight(null, \"\");\t",
728 "\t \treturn Gdk.DragAction.COPY;",
730 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
732 "\tvar node = (JsRender.Node)tr.get_item();",
734 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
737 " \tif (pos == \"above\" || pos == \"below\") {",
738 "\t\tif (node.parent == null) {",
739 "\t\t\tGLib.debug(\"no parent try center\");",
740 "\t\t\tpos = \"over\";",
743 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
744 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
745 "\t \t\t\tpos = \"over\";",
747 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
748 "\t\t\t\tif (_this.view.dragNode != null && is_shift) {",
749 "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
750 "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
751 "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
752 "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
765 " \tif (pos == \"over\") {",
766 "\t \tif (!drop_on_to.contains(node.fqn())) {",
767 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
768 "\t\t\tthis.addHighlight(null, \"\"); ",
769 "\t\t\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
771 "\t\tif (_this.view.dragNode != null && is_shift) {",
772 " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
773 "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
774 " \t\t\t\tthis.addHighlight(null, \"\");",
775 " \t\t\t\treturn Gdk.DragAction.COPY;\t",
782 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
783 "\tvar w = _this.view.getWidgetAt(x,y);",
784 "\tthis.addHighlight(w, pos); ",
785 "\treturn is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;\t\t",
789 "string lastDragString" : "\"\"",
790 "xtype" : "DropTarget",
791 "| void addHighlight" : [
792 "(Gtk.Widget? w, string hl) {",
793 "\tif (this.highlightWidget != null) {",
794 "\t\tvar ww = this.highlightWidget;",
795 "\t\tGLib.debug(\"clear drag from previous highlight\");",
796 "\t\tif (ww.has_css_class(\"drag-below\")) {",
797 "\t\t\t ww.remove_css_class(\"drag-below\");",
799 "\t\tif (ww.has_css_class(\"drag-above\")) {",
800 "\t\t\t ww.remove_css_class(\"drag-above\");",
802 "\t\tif (ww.has_css_class(\"drag-over\")) {",
803 "\t\t\t ww.remove_css_class(\"drag-over\");",
806 "\tif (w != null) {",
807 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
808 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
809 "\t\t\tw.add_css_class(\"drag-\" + hl);",
812 "\tthis.highlightWidget = w;",
823 "* ctor" : "this.updateModel(null)",
826 "xtype" : "TreeListModel",
827 "| Gtk.TreeListModel updateModel" : [
828 "(GLib.ListStore? m) {",
829 "\tthis.el = new Gtk.TreeListModel(",
830 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
831 "\t\tfalse, // passthru",
832 "\t\ttrue, // autexpand",
834 "\t\t\treturn ((JsRender.Node)item).childstore;",
838 "\tif (_this.selmodel.el == null) {",
839 "\t\treturn this.el;",
841 "\t_this.selmodel.el.set_model(this.el);",
845 "| void deleteSelected" : [
850 "\tvar node = _this.selmodel.getSelectedNode();",
853 " if (node == null) {",
854 " \tGLib.debug(\"delete Selected - no node slected?\");",
857 " _this.selmodel.el.unselect_all();",
860 " \tGLib.debug(\"delete Selected - done\");",
863 " print(\"DELETE SELECTED?\");",
864 " //_this.view.blockChanges = true;",
865 " print(\"GET SELECTION?\");",
867 " var s = _this.view.el.get_selection();",
869 " print(\"GET SELECTED?\");",
870 " Gtk.TreeIter iter;",
871 " Gtk.TreeModel mod;",
874 " if (!s.get_selected(out mod, out iter)) {",
875 " return; // nothing seleted..",
880 " this.activePath= \"\"; ",
881 " print(\"GET vnode value?\");",
883 " GLib.Value value;",
884 " this.el.get_value(iter, 2, out value);",
885 " var data = (JsRender.Node)(value.get_object());",
886 " print(\"removing node from Render\\n\");",
887 " if (data.parent == null) {",
888 " _this.main_window.windowstate.file.tree = null;",
892 " print(\"removing node from Tree\\n\"); ",
893 " s.unselect_all();",
894 " this.el.remove(ref iter);",
904 " this.activePath= \"\"; // again!?!? ",
905 " //this.changed(null,true);",
909 " _this.view.blockChanges = false;",
914 "| void loadFile" : [
915 "(JsRender.JsRender f) {",
916 " //console.dump(f);",
918 " _this.drop.highlightWidget = null;",
920 " var m = (GLib.ListStore) this.el.model;",
922 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
924 " _this.main_window.windowstate.file = f;",
927 " if (f.tree == null) {",
929 "\t f.loadItems( );",
930 " } catch (Error e) {",
934 " // if it's still null?",
935 " if (f.tree == null) {",
936 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
940 " \tm.append(f.tree);",
944 " if (f.tree.readItems().size < 1) {",
947 " //this.get('/Window.leftvpaned').el.set_position(80);",
948 " // select first...",
949 " _this.view.el.set_cursor( ",
950 " new Gtk.TreePath.from_string(\"0\"), null, false);",
954 " //this.get('/Window.leftvpaned').el.set_position(200);",
960 " //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
962 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
970 "| void selectNode" : [
971 "(JsRender.Node node) ",
974 "\tvar s = (Gtk.SingleSelection)_this.view.el.model;",
975 "\tfor (var i = 0; i < s.n_items; i++) {",
976 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
977 "\t\tvar lr = (Gtk.TreeListRow)s.get_item(i);",
978 "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
979 "\t\tif (((JsRender.Node)lr.get_item()).oid == node.oid) {",
985 "\t\t// select none?",
986 "\t\tGLib.debug(\"Could not find node\");",
989 "\tGLib.debug(\"Select %d\", row);",
990 "\ts.set_selected(row);",
991 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
992 "\t//_this.node_selected(node);\t\t\t",
1000 "selection_changed" : [
1001 "(position, n_items) => {",
1005 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1006 "\t\t\t// then event was started by some other action",
1007 "\t\t\t// which should manually trigger all the events..",
1008 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1013 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1014 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
1018 "\t\t if (!_this.before_node_change( ) ) {",
1019 "\t\t\t _this.view.blockChanges = true;",
1020 "\t\t\t _this.selmodel.el.unselect_all();",
1021 "\t\t\t _this.view.blockChanges = false;",
1025 "\t\t if (_this.main_window.windowstate.file == null) {",
1026 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
1030 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
1031 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1034 "\t\t// -- it appears that the selection is not updated.",
1035 "\t\t // select the node...",
1036 "\t\t //_this.selmodel.el.set_selected(row);",
1038 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1040 "\t var snode = _this.selmodel.getSelectedNode();",
1041 "\t if (snode == null) {",
1043 "\t GLib.debug(\"selected rows < 1\");",
1044 "\t //??this.model.load( false);",
1045 "\t _this.node_selected(null);",
1053 "\t GLib.debug (\"calling left_tree.node_selected\");",
1054 "\t _this.node_selected(snode);",
1059 "\t // no need to scroll. it's in the view as we clicked on it.",
1060 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1067 "xtype" : "SingleSelection",
1068 "| JsRender.Node getNodeAt" : [
1071 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1073 " var a = tr.get_item();; ",
1074 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1077 " return (JsRender.Node)tr.get_item();",
1081 "| JsRender.Node? getSelectedNode" : [
1083 " if (this.el.selected_item == null) {",
1086 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1087 " return (JsRender.Node)tr.get_item();",
1094 "* pack" : "append_column",
1095 "bool expand" : true,
1096 "bool resizable" : true,
1101 "* prop" : "factory",
1105 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1107 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1108 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1111 "\tvar hbox = (Gtk.Box) expand.child;",
1114 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1115 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1117 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1118 "\tvar node = (JsRender.Node) lr.get_item();",
1120 " GLib.debug(\"node is %s\", node.get_type().name());",
1121 "// was item (1) in old layout",
1126 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1127 " var clsname = node.fqn();",
1129 " var clsb = clsname.split(\".\");",
1130 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1132 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1136 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1137 "\t\t img.set_from_file(fn);",
1140 "\t \t\timg.set_from_paintable(",
1141 "\t\t\t \tic.lookup_icon (",
1142 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1143 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1147 " \t} catch (GLib.Error e) {}",
1149 " expand.set_hide_expander( !node.hasChildren() );",
1150 " \texpand.set_list_row(lr);",
1152 " \tnode.bind_property(\"iconFilename\",",
1154 " GLib.BindingFlags.SYNC_CREATE);",
1156 " \tnode.bind_property(\"nodeTitleProp\",",
1158 " GLib.BindingFlags.SYNC_CREATE);",
1159 " \tnode.bind_property(\"nodeTipProp\",",
1160 " lbl, \"tooltip_markup\",",
1161 " GLib.BindingFlags.SYNC_CREATE);",
1162 " \t// bind image...",
1170 "\tvar expand = new Gtk.TreeExpander();",
1172 "\texpand.set_indent_for_depth(true);",
1173 "\texpand.set_indent_for_icon(true);",
1174 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1175 "\tvar icon = new Gtk.Image();",
1176 "\tvar lbl = new Gtk.Label(\"\");",
1177 "\tlbl.use_markup = true;",
1178 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1180 "\ticon.margin_end = 4;",
1181 " \tlbl.justify = Gtk.Justification.LEFT;",
1182 " \tlbl.xalign = 0;",
1184 "//\tlistitem.activatable = true; ??",
1186 "\thbox.append(icon);",
1187 "\thbox.append(lbl);",
1188 "\texpand.set_child(hbox);",
1189 "\t((Gtk.ListItem)listitem).set_child(expand);",
1195 "xtype" : "SignalListItemFactory"
1198 "title" : "Property",
1199 "xtype" : "ColumnViewColumn"
1203 "* pack" : "append_column",
1204 "int fixed_width" : 25,
1208 "* prop" : "factory",
1213 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1214 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1215 "\tvar node = (JsRender.Node) lr.get_item();",
1218 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1219 "\timg.set_from_paintable(",
1220 "\t \tic.lookup_icon (",
1221 "\t \t\t\"list-add\", null, 16,1, ",
1222 "\t\t\t Gtk.TextDirection.NONE, 0",
1226 " \tvar fqn = node.fqn();",
1227 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1229 "\timg.set_visible(cn.size > 0 ? true : false);",
1238 "\tvar icon = new Gtk.Image();",
1240 "\t((Gtk.ListItem)listitem).set_child(icon);",
1245 "xtype" : "SignalListItemFactory"
1248 "string title" : "Add",
1249 "xtype" : "ColumnViewColumn"
1257 "(keyval, keycode, state) => {",
1259 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
1260 " \t\tthis.is_shift = 1;",
1267 "(keyval, keycode, state) => {",
1268 "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int) keycode, state);",
1269 " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
1270 " \t\tthis.is_shift = 0;",
1272 "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
1279 "xtype" : "EventControllerKey"
1282 "string name" : "left-tree-view",
1283 "xtype" : "ColumnView",
1284 "| Gtk.Widget? getWidgetAt" : [
1285 "(double x, double in_y) {",
1288 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1289 " \tvar colview = gesture.widget;",
1290 " \tvar line_no = check_list_widget(colview, x,y);",
1291 " if (line_no > -1) {",
1292 " \t\tvar item = colview.model.get_item(line_no);",
1296 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1297 " var child = this.el.get_first_child(); ",
1298 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1299 " \tvar line_no = -1; ",
1300 " \tvar reading_header = true;",
1301 " \tvar curr_y = 0;",
1302 " \tvar header_height = 0;",
1304 " \twhile (child != null) {",
1305 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1306 "\t if (reading_header) {",
1309 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1310 "\t\t\t h += child.get_height();",
1311 "\t\t\t\t\tchild = child.get_next_sibling();",
1312 "\t\t\t\t\tcontinue;",
1314 "\t\t\t\t// should be columnlistview",
1315 "\t\t\t\tchild = child.get_first_child(); ",
1316 "\t\t\t GLib.debug(\"header height=%d\", h);",
1317 "\t\t\t\theader_height = h;",
1319 "\t\t\t\treading_header = false;",
1324 "\t\t\tif (y < header_height) {",
1325 "\t\t \treturn null;",
1328 "\t\t\tvar hh = child.get_height();",
1329 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1331 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1332 "\t\t\t return (Gtk.Widget)child;",
1334 "\t\t curr_y += hh ;",
1336 "\t\t if (curr_y > y) {",
1337 "\t\t return null;",
1339 "\t child = child.get_next_sibling(); ",
1345 "| Gtk.Widget? getWidgetAtRow" : [
1349 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1350 " \tvar colview = gesture.widget;",
1351 " \tvar line_no = check_list_widget(colview, x,y);",
1352 " if (line_no > -1) {",
1353 " \t\tvar item = colview.model.get_item(line_no);",
1357 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1358 " var child = this.el.get_first_child(); ",
1359 " \tvar line_no = -1; ",
1360 " \tvar reading_header = true;",
1362 " \twhile (child != null) {",
1363 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1365 " \t if (reading_header) {",
1368 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1370 "\t\t\t\t\tchild = child.get_next_sibling();",
1371 "\t\t\t\t\tcontinue;",
1373 "\t\t\t\t// should be columnlistview",
1374 "\t\t\t\tchild = child.get_first_child(); ",
1378 "\t\t\t\treading_header = false;",
1385 "\t\t\tif (line_no == row) {",
1386 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1387 "\t\t\t return (Gtk.Widget)child;",
1389 "\t child = child.get_next_sibling(); ",
1391 "\t\t//GLib.debug(\"Rturning null\");",
1396 "| int getColAt" : [
1397 "(double x, double y) {",
1400 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1403 "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1404 "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1405 " var child = this.el.get_first_child(); ",
1409 " \twhile (child != null) {",
1411 "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1412 "\t\t\t\tchild = child.get_first_child();",
1413 "\t\t\t\tcontinue;",
1416 "\t\t\t//child.get_allocation(out alloc);",
1417 "\t\t\tif (x < (child.get_width() + offx)) {",
1418 "\t\t\t\treturn col;",
1421 "\t\t\t//offx += child.get_width();",
1423 "\t\t\t//child = child.get_next_sibling();",
1431 "| int getRowAt" : [
1432 "(double x, double in_y, out string pos) {",
1439 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1440 " \tvar colview = gesture.widget;",
1441 " \tvar line_no = check_list_widget(colview, x,y);",
1442 " if (line_no > -1) {",
1443 " \t\tvar item = colview.model.get_item(line_no);",
1449 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
1450 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1451 " var child = this.el.get_first_child(); ",
1452 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1453 " \tvar line_no = -1; ",
1454 " \tvar reading_header = true;",
1455 " \tvar real_y = 0;",
1456 " \tvar header_height = 0;",
1457 " \tpos = \"none\";",
1459 " \twhile (child != null) {",
1460 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1461 " \t if (reading_header) {",
1464 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1465 "\t\t\t h += child.get_height();",
1466 "\t\t\t\t\tchild = child.get_next_sibling();",
1467 "\t\t\t\t\tcontinue;",
1469 "\t\t\t\t// should be columnlistview",
1470 "\t\t\t\tchild = child.get_first_child(); ",
1471 "\t\t\t GLib.debug(\"header height=%d\", h);",
1472 "\t\t\t\theader_height = h;",
1474 "\t\t\t\treading_header = false;",
1478 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1479 " \t\t child = child.get_next_sibling();",
1483 "\t\t \tif (y < header_height) {",
1484 "\t\t \treturn -1;",
1488 "\t\t\tvar hh = child.get_height();",
1489 "\t\t\t//child.get_allocation(out alloc);",
1490 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1491 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1493 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1495 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1496 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1497 "\t\t \t\tpos = \"below\";",
1498 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1499 "\t \t\t\tpos = \"over\";",
1501 " \t\t\t\tpos = \"above\";",
1503 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1504 "\t\t\t return line_no;",
1508 "\t\t if (real_y + hh > y) {",
1512 "\t child = child.get_next_sibling(); ",
1522 "id" : "LeftTreeMenu",
1527 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1532 "label" : "Delete Element",
1536 "_this.LeftTreeMenu.el.hide();",
1537 " _this.model.deleteSelected();",
1546 "label" : "Save as Template",
1550 "_this.LeftTreeMenu.el.hide();",
1551 " DialogSaveTemplate.singleton().showIt(",
1552 " (Gtk.Window) _this.el.get_root (), ",
1553 " _this.main_window.windowstate.file.palete(), ",
1554 " _this.getActiveElement()",
1565 "label" : "Save as Module",
1570 " _this.LeftTreeMenu.el.hide();",
1571 " var node = _this.getActiveElement();",
1574 " var sm = DialogSaveModule.singleton();",
1578 " (Gtk.Window) _this.el.get_root (), ",
1579 " _this.main_window.windowstate.project, ",
1583 " gtk4 migration - disabled this part.. probably not used muchanyway",
1586 " if (name.length < 1) {",
1590 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1591 " node.items.clear();",
1594 " var s = _this.view.el.get_selection();",
1596 " print(\"GET SELECTED?\");",
1597 " Gtk.TreeIter iter;",
1598 " Gtk.TreeModel mod;",
1601 " if (!s.get_selected(out mod, out iter)) {",
1602 " return; // nothing seleted..",
1604 " Gtk.TreeIter citer;",
1605 " var n_cn = mod.iter_n_children(iter) -1;",
1606 " for (var i = n_cn; i > -1; i--) {",
1607 " mod.iter_nth_child(out citer, iter, i);",
1610 " print(\"removing node from Tree\\n\"); ",
1612 " _this.model.el.remove(ref citer);",
1614 " _this.changed();",
1615 " _this.node_selected(node, \"tree\");",
1630 "xtype" : "ScrolledWindow"
1634 "| JsRender.JsRender getActiveFile" : [
1636 " return this.main_window.windowstate.file;",
1640 "| JsRender.Node? getActiveElement" : [
1641 " () { // return path to actie node.",
1644 "\treturn _this.selmodel.getSelectedNode();",
1650 "| void onresize" : [
1654 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1655 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1662 "name" : "WindowLeftTree"