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"
30 " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
33 "bool has_frame" : true,
34 "bool hexpand" : true,
35 "bool vexpand" : true,
39 "# bool blockChanges" : false,
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;",
60 "#left-tree-view indent {",
61 "-gtk-icon-size : 2px;",
65 "\tGtk.StyleContext.add_provider_for_display(",
66 "\t\tthis.el.get_display(),",
68 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
76 "Boolean id" : "view",
77 "Gtk.CssProvider css" : "",
78 "bool button_is_pressed" : false,
79 "bool headers_visible" : false,
80 "bool hexpand" : false,
81 "bool vexpand" : true,
87 "(n_press, x, y) => {",
89 " //console.log(\"button press?\");",
91 " //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
95 " _this.view.button_is_pressed = true;",
97 " _this.view.lastEventSource = \"tree\";",
98 " if (! _this.before_node_change() ) {",
99 " \tGLib.debug(\"before_node_change return false\");",
103 "\t // nothing there -show dialog",
104 " if (_this.model.el.get_n_items() < 1) {",
105 "\t _this.main_window.windowstate.showAddObject(_this.view.el, null);",
106 " GLib.debug(\"no items\");",
110 " var row = _this.view.getRowAt(x,y, out pos );",
112 "\t GLib.debug(\"no row selected items\");",
116 " var node = _this.selmodel.getNodeAt(row);",
117 " if (node == null) {",
118 " \tGLib.warning(\"No node found at row %d\", row);",
124 " if (_this.view.getColAt(x,y) > 0 ) {",
125 "\t GLib.debug(\"add colum clicked.\");",
126 " var fqn = node.fqn();",
127 " \tvar cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
128 " \t\tif (cn.size < 1) {",
132 "\t\t_this.main_window.windowstate.leftTreeBeforeChange();",
133 "\t\t//_this.view.el.get_selection().select_path(res);",
134 "\t\tGLib.debug(\"Button Pressed - start show window\");",
135 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, node);",
136 "\t\tGLib.debug(\"Button Pressed - finsihed show window\");",
146 "(n_press, x, y) => {",
148 " _this.view.button_is_pressed = false;",
155 "xtype" : "GestureClick"
161 "(n_press, x, y) => {",
166 " if (_this.model.el.get_n_items() < 1) {",
168 " GLib.debug(\"no items\");",
172 " var row = _this.view.getRowAt(x,y, out pos );",
174 "\t GLib.debug(\"no row selected items\");",
178 " var node = _this.selmodel.getNodeAt(row);",
179 " if (node == null) {",
180 " \tGLib.warning(\"No node found at row %d\", row);",
183 "\t_this.model.selectNode(node);",
187 "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());",
188 "\t//_this.deletemenu.el.set_parent(_this.view.el);",
189 "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
192 "\t//Gtk.Allocation rect;",
193 "\t//_this.view.el.get_allocation(out rect);",
194 " \t//_this.deletemenu.el.set_has_arrow(false);",
195 "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
198 "\t_this.LeftTreeMenu.el.set_offset( ",
200 "\t\t\t(int)y - (int)_this.view.el.get_height());",
202 " _this.LeftTreeMenu.el.popup();",
209 "xtype" : "GestureClick"
212 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
217 "\tGLib.debug(\"SOURCE: drag-begin\");",
219 " // find what is selected in our tree...",
220 " var data = _this.selmodel.getSelectedNode();",
221 "\tif (data == null) {",
225 " var xname = data.fqn();",
226 " GLib.debug (\"XNAME IS %s\", xname);",
228 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
231 " var paintable = new Gtk.WidgetPaintable(widget);",
232 " this.el.set_icon(paintable, 0,0);",
242 "///\t( drag_context, data, info, time) => {",
245 "\t//print(\"drag-data-get\");",
246 " \tvar ndata = _this.selmodel.getSelectedNode();",
247 "\tif (ndata == null) {",
248 "\t \tGLib.debug(\"return empty string - no selection..\");",
254 "\t//data.set_text(tp,tp.length); ",
256 "\tvar \tstr = ndata.toJsonString();",
257 "\tGLib.debug(\"prepare store: %s\", str);",
258 "\tGLib.Value ov = GLib.Value(typeof(string));",
259 "\tov.set_string(str);",
260 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
262 "\tGLib.Value v = GLib.Value(typeof(string));",
263 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
265 "\t\tcont.get_value(ref v);",
268 "\tGLib.debug(\"set %s\", v.get_string());",
277 "xtype" : "DragSource"
283 "(keyval, keycode, state) => {",
287 "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) {",
291 "\t_this.model.deleteSelected();",
298 "xtype" : "EventControllerKey"
303 "new Gtk.DropTarget ( typeof(string) ,",
304 "\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE )"
306 "Gtk.Widget? highlightWidget" : "null",
307 "JsRender.Node? lastDragNode" : "null",
313 "\tGLib.debug(\"got DropTarget:accept\");",
315 "// NOT REALLY NEEDED? = put stuff in drop?",
318 "/* ( ctx, x, y, time) => {",
319 " //Seed.print(\"TARGET: drag-drop\");",
322 " var src = Gtk.drag_get_source_widget(ctx);",
324 " if (src != this.el) {",
328 " this.drag_in_motion = false; ",
329 " // request data that will be recieved by the recieve... ",
330 " Gtk.drag_get_data",
332 " this.el, // will receive 'drag-data-received' signal ",
333 " ctx, // represents the current state of the DnD ",
334 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
335 " time // time stamp ",
339 " // No target offered by source => error",
345 " // handle drop around self..",
349 " //print(\"GETTING POS\");",
350 " var targetData = \"\";",
352 " Gtk.TreePath path;",
353 " Gtk.TreeViewDropPosition pos;",
354 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
356 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
357 " var isEmpty = false;",
358 " if (_this.model.el.iter_n_children(null) < 1) {",
359 " print(\"got NO children?\\n\");",
360 " isOver = true; //??? ",
362 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
367 " //var action = Gdk.DragAction.COPY;",
368 " // unless we are copying!!! ctl button..",
370 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
371 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
372 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
375 " if (_this.model.el.iter_n_children(null) < 1) {",
376 " // no children.. -- asume it's ok..",
378 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
380 " // continue through to allow drop...",
388 " //print(\"ISOVER? \" + isOver);",
391 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
392 " return true; // not over apoint!?! - no action on drop or motion..",
395 " // drag node is parent of child..",
396 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
397 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
399 " // nned to check a few here..",
400 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
401 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
402 " //Gtk.TreeViewDropPosition.AFTER",
403 " //Gtk.TreeViewDropPosition.BEFORE",
405 " // locally dragged items to not really use the ",
406 " var selection_text = this.dragData;",
410 " if (selection_text == null || selection_text.length < 1) {",
411 " //print(\"Error - drag selection text returned NULL\");",
413 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
414 " return true; /// -- fixme -- this is not really correct..",
417 " // see if we are dragging into ourself?",
418 " print (\"got selection text of \" + selection_text);",
420 " var target_path = path.to_string();",
421 " //print(\"target_path=\"+target_path);",
424 " if (selection_text == target_path) {",
425 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
427 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
429 " return true; /// -- fixme -- this is not really correct..",
434 " //print(\"DUMPING DATA\");",
435 " //console.dump(data);",
438 " //print(data.path.to_string() +' => '+ data.pos);",
440 " // dropList is a list of xtypes that this node could be dropped on.",
441 " // it is set up when we start to drag..",
444 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
446 " print(\"targetDAta: \" + targetData +\"\\n\");",
448 " if (targetData.length < 1) {",
449 " //print(\"Can not find drop node path\");",
451 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
457 " // continue on to allow drop..",
459 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
462 " var delete_selection_data = false;",
464 " if (action == Gdk.DragAction.ASK) {",
465 " // Ask the user to move or copy, then set the ctx action. ",
468 " if (action == Gdk.DragAction.MOVE) {",
469 " delete_selection_data = true;",
472 " // drag around.. - reorder..",
473 " _this.model.moveNode(targetData, action);",
479 " // we can send stuff to souce here...",
482 "// do we always say failure, so we handle the reall drop?",
483 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
501 "\tthis.addHighlight(null,\"\");",
505 " \tvar pos = \"\";",
506 " \t// -- get position..",
507 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
508 "\t\t// still dragging same node",
510 "\t\tthis.lastDragNode = new JsRender.Node(); ",
511 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
516 " var dropNode = new JsRender.Node(); ",
517 "\tdropNode.loadFromJsonString(v.get_string(), 1);",
518 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
520 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
522 " if (_this.model.el.n_items < 1) {",
523 " \t// FIXME check valid drop types?",
524 " \tif (!drop_on_to.contains(\"*top\")) {",
525 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
526 "\t\t\treturn false;\t",
528 "\t\t// add new node to top..",
531 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
532 " \t_this.main_window.windowstate.file.tree = dropNode; ",
535 "\t\tm.append(dropNode);",
536 "\t\t_this.model.selectNode(dropNode); \t",
537 "\t\t_this.changed();",
538 "\t\treturn true; // no need to highlight?",
544 "\tvar row = _this.view.getRowAt(x,y, out pos);",
546 "\t\treturn false; //Gdk.DragAction.COPY;",
548 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
550 "\tvar node = (JsRender.Node)tr.get_item();",
552 " \tif (pos == \"above\" || pos == \"below\") {",
553 "\t\tif (node.parent == null) {",
554 "\t\t\tpos = \"over\";",
556 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
557 "\t\t\t\tpos = \"over\";",
559 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
564 " \tif (pos == \"over\") {",
565 "\t \tif (!drop_on_to.contains(node.fqn())) {",
566 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
567 "\t\t\treturn false;",
573 " \t\tcase \"over\":",
574 "\t \t\tnode.appendChild(dropNode);",
575 " \t\t\t_this.model.selectNode(dropNode); ",
576 " \t\t\t_this.changed();\t\t\t\t \t\t",
577 "\t \t\treturn true;",
579 " \t\tcase \"above\":",
580 " \t\t\tGLib.debug(\"Above - insertBefore\");",
582 " \t\t\tnode.parent.insertBefore(dropNode, node);",
583 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
584 " \t\t\t_this.changed();",
585 " \t\t\treturn true;",
587 " \t\tcase \"below\":",
588 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
589 " \t\t\tnode.parent.insertAfter(dropNode, node);",
590 " \t\t\t_this.model.selectNode(dropNode);\t",
591 " \t\t\t_this.changed();",
592 " \t\t\t// select it",
593 " \t\t\treturn true;",
596 " \t\t\t// should not happen",
597 " \t\t\treturn false;",
610 "\tthis.addHighlight(null,\"\");",
618 "\tstring pos; // over / before / after..",
620 " GLib.debug(\"got drag motion\");",
622 " GLib.Value v = GLib.Value(typeof(string));",
623 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
624 " \tvar cont = this.el.current_drop.get_drag().content ;",
626 " \t\tcont.get_value(ref v);",
627 "\t} catch (GLib.Error e) {",
628 "\t GLib.debug(\"failed to get drag value\");",
629 "\t\treturn Gdk.DragAction.COPY;\t ",
633 "\tGLib.debug(\"got %s\", v.get_string());",
635 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
636 "\t\t// still dragging same node",
638 "\t\tthis.lastDragNode = new JsRender.Node(); ",
639 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
643 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
644 "\t\t\t\tthis.lastDragNode.fqn());",
646 " string[] str = {};",
647 " foreach(var dp in drop_on_to) {",
650 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
653 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
655 " if (_this.model.el.n_items < 1) {",
656 " \t// FIXME check valid drop types?",
657 " \tif (drop_on_to.contains(\"*top\")) {",
658 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
660 "\t\t\tthis.addHighlight(null, \"\");\t\t",
663 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
668 " \tGLib.debug(\"check is over\");",
670 " // if path of source and dest are inside each other..",
671 " // need to add source info to drag?",
673 " \tvar row = _this.view.getRowAt(x,y, out pos);",
676 "\t\tthis.addHighlight(null, \"\");\t",
677 "\t \treturn Gdk.DragAction.COPY;",
679 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
681 "\tvar node = (JsRender.Node)tr.get_item();",
683 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
686 " \tif (pos == \"above\" || pos == \"below\") {",
687 "\t\tif (node.parent == null) {",
688 "\t\t\tGLib.debug(\"no parent try center\");",
689 "\t\t\tpos = \"over\";",
692 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
693 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
694 "\t \t\t\tpos = \"over\";",
696 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
701 " \tif (pos == \"over\") {",
702 "\t \tif (!drop_on_to.contains(node.fqn())) {",
703 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
704 "\t\t\tthis.addHighlight(null, \"\"); ",
705 "\t\t\treturn Gdk.DragAction.COPY;\t\t",
710 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
711 "\tvar w = _this.view.getWidgetAt(x,y);",
712 "\tthis.addHighlight(w, pos); ",
713 " return Gdk.DragAction.COPY;\t\t\t",
717 "string lastDragString" : "\"\"",
718 "xtype" : "DropTarget",
719 "| void addHighlight" : [
720 "(Gtk.Widget? w, string hl) {",
721 "\tif (this.highlightWidget != null) {",
722 "\t\tvar ww = this.highlightWidget;",
723 "\t\tGLib.debug(\"clear drag from previous highlight\");",
724 "\t\tif (ww.has_css_class(\"drag-below\")) {",
725 "\t\t\t ww.remove_css_class(\"drag-below\");",
727 "\t\tif (ww.has_css_class(\"drag-above\")) {",
728 "\t\t\t ww.remove_css_class(\"drag-above\");",
730 "\t\tif (ww.has_css_class(\"drag-over\")) {",
731 "\t\t\t ww.remove_css_class(\"drag-over\");",
734 "\tif (w != null) {",
735 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
736 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
737 "\t\t\tw.add_css_class(\"drag-\" + hl);",
740 "\tthis.highlightWidget = w;",
751 "* ctor" : "this.updateModel(null)",
754 "xtype" : "TreeListModel",
755 "| Gtk.TreeListModel updateModel" : [
756 "(GLib.ListStore? m) {",
757 "\tthis.el = new Gtk.TreeListModel(",
758 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
759 "\t\tfalse, // passthru",
760 "\t\ttrue, // autexpand",
762 "\t\t\treturn ((JsRender.Node)item).childstore;",
766 "\tif (_this.selmodel.el == null) {",
767 "\t\treturn this.el;",
769 "\t_this.selmodel.el.set_model(this.el);",
773 "| void deleteSelected" : [
778 "\tvar node = _this.selmodel.getSelectedNode();",
781 " if (node == null) {",
782 " \tGLib.debug(\"delete Selected - no node slected?\");",
785 " _this.selmodel.el.unselect_all();",
788 " \tGLib.debug(\"delete Selected - done\");",
791 " print(\"DELETE SELECTED?\");",
792 " //_this.view.blockChanges = true;",
793 " print(\"GET SELECTION?\");",
795 " var s = _this.view.el.get_selection();",
797 " print(\"GET SELECTED?\");",
798 " Gtk.TreeIter iter;",
799 " Gtk.TreeModel mod;",
802 " if (!s.get_selected(out mod, out iter)) {",
803 " return; // nothing seleted..",
808 " this.activePath= \"\"; ",
809 " print(\"GET vnode value?\");",
811 " GLib.Value value;",
812 " this.el.get_value(iter, 2, out value);",
813 " var data = (JsRender.Node)(value.get_object());",
814 " print(\"removing node from Render\\n\");",
815 " if (data.parent == null) {",
816 " _this.main_window.windowstate.file.tree = null;",
820 " print(\"removing node from Tree\\n\"); ",
821 " s.unselect_all();",
822 " this.el.remove(ref iter);",
832 " this.activePath= \"\"; // again!?!? ",
833 " //this.changed(null,true);",
837 " _this.view.blockChanges = false;",
842 "| void loadFile" : [
843 "(JsRender.JsRender f) {",
844 " //console.dump(f);",
846 " _this.drop.highlightWidget = null;",
848 " var m = (GLib.ListStore) this.el.model;",
850 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
852 " _this.main_window.windowstate.file = f;",
855 " if (f.tree == null) {",
857 "\t f.loadItems( );",
858 " } catch (Error e) {",
862 " // if it's still null?",
863 " if (f.tree == null) {",
864 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
868 " \tm.append(f.tree);",
872 " if (f.tree.readItems().size < 1) {",
875 " //this.get('/Window.leftvpaned').el.set_position(80);",
876 " // select first...",
877 " _this.view.el.set_cursor( ",
878 " new Gtk.TreePath.from_string(\"0\"), null, false);",
882 " //this.get('/Window.leftvpaned').el.set_position(200);",
888 " //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
890 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
898 "| void selectNode" : [
899 "(JsRender.Node node) ",
902 "\tvar s = (Gtk.SingleSelection)_this.view.el.model;",
903 "\tfor (var i = 0; i < s.n_items; i++) {",
904 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
905 "\t\tvar lr = (Gtk.TreeListRow)s.get_item(i);",
906 "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
907 "\t\tif (((JsRender.Node)lr.get_item()).oid == node.oid) {",
913 "\t\t// select none?",
914 "\t\tGLib.debug(\"Could not find node\");",
917 "\tGLib.debug(\"Select %d\", row);",
918 "\ts.set_selected(row);",
919 "\t_this.node_selected(node);\t\t\t",
927 "selection_changed" : [
928 "(position, n_items) => {",
932 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
933 "\t\t\t// then event was started by some other action",
934 "\t\t\t// which should manually trigger all the events..",
935 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
940 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
941 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
945 "\t\t if (!_this.before_node_change( ) ) {",
946 "\t\t\t _this.view.blockChanges = true;",
947 "\t\t\t _this.selmodel.el.unselect_all();",
948 "\t\t\t _this.view.blockChanges = false;",
952 "\t\t if (_this.main_window.windowstate.file == null) {",
953 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
957 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
958 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
961 "\t\t// -- it appears that the selection is not updated.",
962 "\t\t // select the node...",
963 "\t\t //_this.selmodel.el.set_selected(row);",
965 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
967 "\t var snode = _this.selmodel.getSelectedNode();",
968 "\t if (snode == null) {",
970 "\t GLib.debug(\"selected rows < 1\");",
971 "\t //??this.model.load( false);",
972 "\t _this.node_selected(null);",
980 "\t GLib.debug (\"calling left_tree.node_selected\");",
981 "\t _this.node_selected(snode);",
986 "\t // no need to scroll. it's in the view as we clicked on it.",
987 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
994 "xtype" : "SingleSelection",
995 "| JsRender.Node getNodeAt" : [
998 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1000 " var a = tr.get_item();; ",
1001 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1004 " return (JsRender.Node)tr.get_item();",
1008 "| JsRender.Node? getSelectedNode" : [
1010 " if (this.el.selected_item == null) {",
1013 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1014 " return (JsRender.Node)tr.get_item();",
1021 "* pack" : "append_column",
1022 "bool expand" : true,
1023 "bool resizable" : true,
1028 "* prop" : "factory",
1032 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1034 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1035 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1038 "\tvar hbox = (Gtk.Box) expand.child;",
1041 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1042 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1044 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1045 "\tvar node = (JsRender.Node) lr.get_item();",
1047 " GLib.debug(\"node is %s\", node.get_type().name());",
1048 "// was item (1) in old layout",
1053 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1054 " var clsname = node.fqn();",
1056 " var clsb = clsname.split(\".\");",
1057 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1059 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1063 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1064 "\t\t img.set_from_file(fn);",
1067 "\t \t\timg.set_from_paintable(",
1068 "\t\t\t \tic.lookup_icon (",
1069 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1070 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1074 " \t} catch (GLib.Error e) {}",
1076 " expand.set_hide_expander( !node.hasChildren() );",
1077 " \texpand.set_list_row(lr);",
1079 " \tnode.bind_property(\"iconFilename\",",
1081 " GLib.BindingFlags.SYNC_CREATE);",
1083 " \tnode.bind_property(\"nodeTitleProp\",",
1085 " GLib.BindingFlags.SYNC_CREATE);",
1086 " \tnode.bind_property(\"nodeTipProp\",",
1087 " lbl, \"tooltip_markup\",",
1088 " GLib.BindingFlags.SYNC_CREATE);",
1089 " \t// bind image...",
1097 "\tvar expand = new Gtk.TreeExpander();",
1099 "\texpand.set_indent_for_depth(true);",
1100 "\texpand.set_indent_for_icon(true);",
1101 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1102 "\tvar icon = new Gtk.Image();",
1103 "\tvar lbl = new Gtk.Label(\"\");",
1104 "\tlbl.use_markup = true;",
1105 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1107 "\ticon.margin_end = 4;",
1108 " \tlbl.justify = Gtk.Justification.LEFT;",
1109 " \tlbl.xalign = 0;",
1111 "//\tlistitem.activatable = true; ??",
1113 "\thbox.append(icon);",
1114 "\thbox.append(lbl);",
1115 "\texpand.set_child(hbox);",
1116 "\t((Gtk.ListItem)listitem).set_child(expand);",
1122 "xtype" : "SignalListItemFactory"
1125 "title" : "Property",
1126 "xtype" : "ColumnViewColumn"
1130 "* pack" : "append_column",
1131 "int fixed_width" : 25,
1135 "* prop" : "factory",
1140 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1141 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1142 "\tvar node = (JsRender.Node) lr.get_item();",
1145 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1146 "\timg.set_from_paintable(",
1147 "\t \tic.lookup_icon (",
1148 "\t \t\t\"list-add\", null, 16,1, ",
1149 "\t\t\t Gtk.TextDirection.NONE, 0",
1153 " \tvar fqn = node.fqn();",
1154 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1156 "\timg.set_visible(cn.size > 0 ? true : false);",
1165 "\tvar icon = new Gtk.Image();",
1167 "\t((Gtk.ListItem)listitem).set_child(icon);",
1172 "xtype" : "SignalListItemFactory"
1175 "string title" : "Add",
1176 "xtype" : "ColumnViewColumn"
1179 "string name" : "left-tree-view",
1180 "xtype" : "ColumnView",
1181 "| Gtk.Widget? getWidgetAt" : [
1182 "(double x, double in_y) {",
1185 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1186 " \tvar colview = gesture.widget;",
1187 " \tvar line_no = check_list_widget(colview, x,y);",
1188 " if (line_no > -1) {",
1189 " \t\tvar item = colview.model.get_item(line_no);",
1193 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1194 " var child = this.el.get_first_child(); ",
1195 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1196 " \tvar line_no = -1; ",
1197 " \tvar reading_header = true;",
1198 " \tvar curr_y = 0;",
1199 " \tvar header_height = 0;",
1201 " \twhile (child != null) {",
1202 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1203 "\t if (reading_header) {",
1206 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1207 "\t\t\t h += child.get_height();",
1208 "\t\t\t\t\tchild = child.get_next_sibling();",
1209 "\t\t\t\t\tcontinue;",
1211 "\t\t\t\t// should be columnlistview",
1212 "\t\t\t\tchild = child.get_first_child(); ",
1213 "\t\t\t GLib.debug(\"header height=%d\", h);",
1214 "\t\t\t\theader_height = h;",
1216 "\t\t\t\treading_header = false;",
1221 "\t\t\tif (y < header_height) {",
1222 "\t\t \treturn null;",
1225 "\t\t\tvar hh = child.get_height();",
1226 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1228 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1229 "\t\t\t return (Gtk.Widget)child;",
1231 "\t\t curr_y += hh ;",
1233 "\t\t if (curr_y > y) {",
1234 "\t\t return null;",
1236 "\t child = child.get_next_sibling(); ",
1242 "| Gtk.Widget? getWidgetAtRow" : [
1246 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1247 " \tvar colview = gesture.widget;",
1248 " \tvar line_no = check_list_widget(colview, x,y);",
1249 " if (line_no > -1) {",
1250 " \t\tvar item = colview.model.get_item(line_no);",
1254 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1255 " var child = this.el.get_first_child(); ",
1256 " \tvar line_no = -1; ",
1257 " \tvar reading_header = true;",
1259 " \twhile (child != null) {",
1260 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1262 " \t if (reading_header) {",
1265 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1267 "\t\t\t\t\tchild = child.get_next_sibling();",
1268 "\t\t\t\t\tcontinue;",
1270 "\t\t\t\t// should be columnlistview",
1271 "\t\t\t\tchild = child.get_first_child(); ",
1275 "\t\t\t\treading_header = false;",
1282 "\t\t\tif (line_no == row) {",
1283 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1284 "\t\t\t return (Gtk.Widget)child;",
1286 "\t child = child.get_next_sibling(); ",
1288 "\t\t//GLib.debug(\"Rturning null\");",
1293 "| int getColAt" : [
1294 "(double x, double y) {",
1297 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1300 "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1301 "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1302 " var child = this.el.get_first_child(); ",
1306 " \twhile (child != null) {",
1308 "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1309 "\t\t\t\tchild = child.get_first_child();",
1310 "\t\t\t\tcontinue;",
1313 "\t\t\t//child.get_allocation(out alloc);",
1314 "\t\t\tif (x < (child.get_width() + offx)) {",
1315 "\t\t\t\treturn col;",
1318 "\t\t\t//offx += child.get_width();",
1320 "\t\t\t//child = child.get_next_sibling();",
1328 "| int getRowAt" : [
1329 "(double x, double in_y, out string pos) {",
1336 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1337 " \tvar colview = gesture.widget;",
1338 " \tvar line_no = check_list_widget(colview, x,y);",
1339 " if (line_no > -1) {",
1340 " \t\tvar item = colview.model.get_item(line_no);",
1346 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
1347 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1348 " var child = this.el.get_first_child(); ",
1349 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1350 " \tvar line_no = -1; ",
1351 " \tvar reading_header = true;",
1352 " \tvar real_y = 0;",
1353 " \tvar header_height = 0;",
1354 " \tpos = \"none\";",
1356 " \twhile (child != null) {",
1357 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1358 " \t if (reading_header) {",
1361 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1362 "\t\t\t h += child.get_height();",
1363 "\t\t\t\t\tchild = child.get_next_sibling();",
1364 "\t\t\t\t\tcontinue;",
1366 "\t\t\t\t// should be columnlistview",
1367 "\t\t\t\tchild = child.get_first_child(); ",
1368 "\t\t\t GLib.debug(\"header height=%d\", h);",
1369 "\t\t\t\theader_height = h;",
1371 "\t\t\t\treading_header = false;",
1375 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1376 " \t\t child = child.get_next_sibling();",
1380 "\t\t \tif (y < header_height) {",
1381 "\t\t \treturn -1;",
1385 "\t\t\tvar hh = child.get_height();",
1386 "\t\t\t//child.get_allocation(out alloc);",
1387 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1388 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1390 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1392 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1393 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1394 "\t\t \t\tpos = \"below\";",
1395 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1396 "\t \t\t\tpos = \"over\";",
1398 " \t\t\t\tpos = \"above\";",
1400 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1401 "\t\t\t return line_no;",
1405 "\t\t if (real_y + hh > y) {",
1409 "\t child = child.get_next_sibling(); ",
1419 "id" : "LeftTreeMenu",
1424 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1429 "label" : "Delete Element",
1433 "_this.LeftTreeMenu.el.hide();",
1434 " _this.model.deleteSelected();",
1443 "label" : "Save as Template",
1447 "_this.LeftTreeMenu.el.hide();",
1448 " DialogSaveTemplate.singleton().showIt(",
1449 " (Gtk.Window) _this.el.get_root (), ",
1450 " _this.main_window.windowstate.file.palete(), ",
1451 " _this.getActiveElement()",
1462 "label" : "Save as Module",
1467 " _this.LeftTreeMenu.el.hide();",
1468 " var node = _this.getActiveElement();",
1471 " var sm = DialogSaveModule.singleton();",
1475 " (Gtk.Window) _this.el.get_root (), ",
1476 " _this.main_window.windowstate.project, ",
1480 " gtk4 migration - disabled this part.. probably not used muchanyway",
1483 " if (name.length < 1) {",
1487 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1488 " node.items.clear();",
1491 " var s = _this.view.el.get_selection();",
1493 " print(\"GET SELECTED?\");",
1494 " Gtk.TreeIter iter;",
1495 " Gtk.TreeModel mod;",
1498 " if (!s.get_selected(out mod, out iter)) {",
1499 " return; // nothing seleted..",
1501 " Gtk.TreeIter citer;",
1502 " var n_cn = mod.iter_n_children(iter) -1;",
1503 " for (var i = n_cn; i > -1; i--) {",
1504 " mod.iter_nth_child(out citer, iter, i);",
1507 " print(\"removing node from Tree\\n\"); ",
1509 " _this.model.el.remove(ref citer);",
1511 " _this.changed();",
1512 " _this.node_selected(node, \"tree\");",
1527 "xtype" : "ScrolledWindow"
1531 "| JsRender.JsRender getActiveFile" : [
1533 " return this.main_window.windowstate.file;",
1537 "| JsRender.Node? getActiveElement" : [
1538 " () { // return path to actie node.",
1541 "\treturn _this.selmodel.getSelectedNode();",
1547 "| void onresize" : [
1551 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1552 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1559 "name" : "WindowLeftTree"