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