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