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 "\t_this.selmodel.el.set_model(this.el);",
770 "| void deleteSelected" : [
775 "\tvar node = _this.selmodel.getSelectedNode();",
778 " if (node == null) {",
779 " \tGLib.debug(\"delete Selected - no node slected?\");",
782 " _this.selmodel.el.unselect_all();",
785 " \tGLib.debug(\"delete Selected - done\");",
788 " print(\"DELETE SELECTED?\");",
789 " //_this.view.blockChanges = true;",
790 " print(\"GET SELECTION?\");",
792 " var s = _this.view.el.get_selection();",
794 " print(\"GET SELECTED?\");",
795 " Gtk.TreeIter iter;",
796 " Gtk.TreeModel mod;",
799 " if (!s.get_selected(out mod, out iter)) {",
800 " return; // nothing seleted..",
805 " this.activePath= \"\"; ",
806 " print(\"GET vnode value?\");",
808 " GLib.Value value;",
809 " this.el.get_value(iter, 2, out value);",
810 " var data = (JsRender.Node)(value.get_object());",
811 " print(\"removing node from Render\\n\");",
812 " if (data.parent == null) {",
813 " _this.main_window.windowstate.file.tree = null;",
817 " print(\"removing node from Tree\\n\"); ",
818 " s.unselect_all();",
819 " this.el.remove(ref iter);",
829 " this.activePath= \"\"; // again!?!? ",
830 " //this.changed(null,true);",
834 " _this.view.blockChanges = false;",
839 "| void loadFile" : [
840 "(JsRender.JsRender f) {",
841 " //console.dump(f);",
843 " _this.drop.highlightWidget = null;",
845 " var m = (GLib.ListStore) this.el.model;",
847 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
849 " _this.main_window.windowstate.file = f;",
852 " if (f.tree == null) {",
854 "\t f.loadItems( );",
855 " } catch (Error e) {",
859 " // if it's still null?",
860 " if (f.tree == null) {",
861 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
865 " \tm.append(f.tree);",
869 " if (f.tree.readItems().size < 1) {",
872 " //this.get('/Window.leftvpaned').el.set_position(80);",
873 " // select first...",
874 " _this.view.el.set_cursor( ",
875 " new Gtk.TreePath.from_string(\"0\"), null, false);",
879 " //this.get('/Window.leftvpaned').el.set_position(200);",
885 " //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
887 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
895 "| void selectNode" : [
896 "(JsRender.Node node) ",
899 "\tvar s = (Gtk.SingleSelection)_this.view.el.model;",
900 "\tfor (var i = 0; i < s.n_items; i++) {",
901 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
902 "\t\tvar lr = (Gtk.TreeListRow)s.get_item(i);",
903 "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
904 "\t\tif (((JsRender.Node)lr.get_item()).oid == node.oid) {",
910 "\t\t// select none?",
911 "\t\tGLib.debug(\"Could not find node\");",
914 "\tGLib.debug(\"Select %d\", row);",
915 "\ts.set_selected(row);",
916 "\t_this.node_selected(node);\t\t\t",
924 "selection_changed" : [
925 "(position, n_items) => {",
929 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
930 "\t\t\t// then event was started by some other action",
931 "\t\t\t// which should manually trigger all the events..",
932 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
937 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
938 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
942 "\t\t if (!_this.before_node_change( ) ) {",
943 "\t\t\t _this.view.blockChanges = true;",
944 "\t\t\t _this.selmodel.el.unselect_all();",
945 "\t\t\t _this.view.blockChanges = false;",
949 "\t\t if (_this.main_window.windowstate.file == null) {",
950 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
954 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
955 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
958 "\t\t// -- it appears that the selection is not updated.",
959 "\t\t // select the node...",
960 "\t\t //_this.selmodel.el.set_selected(row);",
962 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
964 "\t var snode = _this.selmodel.getSelectedNode();",
965 "\t if (snode == null) {",
967 "\t GLib.debug(\"selected rows < 1\");",
968 "\t //??this.model.load( false);",
969 "\t _this.node_selected(null);",
977 "\t GLib.debug (\"calling left_tree.node_selected\");",
978 "\t _this.node_selected(snode);",
983 "\t // no need to scroll. it's in the view as we clicked on it.",
984 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
991 "xtype" : "SingleSelection",
992 "| JsRender.Node getNodeAt" : [
995 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
997 " var a = tr.get_item();; ",
998 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1001 " return (JsRender.Node)tr.get_item();",
1005 "| JsRender.Node? getSelectedNode" : [
1007 " if (this.el.selected_item == null) {",
1010 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1011 " return (JsRender.Node)tr.get_item();",
1018 "* pack" : "append_column",
1019 "bool expand" : true,
1020 "bool resizable" : true,
1025 "* prop" : "factory",
1029 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1031 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1032 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1035 "\tvar hbox = (Gtk.Box) expand.child;",
1038 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1039 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1041 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1042 "\tvar node = (JsRender.Node) lr.get_item();",
1044 " GLib.debug(\"node is %s\", node.get_type().name());",
1045 "// was item (1) in old layout",
1050 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1051 " var clsname = node.fqn();",
1053 " var clsb = clsname.split(\".\");",
1054 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1056 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1060 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1061 "\t\t img.set_from_file(fn);",
1064 "\t \t\timg.set_from_paintable(",
1065 "\t\t\t \tic.lookup_icon (",
1066 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1067 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1071 " \t} catch (GLib.Error e) {}",
1073 " expand.set_hide_expander( !node.hasChildren() );",
1074 " \texpand.set_list_row(lr);",
1076 " \tnode.bind_property(\"iconFilename\",",
1078 " GLib.BindingFlags.SYNC_CREATE);",
1080 " \tnode.bind_property(\"nodeTitleProp\",",
1082 " GLib.BindingFlags.SYNC_CREATE);",
1083 " \tnode.bind_property(\"nodeTipProp\",",
1084 " lbl, \"tooltip_markup\",",
1085 " GLib.BindingFlags.SYNC_CREATE);",
1086 " \t// bind image...",
1094 "\tvar expand = new Gtk.TreeExpander();",
1096 "\texpand.set_indent_for_depth(true);",
1097 "\texpand.set_indent_for_icon(true);",
1098 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1099 "\tvar icon = new Gtk.Image();",
1100 "\tvar lbl = new Gtk.Label(\"\");",
1101 "\tlbl.use_markup = true;",
1102 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1104 "\ticon.margin_end = 4;",
1105 " \tlbl.justify = Gtk.Justification.LEFT;",
1106 " \tlbl.xalign = 0;",
1108 "//\tlistitem.activatable = true; ??",
1110 "\thbox.append(icon);",
1111 "\thbox.append(lbl);",
1112 "\texpand.set_child(hbox);",
1113 "\t((Gtk.ListItem)listitem).set_child(expand);",
1119 "xtype" : "SignalListItemFactory"
1122 "title" : "Property",
1123 "xtype" : "ColumnViewColumn"
1127 "* pack" : "append_column",
1128 "int fixed_width" : 25,
1132 "* prop" : "factory",
1137 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1138 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1139 "\tvar node = (JsRender.Node) lr.get_item();",
1142 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1143 "\timg.set_from_paintable(",
1144 "\t \tic.lookup_icon (",
1145 "\t \t\t\"list-add\", null, 16,1, ",
1146 "\t\t\t Gtk.TextDirection.NONE, 0",
1150 " \tvar fqn = node.fqn();",
1151 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1153 "\timg.set_visible(cn.size > 0 ? true : false);",
1162 "\tvar icon = new Gtk.Image();",
1164 "\t((Gtk.ListItem)listitem).set_child(icon);",
1169 "xtype" : "SignalListItemFactory"
1172 "string title" : "Add",
1173 "xtype" : "ColumnViewColumn"
1176 "string name" : "left-tree-view",
1177 "xtype" : "ColumnView",
1178 "| Gtk.Widget? getWidgetAt" : [
1179 "(double x, double in_y) {",
1182 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1183 " \tvar colview = gesture.widget;",
1184 " \tvar line_no = check_list_widget(colview, x,y);",
1185 " if (line_no > -1) {",
1186 " \t\tvar item = colview.model.get_item(line_no);",
1190 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1191 " var child = this.el.get_first_child(); ",
1192 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1193 " \tvar line_no = -1; ",
1194 " \tvar reading_header = true;",
1195 " \tvar curr_y = 0;",
1196 " \tvar header_height = 0;",
1198 " \twhile (child != null) {",
1199 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1200 "\t if (reading_header) {",
1203 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1204 "\t\t\t h += child.get_height();",
1205 "\t\t\t\t\tchild = child.get_next_sibling();",
1206 "\t\t\t\t\tcontinue;",
1208 "\t\t\t\t// should be columnlistview",
1209 "\t\t\t\tchild = child.get_first_child(); ",
1210 "\t\t\t GLib.debug(\"header height=%d\", h);",
1211 "\t\t\t\theader_height = h;",
1213 "\t\t\t\treading_header = false;",
1218 "\t\t\tif (y < header_height) {",
1219 "\t\t \treturn null;",
1222 "\t\t\tvar hh = child.get_height();",
1223 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1225 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1226 "\t\t\t return (Gtk.Widget)child;",
1228 "\t\t curr_y += hh ;",
1230 "\t\t if (curr_y > y) {",
1231 "\t\t return null;",
1233 "\t child = child.get_next_sibling(); ",
1239 "| Gtk.Widget? getWidgetAtRow" : [
1243 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1244 " \tvar colview = gesture.widget;",
1245 " \tvar line_no = check_list_widget(colview, x,y);",
1246 " if (line_no > -1) {",
1247 " \t\tvar item = colview.model.get_item(line_no);",
1251 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1252 " var child = this.el.get_first_child(); ",
1253 " \tvar line_no = -1; ",
1254 " \tvar reading_header = true;",
1256 " \twhile (child != null) {",
1257 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1259 " \t if (reading_header) {",
1262 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1264 "\t\t\t\t\tchild = child.get_next_sibling();",
1265 "\t\t\t\t\tcontinue;",
1267 "\t\t\t\t// should be columnlistview",
1268 "\t\t\t\tchild = child.get_first_child(); ",
1272 "\t\t\t\treading_header = false;",
1279 "\t\t\tif (line_no == row) {",
1280 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1281 "\t\t\t return (Gtk.Widget)child;",
1283 "\t child = child.get_next_sibling(); ",
1285 "\t\t//GLib.debug(\"Rturning null\");",
1290 "| int getColAt" : [
1291 "(double x, double y) {",
1294 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1297 "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1298 "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1299 " var child = this.el.get_first_child(); ",
1303 " \twhile (child != null) {",
1305 "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1306 "\t\t\t\tchild = child.get_first_child();",
1307 "\t\t\t\tcontinue;",
1310 "\t\t\t//child.get_allocation(out alloc);",
1311 "\t\t\tif (x < (child.get_width() + offx)) {",
1312 "\t\t\t\treturn col;",
1315 "\t\t\t//offx += child.get_width();",
1317 "\t\t\t//child = child.get_next_sibling();",
1325 "| int getRowAt" : [
1326 "(double x, double in_y, out string pos) {",
1333 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1334 " \tvar colview = gesture.widget;",
1335 " \tvar line_no = check_list_widget(colview, x,y);",
1336 " if (line_no > -1) {",
1337 " \t\tvar item = colview.model.get_item(line_no);",
1343 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
1344 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1345 " var child = this.el.get_first_child(); ",
1346 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1347 " \tvar line_no = -1; ",
1348 " \tvar reading_header = true;",
1349 " \tvar real_y = 0;",
1350 " \tvar header_height = 0;",
1351 " \tpos = \"none\";",
1353 " \twhile (child != null) {",
1354 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1355 " \t if (reading_header) {",
1358 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1359 "\t\t\t h += child.get_height();",
1360 "\t\t\t\t\tchild = child.get_next_sibling();",
1361 "\t\t\t\t\tcontinue;",
1363 "\t\t\t\t// should be columnlistview",
1364 "\t\t\t\tchild = child.get_first_child(); ",
1365 "\t\t\t GLib.debug(\"header height=%d\", h);",
1366 "\t\t\t\theader_height = h;",
1368 "\t\t\t\treading_header = false;",
1372 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1373 " \t\t child = child.get_next_sibling();",
1377 "\t\t \tif (y < header_height) {",
1378 "\t\t \treturn -1;",
1382 "\t\t\tvar hh = child.get_height();",
1383 "\t\t\t//child.get_allocation(out alloc);",
1384 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1385 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1387 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1389 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1390 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1391 "\t\t \t\tpos = \"below\";",
1392 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1393 "\t \t\t\tpos = \"over\";",
1395 " \t\t\t\tpos = \"above\";",
1397 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1398 "\t\t\t return line_no;",
1402 "\t\t if (real_y + hh > y) {",
1406 "\t child = child.get_next_sibling(); ",
1416 "id" : "LeftTreeMenu",
1421 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1426 "label" : "Delete Element",
1431 " print(\"ACTIVATE?\");",
1433 " \t_this.LeftTreeMenu.el.hide();",
1434 " _this.model.deleteSelected();",
1442 "label" : "Save as Template",
1446 "_this.LeftTreeMenu.el.hide();",
1447 " DialogSaveTemplate.singleton().showIt(",
1448 " (Gtk.Window) _this.el.get_root (), ",
1449 " _this.main_window.windowstate.file.palete(), ",
1450 " _this.getActiveElement()",
1461 "label" : "Save as Module",
1466 " _this.LeftTreeMenu.el.hide();",
1467 " var node = _this.getActiveElement();",
1470 " var sm = DialogSaveModule.singleton();",
1474 " (Gtk.Window) _this.el.get_root (), ",
1475 " _this.main_window.windowstate.project, ",
1479 " gtk4 migration - disabled this part.. probably not used muchanyway",
1482 " if (name.length < 1) {",
1486 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1487 " node.items.clear();",
1490 " var s = _this.view.el.get_selection();",
1492 " print(\"GET SELECTED?\");",
1493 " Gtk.TreeIter iter;",
1494 " Gtk.TreeModel mod;",
1497 " if (!s.get_selected(out mod, out iter)) {",
1498 " return; // nothing seleted..",
1500 " Gtk.TreeIter citer;",
1501 " var n_cn = mod.iter_n_children(iter) -1;",
1502 " for (var i = n_cn; i > -1; i--) {",
1503 " mod.iter_nth_child(out citer, iter, i);",
1506 " print(\"removing node from Tree\\n\"); ",
1508 " _this.model.el.remove(ref citer);",
1510 " _this.changed();",
1511 " _this.node_selected(node, \"tree\");",
1526 "xtype" : "ScrolledWindow"
1530 "| JsRender.JsRender getActiveFile" : [
1532 " return this.main_window.windowstate.file;",
1536 "| JsRender.Node? getActiveElement" : [
1537 " () { // return path to actie node.",
1540 "\treturn _this.selmodel.getSelectedNode();",
1546 "| void onresize" : [
1550 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1551 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1558 "name" : "WindowLeftTree"