e1e1a1760305e707d3dde3e4bf110cacff9b71c2
[roobuilder] / src / Builder4 / WindowLeftTree.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# Xcls_MainWindow main_window" : "null",
7    "$ xns" : "Gtk",
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",
15    "items" : [
16     {
17      "$ xns" : "Gtk",
18      "items" : [
19       {
20        "$ xns" : "Gtk",
21        "* prop" : "factory",
22        "xtype" : "SignalListItemFactory"
23       }
24      ],
25      "xtype" : "ListView"
26     },
27     {
28      "$ xns" : "Gtk",
29      "* init" : [
30       " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
31       " "
32      ],
33      "bool has_frame" : true,
34      "bool hexpand" : true,
35      "bool vexpand" : true,
36      "id" : "viewwin",
37      "items" : [
38       {
39        "# bool blockChanges" : false,
40        "$ string lastEventSource" : "\"\"",
41        "$ xns" : "Gtk",
42        "* init" : [
43         "{",
44         " ",
45         "  this.css = new Gtk.CssProvider();",
46         "//\ttry {",
47         "\t\tthis.css.load_from_string(\"",
48         "#left-tree-view { font-size: 12px;}\t",
49         ".drag-over  { background-color:#88a3bc; }",
50         ".drag-below  {   ",
51         " border-bottom-width: 5px; ",
52         " border-bottom-style: solid;",
53         " border-bottom-color: #88a3bc;",
54         "}",
55         ".drag-above  {",
56         " border-top-width: 5px;",
57         " border-top-style: solid;",
58         " border-top-color: #88a3bc;",
59         "}",
60         "#left-tree-view indent {",
61         "-gtk-icon-size : 2px;",
62         "}",
63         "\");",
64         "",
65         "\tGtk.StyleContext.add_provider_for_display(",
66         "\t\tthis.el.get_display(),",
67         "\t\tthis.css,",
68         "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
69         "\t);",
70         "\t",
71         "\t  ",
72         "}",
73         ""
74        ],
75        "* prop" : "child",
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,
82        "items" : [
83         {
84          "$ xns" : "Gtk",
85          "listeners" : {
86           "pressed" : [
87            "(n_press, x, y) => {",
88            " ",
89            "    //console.log(\"button press?\");",
90            "    ",
91            "    //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
92            "",
93            "",
94            "    ",
95            "    _this.view.button_is_pressed = true;",
96            "      ",
97            "    _this.view.lastEventSource = \"tree\";",
98            "    if (! _this.before_node_change() ) {",
99            "    \tGLib.debug(\"before_node_change return false\");",
100            "       return ;",
101            "    }",
102            "    ",
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\");",
107            "\t    return ;",
108            "    }",
109            "    string pos;",
110            "    var row = _this.view.getRowAt(x,y, out pos );",
111            "    if (row < 0) {",
112            "\t    GLib.debug(\"no row selected items\");",
113            "\t    return;",
114            "    }",
115            "    ",
116            "    var node =   _this.selmodel.getNodeAt(row);",
117            "    if (node == null) {",
118            "    \tGLib.warning(\"No node found at row %d\", row);",
119            "    \treturn;",
120            "\t}",
121            "",
122            "     ",
123            "     ",
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) {",
129            "  \t\t\treturn ;",
130            "\t\t}",
131            "",
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\");",
137            "     \treturn ;",
138            "\t}",
139            "    ",
140            "\t ",
141            "     ",
142            "}",
143            ""
144           ],
145           "released" : [
146            "(n_press, x, y) => {",
147            " ",
148            "    _this.view.button_is_pressed = false;",
149            "",
150            "",
151            "}",
152            ""
153           ]
154          },
155          "xtype" : "GestureClick"
156         },
157         {
158          "$ xns" : "Gtk",
159          "listeners" : {
160           "pressed" : [
161            "(n_press, x, y) => {",
162            "",
163            "\t",
164            "\t  ",
165            "\t ",
166            "    if (_this.model.el.get_n_items() < 1) {",
167            " ",
168            "        GLib.debug(\"no items\");",
169            "\t    return ;",
170            "    }",
171            "    string pos;",
172            "    var row = _this.view.getRowAt(x,y, out pos );",
173            "    if (row < 0) {",
174            "\t    GLib.debug(\"no row selected items\");",
175            "\t    return;",
176            "    }",
177            "    ",
178            "    var node =   _this.selmodel.getNodeAt(row);",
179            "    if (node == null) {",
180            "    \tGLib.warning(\"No node found at row %d\", row);",
181            "    \treturn;",
182            "\t}",
183            "\t_this.model.selectNode(node);",
184            "     ",
185            "     ",
186            "     ",
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);",
190            "\t",
191            "\t",
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); ",
196            "\t",
197            "\t\t",
198            "\t_this.LeftTreeMenu.el.set_offset( ",
199            "\t\t\t(int)x  ,",
200            "\t\t\t(int)y - (int)_this.view.el.get_height());",
201            "",
202            "    _this.LeftTreeMenu.el.popup();",
203            "      ",
204            "}",
205            ""
206           ]
207          },
208          "uint button" : 3,
209          "xtype" : "GestureClick"
210         },
211         {
212          "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY   | Gdk.DragAction.MOVE   ",
213          "$ xns" : "Gtk",
214          "listeners" : {
215           "drag_begin" : [
216            "( drag )  => {",
217            "\tGLib.debug(\"SOURCE: drag-begin\");",
218            "\t ",
219            "    // find what is selected in our tree...",
220            "   var data = _this.selmodel.getSelectedNode();",
221            "\tif (data == null) {",
222            "\t\treturn  ;",
223            "\t}",
224            "\t ",
225            "    var xname = data.fqn();",
226            "    GLib.debug (\"XNAME  IS %s\", xname);",
227            "",
228            " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
229            " \t",
230            " \t",
231            "    var paintable = new Gtk.WidgetPaintable(widget);",
232            "    this.el.set_icon(paintable, 0,0);",
233            "            ",
234            " ",
235            "}"
236           ],
237           "prepare" : [
238            "(x, y) => {",
239            "",
240            "\t",
241            "\t",
242            "///\t( drag_context, data, info, time) => {",
243            "            ",
244            "",
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..\");",
249            "\t\treturn null;",
250            "\t ",
251            "\t}",
252            "",
253            "  ",
254            "\t//data.set_text(tp,tp.length);   ",
255            "",
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);",
261            "    /*",
262            "\tGLib.Value v = GLib.Value(typeof(string));",
263            "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
264            "\t ",
265            "\t\tcont.get_value(ref v);",
266            "\t ",
267            "\t}",
268            "\tGLib.debug(\"set %s\", v.get_string());",
269            "      */  ",
270            " \treturn cont;",
271            "\t ",
272            "\t ",
273            "}",
274            ""
275           ]
276          },
277          "xtype" : "DragSource"
278         },
279         {
280          "$ xns" : "Gtk",
281          "listeners" : {
282           "key_pressed" : [
283            "(keyval, keycode, state) => {",
284            "",
285            " ",
286            "",
287            "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace)  {",
288            "\t\treturn true;",
289            "\t}",
290            "",
291            "\t_this.model.deleteSelected();",
292            "\treturn true;",
293            "",
294            "}",
295            ""
296           ]
297          },
298          "xtype" : "EventControllerKey"
299         },
300         {
301          "$ xns" : "Gtk",
302          "* ctor" : [
303           "new Gtk.DropTarget ( typeof(string) ,",
304           "\t\tGdk.DragAction.COPY   | Gdk.DragAction.MOVE   )"
305          ],
306          "Gtk.Widget? highlightWidget" : "null",
307          "JsRender.Node? lastDragNode" : "null",
308          "id" : "drop",
309          "listeners" : {
310           "accept" : [
311            "(drop) => {",
312            "",
313            "\tGLib.debug(\"got DropTarget:accept\");",
314            " ",
315            "// NOT REALLY NEEDED? = put stuff in drop?",
316            "",
317            "",
318            "/* (  ctx, x, y, time)  => {",
319            "      //Seed.print(\"TARGET: drag-drop\");",
320            "   ",
321            "   ",
322            "    var src = Gtk.drag_get_source_widget(ctx);",
323            "     ",
324            "   if (src != this.el) {",
325            "   ",
326            "    ",
327            "       ",
328            "       this.drag_in_motion = false;   ",
329            "            // request data that will be recieved by the recieve...              ",
330            "        Gtk.drag_get_data",
331            "        (",
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 ",
336            "        );",
337            "",
338            "         ",
339            "        // No target offered by source => error",
340            "   ",
341            "",
342            "         return  false;",
343            "     }",
344            "     ",
345            "     // handle drop around self..",
346            "     ",
347            "                  ",
348            "            ",
349            "    //print(\"GETTING POS\");",
350            "    var  targetData = \"\";",
351            "    ",
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);",
355            "    ",
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; //??? ",
361            "        isEmpty = true;",
362            "        pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
363            "    }",
364            "    ",
365            "     ",
366            "     ",
367            "    //var action = Gdk.DragAction.COPY;",
368            "        // unless we are copying!!! ctl button..",
369            "    ",
370            "    var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
371            "                 Gdk.DragAction.COPY  : Gdk.DragAction.MOVE ;",
372            "                // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
373            "",
374            "      ",
375            "    if (_this.model.el.iter_n_children(null) < 1) {",
376            "        // no children.. -- asume it's ok..",
377            "        ",
378            "        targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
379            "         ",
380            "        // continue through to allow drop...",
381            "",
382            "    } else {",
383            "                ",
384            "                ",
385            "    ",
386            "                ",
387            "                ",
388            "                //print(\"ISOVER? \" + isOver);",
389            "        if (!isOver) {",
390            "            ",
391            "            Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
392            "            return true; // not over apoint!?! - no action on drop or motion..",
393            "        }",
394            "                ",
395            "        // drag node is parent of child..",
396            "        //console.log(\"SRC TREEPATH: \" + src.treepath);",
397            "        //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
398            "        ",
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",
404            "        ",
405            "        // locally dragged items to not really use the ",
406            "        var selection_text = this.dragData;",
407            "        ",
408            "        ",
409            "        ",
410            "        if (selection_text == null || selection_text.length < 1) {",
411            "            //print(\"Error  - drag selection text returned NULL\");",
412            "          ",
413            "             Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
414            "             return true; /// -- fixme -- this is not really correct..",
415            "        }                ",
416            "                ",
417            "                // see if we are dragging into ourself?",
418            "                print (\"got selection text of  \" + selection_text);",
419            "        ",
420            "        var target_path = path.to_string();",
421            "        //print(\"target_path=\"+target_path);",
422            "",
423            "        // ",
424            "        if (selection_text  == target_path) {",
425            "            print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
426            "            ",
427            "             Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
428            "",
429            "             return true; /// -- fixme -- this is not really correct..",
430            "",
431            "        }",
432            "                ",
433            "        // check that ",
434            "        //print(\"DUMPING DATA\");",
435            "        //console.dump(data);",
436            "        // path, pos",
437            "        ",
438            "        //print(data.path.to_string() +' => '+  data.pos);",
439            "        ",
440            "        // dropList is a list of xtypes that this node could be dropped on.",
441            "        // it is set up when we start to drag..",
442            "        ",
443            "        ",
444            "        targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
445            "            ",
446            "        print(\"targetDAta: \" + targetData +\"\\n\");",
447            "        ",
448            "        if (targetData.length < 1) {",
449            "            //print(\"Can not find drop node path\");",
450            "             ",
451            "            Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
452            "            return true;",
453            "        }",
454            "                    ",
455            "                ",
456            "                ",
457            "                // continue on to allow drop..",
458            "  }",
459            "        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
460            "",
461            "",
462            "     var delete_selection_data = false;",
463            "        ",
464            "    if (action == Gdk.DragAction.ASK)  {",
465            "        // Ask the user to move or copy, then set the ctx action. ",
466            "    }",
467            "",
468            "    if (action == Gdk.DragAction.MOVE) {",
469            "        delete_selection_data = true;",
470            "    }",
471            "      ",
472            "                // drag around.. - reorder..",
473            "    _this.model.moveNode(targetData, action);",
474            "        ",
475            "       ",
476            "        ",
477            "        ",
478            "        ",
479            "        // we can send stuff to souce here...",
480            "",
481            "",
482            "// do we always say failure, so we handle the reall drop?",
483            "    Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
484            "",
485            "    return true;",
486            " ",
487            " ",
488            " ",
489            " ",
490            " ",
491            " ",
492            "}",
493            "*/",
494            "\treturn true;",
495            "}",
496            ""
497           ],
498           "drop" : [
499            "(v, x, y) => {",
500            "\t",
501            "\tthis.addHighlight(null,\"\");",
502            " ",
503            " ",
504            " ",
505            " \tvar pos = \"\";",
506            " \t// -- get position..",
507            " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
508            "\t\t// still dragging same node",
509            " ",
510            "\t\tthis.lastDragNode = new JsRender.Node(); ",
511            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
512            "\t}",
513            "    ",
514            " \t     ",
515            "       ",
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());",
519            "   ",
520            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
521            " ",
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",
527            "\t\t}",
528            "\t\t// add new node to top..",
529            "\t\t",
530            "\t\t",
531            "\t\t var m = (GLib.ListStore) _this.model.el.model;",
532            "     \t_this.main_window.windowstate.file.tree = dropNode;  ",
533            "    ",
534            "   ",
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?",
539            "     ",
540            "    }",
541            "",
542            "",
543            "",
544            "\tvar row = _this.view.getRowAt(x,y, out pos);",
545            "\tif (row < 0) {",
546            "\t\treturn   false; //Gdk.DragAction.COPY;",
547            "\t}",
548            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
549            "\t",
550            "\tvar node =  (JsRender.Node)tr.get_item();",
551            "",
552            " \tif (pos == \"above\" || pos == \"below\") {",
553            "\t\tif (node.parent == null) {",
554            "\t\t\tpos = \"over\";",
555            "\t\t} else {",
556            "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
557            "\t\t\t\tpos = \"over\";",
558            " \t\t\t} else {",
559            "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
560            "\t\t\t}",
561            " \t\t}",
562            " \t\t",
563            " \t}",
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;",
568            "",
569            "\t\t}",
570            "\t}",
571            " \t",
572            " \tswitch(pos) {",
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;",
578            "\t \t\t",
579            " \t\tcase \"above\":",
580            " \t\t\tGLib.debug(\"Above - insertBefore\");",
581            " \t\t",
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;",
586            " \t\t\t",
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;",
594            " \t\t\t",
595            " \t\tdefault:",
596            " \t\t\t// should not happen",
597            " \t\t\treturn false;",
598            " \t}",
599            " \t",
600            "\t",
601            "     ",
602            "\t\t",
603            "\t\t",
604            "",
605            "}",
606            " "
607           ],
608           "leave" : [
609            "( ) => {",
610            "\tthis.addHighlight(null,\"\");",
611            "",
612            "}",
613            ""
614           ],
615           "motion" : [
616            "(  x, y) => {",
617            " ",
618            "\tstring pos; // over / before / after..",
619            "",
620            "    GLib.debug(\"got drag motion\");",
621            "",
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 ;",
625            "   \ttry {",
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 ",
630            "\t",
631            "\t}",
632            "",
633            "\tGLib.debug(\"got %s\", v.get_string());",
634            "\t  ",
635            "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
636            "\t\t// still dragging same node",
637            " ",
638            "\t\tthis.lastDragNode = new JsRender.Node(); ",
639            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
640            "\t}",
641            "    ",
642            "",
643            "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
644            "\t\t\t\tthis.lastDragNode.fqn());",
645            "     ",
646            "     string[] str = {};",
647            "     foreach(var dp in drop_on_to) {",
648            "     \tstr += dp;",
649            " \t}",
650            " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
651            "     ",
652            "     ",
653            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
654            " ",
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\");",
659            "\t\t} else {",
660            "\t\t\tthis.addHighlight(null, \"\");\t\t",
661            "\t\t}",
662            "",
663            "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
664            "     ",
665            "    }",
666            "    ",
667            "    ",
668            " \tGLib.debug(\"check is over\");",
669            " \t ",
670            "    // if path of source and dest are inside each other..",
671            "    // need to add source info to drag?",
672            "    // the fail();",
673            " \tvar row = _this.view.getRowAt(x,y, out pos);",
674            " \t",
675            " \tif (row < 0) {",
676            "\t\tthis.addHighlight(null, \"\");\t",
677            "\t \treturn Gdk.DragAction.COPY;",
678            " \t}",
679            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
680            "\t",
681            "\tvar node =  (JsRender.Node)tr.get_item();",
682            "\t",
683            "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
684            "\t",
685            "",
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\";",
690            "\t\t} else {",
691            "\t \t\t ",
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\";",
695            " \t\t\t} else {",
696            "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
697            "\t\t\t}",
698            " \t\t}",
699            " \t\t",
700            " \t}",
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",
706            "\t\t}",
707            "\t}",
708            " \t",
709            " \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",
714            "}"
715           ]
716          },
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\");",
726           "\t\t}",
727           "\t\tif (ww.has_css_class(\"drag-above\")) {",
728           "\t\t\t ww.remove_css_class(\"drag-above\");",
729           "\t\t}",
730           "\t\tif (ww.has_css_class(\"drag-over\")) {",
731           "\t\t\t ww.remove_css_class(\"drag-over\");",
732           "\t\t}",
733           "\t}",
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);",
738           "\t\t}",
739           "\t}",
740           "\tthis.highlightWidget = w;",
741           "}"
742          ]
743         },
744         {
745          "$ xns" : "Gtk",
746          "* prop" : "model",
747          "id" : "selmodel",
748          "items" : [
749           {
750            "$ xns" : "Gtk",
751            "* ctor" : "this.updateModel(null)",
752            "* prop" : "model",
753            "id" : "model",
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",
761             "\t\t(item) => {",
762             "\t\t\treturn ((JsRender.Node)item).childstore;",
763             "\t\t",
764             "\t\t}",
765             "\t);",
766             "\t_this.selmodel.el.set_model(this.el);",
767             "\treturn this.el;",
768             "}"
769            ],
770            "| void deleteSelected" : [
771             "() {",
772             "",
773             "",
774             "\t",
775             "\tvar node = _this.selmodel.getSelectedNode();",
776             "\t",
777             "",
778             "     if (node == null) {",
779             "     \tGLib.debug(\"delete Selected - no node slected?\");",
780             "\t     return;",
781             "     }",
782             "    _this.selmodel.el.unselect_all();",
783             "    ",
784             "    node.remove();",
785             " \tGLib.debug(\"delete Selected - done\");",
786             "    _this.changed();",
787             "/*    ",
788             "    print(\"DELETE SELECTED?\");",
789             "    //_this.view.blockChanges = true;",
790             "    print(\"GET SELECTION?\");",
791             "",
792             "    var s = _this.view.el.get_selection();",
793             "    ",
794             "    print(\"GET  SELECTED?\");",
795             "   Gtk.TreeIter iter;",
796             "    Gtk.TreeModel mod;",
797             "",
798             "    ",
799             "    if (!s.get_selected(out mod, out iter)) {",
800             "        return; // nothing seleted..",
801             "    }",
802             "      ",
803             "",
804             "",
805             "    this.activePath= \"\";      ",
806             "    print(\"GET  vnode value?\");",
807             "",
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;",
814             "    } else {",
815             "        data.remove();",
816             "    }",
817             "    print(\"removing node from Tree\\n\");    ",
818             "    s.unselect_all();",
819             "    this.el.remove(ref iter);",
820             "",
821             "    ",
822             "    ",
823             "    ",
824             "    // ",
825             "    ",
826             "    ",
827             "",
828             "",
829             "    this.activePath= \"\"; // again!?!?      ",
830             "    //this.changed(null,true);",
831             "    ",
832             "    _this.changed();",
833             "    ",
834             "    _this.view.blockChanges = false;",
835             "    */",
836             "}",
837             ""
838            ],
839            "| void loadFile" : [
840             "(JsRender.JsRender f) {",
841             "    //console.dump(f);",
842             "    ",
843             "    _this.drop.highlightWidget = null;",
844             "    ",
845             "    var m = (GLib.ListStore) this.el.model;",
846             "\tm.remove_all();",
847             "    _this.main_window.windowstate.leftTreeNodeSelected(null);",
848             "    // needed???",
849             "    _this.main_window.windowstate.file = f;",
850             "    ",
851             "   ",
852             "    if (f.tree == null) {",
853             "\t    try {",
854             "\t        f.loadItems( );",
855             "        } catch (Error e) {",
856             "    \t\treturn;",
857             "        }",
858             "    }",
859             "    // if it's still null?",
860             "    if (f.tree == null) {",
861             "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
862             "    ",
863             "        return;",
864             "    }",
865             "  \tm.append(f.tree);",
866             "  \t// expand???",
867             "",
868             "/*",
869             "    if (f.tree.readItems().size < 1) {",
870             "        // single item..",
871             "        ",
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);",
876             "        ",
877             "        ",
878             "    } else {",
879             "          //this.get('/Window.leftvpaned').el.set_position(200);",
880             "    }",
881             "  */  ",
882             "    ",
883             "    ",
884             "",
885             "    //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
886             " ",
887             "    _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
888             "   ",
889             "    return;",
890             " ",
891             "            ",
892             "}",
893             ""
894            ],
895            "| void selectNode" : [
896             "(JsRender.Node node) ",
897             "{",
898             "\tvar row = -1;",
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) {",
905             "\t\t\trow  = i;",
906             "\t\t\tbreak;",
907             "\t\t}",
908             "\t}",
909             "\tif (row < 0) {",
910             "\t\t// select none?",
911             "\t\tGLib.debug(\"Could not find node\");",
912             "\t\treturn;",
913             "\t}",
914             "\tGLib.debug(\"Select %d\", row);",
915             "\ts.set_selected(row);",
916             "\t_this.node_selected(node);\t\t\t",
917             "\t",
918             "",
919             "}"
920            ]
921           }
922          ],
923          "listeners" : {
924           "selection_changed" : [
925            "(position, n_items) => {",
926            "",
927            "\t",
928            "\t\t",
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\");",
933            "\t\t//\treturn;",
934            "\t\t//}",
935            "",
936            "",
937            "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
938            "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\");     ",
939            "\t\t   return  ;",
940            "\t\t }",
941            "",
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;",
946            "\t\t\t ",
947            "\t\t\t return;",
948            "\t\t }",
949            "\t\t if (_this.main_window.windowstate.file == null) {",
950            "\t   \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\");     ",
951            "\t\t\treturn;",
952            "\t\t } ",
953            "\t\t ",
954            "\t\t //var render = this.get('/LeftTree').getRenderer();                ",
955            "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
956            "\t\t",
957            "\t\t",
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);",
961            " ",
962            "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
963            "",
964            "\t    var snode = _this.selmodel.getSelectedNode();",
965            "\t    if (snode == null) {",
966            "",
967            "\t         GLib.debug(\"selected rows < 1\");",
968            "\t        //??this.model.load( false);",
969            "\t        _this.node_selected(null);",
970            "\t        ",
971            "\t        return   ;",
972            "\t    }",
973            "\t ",
974            "\t    // why dup_?",
975            "\t    ",
976            "",
977            "\t    GLib.debug (\"calling left_tree.node_selected\");",
978            "\t    _this.node_selected(snode);",
979            "\t   ",
980            "\t     ",
981            "\t    ",
982            "\t     ",
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);",
985            "\t    ",
986            "\t    return  ;",
987            "}",
988            ""
989           ]
990          },
991          "xtype" : "SingleSelection",
992          "| JsRender.Node getNodeAt" : [
993           "(uint row) {",
994           "",
995           "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
996           "   ",
997           "   var a = tr.get_item();;   ",
998           "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
999           "  \t",
1000           "   ",
1001           "   return (JsRender.Node)tr.get_item();",
1002           "\t ",
1003           "}"
1004          ],
1005          "| JsRender.Node? getSelectedNode" : [
1006           "() {",
1007           "  if (this.el.selected_item == null) {",
1008           "\t\treturn null;",
1009           "  }\t\t\t        ",
1010           "   var tr = (Gtk.TreeListRow)this.el.selected_item;",
1011           "   return (JsRender.Node)tr.get_item();",
1012           "\t ",
1013           "}"
1014          ]
1015         },
1016         {
1017          "$ xns" : "Gtk",
1018          "* pack" : "append_column",
1019          "bool expand" : true,
1020          "bool resizable" : true,
1021          "id" : "maincol",
1022          "items" : [
1023           {
1024            "$ xns" : "Gtk",
1025            "* prop" : "factory",
1026            "listeners" : {
1027             "bind" : [
1028              "(listitem) => {",
1029              "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1030              "\t",
1031              "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1032              "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1033              "\t ",
1034              "\t ",
1035              "\tvar hbox = (Gtk.Box) expand.child;",
1036              " ",
1037              "\t",
1038              "\tvar img = (Gtk.Image) hbox.get_first_child();",
1039              "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1040              "\t",
1041              "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1042              "\tvar node = (JsRender.Node) lr.get_item();",
1043              "\t",
1044              "   GLib.debug(\"node is %s\", node.get_type().name());",
1045              "// was item (1) in old layout",
1046              "",
1047              "\t",
1048              " ",
1049              " \t /* ",
1050              " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1051              "    var clsname = node.fqn();",
1052              "    ",
1053              "    var clsb = clsname.split(\".\");",
1054              "    var sub = clsb.length > 1 ? clsb[1].down()  : \"\";",
1055              "     ",
1056              "    var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1057              "    try { ",
1058              "    \t ",
1059              "    \t\t ",
1060              "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1061              "\t\t    img.set_from_file(fn);",
1062              "\t\t \t ",
1063              "\t \t} else {",
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",
1068              "    \t\t\t)",
1069              "\t\t\t );",
1070              "\t \t}",
1071              " \t} catch (GLib.Error e) {}",
1072              "    */",
1073              "    expand.set_hide_expander( !node.hasChildren() );",
1074              " \texpand.set_list_row(lr);",
1075              " \t",
1076              " \tnode.bind_property(\"iconFilename\",",
1077              "                    img, \"file\",",
1078              "                   GLib.BindingFlags.SYNC_CREATE);",
1079              " \t",
1080              " \tnode.bind_property(\"nodeTitleProp\",",
1081              "                    lbl, \"label\",",
1082              "                   GLib.BindingFlags.SYNC_CREATE);",
1083              " \tnode.bind_property(\"nodeTipProp\",",
1084              "                    lbl, \"tooltip_markup\",",
1085              "                   GLib.BindingFlags.SYNC_CREATE);",
1086              " \t// bind image...",
1087              " \t",
1088              "}",
1089              ""
1090             ],
1091             "setup" : [
1092              "(listitem) => {",
1093              "\t",
1094              "\tvar expand = new Gtk.TreeExpander();",
1095              "\t ",
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;",
1103              "\t",
1104              "\ticon.margin_end = 4;",
1105              " \tlbl.justify = Gtk.Justification.LEFT;",
1106              " \tlbl.xalign = 0;",
1107              "",
1108              "//\tlistitem.activatable = true; ??",
1109              "\t",
1110              "\thbox.append(icon);",
1111              "\thbox.append(lbl);",
1112              "\texpand.set_child(hbox);",
1113              "\t((Gtk.ListItem)listitem).set_child(expand);",
1114              "\t",
1115              "}",
1116              ""
1117             ]
1118            },
1119            "xtype" : "SignalListItemFactory"
1120           }
1121          ],
1122          "title" : "Property",
1123          "xtype" : "ColumnViewColumn"
1124         },
1125         {
1126          "$ xns" : "Gtk",
1127          "* pack" : "append_column",
1128          "int fixed_width" : 25,
1129          "items" : [
1130           {
1131            "$ xns" : "Gtk",
1132            "* prop" : "factory",
1133            "listeners" : {
1134             "bind" : [
1135              "(listitem) => {",
1136              "",
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();",
1140              "\t",
1141              "  ",
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",
1147              "\t\t)",
1148              "\t );",
1149              "\t ",
1150              " \tvar fqn = node.fqn();",
1151              "    var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1152              "",
1153              "\timg.set_visible(cn.size > 0 ? true : false);",
1154              " \t ",
1155              "}",
1156              ""
1157             ],
1158             "setup" : [
1159              "(listitem) => {",
1160              "",
1161              "\t ",
1162              "\tvar icon = new Gtk.Image();",
1163              "\t ",
1164              "\t((Gtk.ListItem)listitem).set_child(icon);",
1165              "}",
1166              ""
1167             ]
1168            },
1169            "xtype" : "SignalListItemFactory"
1170           }
1171          ],
1172          "string title" : "Add",
1173          "xtype" : "ColumnViewColumn"
1174         }
1175        ],
1176        "string name" : "left-tree-view",
1177        "xtype" : "ColumnView",
1178        "| Gtk.Widget? getWidgetAt" : [
1179         "(double x,  double in_y) {",
1180         "/*",
1181         "    \t",
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);",
1187         "    \t\t ",
1188         "    \t}",
1189         "    \t*/",
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;",
1197         "    \tvar h = 0;",
1198         "    \twhile (child != null) {",
1199         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1200         "\t        if (reading_header) {",
1201         "\t\t\t\t",
1202         "",
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;",
1207         "\t\t\t\t}",
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;",
1212         "\t\t\t\t",
1213         "\t\t\t\treading_header = false;",
1214         "\t\t\t\t",
1215         "\t        }",
1216         "\t\t    line_no++;",
1217         "",
1218         "\t\t\tif (y < header_height) {",
1219         "\t\t    \treturn null;",
1220         "\t    \t}",
1221         "",
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);",
1224         "",
1225         "\t\t    if (y > curr_y && y <= header_height + hh + curr_y ) {",
1226         "\t\t\t    return (Gtk.Widget)child;",
1227         "\t\t    }",
1228         "\t\t    curr_y +=  hh ;",
1229         "",
1230         "\t\t    if (curr_y > y) {",
1231         "\t\t        return null;",
1232         "\t        }",
1233         "\t        child = child.get_next_sibling(); ",
1234         "    \t}",
1235         "        return null;",
1236         "",
1237         " }"
1238        ],
1239        "| Gtk.Widget? getWidgetAtRow" : [
1240         "(uint row) {",
1241         "/*",
1242         "    \t",
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);",
1248         "    \t\t ",
1249         "    \t}",
1250         "    \t*/",
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;",
1255         "\t ",
1256         "    \twhile (child != null) {",
1257         "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1258         "    \t   ",
1259         "    \t   if (reading_header) {",
1260         "\t\t\t\t",
1261         "",
1262         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1263         "\t\t\t\t   ",
1264         "\t\t\t\t\tchild = child.get_next_sibling();",
1265         "\t\t\t\t\tcontinue;",
1266         "\t\t\t\t}",
1267         "\t\t\t\t// should be columnlistview",
1268         "\t\t\t\tchild = child.get_first_child(); ",
1269         "\t\t\t ",
1270         "\t\t\t ",
1271         "\t\t\t\t",
1272         "\t\t\t\treading_header = false;",
1273         "\t\t\t\t ",
1274         "\t\t    }",
1275         "\t\t    ",
1276         "\t\t  ",
1277         "    \t    ",
1278         "\t\t    line_no++;",
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;",
1282         "\t\t    }",
1283         "\t        child = child.get_next_sibling(); ",
1284         "    \t}",
1285         "\t\t//GLib.debug(\"Rturning null\");",
1286         "        return null;",
1287         "",
1288         " }"
1289        ],
1290        "| int getColAt" : [
1291         "(double x,  double y) {",
1292         "/*",
1293         "    \t",
1294         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1295         "    \t  ",
1296         "    \t*/",
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(); ",
1300         "    \t ",
1301         "    \tvar col = 0;",
1302         "    \tvar offx = 0;",
1303         "    \twhile (child != null) {",
1304         "\t\t\t",
1305         "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1306         "\t\t\t\tchild = child.get_first_child();",
1307         "\t\t\t\tcontinue;",
1308         "\t\t\t}",
1309         "\t\t\t",
1310         "\t\t\t//child.get_allocation(out alloc);",
1311         "\t\t\tif (x <  (child.get_width() + offx)) {",
1312         "\t\t\t\treturn col;",
1313         "\t\t\t}",
1314         "\t\t\treturn 1;",
1315         "\t\t\t//offx += child.get_width();",
1316         "\t\t\t//col++;",
1317         "\t\t\t//child = child.get_next_sibling();",
1318         "\t\t}",
1319         "    \t     ",
1320         "\t\t\t  ",
1321         "        return -1;",
1322         "",
1323         " }"
1324        ],
1325        "| int getRowAt" : [
1326         "(double x,  double in_y, out string pos) {",
1327         "",
1328         "",
1329         "\t ",
1330         "",
1331         "/*",
1332         "    \t",
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);",
1338         "    \t\t ",
1339         "    \t}",
1340         "    \t*/",
1341         " \t\t ",
1342         " \t\t",
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\";",
1352         "    \tvar h = 0;",
1353         "    \twhile (child != null) {",
1354         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1355         "    \t    if (reading_header) {",
1356         "\t\t\t\t",
1357         "",
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;",
1362         "\t\t\t\t}",
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;",
1367         "\t\t\t\t",
1368         "\t\t\t\treading_header = false;",
1369         "\t\t\t\t",
1370         "\t        }",
1371         "\t        ",
1372         "\t\t    if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1373         "    \t\t    child = child.get_next_sibling();",
1374         "    \t\t    continue;",
1375         "\t\t    }",
1376         "\t\t    ",
1377         "\t\t \tif (y < header_height) {",
1378         "\t\t    \treturn -1;",
1379         "\t    \t}",
1380         "\t\t    ",
1381         "\t\t    line_no++;",
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),",
1386         "\t\t\t",
1387         "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1388         "",
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\";",
1394         "    \t\t\t} else {",
1395         "    \t\t\t\tpos = \"above\";",
1396         "\t\t\t\t}",
1397         "\t\t    \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1398         "\t\t\t    return line_no;",
1399         "\t\t    }",
1400         " ",
1401         "",
1402         "\t\t    if (real_y + hh > y) {",
1403         "\t\t        return -1;",
1404         "\t        }",
1405         "\t        real_y += hh;",
1406         "\t        child = child.get_next_sibling(); ",
1407         "    \t}",
1408         "        return -1;",
1409         "",
1410         " }"
1411        ]
1412       },
1413       {
1414        "$ xns" : "Gtk",
1415        "* pack" : false,
1416        "id" : "LeftTreeMenu",
1417        "items" : [
1418         {
1419          "$ xns" : "Gtk",
1420          "* prop" : "child",
1421          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1422          "int spacing" : 0,
1423          "items" : [
1424           {
1425            "$ xns" : "Gtk",
1426            "label" : "Delete Element",
1427            "listeners" : {
1428             "clicked" : [
1429              "  ( ) => {",
1430              "    ",
1431              "    print(\"ACTIVATE?\");",
1432              "    ",
1433              "  \t_this.LeftTreeMenu.el.hide();",
1434              "     _this.model.deleteSelected();",
1435              "}"
1436             ]
1437            },
1438            "xtype" : "Button"
1439           },
1440           {
1441            "$ xns" : "Gtk",
1442            "label" : "Save as Template",
1443            "listeners" : {
1444             "clicked" : [
1445              "  () => {",
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()",
1451              "    );",
1452              "     ",
1453              "    ",
1454              "}"
1455             ]
1456            },
1457            "xtype" : "Button"
1458           },
1459           {
1460            "$ xns" : "Gtk",
1461            "label" : "Save as Module",
1462            "listeners" : {
1463             "clicked" : [
1464              "  () => {",
1465              "    ",
1466              "    _this.LeftTreeMenu.el.hide();",
1467              "    var node = _this.getActiveElement();",
1468              "      ",
1469              "     ",
1470              "     var sm = DialogSaveModule.singleton();",
1471              "     ",
1472              "     ",
1473              "    sm.showIt(",
1474              "            (Gtk.Window) _this.el.get_root (), ",
1475              "            _this.main_window.windowstate.project, ",
1476              "            node",
1477              "     );",
1478              "     /*",
1479              "     gtk4 migration - disabled this part.. probably not used muchanyway",
1480              "     ",
1481              "     ",
1482              "     if (name.length < 1) {",
1483              "            return;",
1484              "  ",
1485              "     }",
1486              "     node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1487              "     node.items.clear();",
1488              "",
1489              "",
1490              "    var s = _this.view.el.get_selection();",
1491              "    ",
1492              "    print(\"GET  SELECTED?\");",
1493              "    Gtk.TreeIter iter;",
1494              "    Gtk.TreeModel mod;",
1495              "",
1496              "    ",
1497              "    if (!s.get_selected(out mod, out iter)) {",
1498              "        return; // nothing seleted..",
1499              "    }",
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);",
1504              "        ",
1505              "",
1506              "        print(\"removing node from Tree\\n\");    ",
1507              "    ",
1508              "        _this.model.el.remove(ref citer);",
1509              "    }",
1510              "    _this.changed();",
1511              "    _this.node_selected(node, \"tree\");",
1512              "     */",
1513              "    ",
1514              "}"
1515             ]
1516            },
1517            "xtype" : "Button"
1518           }
1519          ],
1520          "xtype" : "Box"
1521         }
1522        ],
1523        "xtype" : "Popover"
1524       }
1525      ],
1526      "xtype" : "ScrolledWindow"
1527     }
1528    ],
1529    "xtype" : "Box",
1530    "| JsRender.JsRender getActiveFile" : [
1531     "() {",
1532     "    return this.main_window.windowstate.file;",
1533     "}",
1534     ""
1535    ],
1536    "| JsRender.Node? getActiveElement" : [
1537     " () { // return path to actie node.",
1538     "",
1539     "     ",
1540     "\treturn _this.selmodel.getSelectedNode();",
1541     "    ",
1542     "    ",
1543     "}",
1544     ""
1545    ],
1546    "| void onresize" : [
1547     "() {",
1548     " ",
1549     "\t ",
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 );",
1552     "}",
1553     "",
1554     ""
1555    ]
1556   }
1557  ],
1558  "name" : "WindowLeftTree"
1559 }