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