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;",
63 "#left-tree-view indent:nth-last-child(2) {",
68 "\tGtk.StyleContext.add_provider_for_display(",
69 "\t\tthis.el.get_display(),",
71 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
79 "Boolean id" : "view",
80 "Gtk.CssProvider css" : "",
81 "bool button_is_pressed" : false,
82 "bool headers_visible" : false,
83 "bool hexpand" : false,
84 "bool vexpand" : true,
90 "(n_press, x, y) => {",
92 " //console.log(\"button press?\");",
94 " //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
98 " _this.view.button_is_pressed = true;",
100 " _this.view.lastEventSource = \"tree\";",
101 " if (! _this.before_node_change() ) {",
102 " \tGLib.debug(\"before_node_change return false\");",
106 "\t // nothing there -show dialog",
107 " if (_this.model.el.get_n_items() < 1) {",
108 "\t _this.main_window.windowstate.showAddObject(_this.view.el, null);",
109 " GLib.debug(\"no items\");",
113 " var row = _this.view.getRowAt(x,y, out pos );",
115 "\t GLib.debug(\"no row selected items\");",
119 " var node = _this.selmodel.getNodeAt(row);",
120 " if (node == null) {",
121 " \tGLib.warning(\"No node found at row %d\", row);",
127 " if (_this.view.getColAt(x,y) > 0 ) {",
128 "\t GLib.debug(\"add colum clicked.\");",
129 " var fqn = node.fqn();",
130 " \tvar cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
131 " \t\tif (cn.size < 1) {",
135 "\t\t_this.main_window.windowstate.leftTreeBeforeChange();",
136 "\t\t//_this.view.el.get_selection().select_path(res);",
137 "\t\tGLib.debug(\"Button Pressed - start show window\");",
138 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, node);",
139 "\t\tGLib.debug(\"Button Pressed - finsihed show window\");",
149 "(n_press, x, y) => {",
151 " _this.view.button_is_pressed = false;",
158 "xtype" : "GestureClick"
164 "(n_press, x, y) => {",
169 " if (_this.model.el.get_n_items() < 1) {",
171 " GLib.debug(\"no items\");",
175 " var row = _this.view.getRowAt(x,y, out pos );",
177 "\t GLib.debug(\"no row selected items\");",
181 " var node = _this.selmodel.getNodeAt(row);",
182 " if (node == null) {",
183 " \tGLib.warning(\"No node found at row %d\", row);",
186 "\t_this.model.selectNode(node);",
190 "\tGLib.debug(\"Prssed %d\", (int) this.el.get_current_button());",
191 "\t//_this.deletemenu.el.set_parent(_this.view.el);",
192 "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
195 "\t//Gtk.Allocation rect;",
196 "\t//_this.view.el.get_allocation(out rect);",
197 " \t//_this.deletemenu.el.set_has_arrow(false);",
198 "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
201 "\t_this.LeftTreeMenu.el.set_offset( ",
203 "\t\t\t(int)y - (int)_this.view.el.get_height());",
205 " _this.LeftTreeMenu.el.popup();",
212 "xtype" : "GestureClick"
215 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
220 "\tGLib.debug(\"SOURCE: drag-begin\");",
222 " // find what is selected in our tree...",
223 " var data = _this.selmodel.getSelectedNode();",
224 "\tif (data == null) {",
228 " var xname = data.fqn();",
229 " GLib.debug (\"XNAME IS %s\", xname);",
231 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
234 " var paintable = new Gtk.WidgetPaintable(widget);",
235 " this.el.set_icon(paintable, 0,0);",
245 "///\t( drag_context, data, info, time) => {",
248 "\t//print(\"drag-data-get\");",
249 " \tvar ndata = _this.selmodel.getSelectedNode();",
250 "\tif (ndata == null) {",
251 "\t \tGLib.debug(\"return empty string - no selection..\");",
257 "\t//data.set_text(tp,tp.length); ",
259 "\tvar \tstr = ndata.toJsonString();",
260 "\tGLib.debug(\"prepare store: %s\", str);",
261 "\tGLib.Value ov = GLib.Value(typeof(string));",
262 "\tov.set_string(str);",
263 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
265 "\tGLib.Value v = GLib.Value(typeof(string));",
266 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
268 "\t\tcont.get_value(ref v);",
271 "\tGLib.debug(\"set %s\", v.get_string());",
280 "xtype" : "DragSource"
286 "(keyval, keycode, state) => {",
290 "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace) {",
294 "\t_this.model.deleteSelected();",
301 "xtype" : "EventControllerKey"
306 "new Gtk.DropTarget ( typeof(string) ,",
307 "\t\tGdk.DragAction.COPY | Gdk.DragAction.MOVE )"
309 "Gtk.Widget? highlightWidget" : "null",
310 "JsRender.Node? lastDragNode" : "null",
316 "\tGLib.debug(\"got DropTarget:accept\");",
318 "// NOT REALLY NEEDED? = put stuff in drop?",
321 "/* ( ctx, x, y, time) => {",
322 " //Seed.print(\"TARGET: drag-drop\");",
325 " var src = Gtk.drag_get_source_widget(ctx);",
327 " if (src != this.el) {",
331 " this.drag_in_motion = false; ",
332 " // request data that will be recieved by the recieve... ",
333 " Gtk.drag_get_data",
335 " this.el, // will receive 'drag-data-received' signal ",
336 " ctx, // represents the current state of the DnD ",
337 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
338 " time // time stamp ",
342 " // No target offered by source => error",
348 " // handle drop around self..",
352 " //print(\"GETTING POS\");",
353 " var targetData = \"\";",
355 " Gtk.TreePath path;",
356 " Gtk.TreeViewDropPosition pos;",
357 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
359 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
360 " var isEmpty = false;",
361 " if (_this.model.el.iter_n_children(null) < 1) {",
362 " print(\"got NO children?\\n\");",
363 " isOver = true; //??? ",
365 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
370 " //var action = Gdk.DragAction.COPY;",
371 " // unless we are copying!!! ctl button..",
373 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
374 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
375 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
378 " if (_this.model.el.iter_n_children(null) < 1) {",
379 " // no children.. -- asume it's ok..",
381 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
383 " // continue through to allow drop...",
391 " //print(\"ISOVER? \" + isOver);",
394 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
395 " return true; // not over apoint!?! - no action on drop or motion..",
398 " // drag node is parent of child..",
399 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
400 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
402 " // nned to check a few here..",
403 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
404 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
405 " //Gtk.TreeViewDropPosition.AFTER",
406 " //Gtk.TreeViewDropPosition.BEFORE",
408 " // locally dragged items to not really use the ",
409 " var selection_text = this.dragData;",
413 " if (selection_text == null || selection_text.length < 1) {",
414 " //print(\"Error - drag selection text returned NULL\");",
416 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
417 " return true; /// -- fixme -- this is not really correct..",
420 " // see if we are dragging into ourself?",
421 " print (\"got selection text of \" + selection_text);",
423 " var target_path = path.to_string();",
424 " //print(\"target_path=\"+target_path);",
427 " if (selection_text == target_path) {",
428 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
430 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
432 " return true; /// -- fixme -- this is not really correct..",
437 " //print(\"DUMPING DATA\");",
438 " //console.dump(data);",
441 " //print(data.path.to_string() +' => '+ data.pos);",
443 " // dropList is a list of xtypes that this node could be dropped on.",
444 " // it is set up when we start to drag..",
447 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
449 " print(\"targetDAta: \" + targetData +\"\\n\");",
451 " if (targetData.length < 1) {",
452 " //print(\"Can not find drop node path\");",
454 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
460 " // continue on to allow drop..",
462 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
465 " var delete_selection_data = false;",
467 " if (action == Gdk.DragAction.ASK) {",
468 " // Ask the user to move or copy, then set the ctx action. ",
471 " if (action == Gdk.DragAction.MOVE) {",
472 " delete_selection_data = true;",
475 " // drag around.. - reorder..",
476 " _this.model.moveNode(targetData, action);",
482 " // we can send stuff to souce here...",
485 "// do we always say failure, so we handle the reall drop?",
486 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
504 "\tthis.addHighlight(null,\"\");",
508 " \tvar pos = \"\";",
509 " \t// -- get position..",
510 " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
511 "\t\t// still dragging same node",
513 "\t\tthis.lastDragNode = new JsRender.Node(); ",
514 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
519 " var dropNode = new JsRender.Node(); ",
520 "\tdropNode.loadFromJsonString(v.get_string(), 1);",
521 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
523 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
525 " if (_this.model.el.n_items < 1) {",
526 " \t// FIXME check valid drop types?",
527 " \tif (!drop_on_to.contains(\"*top\")) {",
528 "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
529 "\t\t\treturn false;\t",
531 "\t\t// add new node to top..",
534 "\t\t var m = (GLib.ListStore) _this.model.el.model;",
535 " \t_this.main_window.windowstate.file.tree = dropNode; ",
538 "\t\tm.append(dropNode);",
539 "\t\t_this.model.selectNode(dropNode); \t",
540 "\t\t_this.changed();",
541 "\t\treturn true; // no need to highlight?",
547 "\tvar row = _this.view.getRowAt(x,y, out pos);",
549 "\t\treturn false; //Gdk.DragAction.COPY;",
551 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
553 "\tvar node = (JsRender.Node)tr.get_item();",
555 " \tif (pos == \"above\" || pos == \"below\") {",
556 "\t\tif (node.parent == null) {",
557 "\t\t\tpos = \"over\";",
559 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
560 "\t\t\t\tpos = \"over\";",
562 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
567 " \tif (pos == \"over\") {",
568 "\t \tif (!drop_on_to.contains(node.fqn())) {",
569 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
570 "\t\t\treturn false;",
576 " \t\tcase \"over\":",
577 "\t \t\tnode.appendChild(dropNode);",
578 " \t\t\t_this.model.selectNode(dropNode); ",
579 " \t\t\t_this.changed();\t\t\t\t \t\t",
580 "\t \t\treturn true;",
582 " \t\tcase \"above\":",
583 " \t\t\tGLib.debug(\"Above - insertBefore\");",
585 " \t\t\tnode.parent.insertBefore(dropNode, node);",
586 " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
587 " \t\t\t_this.changed();",
588 " \t\t\treturn true;",
590 " \t\tcase \"below\":",
591 " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
592 " \t\t\tnode.parent.insertAfter(dropNode, node);",
593 " \t\t\t_this.model.selectNode(dropNode);\t",
594 " \t\t\t_this.changed();",
595 " \t\t\t// select it",
596 " \t\t\treturn true;",
599 " \t\t\t// should not happen",
600 " \t\t\treturn false;",
613 "\tthis.addHighlight(null,\"\");",
621 "\tstring pos; // over / before / after..",
623 " GLib.debug(\"got drag motion\");",
625 " GLib.Value v = GLib.Value(typeof(string));",
626 " \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
627 " \tvar cont = this.el.current_drop.get_drag().content ;",
629 " \t\tcont.get_value(ref v);",
630 "\t} catch (GLib.Error e) {",
631 "\t GLib.debug(\"failed to get drag value\");",
632 "\t\treturn Gdk.DragAction.COPY;\t ",
636 "\tGLib.debug(\"got %s\", v.get_string());",
638 "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
639 "\t\t// still dragging same node",
641 "\t\tthis.lastDragNode = new JsRender.Node(); ",
642 "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
646 "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
647 "\t\t\t\tthis.lastDragNode.fqn());",
649 " string[] str = {};",
650 " foreach(var dp in drop_on_to) {",
653 " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
656 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
658 " if (_this.model.el.n_items < 1) {",
659 " \t// FIXME check valid drop types?",
660 " \tif (drop_on_to.contains(\"*top\")) {",
661 "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
663 "\t\t\tthis.addHighlight(null, \"\");\t\t",
666 "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
671 " \tGLib.debug(\"check is over\");",
673 " // if path of source and dest are inside each other..",
674 " // need to add source info to drag?",
676 " \tvar row = _this.view.getRowAt(x,y, out pos);",
679 "\t\tthis.addHighlight(null, \"\");\t",
680 "\t \treturn Gdk.DragAction.COPY;",
682 "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
684 "\tvar node = (JsRender.Node)tr.get_item();",
686 "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
689 " \tif (pos == \"above\" || pos == \"below\") {",
690 "\t\tif (node.parent == null) {",
691 "\t\t\tGLib.debug(\"no parent try center\");",
692 "\t\t\tpos = \"over\";",
695 "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
696 "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
697 "\t \t\t\tpos = \"over\";",
699 "\t\t\t\tGLib.debug(\"drop contains %s - using %s\" , node.parent.fqn(), pos);",
704 " \tif (pos == \"over\") {",
705 "\t \tif (!drop_on_to.contains(node.fqn())) {",
706 "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
707 "\t\t\tthis.addHighlight(null, \"\"); ",
708 "\t\t\treturn Gdk.DragAction.COPY;\t\t",
713 " \t // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
714 "\tvar w = _this.view.getWidgetAt(x,y);",
715 "\tthis.addHighlight(w, pos); ",
716 " return Gdk.DragAction.COPY;\t\t\t",
720 "string lastDragString" : "\"\"",
721 "xtype" : "DropTarget",
722 "| void addHighlight" : [
723 "(Gtk.Widget? w, string hl) {",
724 "\tif (this.highlightWidget != null) {",
725 "\t\tvar ww = this.highlightWidget;",
726 "\t\tGLib.debug(\"clear drag from previous highlight\");",
727 "\t\tif (ww.has_css_class(\"drag-below\")) {",
728 "\t\t\t ww.remove_css_class(\"drag-below\");",
730 "\t\tif (ww.has_css_class(\"drag-above\")) {",
731 "\t\t\t ww.remove_css_class(\"drag-above\");",
733 "\t\tif (ww.has_css_class(\"drag-over\")) {",
734 "\t\t\t ww.remove_css_class(\"drag-over\");",
737 "\tif (w != null) {",
738 "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
739 "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
740 "\t\t\tw.add_css_class(\"drag-\" + hl);",
743 "\tthis.highlightWidget = w;",
754 "* ctor" : "this.updateModel(null)",
757 "xtype" : "TreeListModel",
758 "| Gtk.TreeListModel updateModel" : [
759 "(GLib.ListStore? m) {",
760 "\tthis.el = new Gtk.TreeListModel(",
761 "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
762 "\t\tfalse, // passthru",
763 "\t\ttrue, // autexpand",
765 "\t\t\treturn ((JsRender.Node)item).childstore;",
769 "\tif (_this.selmodel.el == null) {",
770 "\t\treturn this.el;",
772 "\t_this.selmodel.el.set_model(this.el);",
776 "| void deleteSelected" : [
781 "\tvar node = _this.selmodel.getSelectedNode();",
784 " if (node == null) {",
785 " \tGLib.debug(\"delete Selected - no node slected?\");",
788 " _this.selmodel.el.unselect_all();",
791 " \tGLib.debug(\"delete Selected - done\");",
794 " print(\"DELETE SELECTED?\");",
795 " //_this.view.blockChanges = true;",
796 " print(\"GET SELECTION?\");",
798 " var s = _this.view.el.get_selection();",
800 " print(\"GET SELECTED?\");",
801 " Gtk.TreeIter iter;",
802 " Gtk.TreeModel mod;",
805 " if (!s.get_selected(out mod, out iter)) {",
806 " return; // nothing seleted..",
811 " this.activePath= \"\"; ",
812 " print(\"GET vnode value?\");",
814 " GLib.Value value;",
815 " this.el.get_value(iter, 2, out value);",
816 " var data = (JsRender.Node)(value.get_object());",
817 " print(\"removing node from Render\\n\");",
818 " if (data.parent == null) {",
819 " _this.main_window.windowstate.file.tree = null;",
823 " print(\"removing node from Tree\\n\"); ",
824 " s.unselect_all();",
825 " this.el.remove(ref iter);",
835 " this.activePath= \"\"; // again!?!? ",
836 " //this.changed(null,true);",
840 " _this.view.blockChanges = false;",
845 "| void loadFile" : [
846 "(JsRender.JsRender f) {",
847 " //console.dump(f);",
849 " _this.drop.highlightWidget = null;",
851 " var m = (GLib.ListStore) this.el.model;",
853 " _this.main_window.windowstate.leftTreeNodeSelected(null);",
855 " _this.main_window.windowstate.file = f;",
858 " if (f.tree == null) {",
860 "\t f.loadItems( );",
861 " } catch (Error e) {",
865 " // if it's still null?",
866 " if (f.tree == null) {",
867 "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
871 " \tm.append(f.tree);",
875 " if (f.tree.readItems().size < 1) {",
878 " //this.get('/Window.leftvpaned').el.set_position(80);",
879 " // select first...",
880 " _this.view.el.set_cursor( ",
881 " new Gtk.TreePath.from_string(\"0\"), null, false);",
885 " //this.get('/Window.leftvpaned').el.set_position(200);",
891 " //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
893 " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
901 "| void selectNode" : [
902 "(JsRender.Node node) ",
905 "\tvar s = (Gtk.SingleSelection)_this.view.el.model;",
906 "\tfor (var i = 0; i < s.n_items; i++) {",
907 "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
908 "\t\tvar lr = (Gtk.TreeListRow)s.get_item(i);",
909 "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
910 "\t\tif (((JsRender.Node)lr.get_item()).oid == node.oid) {",
916 "\t\t// select none?",
917 "\t\tGLib.debug(\"Could not find node\");",
920 "\tGLib.debug(\"Select %d\", row);",
921 "\ts.set_selected(row);",
922 "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
923 "\t//_this.node_selected(node);\t\t\t",
931 "selection_changed" : [
932 "(position, n_items) => {",
936 "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
937 "\t\t\t// then event was started by some other action",
938 "\t\t\t// which should manually trigger all the events..",
939 "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
944 "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
945 "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\"); ",
949 "\t\t if (!_this.before_node_change( ) ) {",
950 "\t\t\t _this.view.blockChanges = true;",
951 "\t\t\t _this.selmodel.el.unselect_all();",
952 "\t\t\t _this.view.blockChanges = false;",
956 "\t\t if (_this.main_window.windowstate.file == null) {",
957 "\t \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\"); ",
961 "\t\t //var render = this.get('/LeftTree').getRenderer(); ",
962 "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
965 "\t\t// -- it appears that the selection is not updated.",
966 "\t\t // select the node...",
967 "\t\t //_this.selmodel.el.set_selected(row);",
969 "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
971 "\t var snode = _this.selmodel.getSelectedNode();",
972 "\t if (snode == null) {",
974 "\t GLib.debug(\"selected rows < 1\");",
975 "\t //??this.model.load( false);",
976 "\t _this.node_selected(null);",
984 "\t GLib.debug (\"calling left_tree.node_selected\");",
985 "\t _this.node_selected(snode);",
990 "\t // no need to scroll. it's in the view as we clicked on it.",
991 "\t // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
998 "xtype" : "SingleSelection",
999 "| JsRender.Node getNodeAt" : [
1002 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1004 " var a = tr.get_item();; ",
1005 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1008 " return (JsRender.Node)tr.get_item();",
1012 "| JsRender.Node? getSelectedNode" : [
1014 " if (this.el.selected_item == null) {",
1017 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
1018 " return (JsRender.Node)tr.get_item();",
1025 "* pack" : "append_column",
1026 "bool expand" : true,
1027 "bool resizable" : true,
1032 "* prop" : "factory",
1036 "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1038 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1039 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1042 "\tvar hbox = (Gtk.Box) expand.child;",
1045 "\tvar img = (Gtk.Image) hbox.get_first_child();",
1046 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1048 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1049 "\tvar node = (JsRender.Node) lr.get_item();",
1051 " GLib.debug(\"node is %s\", node.get_type().name());",
1052 "// was item (1) in old layout",
1057 " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1058 " var clsname = node.fqn();",
1060 " var clsb = clsname.split(\".\");",
1061 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
1063 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1067 "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1068 "\t\t img.set_from_file(fn);",
1071 "\t \t\timg.set_from_paintable(",
1072 "\t\t\t \tic.lookup_icon (",
1073 "\t\t\t \t\t\"media-playback-stop\", null, 16,1, ",
1074 "\t \t\t\t Gtk.TextDirection.NONE, 0",
1078 " \t} catch (GLib.Error e) {}",
1080 " expand.set_hide_expander( !node.hasChildren() );",
1081 " \texpand.set_list_row(lr);",
1083 " \tnode.bind_property(\"iconFilename\",",
1085 " GLib.BindingFlags.SYNC_CREATE);",
1087 " \tnode.bind_property(\"nodeTitleProp\",",
1089 " GLib.BindingFlags.SYNC_CREATE);",
1090 " \tnode.bind_property(\"nodeTipProp\",",
1091 " lbl, \"tooltip_markup\",",
1092 " GLib.BindingFlags.SYNC_CREATE);",
1093 " \t// bind image...",
1101 "\tvar expand = new Gtk.TreeExpander();",
1103 "\texpand.set_indent_for_depth(true);",
1104 "\texpand.set_indent_for_icon(true);",
1105 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1106 "\tvar icon = new Gtk.Image();",
1107 "\tvar lbl = new Gtk.Label(\"\");",
1108 "\tlbl.use_markup = true;",
1109 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1111 "\ticon.margin_end = 4;",
1112 " \tlbl.justify = Gtk.Justification.LEFT;",
1113 " \tlbl.xalign = 0;",
1115 "//\tlistitem.activatable = true; ??",
1117 "\thbox.append(icon);",
1118 "\thbox.append(lbl);",
1119 "\texpand.set_child(hbox);",
1120 "\t((Gtk.ListItem)listitem).set_child(expand);",
1126 "xtype" : "SignalListItemFactory"
1129 "title" : "Property",
1130 "xtype" : "ColumnViewColumn"
1134 "* pack" : "append_column",
1135 "int fixed_width" : 25,
1139 "* prop" : "factory",
1144 " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1145 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1146 "\tvar node = (JsRender.Node) lr.get_item();",
1149 " var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1150 "\timg.set_from_paintable(",
1151 "\t \tic.lookup_icon (",
1152 "\t \t\t\"list-add\", null, 16,1, ",
1153 "\t\t\t Gtk.TextDirection.NONE, 0",
1157 " \tvar fqn = node.fqn();",
1158 " var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1160 "\timg.set_visible(cn.size > 0 ? true : false);",
1169 "\tvar icon = new Gtk.Image();",
1171 "\t((Gtk.ListItem)listitem).set_child(icon);",
1176 "xtype" : "SignalListItemFactory"
1179 "string title" : "Add",
1180 "xtype" : "ColumnViewColumn"
1183 "string name" : "left-tree-view",
1184 "xtype" : "ColumnView",
1185 "| Gtk.Widget? getWidgetAt" : [
1186 "(double x, double in_y) {",
1189 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1190 " \tvar colview = gesture.widget;",
1191 " \tvar line_no = check_list_widget(colview, x,y);",
1192 " if (line_no > -1) {",
1193 " \t\tvar item = colview.model.get_item(line_no);",
1197 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1198 " var child = this.el.get_first_child(); ",
1199 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1200 " \tvar line_no = -1; ",
1201 " \tvar reading_header = true;",
1202 " \tvar curr_y = 0;",
1203 " \tvar header_height = 0;",
1205 " \twhile (child != null) {",
1206 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1207 "\t if (reading_header) {",
1210 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1211 "\t\t\t h += child.get_height();",
1212 "\t\t\t\t\tchild = child.get_next_sibling();",
1213 "\t\t\t\t\tcontinue;",
1215 "\t\t\t\t// should be columnlistview",
1216 "\t\t\t\tchild = child.get_first_child(); ",
1217 "\t\t\t GLib.debug(\"header height=%d\", h);",
1218 "\t\t\t\theader_height = h;",
1220 "\t\t\t\treading_header = false;",
1225 "\t\t\tif (y < header_height) {",
1226 "\t\t \treturn null;",
1229 "\t\t\tvar hh = child.get_height();",
1230 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1232 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
1233 "\t\t\t return (Gtk.Widget)child;",
1235 "\t\t curr_y += hh ;",
1237 "\t\t if (curr_y > y) {",
1238 "\t\t return null;",
1240 "\t child = child.get_next_sibling(); ",
1246 "| Gtk.Widget? getWidgetAtRow" : [
1250 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1251 " \tvar colview = gesture.widget;",
1252 " \tvar line_no = check_list_widget(colview, x,y);",
1253 " if (line_no > -1) {",
1254 " \t\tvar item = colview.model.get_item(line_no);",
1258 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1259 " var child = this.el.get_first_child(); ",
1260 " \tvar line_no = -1; ",
1261 " \tvar reading_header = true;",
1263 " \twhile (child != null) {",
1264 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1266 " \t if (reading_header) {",
1269 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1271 "\t\t\t\t\tchild = child.get_next_sibling();",
1272 "\t\t\t\t\tcontinue;",
1274 "\t\t\t\t// should be columnlistview",
1275 "\t\t\t\tchild = child.get_first_child(); ",
1279 "\t\t\t\treading_header = false;",
1286 "\t\t\tif (line_no == row) {",
1287 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1288 "\t\t\t return (Gtk.Widget)child;",
1290 "\t child = child.get_next_sibling(); ",
1292 "\t\t//GLib.debug(\"Rturning null\");",
1297 "| int getColAt" : [
1298 "(double x, double y) {",
1301 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1304 "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1305 "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1306 " var child = this.el.get_first_child(); ",
1310 " \twhile (child != null) {",
1312 "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1313 "\t\t\t\tchild = child.get_first_child();",
1314 "\t\t\t\tcontinue;",
1317 "\t\t\t//child.get_allocation(out alloc);",
1318 "\t\t\tif (x < (child.get_width() + offx)) {",
1319 "\t\t\t\treturn col;",
1322 "\t\t\t//offx += child.get_width();",
1324 "\t\t\t//child = child.get_next_sibling();",
1332 "| int getRowAt" : [
1333 "(double x, double in_y, out string pos) {",
1340 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1341 " \tvar colview = gesture.widget;",
1342 " \tvar line_no = check_list_widget(colview, x,y);",
1343 " if (line_no > -1) {",
1344 " \t\tvar item = colview.model.get_item(line_no);",
1350 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
1351 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1352 " var child = this.el.get_first_child(); ",
1353 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1354 " \tvar line_no = -1; ",
1355 " \tvar reading_header = true;",
1356 " \tvar real_y = 0;",
1357 " \tvar header_height = 0;",
1358 " \tpos = \"none\";",
1360 " \twhile (child != null) {",
1361 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1362 " \t if (reading_header) {",
1365 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1366 "\t\t\t h += child.get_height();",
1367 "\t\t\t\t\tchild = child.get_next_sibling();",
1368 "\t\t\t\t\tcontinue;",
1370 "\t\t\t\t// should be columnlistview",
1371 "\t\t\t\tchild = child.get_first_child(); ",
1372 "\t\t\t GLib.debug(\"header height=%d\", h);",
1373 "\t\t\t\theader_height = h;",
1375 "\t\t\t\treading_header = false;",
1379 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1380 " \t\t child = child.get_next_sibling();",
1384 "\t\t \tif (y < header_height) {",
1385 "\t\t \treturn -1;",
1389 "\t\t\tvar hh = child.get_height();",
1390 "\t\t\t//child.get_allocation(out alloc);",
1391 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1392 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1394 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1396 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
1397 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1398 "\t\t \t\tpos = \"below\";",
1399 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1400 "\t \t\t\tpos = \"over\";",
1402 " \t\t\t\tpos = \"above\";",
1404 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1405 "\t\t\t return line_no;",
1409 "\t\t if (real_y + hh > y) {",
1413 "\t child = child.get_next_sibling(); ",
1423 "id" : "LeftTreeMenu",
1428 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1433 "label" : "Delete Element",
1437 "_this.LeftTreeMenu.el.hide();",
1438 " _this.model.deleteSelected();",
1447 "label" : "Save as Template",
1451 "_this.LeftTreeMenu.el.hide();",
1452 " DialogSaveTemplate.singleton().showIt(",
1453 " (Gtk.Window) _this.el.get_root (), ",
1454 " _this.main_window.windowstate.file.palete(), ",
1455 " _this.getActiveElement()",
1466 "label" : "Save as Module",
1471 " _this.LeftTreeMenu.el.hide();",
1472 " var node = _this.getActiveElement();",
1475 " var sm = DialogSaveModule.singleton();",
1479 " (Gtk.Window) _this.el.get_root (), ",
1480 " _this.main_window.windowstate.project, ",
1484 " gtk4 migration - disabled this part.. probably not used muchanyway",
1487 " if (name.length < 1) {",
1491 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1492 " node.items.clear();",
1495 " var s = _this.view.el.get_selection();",
1497 " print(\"GET SELECTED?\");",
1498 " Gtk.TreeIter iter;",
1499 " Gtk.TreeModel mod;",
1502 " if (!s.get_selected(out mod, out iter)) {",
1503 " return; // nothing seleted..",
1505 " Gtk.TreeIter citer;",
1506 " var n_cn = mod.iter_n_children(iter) -1;",
1507 " for (var i = n_cn; i > -1; i--) {",
1508 " mod.iter_nth_child(out citer, iter, i);",
1511 " print(\"removing node from Tree\\n\"); ",
1513 " _this.model.el.remove(ref citer);",
1515 " _this.changed();",
1516 " _this.node_selected(node, \"tree\");",
1531 "xtype" : "ScrolledWindow"
1535 "| JsRender.JsRender getActiveFile" : [
1537 " return this.main_window.windowstate.file;",
1541 "| JsRender.Node? getActiveElement" : [
1542 " () { // return path to actie node.",
1545 "\treturn _this.selmodel.getSelectedNode();",
1551 "| void onresize" : [
1555 "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1556 "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );",
1563 "name" : "WindowLeftTree"