expanding tree when error buttons pressed
[roobuilder] / src / Builder4 / WindowLeftTree.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# Xcls_MainWindow? main_window" : "null",
7    "# int last_error_counter" : "-1",
8    "$ xns" : "Gtk",
9    "@ bool before_node_change" : "()",
10    "@ void changed" : "()",
11    "@ void node_selected" : "(JsRender.Node? node)",
12    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
13    "bool hexpand" : true,
14    "bool vexpand" : true,
15    "id" : "WindowLeftTree",
16    "items" : [
17     {
18      "$ xns" : "Gtk",
19      "items" : [
20       {
21        "$ xns" : "Gtk",
22        "* prop" : "factory",
23        "xtype" : "SignalListItemFactory"
24       }
25      ],
26      "xtype" : "ListView"
27     },
28     {
29      "$ xns" : "Gtk",
30      "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
31      "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
32      "bool has_frame" : true,
33      "bool hexpand" : true,
34      "bool vexpand" : true,
35      "id" : "viewwin",
36      "items" : [
37       {
38        "# bool blockChanges" : false,
39        "$ JsRender.Node? dragNode" : "null",
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         ".node-err  {",
61         " border-top-width: 5px;",
62         " border-top-style: solid;",
63         " border-top-color: red;",
64         " border-bottom-width: 5px; ",
65         " border-bottom-style: solid;",
66         " border-bottom-color: red;",
67         "}",
68         ".node-warn  {",
69         " border-top-width: 5px;",
70         " border-top-style: solid;",
71         " border-top-color: #ABF4EB;",
72         " border-bottom-width: 5px; ",
73         " border-bottom-style: solid;",
74         " border-bottom-color: #ABF4EB;",
75         "}",
76         ".node-depr  {",
77         " border-top-width: 5px;",
78         " border-top-style: solid;",
79         " border-top-color: #EEA9FF;",
80         " border-bottom-width: 5px; ",
81         " border-bottom-style: solid;",
82         " border-bottom-color: #EEA9FF;",
83         "}",
84         "",
85         "#left-tree-view indent {",
86         "-gtk-icon-size : 2px;",
87         "}",
88         "#left-tree-view indent:nth-last-child(2)  {",
89         "min-width: 24px;",
90         "}",
91         "\");",
92         "",
93         "\tGtk.StyleContext.add_provider_for_display(",
94         "\t\tthis.el.get_display(),",
95         "\t\tthis.css,",
96         "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
97         "\t);",
98         "\t",
99         "\t  ",
100         "}",
101         ""
102        ],
103        "* prop" : "child",
104        "Boolean id" : "view",
105        "Gtk.CssProvider css" : "",
106        "bool button_is_pressed" : false,
107        "bool headers_visible" : false,
108        "bool hexpand" : false,
109        "bool vexpand" : true,
110        "items" : [
111         {
112          "$ xns" : "Gtk",
113          "listeners" : {
114           "pressed" : [
115            "(n_press, x, y) => {",
116            " ",
117            "    //console.log(\"button press?\");",
118            "    ",
119            "    //this.el.set_state(Gtk.EventSequenceState.CLAIMED);",
120            "",
121            "",
122            "    ",
123            "    _this.view.button_is_pressed = true;",
124            "      ",
125            "    _this.view.lastEventSource = \"tree\";",
126            "    if (! _this.before_node_change() ) {",
127            "    \tGLib.debug(\"before_node_change return false\");",
128            "       return ;",
129            "    }",
130            "    ",
131            "\t // nothing there -show dialog",
132            "    if (_this.model.el.get_n_items() < 1) {",
133            "\t    _this.main_window.windowstate.showAddObject(_this.view.el, null);",
134            "        GLib.debug(\"no items\");",
135            "\t    return ;",
136            "    }",
137            "    string pos;",
138            "    var row = _this.view.getRowAt(x,y, out pos );",
139            "    if (row < 0) {",
140            "\t    GLib.debug(\"no row selected items\");",
141            "\t    return;",
142            "    }",
143            "    ",
144            "    var node =   _this.selmodel.getNodeAt(row);",
145            "    if (node == null) {",
146            "    \tGLib.warning(\"No node found at row %d\", row);",
147            "    \treturn;",
148            "\t}",
149            "",
150            "     ",
151            "     ",
152            "    if (_this.view.getColAt(x,y) > 0 ) {",
153            "\t    GLib.debug(\"add colum clicked.\");",
154            "        var fqn = node.fqn();",
155            "    \tvar cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
156            "  \t\tif (cn.size < 1) {",
157            "  \t\t\treturn ;",
158            "\t\t}",
159            "",
160            "\t\t_this.main_window.windowstate.leftTreeBeforeChange();",
161            "\t\t//_this.view.el.get_selection().select_path(res);",
162            "\t\tGLib.debug(\"Button Pressed - start show window\");",
163            "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, node);",
164            "\t\tGLib.debug(\"Button Pressed - finsihed show window\");",
165            "     \treturn ;",
166            "\t}",
167            "    ",
168            "\t ",
169            "     ",
170            "}",
171            ""
172           ],
173           "released" : [
174            "(n_press, x, y) => {",
175            " ",
176            "    _this.view.button_is_pressed = false;",
177            "",
178            "",
179            "}",
180            ""
181           ]
182          },
183          "xtype" : "GestureClick"
184         },
185         {
186          "$ xns" : "Gtk",
187          "listeners" : {
188           "pressed" : [
189            "(n_press, x, y) => {",
190            "",
191            "\t",
192            "\t  ",
193            "\t ",
194            "    if (_this.model.el.get_n_items() < 1) {",
195            " ",
196            "        GLib.debug(\"no items\");",
197            "\t    return ;",
198            "    }",
199            "    string pos;",
200            "    var row = _this.view.getRowAt(x,y, out pos );",
201            "    if (row < 0) {",
202            "\t    GLib.debug(\"no row selected items\");",
203            "\t    return;",
204            "    }",
205            "    ",
206            "    var node =   _this.selmodel.getNodeAt(row);",
207            "    if (node == null) {",
208            "    \tGLib.warning(\"No node found at row %d\", row);",
209            "    \treturn;",
210            "\t}",
211            "\t",
212            "\t",
213            "\t_this.model.selectNode(node);",
214            "     ",
215            "     ",
216            "     ",
217            "\tGLib.debug(\"Prssed %d\", (int)  this.el.get_current_button());",
218            "\t//_this.deletemenu.el.set_parent(_this.view.el);",
219            "\t_this.LeftTreeMenu.el.set_parent(_this.view.el);",
220            "\t",
221            "\t",
222            "\t//Gtk.Allocation rect;",
223            "\t//_this.view.el.get_allocation(out rect);",
224            " \t//_this.deletemenu.el.set_has_arrow(false);",
225            "\t_this.LeftTreeMenu.el.set_position(Gtk.PositionType.BOTTOM); ",
226            "\t",
227            "\t\t",
228            "\t_this.LeftTreeMenu.el.set_offset( ",
229            "\t\t\t(int)x  ,",
230            "\t\t\t(int)y - (int)_this.view.el.get_height());",
231            "",
232            "    _this.LeftTreeMenu.el.popup();",
233            "      ",
234            "}",
235            ""
236           ]
237          },
238          "uint button" : 3,
239          "xtype" : "GestureClick"
240         },
241         {
242          "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY   | Gdk.DragAction.MOVE   ",
243          "$ xns" : "Gtk",
244          "listeners" : {
245           "drag_begin" : [
246            "( drag )  => {",
247            "\tGLib.debug(\"SOURCE: drag-begin\");",
248            "\t ",
249            "    // find what is selected in our tree...",
250            "    var data = _this.selmodel.getSelectedNode();",
251            "\tif (data == null) {",
252            "\t\treturn  ;",
253            "\t}",
254            "\t_this.view.dragNode = data;",
255            "    var xname = data.fqn();",
256            "    GLib.debug (\"XNAME  IS %s\", xname);",
257            "",
258            " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
259            " \t",
260            " \t",
261            "    var paintable = new Gtk.WidgetPaintable(widget);",
262            "    this.el.set_icon(paintable, 0,0);",
263            "            ",
264            " ",
265            "}"
266           ],
267           "drag_cancel" : [
268            "(drag, reason) => {",
269            "",
270            "\t_this.view.dragNode = null;",
271            "\treturn true;",
272            "}",
273            ""
274           ],
275           "drag_end" : [
276            "(drag, delete_data) => {",
277            "",
278            "_this.view.dragNode = null;",
279            "}",
280            ""
281           ],
282           "prepare" : [
283            "(x, y) => {",
284            "",
285            "\t",
286            "\t",
287            "///\t( drag_context, data, info, time) => {",
288            "            ",
289            "",
290            "\t//print(\"drag-data-get\");",
291            " \tvar ndata = _this.selmodel.getSelectedNode();",
292            "\tif (ndata == null) {",
293            "\t \tGLib.debug(\"return empty string - no selection..\");",
294            "\t\treturn null;",
295            "\t ",
296            "\t}",
297            "",
298            "  ",
299            "\t//data.set_text(tp,tp.length);   ",
300            "",
301            "\tvar \tstr = ndata.toJsonString();",
302            "\tGLib.debug(\"prepare  store: %s\", str);",
303            "\tGLib.Value ov = GLib.Value(typeof(string));",
304            "\tov.set_string(str);",
305            " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
306            "    /*",
307            "\tGLib.Value v = GLib.Value(typeof(string));",
308            "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
309            "\t ",
310            "\t\tcont.get_value(ref v);",
311            "\t ",
312            "\t}",
313            "\tGLib.debug(\"set %s\", v.get_string());",
314            "      */  ",
315            " \treturn cont;",
316            "\t ",
317            "\t ",
318            "}",
319            ""
320           ]
321          },
322          "xtype" : "DragSource"
323         },
324         {
325          "$ xns" : "Gtk",
326          "listeners" : {
327           "key_pressed" : [
328            "(keyval, keycode, state) => {",
329            "",
330            " ",
331            "",
332            "\tif (keyval != Gdk.Key.Delete && keyval != Gdk.Key.BackSpace)  {",
333            "\t\treturn true;",
334            "\t}",
335            "",
336            "\t_this.model.deleteSelected();",
337            "\treturn true;",
338            "",
339            "}",
340            ""
341           ]
342          },
343          "xtype" : "EventControllerKey"
344         },
345         {
346          "$ xns" : "Gtk",
347          "id" : "keystate",
348          "int is_shift" : 0,
349          "listeners" : {
350           "key_pressed" : [
351            "(keyval, keycode, state) => {",
352            "",
353            " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
354            " \t\tthis.is_shift = 1;",
355            "\t}",
356            "\treturn true;",
357            "}",
358            ""
359           ],
360           "key_released" : [
361            "(keyval, keycode, state) => {",
362            "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int)  keycode, state);",
363            " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
364            " \t\tthis.is_shift = 0;",
365            "\t}",
366            "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
367            "",
368            "",
369            " ",
370            "}"
371           ]
372          },
373          "xtype" : "EventControllerKey"
374         },
375         {
376          "$ xns" : "Gtk",
377          "* ctor" : [
378           "new Gtk.DropTarget ( typeof(string) ,",
379           "\t\tGdk.DragAction.COPY   | Gdk.DragAction.MOVE   )"
380          ],
381          "Gtk.Widget? highlightWidget" : "null",
382          "JsRender.Node? lastDragNode" : "null",
383          "id" : "drop",
384          "listeners" : {
385           "accept" : [
386            "(drop) => {",
387            "",
388            "\tGLib.debug(\"got DropTarget:accept\");",
389            " ",
390            "// NOT REALLY NEEDED? = put stuff in drop?",
391            "",
392            "",
393            "/* (  ctx, x, y, time)  => {",
394            "      //Seed.print(\"TARGET: drag-drop\");",
395            "   ",
396            "   ",
397            "    var src = Gtk.drag_get_source_widget(ctx);",
398            "     ",
399            "   if (src != this.el) {",
400            "   ",
401            "    ",
402            "       ",
403            "       this.drag_in_motion = false;   ",
404            "            // request data that will be recieved by the recieve...              ",
405            "        Gtk.drag_get_data",
406            "        (",
407            "                this.el,         // will receive 'drag-data-received' signal ",
408            "                ctx,        // represents the current state of the DnD ",
409            "                Gdk.Atom.intern(\"application/json\",true),    // the target type we want ",
410            "                time            // time stamp ",
411            "        );",
412            "",
413            "         ",
414            "        // No target offered by source => error",
415            "   ",
416            "",
417            "         return  false;",
418            "     }",
419            "     ",
420            "     // handle drop around self..",
421            "     ",
422            "                  ",
423            "            ",
424            "    //print(\"GETTING POS\");",
425            "    var  targetData = \"\";",
426            "    ",
427            "    Gtk.TreePath path;",
428            "    Gtk.TreeViewDropPosition pos;",
429            "    var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
430            "    ",
431            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
432            "    var isEmpty = false;",
433            "    if (_this.model.el.iter_n_children(null) < 1) {",
434            "        print(\"got NO children?\\n\");",
435            "        isOver = true; //??? ",
436            "        isEmpty = true;",
437            "        pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
438            "    }",
439            "    ",
440            "     ",
441            "     ",
442            "    //var action = Gdk.DragAction.COPY;",
443            "        // unless we are copying!!! ctl button..",
444            "    ",
445            "    var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
446            "                 Gdk.DragAction.COPY  : Gdk.DragAction.MOVE ;",
447            "                // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
448            "",
449            "      ",
450            "    if (_this.model.el.iter_n_children(null) < 1) {",
451            "        // no children.. -- asume it's ok..",
452            "        ",
453            "        targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
454            "         ",
455            "        // continue through to allow drop...",
456            "",
457            "    } else {",
458            "                ",
459            "                ",
460            "    ",
461            "                ",
462            "                ",
463            "                //print(\"ISOVER? \" + isOver);",
464            "        if (!isOver) {",
465            "            ",
466            "            Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
467            "            return true; // not over apoint!?! - no action on drop or motion..",
468            "        }",
469            "                ",
470            "        // drag node is parent of child..",
471            "        //console.log(\"SRC TREEPATH: \" + src.treepath);",
472            "        //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
473            "        ",
474            "        // nned to check a  few here..",
475            "        //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
476            "        //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
477            "        //Gtk.TreeViewDropPosition.AFTER",
478            "        //Gtk.TreeViewDropPosition.BEFORE",
479            "        ",
480            "        // locally dragged items to not really use the ",
481            "        var selection_text = this.dragData;",
482            "        ",
483            "        ",
484            "        ",
485            "        if (selection_text == null || selection_text.length < 1) {",
486            "            //print(\"Error  - drag selection text returned NULL\");",
487            "          ",
488            "             Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
489            "             return true; /// -- fixme -- this is not really correct..",
490            "        }                ",
491            "                ",
492            "                // see if we are dragging into ourself?",
493            "                print (\"got selection text of  \" + selection_text);",
494            "        ",
495            "        var target_path = path.to_string();",
496            "        //print(\"target_path=\"+target_path);",
497            "",
498            "        // ",
499            "        if (selection_text  == target_path) {",
500            "            print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
501            "            ",
502            "             Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
503            "",
504            "             return true; /// -- fixme -- this is not really correct..",
505            "",
506            "        }",
507            "                ",
508            "        // check that ",
509            "        //print(\"DUMPING DATA\");",
510            "        //console.dump(data);",
511            "        // path, pos",
512            "        ",
513            "        //print(data.path.to_string() +' => '+  data.pos);",
514            "        ",
515            "        // dropList is a list of xtypes that this node could be dropped on.",
516            "        // it is set up when we start to drag..",
517            "        ",
518            "        ",
519            "        targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
520            "            ",
521            "        print(\"targetDAta: \" + targetData +\"\\n\");",
522            "        ",
523            "        if (targetData.length < 1) {",
524            "            //print(\"Can not find drop node path\");",
525            "             ",
526            "            Gtk.drag_finish (ctx, false, false, time);        // drop failed..",
527            "            return true;",
528            "        }",
529            "                    ",
530            "                ",
531            "                ",
532            "                // continue on to allow drop..",
533            "  }",
534            "        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
535            "",
536            "",
537            "     var delete_selection_data = false;",
538            "        ",
539            "    if (action == Gdk.DragAction.ASK)  {",
540            "        // Ask the user to move or copy, then set the ctx action. ",
541            "    }",
542            "",
543            "    if (action == Gdk.DragAction.MOVE) {",
544            "        delete_selection_data = true;",
545            "    }",
546            "      ",
547            "                // drag around.. - reorder..",
548            "    _this.model.moveNode(targetData, action);",
549            "        ",
550            "       ",
551            "        ",
552            "        ",
553            "        ",
554            "        // we can send stuff to souce here...",
555            "",
556            "",
557            "// do we always say failure, so we handle the reall drop?",
558            "    Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
559            "",
560            "    return true;",
561            " ",
562            " ",
563            " ",
564            " ",
565            " ",
566            " ",
567            "}",
568            "*/",
569            "\treturn true;",
570            "}",
571            ""
572           ],
573           "drop" : [
574            "(v, x, y) => {",
575            "\t",
576            "\tthis.addHighlight(null,\"\");",
577            " ",
578            " \tvar is_shift = _this.keystate.is_shift > 0;",
579            " ",
580            " \tvar pos = \"\";",
581            " \t// -- get position..",
582            " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
583            "\t\t// still dragging same node",
584            " ",
585            "\t\tthis.lastDragNode = new JsRender.Node(); ",
586            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
587            "\t}",
588            "    ",
589            " \t     ",
590            "       ",
591            "    var dropNode = new JsRender.Node(); ",
592            "\tdropNode.loadFromJsonString(v.get_string(), 1);",
593            "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
594            "   ",
595            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
596            " ",
597            "    if (_this.model.el.n_items < 1) {",
598            "    \t// FIXME check valid drop types?",
599            "    \tif (!drop_on_to.contains(\"*top\")) {",
600            "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
601            "\t\t\treturn false;\t",
602            "\t\t}",
603            "\t\t// add new node to top..",
604            "\t\t",
605            "\t\t",
606            "\t\t var m = (GLib.ListStore) _this.model.el.model;",
607            "     \t_this.main_window.windowstate.file.tree = dropNode;  ",
608            "    \tdropNode.updated_count++;",
609            "   ",
610            "\t\tm.append(dropNode);",
611            "\t\t_this.model.selectNode(dropNode); \t",
612            "\t\t_this.changed();",
613            "\t\treturn true; // no need to highlight?",
614            "     ",
615            "    }",
616            "",
617            "",
618            "",
619            "\tvar row = _this.view.getRowAt(x,y, out pos);",
620            "\tif (row < 0) {",
621            "\t\treturn   false; //Gdk.DragAction.COPY;",
622            "\t}",
623            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
624            "\t",
625            "\tvar node =  (JsRender.Node)tr.get_item();",
626            "",
627            " \tif (pos == \"above\" || pos == \"below\") {",
628            "\t\tif (node.parent == null) {",
629            "\t\t\tpos = \"over\";",
630            "\t\t} else {",
631            "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
632            "\t\t\t\tpos = \"over\";",
633            " \t\t\t} else {",
634            "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
635            "\t\t\t\tif (_this.view.dragNode  != null && is_shift) {",
636            "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
637            "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
638            "  \t\t\t\t\t\treturn false;\t",
639            "\t\t \t\t\t}",
640            "\t\t \t\t\t",
641            "\t\t \t\t}",
642            "\t\t\t\t",
643            "\t\t\t\t",
644            "\t\t\t}",
645            " \t\t}",
646            " \t\t",
647            " \t}",
648            " \tif (pos == \"over\") {",
649            "\t \tif (!drop_on_to.contains(node.fqn())) {",
650            "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
651            "\t\t\treturn false;",
652            "",
653            "\t\t}",
654            "\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
655            " \t\t\tGLib.debug(\"shift drop not self not allowed\");",
656            "\t\t\treturn false;\t",
657            "\t\t}",
658            "\t}",
659            " \t",
660            " \tswitch(pos) {",
661            " \t\tcase \"over\":",
662            "\t \t\tnode.appendChild(dropNode);",
663            "\t \t\tif (is_shift && _this.view.dragNode != null) {",
664            "\t\t \t\t_this.model.selectNode(null); ",
665            "\t\t \t\t_this.view.dragNode.remove();",
666            "\t \t\t}",
667            "\t \t\t\t",
668            "\t \t\tdropNode.updated_count++;",
669            " \t\t\t_this.model.selectNode(dropNode); ",
670            " \t\t\t",
671            " \t\t\t_this.changed();\t\t\t\t \t\t",
672            "\t \t\treturn true;",
673            "\t \t\t",
674            " \t\tcase \"above\":",
675            " \t\t\tGLib.debug(\"Above - insertBefore\");",
676            " \t\t",
677            "\t\t\tnode.parent.insertBefore(dropNode, node);",
678            "\t \t\tif (is_shift && _this.view.dragNode != null) {",
679            "\t\t \t\t_this.model.selectNode(null); \t \t\t",
680            "\t\t \t\t_this.view.dragNode.remove();",
681            "\t \t\t}",
682            "\t\t\tdropNode.updated_count++;",
683            " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
684            " \t\t\t_this.changed();",
685            " \t\t\treturn true;",
686            " \t\t\t",
687            " \t\tcase \"below\":",
688            " \t\t\tGLib.debug(\"Below - insertAfter\"); \t\t",
689            "\t \t\tif (is_shift && _this.view.dragNode != null) {",
690            "\t\t \t\t_this.model.selectNode(null); \t \t\t",
691            "\t\t \t\t_this.view.dragNode.remove();",
692            "\t \t\t}",
693            "\t",
694            " \t\t\t",
695            " \t\t\tnode.parent.insertAfter(dropNode, node);",
696            " \t\t\tdropNode.updated_count++;",
697            " \t\t\t_this.model.selectNode(dropNode);\t",
698            " \t\t\t_this.changed();",
699            " \t\t\t// select it",
700            " \t\t\treturn true;",
701            " \t\t\t",
702            " \t\tdefault:",
703            " \t\t\t// should not happen",
704            " \t\t\treturn false;",
705            " \t}",
706            " \t",
707            "\t",
708            "     ",
709            "\t\t",
710            "\t\t",
711            "",
712            "}",
713            " "
714           ],
715           "leave" : [
716            "( ) => {",
717            "\tthis.addHighlight(null,\"\");",
718            "",
719            "}",
720            ""
721           ],
722           "motion" : [
723            "(  x, y) => {",
724            " ",
725            "\tvar is_shift = _this.keystate.is_shift > 0;",
726            "\t",
727            "\tGLib.debug(\"shift is    %s\", _this.keystate.is_shift > 0 ? \"SHIFT\" : \"-\");",
728            "\tstring pos; // over / before / after..",
729            "",
730            "    //GLib.debug(\"got drag motion\");",
731            "",
732            "    GLib.Value v = GLib.Value(typeof(string));",
733            "   \t//var str = drop.read_text( [ \"text/plain\" ] 0);",
734            "   \tvar cont = this.el.current_drop.get_drag().content ;",
735            "   \ttry {",
736            "  \t\tcont.get_value(ref v);",
737            "\t} catch (GLib.Error e) {",
738            "\t    GLib.debug(\"failed to get drag value\");",
739            "\t\treturn Gdk.DragAction.COPY;\t ",
740            "\t",
741            "\t}",
742            " ",
743            "\t//GLib.debug(\"got %s\", v.get_string());",
744            "\t  ",
745            "\tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
746            "\t\t// still dragging same node",
747            " ",
748            "\t\tthis.lastDragNode = new JsRender.Node(); ",
749            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
750            "\t}",
751            "    ",
752            "",
753            "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(",
754            "\t\t\t\tthis.lastDragNode.fqn());",
755            "     ",
756            "     string[] str = {};",
757            "     foreach(var dp in drop_on_to) {",
758            "     \tstr += dp;",
759            " \t}",
760            " \tGLib.debug(\"droplist: %s\", string.joinv(\", \", str));",
761            "     ",
762            "     ",
763            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
764            " ",
765            "    if (_this.model.el.n_items < 1) {",
766            "    \t// FIXME check valid drop types?",
767            "    \tif (drop_on_to.contains(\"*top\")) {",
768            "\t\t\tthis.addHighlight(_this.view.el, \"over\");",
769            "\t\t} else {",
770            "\t\t\tthis.addHighlight(null, \"\");\t\t",
771            "\t\t}",
772            "",
773            "\t\treturn Gdk.DragAction.COPY; // no need to highlight?",
774            "     ",
775            "    }",
776            "    ",
777            "    ",
778            " \tGLib.debug(\"check is over\");",
779            " \t ",
780            "    // if path of source and dest are inside each other..",
781            "    // need to add source info to drag?",
782            "    // the fail();",
783            " \tvar row = _this.view.getRowAt(x,y, out pos);",
784            " \t",
785            " \tif (row < 0) {",
786            "\t\tthis.addHighlight(null, \"\");\t",
787            "\t \treturn Gdk.DragAction.COPY;",
788            " \t}",
789            "\tvar tr = (Gtk.TreeListRow)_this.view.el.model.get_object(row);",
790            "\t",
791            "\tvar node =  (JsRender.Node)tr.get_item();",
792            "\t",
793            "\tGLib.debug(\"Drop over node: %s\", node.fqn());",
794            "\t",
795            "",
796            " \tif (pos == \"above\" || pos == \"below\") {",
797            "\t\tif (node.parent == null) {",
798            "\t\t\tGLib.debug(\"no parent try center\");",
799            "\t\t\tpos = \"over\";",
800            "\t\t} else {",
801            "\t \t\t ",
802            "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
803            "\t\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
804            "\t \t\t\tpos = \"over\";",
805            " \t\t\t} else {",
806            "\t\t\t\tGLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
807            "\t\t\t\tif (_this.view.dragNode  != null && is_shift) {",
808            "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
809            "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
810            "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
811            "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
812            "\t\t \t\t\t}",
813            "\t\t \t\t\t",
814            "\t\t \t\t}",
815            "\t\t\t\t",
816            "\t\t\t}",
817            "\t\t\t",
818            "\t\t\t",
819            "\t\t\t",
820            " \t\t}",
821            " \t\t",
822            " \t\t",
823            " \t}",
824            " \tif (pos == \"over\") {",
825            "\t \tif (!drop_on_to.contains(node.fqn())) {",
826            "\t\t\tGLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
827            "\t\t\tthis.addHighlight(null, \"\"); ",
828            "\t\t\treturn is_shift ?  Gdk.DragAction.MOVE :  Gdk.DragAction.COPY;\t\t",
829            "\t\t}",
830            "\t\tif (_this.view.dragNode  != null && is_shift) {",
831            " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
832            "\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
833            " \t\t\t\tthis.addHighlight(null, \"\");",
834            " \t\t\t\treturn Gdk.DragAction.COPY;\t",
835            " \t\t\t}",
836            "\t\t}",
837            " \t\t\t",
838            "\t}",
839            " \t",
840            " \t",
841            " \t    // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
842            "\tvar w = _this.view.getWidgetAt(x,y);",
843            "\tthis.addHighlight(w, pos); ",
844            "\treturn is_shift ?  Gdk.DragAction.MOVE :  Gdk.DragAction.COPY;\t\t",
845            "}"
846           ]
847          },
848          "string lastDragString" : "\"\"",
849          "xtype" : "DropTarget",
850          "| void addHighlight" : [
851           "(Gtk.Widget? w, string hl) {",
852           "\tif (this.highlightWidget != null) {",
853           "\t\tvar ww  = this.highlightWidget;",
854           "\t\tGLib.debug(\"clear drag from previous highlight\");",
855           "\t\tif (ww.has_css_class(\"drag-below\")) {",
856           "\t\t\t ww.remove_css_class(\"drag-below\");",
857           "\t\t}",
858           "\t\tif (ww.has_css_class(\"drag-above\")) {",
859           "\t\t\t ww.remove_css_class(\"drag-above\");",
860           "\t\t}",
861           "\t\tif (ww.has_css_class(\"drag-over\")) {",
862           "\t\t\t ww.remove_css_class(\"drag-over\");",
863           "\t\t}",
864           "\t}",
865           "\tif (w != null) {",
866           "\t\tGLib.debug(\"add drag=%s to widget\", hl);\t",
867           "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
868           "\t\t\tw.add_css_class(\"drag-\" + hl);",
869           "\t\t}",
870           "\t}",
871           "\tthis.highlightWidget = w;",
872           "}"
873          ]
874         },
875         {
876          "$ xns" : "Gtk",
877          "* prop" : "model",
878          "id" : "selmodel",
879          "items" : [
880           {
881            "$ xns" : "Gtk",
882            "* ctor" : "this.updateModel(null)",
883            "* prop" : "model",
884            "id" : "model",
885            "xtype" : "TreeListModel",
886            "| Gtk.TreeListModel updateModel" : [
887             "(GLib.ListStore? m) {",
888             "\tthis.el = new Gtk.TreeListModel(",
889             "\t\tm != null ? m : new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
890             "\t\tfalse, // passthru",
891             "\t\ttrue, // autexpand",
892             "\t\t(item) => {",
893             "\t\t\treturn ((JsRender.Node)item).childstore;",
894             "\t\t",
895             "\t\t}",
896             "\t);",
897             "\tif (_this.selmodel.el == null) {",
898             "\t\treturn this.el;",
899             "\t}",
900             "\t_this.selmodel.el.set_model(this.el);",
901             "\treturn this.el;",
902             "}"
903            ],
904            "| int nodeToRow" : [
905             "(JsRender.Node node) ",
906             "{",
907             "\tvar row = -1;",
908             "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
909             "\tfor (var i = 0; i < s.n_items; i++) {",
910             "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
911             "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
912             "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
913             "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {",
914             "\t\t\treturn i;",
915             "\t\t\t",
916             "\t\t}",
917             "\t}",
918             "\treturn -1;\t\t\t",
919             "\t",
920             "",
921             "}"
922            ],
923            "| void deleteSelected" : [
924             "() {",
925             "",
926             "",
927             "\t",
928             "\tvar node = _this.selmodel.getSelectedNode();",
929             "\t",
930             "",
931             "     if (node == null) {",
932             "     \tGLib.debug(\"delete Selected - no node slected?\");",
933             "\t     return;",
934             "     }",
935             "    _this.selmodel.el.unselect_all();",
936             "    ",
937             "    node.remove();",
938             " \tGLib.debug(\"delete Selected - done\");",
939             "    _this.changed();",
940             "/*    ",
941             "    print(\"DELETE SELECTED?\");",
942             "    //_this.view.blockChanges = true;",
943             "    print(\"GET SELECTION?\");",
944             "",
945             "    var s = _this.view.el.get_selection();",
946             "    ",
947             "    print(\"GET  SELECTED?\");",
948             "   Gtk.TreeIter iter;",
949             "    Gtk.TreeModel mod;",
950             "",
951             "    ",
952             "    if (!s.get_selected(out mod, out iter)) {",
953             "        return; // nothing seleted..",
954             "    }",
955             "      ",
956             "",
957             "",
958             "    this.activePath= \"\";      ",
959             "    print(\"GET  vnode value?\");",
960             "",
961             "    GLib.Value value;",
962             "    this.el.get_value(iter, 2, out value);",
963             "    var data = (JsRender.Node)(value.get_object());",
964             "    print(\"removing node from Render\\n\");",
965             "    if (data.parent == null) {",
966             "       _this.main_window.windowstate.file.tree = null;",
967             "    } else {",
968             "        data.remove();",
969             "    }",
970             "    print(\"removing node from Tree\\n\");    ",
971             "    s.unselect_all();",
972             "    this.el.remove(ref iter);",
973             "",
974             "    ",
975             "    ",
976             "    ",
977             "    // ",
978             "    ",
979             "    ",
980             "",
981             "",
982             "    this.activePath= \"\"; // again!?!?      ",
983             "    //this.changed(null,true);",
984             "    ",
985             "    _this.changed();",
986             "    ",
987             "    _this.view.blockChanges = false;",
988             "    */",
989             "}",
990             ""
991            ],
992            "| void loadFile" : [
993             "(JsRender.JsRender f) {",
994             "    //console.dump(f);",
995             "    ",
996             "    _this.drop.highlightWidget = null;",
997             "    ",
998             "    var m = (GLib.ListStore) this.el.model;",
999             "\tm.remove_all();",
1000             "    _this.main_window.windowstate.leftTreeNodeSelected(null);",
1001             "    // needed???",
1002             "    _this.main_window.windowstate.file = f;",
1003             "    _this.last_error_counter = -1;",
1004             "   ",
1005             "    if (f.tree == null) {",
1006             "\t    try {",
1007             "\t        f.loadItems( );",
1008             "        } catch (Error e) {",
1009             "    \t\treturn;",
1010             "        }",
1011             "    }",
1012             "    // if it's still null?",
1013             "    if (f.tree == null) {",
1014             "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1015             "    \t_this.updateErrors();",
1016             "        return;",
1017             "    }",
1018             "  \tm.append(f.tree);",
1019             "\t_this.updateErrors();",
1020             " ",
1021             "    _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1022             "   ",
1023             "    return;",
1024             " ",
1025             "            ",
1026             "}",
1027             ""
1028            ],
1029            "| void selectNode" : [
1030             "(JsRender.Node node) ",
1031             "{",
1032             "\tvar row = this.nodeToRow(node);",
1033             "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1034             "\t ",
1035             "\tif (row < 0) {",
1036             "\t\t// select none?",
1037             "\t\tGLib.debug(\"Could not find node\");",
1038             "\t\treturn;",
1039             "\t}",
1040             "\tGLib.debug(\"Select %d\", row);",
1041             "\ts.set_selected(row);",
1042             "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1043             "\t//_this.node_selected(node);\t\t\t",
1044             "\t",
1045             "",
1046             "}"
1047            ]
1048           }
1049          ],
1050          "listeners" : {
1051           "selection_changed" : [
1052            "(position, n_items) => {",
1053            "",
1054            "\t",
1055            "\t\t",
1056            "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1057            "\t\t\t// then event was started by some other action",
1058            "\t\t\t// which should manually trigger all the events..",
1059            "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1060            "\t\t//\treturn;",
1061            "\t\t//}",
1062            "",
1063            "",
1064            "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1065            "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\");     ",
1066            "\t\t   return  ;",
1067            "\t\t }",
1068            "",
1069            "\t\t  if (!_this.before_node_change( ) ) {",
1070            "\t\t\t _this.view.blockChanges = true;",
1071            "\t\t\t _this.selmodel.el.unselect_all();",
1072            "\t\t\t _this.view.blockChanges = false;",
1073            "\t\t\t ",
1074            "\t\t\t return;",
1075            "\t\t }",
1076            "\t\t if (_this.main_window.windowstate.file == null) {",
1077            "\t   \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\");     ",
1078            "\t\t\treturn;",
1079            "\t\t } ",
1080            "\t\t ",
1081            "\t\t //var render = this.get('/LeftTree').getRenderer();                ",
1082            "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1083            "\t\t",
1084            "\t\t",
1085            "\t\t// -- it appears that the selection is not updated.",
1086            "\t\t // select the node...",
1087            "\t\t //_this.selmodel.el.set_selected(row);",
1088            " ",
1089            "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1090            "",
1091            "\t    var snode = _this.selmodel.getSelectedNode();",
1092            "\t    if (snode == null) {",
1093            "",
1094            "\t         GLib.debug(\"selected rows < 1\");",
1095            "\t        //??this.model.load( false);",
1096            "\t        _this.node_selected(null);",
1097            "\t        ",
1098            "\t        return   ;",
1099            "\t    }",
1100            "\t ",
1101            "\t    // why dup_?",
1102            "\t    ",
1103            "",
1104            "\t    GLib.debug (\"calling left_tree.node_selected\");",
1105            "\t    _this.node_selected(snode);",
1106            "\t   ",
1107            "\t     ",
1108            "\t    ",
1109            "\t     ",
1110            "\t    // no need to scroll. it's in the view as we clicked on it.",
1111            "\t   // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1112            "\t    ",
1113            "\t    return  ;",
1114            "}",
1115            ""
1116           ]
1117          },
1118          "xtype" : "SingleSelection",
1119          "| JsRender.Node getNodeAt" : [
1120           "(uint row) {",
1121           "",
1122           "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1123           "   ",
1124           "   var a = tr.get_item();;   ",
1125           "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1126           "  \t",
1127           "   ",
1128           "   return (JsRender.Node)tr.get_item();",
1129           "\t ",
1130           "}"
1131          ],
1132          "| JsRender.Node? getSelectedNode" : [
1133           "() {",
1134           "  if (this.el.selected_item == null) {",
1135           "\t\treturn null;",
1136           "  }\t\t\t        ",
1137           "   var tr = (Gtk.TreeListRow)this.el.selected_item;",
1138           "   return (JsRender.Node)tr.get_item();",
1139           "\t ",
1140           "}"
1141          ]
1142         },
1143         {
1144          "$ xns" : "Gtk",
1145          "* pack" : "append_column",
1146          "bool expand" : true,
1147          "bool resizable" : true,
1148          "id" : "maincol",
1149          "items" : [
1150           {
1151            "$ xns" : "Gtk",
1152            "* prop" : "factory",
1153            "listeners" : {
1154             "bind" : [
1155              "(listitem) => {",
1156              "\t GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1157              "\t",
1158              "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1159              "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1160              "\t ",
1161              "\t ",
1162              "\tvar hbox = (Gtk.Box) expand.child;",
1163              " ",
1164              "\t",
1165              "\tvar img = (Gtk.Image) hbox.get_first_child();",
1166              "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1167              "\t",
1168              "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1169              "\tvar node = (JsRender.Node) lr.get_item();",
1170              "\t",
1171              "   GLib.debug(\"node is %s\", node.get_type().name());",
1172              "// was item (1) in old layout",
1173              "",
1174              "\t",
1175              " ",
1176              " \t /* ",
1177              " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1178              "    var clsname = node.fqn();",
1179              "    ",
1180              "    var clsb = clsname.split(\".\");",
1181              "    var sub = clsb.length > 1 ? clsb[1].down()  : \"\";",
1182              "     ",
1183              "    var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1184              "    try { ",
1185              "    \t ",
1186              "    \t\t ",
1187              "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1188              "\t\t    img.set_from_file(fn);",
1189              "\t\t \t ",
1190              "\t \t} else {",
1191              "\t \t\timg.set_from_paintable(",
1192              "\t\t\t \tic.lookup_icon (",
1193              "\t\t\t \t\t\"media-playback-stop\", null,  16,1, ",
1194              "\t    \t\t\t Gtk.TextDirection.NONE, 0",
1195              "    \t\t\t)",
1196              "\t\t\t );",
1197              "\t \t}",
1198              " \t} catch (GLib.Error e) {}",
1199              "    */",
1200              "    expand.set_hide_expander( !node.hasChildren() );",
1201              " \texpand.set_list_row(lr);",
1202              " \t",
1203              " \tnode.bind_property(\"iconResourceName\",",
1204              "                    img, \"resource\",",
1205              "                   GLib.BindingFlags.SYNC_CREATE);",
1206              " \t",
1207              " \tnode.bind_property(\"nodeTitleProp\",",
1208              "                    lbl, \"label\",",
1209              "                   GLib.BindingFlags.SYNC_CREATE);",
1210              " \tnode.bind_property(\"nodeTipProp\",",
1211              "                    lbl, \"tooltip_markup\",",
1212              "                   GLib.BindingFlags.SYNC_CREATE);",
1213              " \t// bind image...",
1214              " \t",
1215              "}",
1216              ""
1217             ],
1218             "setup" : [
1219              "(listitem) => {",
1220              "\t",
1221              "\tvar expand = new Gtk.TreeExpander();",
1222              "\t ",
1223              "\texpand.set_indent_for_depth(true);",
1224              "\texpand.set_indent_for_icon(true);",
1225              "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1226              "\tvar icon = new Gtk.Image();",
1227              "\tvar lbl = new Gtk.Label(\"\");",
1228              "\tlbl.use_markup = true;",
1229              "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1230              "\t",
1231              "\ticon.margin_end = 4;",
1232              " \tlbl.justify = Gtk.Justification.LEFT;",
1233              " \tlbl.xalign = 0;",
1234              "",
1235              "//\tlistitem.activatable = true; ??",
1236              "\t",
1237              "\thbox.append(icon);",
1238              "\thbox.append(lbl);",
1239              "\texpand.set_child(hbox);",
1240              "\t((Gtk.ListItem)listitem).set_child(expand);",
1241              "\t",
1242              "}",
1243              ""
1244             ]
1245            },
1246            "xtype" : "SignalListItemFactory"
1247           }
1248          ],
1249          "title" : "Property",
1250          "xtype" : "ColumnViewColumn"
1251         },
1252         {
1253          "$ xns" : "Gtk",
1254          "* pack" : "append_column",
1255          "int fixed_width" : 25,
1256          "items" : [
1257           {
1258            "$ xns" : "Gtk",
1259            "* prop" : "factory",
1260            "listeners" : {
1261             "bind" : [
1262              "(listitem) => {",
1263              "",
1264              " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1265              " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1266              "\tvar node = (JsRender.Node) lr.get_item();",
1267              "\t",
1268              "  ",
1269              "    var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1270              "\timg.set_from_paintable(",
1271              "\t \tic.lookup_icon (",
1272              "\t \t\t\"list-add\", null,  16,1, ",
1273              "\t\t\t Gtk.TextDirection.NONE, 0",
1274              "\t\t)",
1275              "\t );",
1276              "\t ",
1277              " \tvar fqn = node.fqn();",
1278              "    var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1279              "",
1280              "\timg.set_visible(cn.size > 0 ? true : false);",
1281              " \t ",
1282              "}",
1283              ""
1284             ],
1285             "setup" : [
1286              "(listitem) => {",
1287              "",
1288              "\t ",
1289              "\tvar icon = new Gtk.Image();",
1290              "\t ",
1291              "\t((Gtk.ListItem)listitem).set_child(icon);",
1292              "}",
1293              ""
1294             ]
1295            },
1296            "xtype" : "SignalListItemFactory"
1297           }
1298          ],
1299          "string title" : "Add",
1300          "xtype" : "ColumnViewColumn"
1301         }
1302        ],
1303        "string name" : "left-tree-view",
1304        "xtype" : "ColumnView",
1305        "| Gtk.Widget? getWidgetAt" : [
1306         "(double x,  double in_y) {",
1307         "/*",
1308         "    \t",
1309         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1310         "    \tvar colview = gesture.widget;",
1311         "    \tvar line_no = check_list_widget(colview, x,y);",
1312         "         if (line_no > -1) {",
1313         "    \t\tvar item = colview.model.get_item(line_no);",
1314         "    \t\t ",
1315         "    \t}",
1316         "    \t*/",
1317         "    \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1318         "        var  child = this.el.get_first_child(); ",
1319         "    \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1320         "    \tvar line_no = -1; ",
1321         "    \tvar reading_header = true;",
1322         "    \tvar curr_y = 0;",
1323         "    \tvar header_height  = 0;",
1324         "    \tvar h = 0;",
1325         "    \twhile (child != null) {",
1326         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1327         "\t        if (reading_header) {",
1328         "\t\t\t\t",
1329         "",
1330         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1331         "\t\t\t        h += child.get_height();",
1332         "\t\t\t\t\tchild = child.get_next_sibling();",
1333         "\t\t\t\t\tcontinue;",
1334         "\t\t\t\t}",
1335         "\t\t\t\t// should be columnlistview",
1336         "\t\t\t\tchild = child.get_first_child(); ",
1337         "\t\t\t    GLib.debug(\"header height=%d\", h);",
1338         "\t\t\t\theader_height =  h;",
1339         "\t\t\t\t",
1340         "\t\t\t\treading_header = false;",
1341         "\t\t\t\tcontinue;",
1342         "\t        }",
1343         "\t\t    line_no++;",
1344         "",
1345         "\t\t\tif (y < header_height) {",
1346         "\t\t    \treturn null;",
1347         "\t    \t}",
1348         "",
1349         "\t\t\tvar hh = child.get_height();",
1350         "\t\t\t//GLib.debug(\"got cell xy = %d,%d  w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1351         "\t\t\tif (child.has_css_class(\"node-err\") || ",
1352         "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
1353         "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
1354         "\t\t\t\thh += 10;",
1355         "\t\t\t",
1356         "\t\t\t}\t",
1357         "\t\t    if (y > curr_y && y <= header_height + hh + curr_y ) {",
1358         "\t\t\t    return (Gtk.Widget)child;",
1359         "\t\t    }",
1360         "\t\t    curr_y +=  hh ;",
1361         "",
1362         "\t\t    if (curr_y > y) {",
1363         "\t\t        return null;",
1364         "\t        }",
1365         "\t        child = child.get_next_sibling(); ",
1366         "    \t}",
1367         "        return null;",
1368         "",
1369         " }"
1370        ],
1371        "| Gtk.Widget? getWidgetAtRow" : [
1372         "(uint row) {",
1373         "/*",
1374         "    \t",
1375         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1376         "    \tvar colview = gesture.widget;",
1377         "    \tvar line_no = check_list_widget(colview, x,y);",
1378         "         if (line_no > -1) {",
1379         "    \t\tvar item = colview.model.get_item(line_no);",
1380         "    \t\t ",
1381         "    \t}",
1382         "    \t*/",
1383         "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1384         "        var  child = this.el.get_first_child(); ",
1385         "    \tvar line_no = -1; ",
1386         "    \tvar reading_header = true;",
1387         "\t ",
1388         "    \twhile (child != null) {",
1389         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1390         "    \t   ",
1391         "    \t   if (reading_header) {",
1392         "\t\t\t\t",
1393         "",
1394         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1395         "\t\t\t\t   ",
1396         "\t\t\t\t\tchild = child.get_next_sibling();",
1397         "\t\t\t\t\tcontinue;",
1398         "\t\t\t\t}",
1399         "\t\t\t\t// should be columnlistview",
1400         "\t\t\t\tchild = child.get_first_child(); ",
1401         "\t\t\t ",
1402         "\t\t\t ",
1403         "\t\t\t\t",
1404         "\t\t\t\treading_header = false;",
1405         "\t\t\t\tcontinue;",
1406         "\t\t    }",
1407         "\t\t    ",
1408         "\t\t  ",
1409         "    \t    ",
1410         "\t\t    line_no++;",
1411         "\t\t\tif (line_no == row) {",
1412         "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1413         "\t\t\t    return (Gtk.Widget)child;",
1414         "\t\t    }",
1415         "\t        child = child.get_next_sibling(); ",
1416         "    \t}",
1417         "\t\t//GLib.debug(\"Rturning null\");",
1418         "        return null;",
1419         "",
1420         " }"
1421        ],
1422        "| int getColAt" : [
1423         "(double x,  double y) {",
1424         "\t/*",
1425         "\t\t\t",
1426         "\tfrom    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1427         "    \t  ",
1428         "\t*/",
1429         "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1430         "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1431         "    var  child = this.el.get_first_child(); ",
1432         "\t ",
1433         "\tvar col = 0;",
1434         "\tvar offx = 0;",
1435         "\twhile (child != null) {",
1436         "\t\t",
1437         "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1438         "\t\t\tchild = child.get_first_child();",
1439         "\t\t\tcontinue;",
1440         "\t\t}",
1441         "\t\t",
1442         "\t\t//child.get_allocation(out alloc);",
1443         "\t\tif (x <  (child.get_width() + offx)) {",
1444         "\t\t\treturn col;",
1445         "\t\t}",
1446         "\t\treturn 1;",
1447         "\t\t//offx += child.get_width();",
1448         "\t\t//col++;",
1449         "\t\t//child = child.get_next_sibling();",
1450         "\t}",
1451         "\t     ",
1452         "\t\t  ",
1453         "    return -1;",
1454         "",
1455         " }"
1456        ],
1457        "| int getRowAt" : [
1458         "(double x,  double in_y, out string pos) {",
1459         "",
1460         "",
1461         "\t ",
1462         "",
1463         "/*",
1464         "    \t",
1465         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1466         "    \tvar colview = gesture.widget;",
1467         "    \tvar line_no = check_list_widget(colview, x,y);",
1468         "         if (line_no > -1) {",
1469         "    \t\tvar item = colview.model.get_item(line_no);",
1470         "    \t\t ",
1471         "    \t}",
1472         "    \t*/",
1473         " \t\t ",
1474         " \t\t",
1475         " \t\tGLib.debug(\"get Widget At Row x = %d  y = %d\", (int) x, (int) in_y);",
1476         "    \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
1477         "        var  child = this.el.get_first_child(); ",
1478         "    \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1479         "    \tvar line_no = -1; ",
1480         "    \tvar reading_header = true;",
1481         "    \tvar real_y = 0;",
1482         "    \tvar header_height  = 0;",
1483         "    \tpos = \"none\";",
1484         "    \tvar h = 0;",
1485         "    \twhile (child != null) {",
1486         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1487         "    \t    if (reading_header) {",
1488         "\t\t\t\t",
1489         "",
1490         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1491         "\t\t\t        h += child.get_height();",
1492         "\t\t\t\t\tchild = child.get_next_sibling();",
1493         "\t\t\t\t\tcontinue;",
1494         "\t\t\t\t}",
1495         "\t\t\t\t// should be columnlistview",
1496         "\t\t\t\tchild = child.get_first_child(); ",
1497         "\t\t\t    //GLib.debug(\"header height=%d\", h);",
1498         "\t\t\t\theader_height =  h;",
1499         "\t\t\t\t",
1500         "\t\t\t\treading_header = false;",
1501         "\t\t\t\tcontinue;",
1502         "\t\t\t\t",
1503         "\t        }",
1504         "\t        ",
1505         "\t\t    if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
1506         "    \t\t    child = child.get_next_sibling();",
1507         "    \t\t    continue;",
1508         "\t\t    }",
1509         "\t\t    ",
1510         "\t\t \tif (y < header_height) {",
1511         "\t\t    \treturn -1;",
1512         "\t    \t}",
1513         "\t\t    ",
1514         "\t\t    line_no++;",
1515         "\t\t\tvar hh = child.get_height();",
1516         "\t\t\t",
1517         "\t\t\tif (child.has_css_class(\"node-err\") || ",
1518         "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
1519         "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
1520         "\t\t\t\thh += 10;",
1521         "\t\t\t",
1522         "\t\t\t}",
1523         "\t\t\t//child.get_allocation(out alloc);",
1524         "\t\t\t//GLib.debug(\"got cell xy = %d,%d  w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
1525         "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
1526         "\t\t\t",
1527         "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
1528         "",
1529         "\t\t    if (y >  (header_height + real_y) && y <= (header_height +  real_y + hh) ) {",
1530         "\t\t    \tif (y > ( header_height + real_y + (hh * 0.8))) {",
1531         "\t\t    \t\tpos = \"below\";",
1532         "\t    \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
1533         "\t    \t\t\tpos = \"over\";",
1534         "    \t\t\t} else {",
1535         "    \t\t\t\tpos = \"above\";",
1536         "\t\t\t\t}",
1537         "\t\t    \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
1538         "\t\t\t    return line_no;",
1539         "\t\t    }",
1540         " ",
1541         "",
1542         "\t\t    if (real_y + hh > y) {",
1543         "\t\t        return -1;",
1544         "\t        }",
1545         "\t        real_y += hh;",
1546         "\t        child = child.get_next_sibling(); ",
1547         "    \t}",
1548         "        return -1;",
1549         "",
1550         " }"
1551        ]
1552       },
1553       {
1554        "$ xns" : "Gtk",
1555        "* pack" : false,
1556        "id" : "LeftTreeMenu",
1557        "items" : [
1558         {
1559          "$ xns" : "Gtk",
1560          "* prop" : "child",
1561          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1562          "int spacing" : 0,
1563          "items" : [
1564           {
1565            "$ xns" : "Gtk",
1566            "bool has_frame" : false,
1567            "label" : "Delete Element",
1568            "listeners" : {
1569             "clicked" : [
1570              " ( ) => {",
1571              "_this.LeftTreeMenu.el.hide();",
1572              " _this.model.deleteSelected();",
1573              "_this.changed();",
1574              "}"
1575             ]
1576            },
1577            "xtype" : "Button"
1578           },
1579           {
1580            "$ xns" : "Gtk",
1581            "bool has_frame" : false,
1582            "label" : "Save as Template",
1583            "listeners" : {
1584             "clicked" : [
1585              "  () => {",
1586              "_this.LeftTreeMenu.el.hide();",
1587              "     DialogSaveTemplate.singleton().showIt(",
1588              "            (Gtk.Window) _this.el.get_root (), ",
1589              "            _this.main_window.windowstate.file.palete(), ",
1590              "            _this.getActiveElement()",
1591              "    );",
1592              "     ",
1593              "    ",
1594              "}"
1595             ]
1596            },
1597            "xtype" : "Button"
1598           },
1599           {
1600            "$ xns" : "Gtk",
1601            "bool has_frame" : false,
1602            "label" : "Save as Module",
1603            "listeners" : {
1604             "clicked" : [
1605              "  () => {",
1606              "    ",
1607              "    _this.LeftTreeMenu.el.hide();",
1608              "    var node = _this.getActiveElement();",
1609              "      ",
1610              "     ",
1611              "     var sm = DialogSaveModule.singleton();",
1612              "     ",
1613              "     ",
1614              "    sm.showIt(",
1615              "            (Gtk.Window) _this.el.get_root (), ",
1616              "            _this.main_window.windowstate.project, ",
1617              "            node",
1618              "     );",
1619              "     /*",
1620              "     gtk4 migration - disabled this part.. probably not used muchanyway",
1621              "     ",
1622              "     ",
1623              "     if (name.length < 1) {",
1624              "            return;",
1625              "  ",
1626              "     }",
1627              "     node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1628              "     node.items.clear();",
1629              "",
1630              "",
1631              "    var s = _this.view.el.get_selection();",
1632              "    ",
1633              "    print(\"GET  SELECTED?\");",
1634              "    Gtk.TreeIter iter;",
1635              "    Gtk.TreeModel mod;",
1636              "",
1637              "    ",
1638              "    if (!s.get_selected(out mod, out iter)) {",
1639              "        return; // nothing seleted..",
1640              "    }",
1641              "    Gtk.TreeIter citer;",
1642              "    var n_cn = mod.iter_n_children(iter) -1;",
1643              "    for (var i = n_cn; i > -1; i--) {",
1644              "        mod.iter_nth_child(out citer, iter, i);",
1645              "        ",
1646              "",
1647              "        print(\"removing node from Tree\\n\");    ",
1648              "    ",
1649              "        _this.model.el.remove(ref citer);",
1650              "    }",
1651              "    _this.changed();",
1652              "    _this.node_selected(node, \"tree\");",
1653              "     */",
1654              "    ",
1655              "}"
1656             ]
1657            },
1658            "xtype" : "Button"
1659           }
1660          ],
1661          "xtype" : "Box"
1662         }
1663        ],
1664        "xtype" : "Popover"
1665       }
1666      ],
1667      "xtype" : "ScrolledWindow"
1668     }
1669    ],
1670    "xtype" : "Box",
1671    "| JsRender.JsRender getActiveFile" : [
1672     "() {",
1673     "    return this.main_window.windowstate.file;",
1674     "    ",
1675     "}",
1676     ""
1677    ],
1678    "| JsRender.Node? getActiveElement" : [
1679     " () { // return path to actie node.",
1680     "",
1681     "     ",
1682     "\treturn _this.selmodel.getSelectedNode();",
1683     "    ",
1684     "    ",
1685     "}",
1686     ""
1687    ],
1688    "| void onresize" : [
1689     "() {",
1690     " ",
1691     "\t ",
1692     "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1693     "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width()  - 32 );",
1694     "}",
1695     "",
1696     ""
1697    ],
1698    "| void removeErrors" : [
1699     "() {",
1700     "\tvar  child = this.view.el.get_first_child(); ",
1701     " ",
1702     "\tvar reading_header = true;",
1703     " ",
1704     "\twhile (child != null) {",
1705     "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1706     "\t   ",
1707     "\t   if (reading_header) {",
1708     "\t\t\t",
1709     "",
1710     "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1711     "\t\t\t   ",
1712     "\t\t\t\tchild = child.get_next_sibling();",
1713     "\t\t\t\tcontinue;",
1714     "\t\t\t}",
1715     "\t\t\t// should be columnlistview",
1716     "\t\t\tchild = child.get_first_child(); ",
1717     "\t\t ",
1718     "\t\t ",
1719     "\t\t\t",
1720     "\t\t\treading_header = false;",
1721     "\t\t\t continue;",
1722     "\t    }",
1723     "\t    ",
1724     "\t  \tif (child.has_css_class(\"node-err\")) {",
1725     "\t\t\tchild.remove_css_class(\"node-err\");",
1726     "\t\t}",
1727     "\t\tif (child.has_css_class(\"node-warn\")) {",
1728     "\t\t\tchild.remove_css_class(\"node-warn\");",
1729     "\t\t}",
1730     "\t\t",
1731     "\t\tif (child.has_css_class(\"node-depr\")) {",
1732     "\t\t\tchild.remove_css_class(\"node-depr\");",
1733     "\t\t}",
1734     "\t\t",
1735     "        child = child.get_next_sibling(); ",
1736     "\t}",
1737     "\t//GLib.debug(\"Rturning null\");",
1738     "     ",
1739     "}"
1740    ],
1741    "| void updateErrors" : [
1742     "() {",
1743     "\tvar file = this.getActiveFile();",
1744     "\tif (file == null) {",
1745     "\t\treturn;",
1746     "\t}",
1747     "\t",
1748     "\tvar ar = file.getErrors();",
1749     "\tif (ar == null || ar.size < 1) {",
1750     "\t\tif (this.last_error_counter != file.error_counter) {",
1751     "\t\t\tthis.removeErrors();",
1752     "\t\t}",
1753     "\t",
1754     "\t\tthis.last_error_counter = file.error_counter ;",
1755     "",
1756     "\t\treturn;",
1757     "\t}",
1758     " \tif (this.last_error_counter == file.error_counter) {",
1759     "\t\treturn;",
1760     "\t}",
1761     "\tthis.removeErrors();",
1762     "\t",
1763     "\tforeach(var diag in ar) { ",
1764     "\t",
1765     "\t\t ",
1766     "//        print(\"get inter\\n\");",
1767     "\t    var node= file.lineToNode( (int)diag.range.start.line) ;",
1768     "\t    if (node == null) {",
1769     "\t    \tcontinue;",
1770     "    \t}",
1771     "    \tvar row = _this.model.nodeToRow(node);",
1772     "    \tif (row < 0) {",
1773     "    \t\tcontinue;",
1774     "\t\t}",
1775     "    \tvar w = this.view.getWidgetAtRow(row);",
1776     "    \tif (w == null) {",
1777     "    \t\treturn;",
1778     "\t\t}",
1779     "\t\t// always show errors.",
1780     "\t\tvar ed = diag.category.down();",
1781     "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1782     "\t\t\tcontinue;",
1783     "\t\t}",
1784     "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1785     "\t\t\tw.remove_css_class(\"node-warn\");",
1786     "\t\t}",
1787     "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1788     "\t\t\tw.remove_css_class(\"node-depr\");",
1789     "\t\t}",
1790     "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1791     "\t\t\tw.add_css_class(\"node-\" + ed);",
1792     "\t\t}",
1793     "\t\t",
1794     "\t}",
1795     "\t",
1796     "}"
1797    ]
1798   }
1799  ],
1800  "name" : "WindowLeftTree"
1801 }