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