meson.build.o7QLX02
[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         "#left-tree-view indent:nth-last-child(2)  {",
64         "min-width: 24px;",
65         "}",
66         "\");",
67         "",
68         "\tGtk.StyleContext.add_provider_for_display(",
69         "\t\tthis.el.get_display(),",
70         "\t\tthis.css,",
71         "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
72         "\t);",
73         "\t",
74         "\t  ",
75         "}",
76         ""
77        ],
78        "* prop" : "child",
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,
85        "items" : [
86         {
87          "$ xns" : "Gtk",
88          "listeners" : {
89           "pressed" : [
90            "(n_press, x, y) => {",
91            " ",
92            "    //console.log(\"button press?\");",
93            "    ",
94            "    //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
95            "",
96            "",
97            "    ",
98            "    _this.view.button_is_pressed = true;",
99            "      ",
100            "    _this.view.lastEventSource = \"tree\";",
101            "    if (! _this.before_node_change() ) {",
102            "    \tGLib.debug(\"before_node_change return false\");",
103            "       return ;",
104            "    }",
105            "    ",
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\");",
110            "\t    return ;",
111            "    }",
112            "    string pos;",
113            "    var row = _this.view.getRowAt(x,y, out pos );",
114            "    if (row < 0) {",
115            "\t    GLib.debug(\"no row selected items\");",
116            "\t    return;",
117            "    }",
118            "    ",
119            "    var node =   _this.selmodel.getNodeAt(row);",
120            "    if (node == null) {",
121            "    \tGLib.warning(\"No node found at row %d\", row);",
122            "    \treturn;",
123            "\t}",
124            "",
125            "     ",
126            "     ",
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) {",
132            "  \t\t\treturn ;",
133            "\t\t}",
134            "",
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\");",
140            "     \treturn ;",
141            "\t}",
142            "    ",
143            "\t ",
144            "     ",
145            "}",
146            ""
147           ],
148           "released" : [
149            "(n_press, x, y) => {",
150            " ",
151            "    _this.view.button_is_pressed = false;",
152            "",
153            "",
154            "}",
155            ""
156           ]
157          },
158          "xtype" : "GestureClick"
159         },
160         {
161          "$ xns" : "Gtk",
162          "listeners" : {
163           "pressed" : [
164            "(n_press, x, y) => {",
165            "",
166            "\t",
167            "\t  ",
168            "\t ",
169            "    if (_this.model.el.get_n_items() < 1) {",
170            " ",
171            "        GLib.debug(\"no items\");",
172            "\t    return ;",
173            "    }",
174            "    string pos;",
175            "    var row = _this.view.getRowAt(x,y, out pos );",
176            "    if (row < 0) {",
177            "\t    GLib.debug(\"no row selected items\");",
178            "\t    return;",
179            "    }",
180            "    ",
181            "    var node =   _this.selmodel.getNodeAt(row);",
182            "    if (node == null) {",
183            "    \tGLib.warning(\"No node found at row %d\", row);",
184            "    \treturn;",
185            "\t}",
186            "\t_this.model.selectNode(node);",
187            "     ",
188            "     ",
189            "     ",
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);",
193            "\t",
194            "\t",
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); ",
199            "\t",
200            "\t\t",
201            "\t_this.LeftTreeMenu.el.set_offset( ",
202            "\t\t\t(int)x  ,",
203            "\t\t\t(int)y - (int)_this.view.el.get_height());",
204            "",
205            "    _this.LeftTreeMenu.el.popup();",
206            "      ",
207            "}",
208            ""
209           ]
210          },
211          "uint button" : 3,
212          "xtype" : "GestureClick"
213         },
214         {
215          "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY   | Gdk.DragAction.MOVE   ",
216          "$ xns" : "Gtk",
217          "listeners" : {
218           "drag_begin" : [
219            "( drag )  => {",
220            "\tGLib.debug(\"SOURCE: drag-begin\");",
221            "\t ",
222            "    // find what is selected in our tree...",
223            "   var data = _this.selmodel.getSelectedNode();",
224            "\tif (data == null) {",
225            "\t\treturn  ;",
226            "\t}",
227            "\t ",
228            "    var xname = data.fqn();",
229            "    GLib.debug (\"XNAME  IS %s\", xname);",
230            "",
231            " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
232            " \t",
233            " \t",
234            "    var paintable = new Gtk.WidgetPaintable(widget);",
235            "    this.el.set_icon(paintable, 0,0);",
236            "            ",
237            " ",
238            "}"
239           ],
240           "prepare" : [
241            "(x, y) => {",
242            "",
243            "\t",
244            "\t",
245            "///\t( drag_context, data, info, time) => {",
246            "            ",
247            "",
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..\");",
252            "\t\treturn null;",
253            "\t ",
254            "\t}",
255            "",
256            "  ",
257            "\t//data.set_text(tp,tp.length);   ",
258            "",
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);",
264            "    /*",
265            "\tGLib.Value v = GLib.Value(typeof(string));",
266            "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
267            "\t ",
268            "\t\tcont.get_value(ref v);",
269            "\t ",
270            "\t}",
271            "\tGLib.debug(\"set %s\", v.get_string());",
272            "      */  ",
273            " \treturn cont;",
274            "\t ",
275            "\t ",
276            "}",
277            ""
278           ]
279          },
280          "xtype" : "DragSource"
281         },
282         {
283          "$ xns" : "Gtk",
284          "listeners" : {
285           "key_pressed" : [
286            "(keyval, keycode, state) => {",
287            "",
288            " ",
289            "",
290            "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace)  {",
291            "\t\treturn true;",
292            "\t}",
293            "",
294            "\t_this.model.deleteSelected();",
295            "\treturn true;",
296            "",
297            "}",
298            ""
299           ]
300          },
301          "xtype" : "EventControllerKey"
302         },
303         {
304          "$ xns" : "Gtk",
305          "* ctor" : [
306           "new Gtk.DropTarget ( typeof(string) ,",
307           "\t\tGdk.DragAction.COPY   | Gdk.DragAction.MOVE   )"
308          ],
309          "Gtk.Widget? highlightWidget" : "null",
310          "JsRender.Node? lastDragNode" : "null",
311          "id" : "drop",
312          "listeners" : {
313           "accept" : [
314            "(drop) => {",
315            "",
316            "\tGLib.debug(\"got DropTarget:accept\");",
317            " ",
318            "// NOT REALLY NEEDED? = put stuff in drop?",
319            "",
320            "",
321            "/* (  ctx, x, y, time)  => {",
322            "      //Seed.print(\"TARGET: drag-drop\");",
323            "   ",
324            "   ",
325            "    var src = Gtk.drag_get_source_widget(ctx);",
326            "     ",
327            "   if (src != this.el) {",
328            "   ",
329            "    ",
330            "       ",
331            "       this.drag_in_motion = false;   ",
332            "            // request data that will be recieved by the recieve...              ",
333            "        Gtk.drag_get_data",
334            "        (",
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 ",
339            "        );",
340            "",
341            "         ",
342            "        // No target offered by source => error",
343            "   ",
344            "",
345            "         return  false;",
346            "     }",
347            "     ",
348            "     // handle drop around self..",
349            "     ",
350            "                  ",
351            "            ",
352            "    //print(\"GETTING POS\");",
353            "    var  targetData = \"\";",
354            "    ",
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);",
358            "    ",
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; //??? ",
364            "        isEmpty = true;",
365            "        pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
366            "    }",
367            "    ",
368            "     ",
369            "     ",
370            "    //var action = Gdk.DragAction.COPY;",
371            "        // unless we are copying!!! ctl button..",
372            "    ",
373            "    var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
374            "                 Gdk.DragAction.COPY  : Gdk.DragAction.MOVE ;",
375            "                // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
376            "",
377            "      ",
378            "    if (_this.model.el.iter_n_children(null) < 1) {",
379            "        // no children.. -- asume it's ok..",
380            "        ",
381            "        targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
382            "         ",
383            "        // continue through to allow drop...",
384            "",
385            "    } else {",
386            "                ",
387            "                ",
388            "    ",
389            "                ",
390            "                ",
391            "                //print(\"ISOVER? \" + isOver);",
392            "        if (!isOver) {",
393            "            ",
394            "            Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
395            "            return true; // not over apoint!?! - no action on drop or motion..",
396            "        }",
397            "                ",
398            "        // drag node is parent of child..",
399            "        //console.log(\"SRC TREEPATH: \" + src.treepath);",
400            "        //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
401            "        ",
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",
407            "        ",
408            "        // locally dragged items to not really use the ",
409            "        var selection_text = this.dragData;",
410            "        ",
411            "        ",
412            "        ",
413            "        if (selection_text == null || selection_text.length < 1) {",
414            "            //print(\"Error  - drag selection text returned NULL\");",
415            "          ",
416            "             Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
417            "             return true; /// -- fixme -- this is not really correct..",
418            "        }                ",
419            "                ",
420            "                // see if we are dragging into ourself?",
421            "                print (\"got selection text of  \" + selection_text);",
422            "        ",
423            "        var target_path = path.to_string();",
424            "        //print(\"target_path=\"+target_path);",
425            "",
426            "        // ",
427            "        if (selection_text  == target_path) {",
428            "            print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
429            "            ",
430            "             Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
431            "",
432            "             return true; /// -- fixme -- this is not really correct..",
433            "",
434            "        }",
435            "                ",
436            "        // check that ",
437            "        //print(\"DUMPING DATA\");",
438            "        //console.dump(data);",
439            "        // path, pos",
440            "        ",
441            "        //print(data.path.to_string() +' => '+  data.pos);",
442            "        ",
443            "        // dropList is a list of xtypes that this node could be dropped on.",
444            "        // it is set up when we start to drag..",
445            "        ",
446            "        ",
447            "        targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
448            "            ",
449            "        print(\"targetDAta: \" + targetData +\"\\n\");",
450            "        ",
451            "        if (targetData.length < 1) {",
452            "            //print(\"Can not find drop node path\");",
453            "             ",
454            "            Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
455            "            return true;",
456            "        }",
457            "                    ",
458            "                ",
459            "                ",
460            "                // continue on to allow drop..",
461            "  }",
462            "        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
463            "",
464            "",
465            "     var delete_selection_data = false;",
466            "        ",
467            "    if (action == Gdk.DragAction.ASK)  {",
468            "        // Ask the user to move or copy, then set the ctx action. ",
469            "    }",
470            "",
471            "    if (action == Gdk.DragAction.MOVE) {",
472            "        delete_selection_data = true;",
473            "    }",
474            "      ",
475            "                // drag around.. - reorder..",
476            "    _this.model.moveNode(targetData, action);",
477            "        ",
478            "       ",
479            "        ",
480            "        ",
481            "        ",
482            "        // we can send stuff to souce here...",
483            "",
484            "",
485            "// do we always say failure, so we handle the reall drop?",
486            "    Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
487            "",
488            "    return true;",
489            " ",
490            " ",
491            " ",
492            " ",
493            " ",
494            " ",
495            "}",
496            "*/",
497            "\treturn true;",
498            "}",
499            ""
500           ],
501           "drop" : [
502            "(v, x, y) => {",
503            "\t",
504            "\tthis.addHighlight(null,\"\");",
505            " ",
506            " ",
507            " ",
508            " \tvar pos = \"\";",
509            " \t// -- get position..",
510            " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
511            "\t\t// still dragging same node",
512            " ",
513            "\t\tthis.lastDragNode = new JsRender.Node(); ",
514            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
515            "\t}",
516            "    ",
517            " \t     ",
518            "       ",
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());",
522            "   ",
523            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
524            " ",
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",
530            "\t\t}",
531            "\t\t// add new node to top..",
532            "\t\t",
533            "\t\t",
534            "\t\t var m = (GLib.ListStore) _this.model.el.model;",
535            "     \t_this.main_window.windowstate.file.tree = dropNode;  ",
536            "    ",
537            "   ",
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?",
542            "     ",
543            "    }",
544            "",
545            "",
546            "",
547            "\tvar row = _this.view.getRowAt(x,y, out pos);",
548            "\tif (row < 0) {",
549            "\t\treturn   false; //Gdk.DragAction.COPY;",
550            "\t}",
551            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
552            "\t",
553            "\tvar node =  (JsRender.Node)tr.get_item();",
554            "",
555            " \tif (pos == \"above\" || pos == \"below\") {",
556            "\t\tif (node.parent == null) {",
557            "\t\t\tpos = \"over\";",
558            "\t\t} else {",
559            "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
560            "\t\t\t\tpos = \"over\";",
561            " \t\t\t} else {",
562            "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
563            "\t\t\t}",
564            " \t\t}",
565            " \t\t",
566            " \t}",
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;",
571            "",
572            "\t\t}",
573            "\t}",
574            " \t",
575            " \tswitch(pos) {",
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;",
581            "\t \t\t",
582            " \t\tcase \"above\":",
583            " \t\t\tGLib.debug(\"Above - insertBefore\");",
584            " \t\t",
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;",
589            " \t\t\t",
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;",
597            " \t\t\t",
598            " \t\tdefault:",
599            " \t\t\t// should not happen",
600            " \t\t\treturn false;",
601            " \t}",
602            " \t",
603            "\t",
604            "     ",
605            "\t\t",
606            "\t\t",
607            "",
608            "}",
609            " "
610           ],
611           "leave" : [
612            "( ) => {",
613            "\tthis.addHighlight(null,\"\");",
614            "",
615            "}",
616            ""
617           ],
618           "motion" : [
619            "(  x, y) => {",
620            " ",
621            "\tstring pos; // over / before / after..",
622            "",
623            "    GLib.debug(\"got drag motion\");",
624            "",
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 ;",
628            "   \ttry {",
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 ",
633            "\t",
634            "\t}",
635            "",
636            "\tGLib.debug(\"got %s\", v.get_string());",
637            "\t  ",
638            "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
639            "\t\t// still dragging same node",
640            " ",
641            "\t\tthis.lastDragNode = new JsRender.Node(); ",
642            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
643            "\t}",
644            "    ",
645            "",
646            "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
647            "\t\t\t\tthis.lastDragNode.fqn());",
648            "     ",
649            "     string[] str = {};",
650            "     foreach(var dp in drop_on_to) {",
651            "     \tstr += dp;",
652            " \t}",
653            " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
654            "     ",
655            "     ",
656            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
657            " ",
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\");",
662            "\t\t} else {",
663            "\t\t\tthis.addHighlight(null, \"\");\t\t",
664            "\t\t}",
665            "",
666            "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
667            "     ",
668            "    }",
669            "    ",
670            "    ",
671            " \tGLib.debug(\"check is over\");",
672            " \t ",
673            "    // if path of source and dest are inside each other..",
674            "    // need to add source info to drag?",
675            "    // the fail();",
676            " \tvar row = _this.view.getRowAt(x,y, out pos);",
677            " \t",
678            " \tif (row < 0) {",
679            "\t\tthis.addHighlight(null, \"\");\t",
680            "\t \treturn Gdk.DragAction.COPY;",
681            " \t}",
682            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
683            "\t",
684            "\tvar node =  (JsRender.Node)tr.get_item();",
685            "\t",
686            "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
687            "\t",
688            "",
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\";",
693            "\t\t} else {",
694            "\t \t\t ",
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\";",
698            " \t\t\t} else {",
699            "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
700            "\t\t\t}",
701            " \t\t}",
702            " \t\t",
703            " \t}",
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",
709            "\t\t}",
710            "\t}",
711            " \t",
712            " \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",
717            "}"
718           ]
719          },
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\");",
729           "\t\t}",
730           "\t\tif (ww.has_css_class(\"drag-above\")) {",
731           "\t\t\t ww.remove_css_class(\"drag-above\");",
732           "\t\t}",
733           "\t\tif (ww.has_css_class(\"drag-over\")) {",
734           "\t\t\t ww.remove_css_class(\"drag-over\");",
735           "\t\t}",
736           "\t}",
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);",
741           "\t\t}",
742           "\t}",
743           "\tthis.highlightWidget = w;",
744           "}"
745          ]
746         },
747         {
748          "$ xns" : "Gtk",
749          "* prop" : "model",
750          "id" : "selmodel",
751          "items" : [
752           {
753            "$ xns" : "Gtk",
754            "* ctor" : "this.updateModel(null)",
755            "* prop" : "model",
756            "id" : "model",
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",
764             "\t\t(item) => {",
765             "\t\t\treturn ((JsRender.Node)item).childstore;",
766             "\t\t",
767             "\t\t}",
768             "\t);",
769             "\tif (_this.selmodel.el == null) {",
770             "\t\treturn this.el;",
771             "\t}",
772             "\t_this.selmodel.el.set_model(this.el);",
773             "\treturn this.el;",
774             "}"
775            ],
776            "| void deleteSelected" : [
777             "() {",
778             "",
779             "",
780             "\t",
781             "\tvar node = _this.selmodel.getSelectedNode();",
782             "\t",
783             "",
784             "     if (node == null) {",
785             "     \tGLib.debug(\"delete Selected - no node slected?\");",
786             "\t     return;",
787             "     }",
788             "    _this.selmodel.el.unselect_all();",
789             "    ",
790             "    node.remove();",
791             " \tGLib.debug(\"delete Selected - done\");",
792             "    _this.changed();",
793             "/*    ",
794             "    print(\"DELETE SELECTED?\");",
795             "    //_this.view.blockChanges = true;",
796             "    print(\"GET SELECTION?\");",
797             "",
798             "    var s = _this.view.el.get_selection();",
799             "    ",
800             "    print(\"GET  SELECTED?\");",
801             "   Gtk.TreeIter iter;",
802             "    Gtk.TreeModel mod;",
803             "",
804             "    ",
805             "    if (!s.get_selected(out mod, out iter)) {",
806             "        return; // nothing seleted..",
807             "    }",
808             "      ",
809             "",
810             "",
811             "    this.activePath= \"\";      ",
812             "    print(\"GET  vnode value?\");",
813             "",
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;",
820             "    } else {",
821             "        data.remove();",
822             "    }",
823             "    print(\"removing node from Tree\\n\");    ",
824             "    s.unselect_all();",
825             "    this.el.remove(ref iter);",
826             "",
827             "    ",
828             "    ",
829             "    ",
830             "    // ",
831             "    ",
832             "    ",
833             "",
834             "",
835             "    this.activePath= \"\"; // again!?!?      ",
836             "    //this.changed(null,true);",
837             "    ",
838             "    _this.changed();",
839             "    ",
840             "    _this.view.blockChanges = false;",
841             "    */",
842             "}",
843             ""
844            ],
845            "| void loadFile" : [
846             "(JsRender.JsRender f) {",
847             "    //console.dump(f);",
848             "    ",
849             "    _this.drop.highlightWidget = null;",
850             "    ",
851             "    var m = (GLib.ListStore) this.el.model;",
852             "\tm.remove_all();",
853             "    _this.main_window.windowstate.leftTreeNodeSelected(null);",
854             "    // needed???",
855             "    _this.main_window.windowstate.file = f;",
856             "    ",
857             "   ",
858             "    if (f.tree == null) {",
859             "\t    try {",
860             "\t        f.loadItems( );",
861             "        } catch (Error e) {",
862             "    \t\treturn;",
863             "        }",
864             "    }",
865             "    // if it's still null?",
866             "    if (f.tree == null) {",
867             "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
868             "    ",
869             "        return;",
870             "    }",
871             "  \tm.append(f.tree);",
872             "  \t// expand???",
873             "",
874             "/*",
875             "    if (f.tree.readItems().size < 1) {",
876             "        // single item..",
877             "        ",
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);",
882             "        ",
883             "        ",
884             "    } else {",
885             "          //this.get('/Window.leftvpaned').el.set_position(200);",
886             "    }",
887             "  */  ",
888             "    ",
889             "    ",
890             "",
891             "    //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
892             " ",
893             "    _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
894             "   ",
895             "    return;",
896             " ",
897             "            ",
898             "}",
899             ""
900            ],
901            "| void selectNode" : [
902             "(JsRender.Node node) ",
903             "{",
904             "\tvar row = -1;",
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) {",
911             "\t\t\trow  = i;",
912             "\t\t\tbreak;",
913             "\t\t}",
914             "\t}",
915             "\tif (row < 0) {",
916             "\t\t// select none?",
917             "\t\tGLib.debug(\"Could not find node\");",
918             "\t\treturn;",
919             "\t}",
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",
924             "\t",
925             "",
926             "}"
927            ]
928           }
929          ],
930          "listeners" : {
931           "selection_changed" : [
932            "(position, n_items) => {",
933            "",
934            "\t",
935            "\t\t",
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\");",
940            "\t\t//\treturn;",
941            "\t\t//}",
942            "",
943            "",
944            "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
945            "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\");     ",
946            "\t\t   return  ;",
947            "\t\t }",
948            "",
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;",
953            "\t\t\t ",
954            "\t\t\t return;",
955            "\t\t }",
956            "\t\t if (_this.main_window.windowstate.file == null) {",
957            "\t   \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\");     ",
958            "\t\t\treturn;",
959            "\t\t } ",
960            "\t\t ",
961            "\t\t //var render = this.get('/LeftTree').getRenderer();                ",
962            "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
963            "\t\t",
964            "\t\t",
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);",
968            " ",
969            "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
970            "",
971            "\t    var snode = _this.selmodel.getSelectedNode();",
972            "\t    if (snode == null) {",
973            "",
974            "\t         GLib.debug(\"selected rows < 1\");",
975            "\t        //??this.model.load( false);",
976            "\t        _this.node_selected(null);",
977            "\t        ",
978            "\t        return   ;",
979            "\t    }",
980            "\t ",
981            "\t    // why dup_?",
982            "\t    ",
983            "",
984            "\t    GLib.debug (\"calling left_tree.node_selected\");",
985            "\t    _this.node_selected(snode);",
986            "\t   ",
987            "\t     ",
988            "\t    ",
989            "\t     ",
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);",
992            "\t    ",
993            "\t    return  ;",
994            "}",
995            ""
996           ]
997          },
998          "xtype" : "SingleSelection",
999          "| JsRender.Node getNodeAt" : [
1000           "(uint row) {",
1001           "",
1002           "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1003           "   ",
1004           "   var a = tr.get_item();;   ",
1005           "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1006           "  \t",
1007           "   ",
1008           "   return (JsRender.Node)tr.get_item();",
1009           "\t ",
1010           "}"
1011          ],
1012          "| JsRender.Node? getSelectedNode" : [
1013           "() {",
1014           "  if (this.el.selected_item == null) {",
1015           "\t\treturn null;",
1016           "  }\t\t\t        ",
1017           "   var tr = (Gtk.TreeListRow)this.el.selected_item;",
1018           "   return (JsRender.Node)tr.get_item();",
1019           "\t ",
1020           "}"
1021          ]
1022         },
1023         {
1024          "$ xns" : "Gtk",
1025          "* pack" : "append_column",
1026          "bool expand" : true,
1027          "bool resizable" : true,
1028          "id" : "maincol",
1029          "items" : [
1030           {
1031            "$ xns" : "Gtk",
1032            "* prop" : "factory",
1033            "listeners" : {
1034             "bind" : [
1035              "(listitem) => {",
1036              "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1037              "\t",
1038              "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1039              "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1040              "\t ",
1041              "\t ",
1042              "\tvar hbox = (Gtk.Box) expand.child;",
1043              " ",
1044              "\t",
1045              "\tvar img = (Gtk.Image) hbox.get_first_child();",
1046              "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1047              "\t",
1048              "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1049              "\tvar node = (JsRender.Node) lr.get_item();",
1050              "\t",
1051              "   GLib.debug(\"node is %s\", node.get_type().name());",
1052              "// was item (1) in old layout",
1053              "",
1054              "\t",
1055              " ",
1056              " \t /* ",
1057              " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1058              "    var clsname = node.fqn();",
1059              "    ",
1060              "    var clsb = clsname.split(\".\");",
1061              "    var sub = clsb.length > 1 ? clsb[1].down()  : \"\";",
1062              "     ",
1063              "    var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1064              "    try { ",
1065              "    \t ",
1066              "    \t\t ",
1067              "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1068              "\t\t    img.set_from_file(fn);",
1069              "\t\t \t ",
1070              "\t \t} else {",
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",
1075              "    \t\t\t)",
1076              "\t\t\t );",
1077              "\t \t}",
1078              " \t} catch (GLib.Error e) {}",
1079              "    */",
1080              "    expand.set_hide_expander( !node.hasChildren() );",
1081              " \texpand.set_list_row(lr);",
1082              " \t",
1083              " \tnode.bind_property(\"iconFilename\",",
1084              "                    img, \"file\",",
1085              "                   GLib.BindingFlags.SYNC_CREATE);",
1086              " \t",
1087              " \tnode.bind_property(\"nodeTitleProp\",",
1088              "                    lbl, \"label\",",
1089              "                   GLib.BindingFlags.SYNC_CREATE);",
1090              " \tnode.bind_property(\"nodeTipProp\",",
1091              "                    lbl, \"tooltip_markup\",",
1092              "                   GLib.BindingFlags.SYNC_CREATE);",
1093              " \t// bind image...",
1094              " \t",
1095              "}",
1096              ""
1097             ],
1098             "setup" : [
1099              "(listitem) => {",
1100              "\t",
1101              "\tvar expand = new Gtk.TreeExpander();",
1102              "\t ",
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;",
1110              "\t",
1111              "\ticon.margin_end = 4;",
1112              " \tlbl.justify = Gtk.Justification.LEFT;",
1113              " \tlbl.xalign = 0;",
1114              "",
1115              "//\tlistitem.activatable = true; ??",
1116              "\t",
1117              "\thbox.append(icon);",
1118              "\thbox.append(lbl);",
1119              "\texpand.set_child(hbox);",
1120              "\t((Gtk.ListItem)listitem).set_child(expand);",
1121              "\t",
1122              "}",
1123              ""
1124             ]
1125            },
1126            "xtype" : "SignalListItemFactory"
1127           }
1128          ],
1129          "title" : "Property",
1130          "xtype" : "ColumnViewColumn"
1131         },
1132         {
1133          "$ xns" : "Gtk",
1134          "* pack" : "append_column",
1135          "int fixed_width" : 25,
1136          "items" : [
1137           {
1138            "$ xns" : "Gtk",
1139            "* prop" : "factory",
1140            "listeners" : {
1141             "bind" : [
1142              "(listitem) => {",
1143              "",
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();",
1147              "\t",
1148              "  ",
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",
1154              "\t\t)",
1155              "\t );",
1156              "\t ",
1157              " \tvar fqn = node.fqn();",
1158              "    var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1159              "",
1160              "\timg.set_visible(cn.size > 0 ? true : false);",
1161              " \t ",
1162              "}",
1163              ""
1164             ],
1165             "setup" : [
1166              "(listitem) => {",
1167              "",
1168              "\t ",
1169              "\tvar icon = new Gtk.Image();",
1170              "\t ",
1171              "\t((Gtk.ListItem)listitem).set_child(icon);",
1172              "}",
1173              ""
1174             ]
1175            },
1176            "xtype" : "SignalListItemFactory"
1177           }
1178          ],
1179          "string title" : "Add",
1180          "xtype" : "ColumnViewColumn"
1181         }
1182        ],
1183        "string name" : "left-tree-view",
1184        "xtype" : "ColumnView",
1185        "| Gtk.Widget? getWidgetAt" : [
1186         "(double x,  double in_y) {",
1187         "/*",
1188         "    \t",
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);",
1194         "    \t\t ",
1195         "    \t}",
1196         "    \t*/",
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;",
1204         "    \tvar h = 0;",
1205         "    \twhile (child != null) {",
1206         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1207         "\t        if (reading_header) {",
1208         "\t\t\t\t",
1209         "",
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;",
1214         "\t\t\t\t}",
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;",
1219         "\t\t\t\t",
1220         "\t\t\t\treading_header = false;",
1221         "\t\t\t\t",
1222         "\t        }",
1223         "\t\t    line_no++;",
1224         "",
1225         "\t\t\tif (y < header_height) {",
1226         "\t\t    \treturn null;",
1227         "\t    \t}",
1228         "",
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);",
1231         "",
1232         "\t\t    if (y > curr_y && y <= header_height + hh + curr_y ) {",
1233         "\t\t\t    return (Gtk.Widget)child;",
1234         "\t\t    }",
1235         "\t\t    curr_y +=  hh ;",
1236         "",
1237         "\t\t    if (curr_y > y) {",
1238         "\t\t        return null;",
1239         "\t        }",
1240         "\t        child = child.get_next_sibling(); ",
1241         "    \t}",
1242         "        return null;",
1243         "",
1244         " }"
1245        ],
1246        "| Gtk.Widget? getWidgetAtRow" : [
1247         "(uint row) {",
1248         "/*",
1249         "    \t",
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);",
1255         "    \t\t ",
1256         "    \t}",
1257         "    \t*/",
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;",
1262         "\t ",
1263         "    \twhile (child != null) {",
1264         "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1265         "    \t   ",
1266         "    \t   if (reading_header) {",
1267         "\t\t\t\t",
1268         "",
1269         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1270         "\t\t\t\t   ",
1271         "\t\t\t\t\tchild = child.get_next_sibling();",
1272         "\t\t\t\t\tcontinue;",
1273         "\t\t\t\t}",
1274         "\t\t\t\t// should be columnlistview",
1275         "\t\t\t\tchild = child.get_first_child(); ",
1276         "\t\t\t ",
1277         "\t\t\t ",
1278         "\t\t\t\t",
1279         "\t\t\t\treading_header = false;",
1280         "\t\t\t\t ",
1281         "\t\t    }",
1282         "\t\t    ",
1283         "\t\t  ",
1284         "    \t    ",
1285         "\t\t    line_no++;",
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;",
1289         "\t\t    }",
1290         "\t        child = child.get_next_sibling(); ",
1291         "    \t}",
1292         "\t\t//GLib.debug(\"Rturning null\");",
1293         "        return null;",
1294         "",
1295         " }"
1296        ],
1297        "| int getColAt" : [
1298         "(double x,  double y) {",
1299         "/*",
1300         "    \t",
1301         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1302         "    \t  ",
1303         "    \t*/",
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(); ",
1307         "    \t ",
1308         "    \tvar col = 0;",
1309         "    \tvar offx = 0;",
1310         "    \twhile (child != null) {",
1311         "\t\t\t",
1312         "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1313         "\t\t\t\tchild = child.get_first_child();",
1314         "\t\t\t\tcontinue;",
1315         "\t\t\t}",
1316         "\t\t\t",
1317         "\t\t\t//child.get_allocation(out alloc);",
1318         "\t\t\tif (x <  (child.get_width() + offx)) {",
1319         "\t\t\t\treturn col;",
1320         "\t\t\t}",
1321         "\t\t\treturn 1;",
1322         "\t\t\t//offx += child.get_width();",
1323         "\t\t\t//col++;",
1324         "\t\t\t//child = child.get_next_sibling();",
1325         "\t\t}",
1326         "    \t     ",
1327         "\t\t\t  ",
1328         "        return -1;",
1329         "",
1330         " }"
1331        ],
1332        "| int getRowAt" : [
1333         "(double x,  double in_y, out string pos) {",
1334         "",
1335         "",
1336         "\t ",
1337         "",
1338         "/*",
1339         "    \t",
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);",
1345         "    \t\t ",
1346         "    \t}",
1347         "    \t*/",
1348         " \t\t ",
1349         " \t\t",
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\";",
1359         "    \tvar h = 0;",
1360         "    \twhile (child != null) {",
1361         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1362         "    \t    if (reading_header) {",
1363         "\t\t\t\t",
1364         "",
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;",
1369         "\t\t\t\t}",
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;",
1374         "\t\t\t\t",
1375         "\t\t\t\treading_header = false;",
1376         "\t\t\t\t",
1377         "\t        }",
1378         "\t        ",
1379         "\t\t    if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1380         "    \t\t    child = child.get_next_sibling();",
1381         "    \t\t    continue;",
1382         "\t\t    }",
1383         "\t\t    ",
1384         "\t\t \tif (y < header_height) {",
1385         "\t\t    \treturn -1;",
1386         "\t    \t}",
1387         "\t\t    ",
1388         "\t\t    line_no++;",
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),",
1393         "\t\t\t",
1394         "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1395         "",
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\";",
1401         "    \t\t\t} else {",
1402         "    \t\t\t\tpos = \"above\";",
1403         "\t\t\t\t}",
1404         "\t\t    \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1405         "\t\t\t    return line_no;",
1406         "\t\t    }",
1407         " ",
1408         "",
1409         "\t\t    if (real_y + hh > y) {",
1410         "\t\t        return -1;",
1411         "\t        }",
1412         "\t        real_y += hh;",
1413         "\t        child = child.get_next_sibling(); ",
1414         "    \t}",
1415         "        return -1;",
1416         "",
1417         " }"
1418        ]
1419       },
1420       {
1421        "$ xns" : "Gtk",
1422        "* pack" : false,
1423        "id" : "LeftTreeMenu",
1424        "items" : [
1425         {
1426          "$ xns" : "Gtk",
1427          "* prop" : "child",
1428          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1429          "int spacing" : 0,
1430          "items" : [
1431           {
1432            "$ xns" : "Gtk",
1433            "label" : "Delete Element",
1434            "listeners" : {
1435             "clicked" : [
1436              " ( ) => {",
1437              "_this.LeftTreeMenu.el.hide();",
1438              " _this.model.deleteSelected();",
1439              "_this.changed();",
1440              "}"
1441             ]
1442            },
1443            "xtype" : "Button"
1444           },
1445           {
1446            "$ xns" : "Gtk",
1447            "label" : "Save as Template",
1448            "listeners" : {
1449             "clicked" : [
1450              "  () => {",
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()",
1456              "    );",
1457              "     ",
1458              "    ",
1459              "}"
1460             ]
1461            },
1462            "xtype" : "Button"
1463           },
1464           {
1465            "$ xns" : "Gtk",
1466            "label" : "Save as Module",
1467            "listeners" : {
1468             "clicked" : [
1469              "  () => {",
1470              "    ",
1471              "    _this.LeftTreeMenu.el.hide();",
1472              "    var node = _this.getActiveElement();",
1473              "      ",
1474              "     ",
1475              "     var sm = DialogSaveModule.singleton();",
1476              "     ",
1477              "     ",
1478              "    sm.showIt(",
1479              "            (Gtk.Window) _this.el.get_root (), ",
1480              "            _this.main_window.windowstate.project, ",
1481              "            node",
1482              "     );",
1483              "     /*",
1484              "     gtk4 migration - disabled this part.. probably not used muchanyway",
1485              "     ",
1486              "     ",
1487              "     if (name.length < 1) {",
1488              "            return;",
1489              "  ",
1490              "     }",
1491              "     node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1492              "     node.items.clear();",
1493              "",
1494              "",
1495              "    var s = _this.view.el.get_selection();",
1496              "    ",
1497              "    print(\"GET  SELECTED?\");",
1498              "    Gtk.TreeIter iter;",
1499              "    Gtk.TreeModel mod;",
1500              "",
1501              "    ",
1502              "    if (!s.get_selected(out mod, out iter)) {",
1503              "        return; // nothing seleted..",
1504              "    }",
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);",
1509              "        ",
1510              "",
1511              "        print(\"removing node from Tree\\n\");    ",
1512              "    ",
1513              "        _this.model.el.remove(ref citer);",
1514              "    }",
1515              "    _this.changed();",
1516              "    _this.node_selected(node, \"tree\");",
1517              "     */",
1518              "    ",
1519              "}"
1520             ]
1521            },
1522            "xtype" : "Button"
1523           }
1524          ],
1525          "xtype" : "Box"
1526         }
1527        ],
1528        "xtype" : "Popover"
1529       }
1530      ],
1531      "xtype" : "ScrolledWindow"
1532     }
1533    ],
1534    "xtype" : "Box",
1535    "| JsRender.JsRender getActiveFile" : [
1536     "() {",
1537     "    return this.main_window.windowstate.file;",
1538     "}",
1539     ""
1540    ],
1541    "| JsRender.Node? getActiveElement" : [
1542     " () { // return path to actie node.",
1543     "",
1544     "     ",
1545     "\treturn _this.selmodel.getSelectedNode();",
1546     "    ",
1547     "    ",
1548     "}",
1549     ""
1550    ],
1551    "| void onresize" : [
1552     "() {",
1553     " ",
1554     "\t ",
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 );",
1557     "}",
1558     "",
1559     ""
1560    ]
1561   }
1562  ],
1563  "name" : "WindowLeftTree"
1564 }