fix line numbering issues with vala generator - hopefully fixes completion in node...
[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             "\tif (_this.selmodel.el == null) {",
767             "\t\treturn this.el;",
768             "\t}",
769             "\t_this.selmodel.el.set_model(this.el);",
770             "\treturn this.el;",
771             "}"
772            ],
773            "| void deleteSelected" : [
774             "() {",
775             "",
776             "",
777             "\t",
778             "\tvar node = _this.selmodel.getSelectedNode();",
779             "\t",
780             "",
781             "     if (node == null) {",
782             "     \tGLib.debug(\"delete Selected - no node slected?\");",
783             "\t     return;",
784             "     }",
785             "    _this.selmodel.el.unselect_all();",
786             "    ",
787             "    node.remove();",
788             " \tGLib.debug(\"delete Selected - done\");",
789             "    _this.changed();",
790             "/*    ",
791             "    print(\"DELETE SELECTED?\");",
792             "    //_this.view.blockChanges = true;",
793             "    print(\"GET SELECTION?\");",
794             "",
795             "    var s = _this.view.el.get_selection();",
796             "    ",
797             "    print(\"GET  SELECTED?\");",
798             "   Gtk.TreeIter iter;",
799             "    Gtk.TreeModel mod;",
800             "",
801             "    ",
802             "    if (!s.get_selected(out mod, out iter)) {",
803             "        return; // nothing seleted..",
804             "    }",
805             "      ",
806             "",
807             "",
808             "    this.activePath= \"\";      ",
809             "    print(\"GET  vnode value?\");",
810             "",
811             "    GLib.Value value;",
812             "    this.el.get_value(iter, 2, out value);",
813             "    var data = (JsRender.Node)(value.get_object());",
814             "    print(\"removing node from Render\\n\");",
815             "    if (data.parent == null) {",
816             "       _this.main_window.windowstate.file.tree = null;",
817             "    } else {",
818             "        data.remove();",
819             "    }",
820             "    print(\"removing node from Tree\\n\");    ",
821             "    s.unselect_all();",
822             "    this.el.remove(ref iter);",
823             "",
824             "    ",
825             "    ",
826             "    ",
827             "    // ",
828             "    ",
829             "    ",
830             "",
831             "",
832             "    this.activePath= \"\"; // again!?!?      ",
833             "    //this.changed(null,true);",
834             "    ",
835             "    _this.changed();",
836             "    ",
837             "    _this.view.blockChanges = false;",
838             "    */",
839             "}",
840             ""
841            ],
842            "| void loadFile" : [
843             "(JsRender.JsRender f) {",
844             "    //console.dump(f);",
845             "    ",
846             "    _this.drop.highlightWidget = null;",
847             "    ",
848             "    var m = (GLib.ListStore) this.el.model;",
849             "\tm.remove_all();",
850             "    _this.main_window.windowstate.leftTreeNodeSelected(null);",
851             "    // needed???",
852             "    _this.main_window.windowstate.file = f;",
853             "    ",
854             "   ",
855             "    if (f.tree == null) {",
856             "\t    try {",
857             "\t        f.loadItems( );",
858             "        } catch (Error e) {",
859             "    \t\treturn;",
860             "        }",
861             "    }",
862             "    // if it's still null?",
863             "    if (f.tree == null) {",
864             "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
865             "    ",
866             "        return;",
867             "    }",
868             "  \tm.append(f.tree);",
869             "  \t// expand???",
870             "",
871             "/*",
872             "    if (f.tree.readItems().size < 1) {",
873             "        // single item..",
874             "        ",
875             "        //this.get('/Window.leftvpaned').el.set_position(80);",
876             "        // select first...",
877             "        _this.view.el.set_cursor( ",
878             "            new  Gtk.TreePath.from_string(\"0\"), null, false);",
879             "        ",
880             "        ",
881             "    } else {",
882             "          //this.get('/Window.leftvpaned').el.set_position(200);",
883             "    }",
884             "  */  ",
885             "    ",
886             "    ",
887             "",
888             "    //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);",
889             " ",
890             "    _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
891             "   ",
892             "    return;",
893             " ",
894             "            ",
895             "}",
896             ""
897            ],
898            "| void selectNode" : [
899             "(JsRender.Node node) ",
900             "{",
901             "\tvar row = -1;",
902             "\tvar s = (Gtk.SingleSelection)_this.view.el.model;",
903             "\tfor (var i = 0; i < s.n_items; i++) {",
904             "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
905             "\t\tvar lr = (Gtk.TreeListRow)s.get_item(i);",
906             "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
907             "\t\tif (((JsRender.Node)lr.get_item()).oid == node.oid) {",
908             "\t\t\trow  = i;",
909             "\t\t\tbreak;",
910             "\t\t}",
911             "\t}",
912             "\tif (row < 0) {",
913             "\t\t// select none?",
914             "\t\tGLib.debug(\"Could not find node\");",
915             "\t\treturn;",
916             "\t}",
917             "\tGLib.debug(\"Select %d\", row);",
918             "\ts.set_selected(row);",
919             "\t_this.node_selected(node);\t\t\t",
920             "\t",
921             "",
922             "}"
923            ]
924           }
925          ],
926          "listeners" : {
927           "selection_changed" : [
928            "(position, n_items) => {",
929            "",
930            "\t",
931            "\t\t",
932            "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
933            "\t\t\t// then event was started by some other action",
934            "\t\t\t// which should manually trigger all the events..",
935            "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
936            "\t\t//\treturn;",
937            "\t\t//}",
938            "",
939            "",
940            "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
941            "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\");     ",
942            "\t\t   return  ;",
943            "\t\t }",
944            "",
945            "\t\t  if (!_this.before_node_change( ) ) {",
946            "\t\t\t _this.view.blockChanges = true;",
947            "\t\t\t _this.selmodel.el.unselect_all();",
948            "\t\t\t _this.view.blockChanges = false;",
949            "\t\t\t ",
950            "\t\t\t return;",
951            "\t\t }",
952            "\t\t if (_this.main_window.windowstate.file == null) {",
953            "\t   \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\");     ",
954            "\t\t\treturn;",
955            "\t\t } ",
956            "\t\t ",
957            "\t\t //var render = this.get('/LeftTree').getRenderer();                ",
958            "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
959            "\t\t",
960            "\t\t",
961            "\t\t// -- it appears that the selection is not updated.",
962            "\t\t // select the node...",
963            "\t\t //_this.selmodel.el.set_selected(row);",
964            " ",
965            "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
966            "",
967            "\t    var snode = _this.selmodel.getSelectedNode();",
968            "\t    if (snode == null) {",
969            "",
970            "\t         GLib.debug(\"selected rows < 1\");",
971            "\t        //??this.model.load( false);",
972            "\t        _this.node_selected(null);",
973            "\t        ",
974            "\t        return   ;",
975            "\t    }",
976            "\t ",
977            "\t    // why dup_?",
978            "\t    ",
979            "",
980            "\t    GLib.debug (\"calling left_tree.node_selected\");",
981            "\t    _this.node_selected(snode);",
982            "\t   ",
983            "\t     ",
984            "\t    ",
985            "\t     ",
986            "\t    // no need to scroll. it's in the view as we clicked on it.",
987            "\t   // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
988            "\t    ",
989            "\t    return  ;",
990            "}",
991            ""
992           ]
993          },
994          "xtype" : "SingleSelection",
995          "| JsRender.Node getNodeAt" : [
996           "(uint row) {",
997           "",
998           "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
999           "   ",
1000           "   var a = tr.get_item();;   ",
1001           "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1002           "  \t",
1003           "   ",
1004           "   return (JsRender.Node)tr.get_item();",
1005           "\t ",
1006           "}"
1007          ],
1008          "| JsRender.Node? getSelectedNode" : [
1009           "() {",
1010           "  if (this.el.selected_item == null) {",
1011           "\t\treturn null;",
1012           "  }\t\t\t        ",
1013           "   var tr = (Gtk.TreeListRow)this.el.selected_item;",
1014           "   return (JsRender.Node)tr.get_item();",
1015           "\t ",
1016           "}"
1017          ]
1018         },
1019         {
1020          "$ xns" : "Gtk",
1021          "* pack" : "append_column",
1022          "bool expand" : true,
1023          "bool resizable" : true,
1024          "id" : "maincol",
1025          "items" : [
1026           {
1027            "$ xns" : "Gtk",
1028            "* prop" : "factory",
1029            "listeners" : {
1030             "bind" : [
1031              "(listitem) => {",
1032              "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1033              "\t",
1034              "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1035              "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1036              "\t ",
1037              "\t ",
1038              "\tvar hbox = (Gtk.Box) expand.child;",
1039              " ",
1040              "\t",
1041              "\tvar img = (Gtk.Image) hbox.get_first_child();",
1042              "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1043              "\t",
1044              "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1045              "\tvar node = (JsRender.Node) lr.get_item();",
1046              "\t",
1047              "   GLib.debug(\"node is %s\", node.get_type().name());",
1048              "// was item (1) in old layout",
1049              "",
1050              "\t",
1051              " ",
1052              " \t /* ",
1053              " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1054              "    var clsname = node.fqn();",
1055              "    ",
1056              "    var clsb = clsname.split(\".\");",
1057              "    var sub = clsb.length > 1 ? clsb[1].down()  : \"\";",
1058              "     ",
1059              "    var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1060              "    try { ",
1061              "    \t ",
1062              "    \t\t ",
1063              "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1064              "\t\t    img.set_from_file(fn);",
1065              "\t\t \t ",
1066              "\t \t} else {",
1067              "\t \t\timg.set_from_paintable(",
1068              "\t\t\t \tic.lookup_icon (",
1069              "\t\t\t \t\t\"media-playback-stop\", null,  16,1, ",
1070              "\t    \t\t\t Gtk.TextDirection.NONE, 0",
1071              "    \t\t\t)",
1072              "\t\t\t );",
1073              "\t \t}",
1074              " \t} catch (GLib.Error e) {}",
1075              "    */",
1076              "    expand.set_hide_expander( !node.hasChildren() );",
1077              " \texpand.set_list_row(lr);",
1078              " \t",
1079              " \tnode.bind_property(\"iconFilename\",",
1080              "                    img, \"file\",",
1081              "                   GLib.BindingFlags.SYNC_CREATE);",
1082              " \t",
1083              " \tnode.bind_property(\"nodeTitleProp\",",
1084              "                    lbl, \"label\",",
1085              "                   GLib.BindingFlags.SYNC_CREATE);",
1086              " \tnode.bind_property(\"nodeTipProp\",",
1087              "                    lbl, \"tooltip_markup\",",
1088              "                   GLib.BindingFlags.SYNC_CREATE);",
1089              " \t// bind image...",
1090              " \t",
1091              "}",
1092              ""
1093             ],
1094             "setup" : [
1095              "(listitem) => {",
1096              "\t",
1097              "\tvar expand = new Gtk.TreeExpander();",
1098              "\t ",
1099              "\texpand.set_indent_for_depth(true);",
1100              "\texpand.set_indent_for_icon(true);",
1101              "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1102              "\tvar icon = new Gtk.Image();",
1103              "\tvar lbl = new Gtk.Label(\"\");",
1104              "\tlbl.use_markup = true;",
1105              "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1106              "\t",
1107              "\ticon.margin_end = 4;",
1108              " \tlbl.justify = Gtk.Justification.LEFT;",
1109              " \tlbl.xalign = 0;",
1110              "",
1111              "//\tlistitem.activatable = true; ??",
1112              "\t",
1113              "\thbox.append(icon);",
1114              "\thbox.append(lbl);",
1115              "\texpand.set_child(hbox);",
1116              "\t((Gtk.ListItem)listitem).set_child(expand);",
1117              "\t",
1118              "}",
1119              ""
1120             ]
1121            },
1122            "xtype" : "SignalListItemFactory"
1123           }
1124          ],
1125          "title" : "Property",
1126          "xtype" : "ColumnViewColumn"
1127         },
1128         {
1129          "$ xns" : "Gtk",
1130          "* pack" : "append_column",
1131          "int fixed_width" : 25,
1132          "items" : [
1133           {
1134            "$ xns" : "Gtk",
1135            "* prop" : "factory",
1136            "listeners" : {
1137             "bind" : [
1138              "(listitem) => {",
1139              "",
1140              " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1141              " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1142              "\tvar node = (JsRender.Node) lr.get_item();",
1143              "\t",
1144              "  ",
1145              "    var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1146              "\timg.set_from_paintable(",
1147              "\t \tic.lookup_icon (",
1148              "\t \t\t\"list-add\", null,  16,1, ",
1149              "\t\t\t Gtk.TextDirection.NONE, 0",
1150              "\t\t)",
1151              "\t );",
1152              "\t ",
1153              " \tvar fqn = node.fqn();",
1154              "    var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1155              "",
1156              "\timg.set_visible(cn.size > 0 ? true : false);",
1157              " \t ",
1158              "}",
1159              ""
1160             ],
1161             "setup" : [
1162              "(listitem) => {",
1163              "",
1164              "\t ",
1165              "\tvar icon = new Gtk.Image();",
1166              "\t ",
1167              "\t((Gtk.ListItem)listitem).set_child(icon);",
1168              "}",
1169              ""
1170             ]
1171            },
1172            "xtype" : "SignalListItemFactory"
1173           }
1174          ],
1175          "string title" : "Add",
1176          "xtype" : "ColumnViewColumn"
1177         }
1178        ],
1179        "string name" : "left-tree-view",
1180        "xtype" : "ColumnView",
1181        "| Gtk.Widget? getWidgetAt" : [
1182         "(double x,  double in_y) {",
1183         "/*",
1184         "    \t",
1185         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1186         "    \tvar colview = gesture.widget;",
1187         "    \tvar line_no = check_list_widget(colview, x,y);",
1188         "         if (line_no > -1) {",
1189         "    \t\tvar item = colview.model.get_item(line_no);",
1190         "    \t\t ",
1191         "    \t}",
1192         "    \t*/",
1193         "    \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1194         "        var  child = this.el.get_first_child(); ",
1195         "    \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1196         "    \tvar line_no = -1; ",
1197         "    \tvar reading_header = true;",
1198         "    \tvar curr_y = 0;",
1199         "    \tvar header_height  = 0;",
1200         "    \tvar h = 0;",
1201         "    \twhile (child != null) {",
1202         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1203         "\t        if (reading_header) {",
1204         "\t\t\t\t",
1205         "",
1206         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1207         "\t\t\t        h += child.get_height();",
1208         "\t\t\t\t\tchild = child.get_next_sibling();",
1209         "\t\t\t\t\tcontinue;",
1210         "\t\t\t\t}",
1211         "\t\t\t\t// should be columnlistview",
1212         "\t\t\t\tchild = child.get_first_child(); ",
1213         "\t\t\t    GLib.debug(\"header height=%d\", h);",
1214         "\t\t\t\theader_height =  h;",
1215         "\t\t\t\t",
1216         "\t\t\t\treading_header = false;",
1217         "\t\t\t\t",
1218         "\t        }",
1219         "\t\t    line_no++;",
1220         "",
1221         "\t\t\tif (y < header_height) {",
1222         "\t\t    \treturn null;",
1223         "\t    \t}",
1224         "",
1225         "\t\t\tvar hh = child.get_height();",
1226         "\t\t\t//GLib.debug(\"got cell xy = %d,%d  w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1227         "",
1228         "\t\t    if (y > curr_y && y <= header_height + hh + curr_y ) {",
1229         "\t\t\t    return (Gtk.Widget)child;",
1230         "\t\t    }",
1231         "\t\t    curr_y +=  hh ;",
1232         "",
1233         "\t\t    if (curr_y > y) {",
1234         "\t\t        return null;",
1235         "\t        }",
1236         "\t        child = child.get_next_sibling(); ",
1237         "    \t}",
1238         "        return null;",
1239         "",
1240         " }"
1241        ],
1242        "| Gtk.Widget? getWidgetAtRow" : [
1243         "(uint row) {",
1244         "/*",
1245         "    \t",
1246         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1247         "    \tvar colview = gesture.widget;",
1248         "    \tvar line_no = check_list_widget(colview, x,y);",
1249         "         if (line_no > -1) {",
1250         "    \t\tvar item = colview.model.get_item(line_no);",
1251         "    \t\t ",
1252         "    \t}",
1253         "    \t*/",
1254         "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1255         "        var  child = this.el.get_first_child(); ",
1256         "    \tvar line_no = -1; ",
1257         "    \tvar reading_header = true;",
1258         "\t ",
1259         "    \twhile (child != null) {",
1260         "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
1261         "    \t   ",
1262         "    \t   if (reading_header) {",
1263         "\t\t\t\t",
1264         "",
1265         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1266         "\t\t\t\t   ",
1267         "\t\t\t\t\tchild = child.get_next_sibling();",
1268         "\t\t\t\t\tcontinue;",
1269         "\t\t\t\t}",
1270         "\t\t\t\t// should be columnlistview",
1271         "\t\t\t\tchild = child.get_first_child(); ",
1272         "\t\t\t ",
1273         "\t\t\t ",
1274         "\t\t\t\t",
1275         "\t\t\t\treading_header = false;",
1276         "\t\t\t\t ",
1277         "\t\t    }",
1278         "\t\t    ",
1279         "\t\t  ",
1280         "    \t    ",
1281         "\t\t    line_no++;",
1282         "\t\t\tif (line_no == row) {",
1283         "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1284         "\t\t\t    return (Gtk.Widget)child;",
1285         "\t\t    }",
1286         "\t        child = child.get_next_sibling(); ",
1287         "    \t}",
1288         "\t\t//GLib.debug(\"Rturning null\");",
1289         "        return null;",
1290         "",
1291         " }"
1292        ],
1293        "| int getColAt" : [
1294         "(double x,  double y) {",
1295         "/*",
1296         "    \t",
1297         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1298         "    \t  ",
1299         "    \t*/",
1300         "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1301         "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1302         "        var  child = this.el.get_first_child(); ",
1303         "    \t ",
1304         "    \tvar col = 0;",
1305         "    \tvar offx = 0;",
1306         "    \twhile (child != null) {",
1307         "\t\t\t",
1308         "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1309         "\t\t\t\tchild = child.get_first_child();",
1310         "\t\t\t\tcontinue;",
1311         "\t\t\t}",
1312         "\t\t\t",
1313         "\t\t\t//child.get_allocation(out alloc);",
1314         "\t\t\tif (x <  (child.get_width() + offx)) {",
1315         "\t\t\t\treturn col;",
1316         "\t\t\t}",
1317         "\t\t\treturn 1;",
1318         "\t\t\t//offx += child.get_width();",
1319         "\t\t\t//col++;",
1320         "\t\t\t//child = child.get_next_sibling();",
1321         "\t\t}",
1322         "    \t     ",
1323         "\t\t\t  ",
1324         "        return -1;",
1325         "",
1326         " }"
1327        ],
1328        "| int getRowAt" : [
1329         "(double x,  double in_y, out string pos) {",
1330         "",
1331         "",
1332         "\t ",
1333         "",
1334         "/*",
1335         "    \t",
1336         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1337         "    \tvar colview = gesture.widget;",
1338         "    \tvar line_no = check_list_widget(colview, x,y);",
1339         "         if (line_no > -1) {",
1340         "    \t\tvar item = colview.model.get_item(line_no);",
1341         "    \t\t ",
1342         "    \t}",
1343         "    \t*/",
1344         " \t\t ",
1345         " \t\t",
1346         " \t\t//GLib.debug(\"offset = %d  y = %d\", (int) voff, (int) in_y);",
1347         "    \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1348         "        var  child = this.el.get_first_child(); ",
1349         "    \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1350         "    \tvar line_no = -1; ",
1351         "    \tvar reading_header = true;",
1352         "    \tvar real_y = 0;",
1353         "    \tvar header_height  = 0;",
1354         "    \tpos = \"none\";",
1355         "    \tvar h = 0;",
1356         "    \twhile (child != null) {",
1357         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1358         "    \t    if (reading_header) {",
1359         "\t\t\t\t",
1360         "",
1361         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1362         "\t\t\t        h += child.get_height();",
1363         "\t\t\t\t\tchild = child.get_next_sibling();",
1364         "\t\t\t\t\tcontinue;",
1365         "\t\t\t\t}",
1366         "\t\t\t\t// should be columnlistview",
1367         "\t\t\t\tchild = child.get_first_child(); ",
1368         "\t\t\t    GLib.debug(\"header height=%d\", h);",
1369         "\t\t\t\theader_height =  h;",
1370         "\t\t\t\t",
1371         "\t\t\t\treading_header = false;",
1372         "\t\t\t\t",
1373         "\t        }",
1374         "\t        ",
1375         "\t\t    if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1376         "    \t\t    child = child.get_next_sibling();",
1377         "    \t\t    continue;",
1378         "\t\t    }",
1379         "\t\t    ",
1380         "\t\t \tif (y < header_height) {",
1381         "\t\t    \treturn -1;",
1382         "\t    \t}",
1383         "\t\t    ",
1384         "\t\t    line_no++;",
1385         "\t\t\tvar hh = child.get_height();",
1386         "\t\t\t//child.get_allocation(out alloc);",
1387         "\t\t\t//GLib.debug(\"got cell xy = %d,%d  w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1388         "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1389         "\t\t\t",
1390         "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1391         "",
1392         "\t\t    if (y >  (header_height + real_y) && y <= (header_height +  real_y + hh) ) {",
1393         "\t\t    \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1394         "\t\t    \t\tpos = \"below\";",
1395         "\t    \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1396         "\t    \t\t\tpos = \"over\";",
1397         "    \t\t\t} else {",
1398         "    \t\t\t\tpos = \"above\";",
1399         "\t\t\t\t}",
1400         "\t\t    \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1401         "\t\t\t    return line_no;",
1402         "\t\t    }",
1403         " ",
1404         "",
1405         "\t\t    if (real_y + hh > y) {",
1406         "\t\t        return -1;",
1407         "\t        }",
1408         "\t        real_y += hh;",
1409         "\t        child = child.get_next_sibling(); ",
1410         "    \t}",
1411         "        return -1;",
1412         "",
1413         " }"
1414        ]
1415       },
1416       {
1417        "$ xns" : "Gtk",
1418        "* pack" : false,
1419        "id" : "LeftTreeMenu",
1420        "items" : [
1421         {
1422          "$ xns" : "Gtk",
1423          "* prop" : "child",
1424          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1425          "int spacing" : 0,
1426          "items" : [
1427           {
1428            "$ xns" : "Gtk",
1429            "label" : "Delete Element",
1430            "listeners" : {
1431             "clicked" : [
1432              " ( ) => {",
1433              "_this.LeftTreeMenu.el.hide();",
1434              " _this.model.deleteSelected();",
1435              "_this.changed();",
1436              "}"
1437             ]
1438            },
1439            "xtype" : "Button"
1440           },
1441           {
1442            "$ xns" : "Gtk",
1443            "label" : "Save as Template",
1444            "listeners" : {
1445             "clicked" : [
1446              "  () => {",
1447              "_this.LeftTreeMenu.el.hide();",
1448              "     DialogSaveTemplate.singleton().showIt(",
1449              "            (Gtk.Window) _this.el.get_root (), ",
1450              "            _this.main_window.windowstate.file.palete(), ",
1451              "            _this.getActiveElement()",
1452              "    );",
1453              "     ",
1454              "    ",
1455              "}"
1456             ]
1457            },
1458            "xtype" : "Button"
1459           },
1460           {
1461            "$ xns" : "Gtk",
1462            "label" : "Save as Module",
1463            "listeners" : {
1464             "clicked" : [
1465              "  () => {",
1466              "    ",
1467              "    _this.LeftTreeMenu.el.hide();",
1468              "    var node = _this.getActiveElement();",
1469              "      ",
1470              "     ",
1471              "     var sm = DialogSaveModule.singleton();",
1472              "     ",
1473              "     ",
1474              "    sm.showIt(",
1475              "            (Gtk.Window) _this.el.get_root (), ",
1476              "            _this.main_window.windowstate.project, ",
1477              "            node",
1478              "     );",
1479              "     /*",
1480              "     gtk4 migration - disabled this part.. probably not used muchanyway",
1481              "     ",
1482              "     ",
1483              "     if (name.length < 1) {",
1484              "            return;",
1485              "  ",
1486              "     }",
1487              "     node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1488              "     node.items.clear();",
1489              "",
1490              "",
1491              "    var s = _this.view.el.get_selection();",
1492              "    ",
1493              "    print(\"GET  SELECTED?\");",
1494              "    Gtk.TreeIter iter;",
1495              "    Gtk.TreeModel mod;",
1496              "",
1497              "    ",
1498              "    if (!s.get_selected(out mod, out iter)) {",
1499              "        return; // nothing seleted..",
1500              "    }",
1501              "    Gtk.TreeIter citer;",
1502              "    var n_cn = mod.iter_n_children(iter) -1;",
1503              "    for (var i = n_cn; i > -1; i--) {",
1504              "        mod.iter_nth_child(out citer, iter, i);",
1505              "        ",
1506              "",
1507              "        print(\"removing node from Tree\\n\");    ",
1508              "    ",
1509              "        _this.model.el.remove(ref citer);",
1510              "    }",
1511              "    _this.changed();",
1512              "    _this.node_selected(node, \"tree\");",
1513              "     */",
1514              "    ",
1515              "}"
1516             ]
1517            },
1518            "xtype" : "Button"
1519           }
1520          ],
1521          "xtype" : "Box"
1522         }
1523        ],
1524        "xtype" : "Popover"
1525       }
1526      ],
1527      "xtype" : "ScrolledWindow"
1528     }
1529    ],
1530    "xtype" : "Box",
1531    "| JsRender.JsRender getActiveFile" : [
1532     "() {",
1533     "    return this.main_window.windowstate.file;",
1534     "}",
1535     ""
1536    ],
1537    "| JsRender.Node? getActiveElement" : [
1538     " () { // return path to actie node.",
1539     "",
1540     "     ",
1541     "\treturn _this.selmodel.getSelectedNode();",
1542     "    ",
1543     "    ",
1544     "}",
1545     ""
1546    ],
1547    "| void onresize" : [
1548     "() {",
1549     " ",
1550     "\t ",
1551     "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1552     "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width()  - 32 );",
1553     "}",
1554     "",
1555     ""
1556    ]
1557   }
1558  ],
1559  "name" : "WindowLeftTree"
1560 }