Fix #8099 - convert left tree to use get_data<> methods
[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_widget = _this.view.getRowWidgetAt(x,y, out pos );",
140            "    if (row_widget == null) {",
141            "\t    GLib.debug(\"no row selected items\");",
142            "\t    return;",
143            "    }",
144            "    ",
145            "    var node =   row_widget.get_data<JsRender.Node>(\"node\");",
146            "    if (node == null) {",
147            "    \tGLib.warning(\"No node found bound to widget\");",
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_widget = _this.view.getRowWidgetAt(x,y, out pos );",
202            "    if (row_widget == null) {",
203            "\t    GLib.debug(\"no row selected items\");",
204            "\t    return;",
205            "    }",
206            "    ",
207            "    var node =  row_widget.get_data<JsRender.Node>(\"node\");",
208            "    if (node == null) {",
209            "    \tGLib.warning(\"No node found from widget\");",
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 = data.get_data<Gtk.Widget>(\"tree-row\");",
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_widget = _this.view.getRowWidgetAt(x,y, out pos);",
580            "\tthis.addHighlight(null,\"\");",
581            " ",
582            " \tvar is_shift = _this.keystate.is_shift > 0;",
583            " ",
584            "",
585            " \t// -- get position..",
586            " \tif (this.lastDragString != v.get_string() || this.lastDragNode == null) {",
587            "\t\t// still dragging same node",
588            " ",
589            "\t\tthis.lastDragNode = new JsRender.Node(); ",
590            "\t\tthis.lastDragNode.loadFromJsonString(v.get_string(), 1);",
591            "\t}",
592            "    ",
593            " \t     ",
594            "       ",
595            "    var dropNode = new JsRender.Node(); ",
596            "\tdropNode.loadFromJsonString(v.get_string(), 2);",
597            "\tGLib.debug(\"dropped node %s\", dropNode.toJsonString());",
598            "\t",
599            "\t",
600            "\tvar drop_on_to = _this.main_window.windowstate.file.palete().getDropList(dropNode.fqn());",
601            "   ",
602            "    // if there are not items in the tree.. the we have to set isOver to true for anything..",
603            " ",
604            "    if (_this.model.el.n_items < 1) {",
605            "    \t// FIXME check valid drop types?",
606            "    \tif (!drop_on_to.contains(\"*top\")) {",
607            "\t\t\tGLib.debug(\"drop on to list does not contain top?\");",
608            "\t\t\treturn false;\t",
609            "\t\t}",
610            "\t\t// add new node to top..",
611            "\t\tGLib.debug(\"adding to top\");",
612            "\t\t",
613            "\t\t var m = (GLib.ListStore) _this.model.el.model;",
614            "     \t_this.main_window.windowstate.file.tree = dropNode;  ",
615            "    \tdropNode.updated_count++;",
616            "   ",
617            "\t\tm.append(dropNode);",
618            "\t\t_this.model.selectNode(dropNode); \t",
619            "\t\t_this.changed();",
620            "\t\t_this.node_selected(dropNode);",
621            "\t\treturn true; // no need to highlight?",
622            "     ",
623            "    }",
624            "",
625            "",
626            "",
627            "",
628            "\tif (row_widget == null) {",
629            "\t\tGLib.debug(\"could not get row %d,%d, %s\", (int)x,(int)y,pos);",
630            "\t\treturn   false; //Gdk.DragAction.COPY;",
631            "\t}",
632            " \t",
633            "\tvar node =  row_widget.get_data<JsRender.Node>(\"node\");",
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            " \t var row_widget = _this.view.getRowWidgetAt( x,y, out pos);    ",
793            "// \tvar row = _this.view.getRowAt(x,y, out pos);",
794            " \t//GLib.debug(\"check is over %d, %d, %s\", (int)x,(int)y, pos);",
795            "",
796            " \tif (row_widget == null) {",
797            "\t\tthis.addHighlight(null, \"\");\t",
798            "\t \treturn Gdk.DragAction.COPY;",
799            " \t}",
800            " \tvar node = row_widget.get_data<JsRender.Node>(\"node\");",
801            "\t",
802            "\t//GLib.debug(\"Drop over node: %s\", node.fqn());",
803            "\t",
804            "",
805            " \tif (pos == \"above\" || pos == \"below\") {",
806            "\t\tif (node.parent == null) {",
807            "\t\t\t//GLib.debug(\"no parent try center\");",
808            "\t\t\tpos = \"over\";",
809            "\t\t} else {",
810            "\t \t\t ",
811            "\t \t\tif (!drop_on_to.contains(node.parent.fqn())) {",
812            "\t\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.parent.fqn());",
813            "\t \t\t\tpos = \"over\";",
814            " \t\t\t} else {",
815            "\t\t\t\t//GLib.debug(\"drop  contains %s - using %s\" , node.parent.fqn(), pos);",
816            "\t\t\t\tif (_this.view.dragNode  != null && is_shift) {",
817            "\t\t \t\t\tif (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {",
818            "\t\t\t \t\t\tGLib.debug(\"shift drop not self not allowed\");",
819            "\t\t \t\t\t\tthis.addHighlight(null, \"\");",
820            "\t\t \t\t\t\treturn Gdk.DragAction.COPY;\t",
821            "\t\t \t\t\t}",
822            "\t\t \t\t\t",
823            "\t\t \t\t}",
824            "\t\t\t\t",
825            "\t\t\t}",
826            "\t\t\t",
827            "\t\t\t",
828            "\t\t\t",
829            " \t\t}",
830            " \t\t",
831            " \t\t",
832            " \t}",
833            " \tif (pos == \"over\") {",
834            "\t \tif (!drop_on_to.contains(node.fqn())) {",
835            "\t\t\t//GLib.debug(\"drop on does not contain %s - try center\" , node.fqn());",
836            "\t\t\tthis.addHighlight(null, \"\"); ",
837            "\t\t\treturn is_shift ?  Gdk.DragAction.MOVE :  Gdk.DragAction.COPY;\t\t",
838            "\t\t}",
839            "\t\tif (_this.view.dragNode  != null && is_shift) {",
840            " \t\t\tif (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {",
841            "\t \t\t\t//GLib.debug(\"shift drop not self not allowed\");",
842            " \t\t\t\tthis.addHighlight(null, \"\");",
843            " \t\t\t\treturn Gdk.DragAction.COPY;\t",
844            " \t\t\t}",
845            "\t\t}",
846            " \t\t\t",
847            "\t}",
848            " \t",
849            " \t",
850            " \t    // _this.view.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
851            "",
852            "\tthis.addHighlight(row_widget, pos); ",
853            "\treturn is_shift ?  Gdk.DragAction.MOVE :  Gdk.DragAction.COPY;\t\t",
854            "}"
855           ]
856          },
857          "string lastDragString" : "\"\"",
858          "xtype" : "DropTarget",
859          "| void addHighlight" : [
860           "(Gtk.Widget? w, string hl) {",
861           "\tif (this.highlightWidget != null) {",
862           "\t\tvar ww  = this.highlightWidget;",
863           "\t\t//GLib.debug(\"clear drag from previous highlight\");",
864           "\t\tif (ww.has_css_class(\"drag-below\")) {",
865           "\t\t\t ww.remove_css_class(\"drag-below\");",
866           "\t\t}",
867           "\t\tif (ww.has_css_class(\"drag-above\")) {",
868           "\t\t\t ww.remove_css_class(\"drag-above\");",
869           "\t\t}",
870           "\t\tif (ww.has_css_class(\"drag-over\")) {",
871           "\t\t\t ww.remove_css_class(\"drag-over\");",
872           "\t\t}",
873           "\t}",
874           "\tif (w != null) {",
875           "\t\t//GLib.debug(\"add drag=%s to widget\", hl);\t",
876           "\t\tif (!w.has_css_class(\"drag-\" + hl)) {",
877           "\t\t\tw.add_css_class(\"drag-\" + hl);",
878           "\t\t}",
879           "\t}",
880           "\tthis.highlightWidget = w;",
881           "}"
882          ]
883         },
884         {
885          "$ xns" : "Gtk",
886          "* prop" : "model",
887          "bool can_unselect" : true,
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             "    if (node.parent != null) {",
948             "\t\tnode.remove();",
949             "\t \tGLib.debug(\"delete Selected - done\");",
950             "\t\t_this.changed();",
951             "\t\treturn;",
952             "\t}",
953             "\tthis.updateModel(null);",
954             "\t_this.main_window.windowstate.file.tree = null;",
955             "\t_this.changed();",
956             "\t_this.node_selected(null);",
957             "/*    ",
958             "    print(\"DELETE SELECTED?\");",
959             "    //_this.view.blockChanges = true;",
960             "    print(\"GET SELECTION?\");",
961             "",
962             "    var s = _this.view.el.get_selection();",
963             "    ",
964             "    print(\"GET  SELECTED?\");",
965             "   Gtk.TreeIter iter;",
966             "    Gtk.TreeModel mod;",
967             "",
968             "    ",
969             "    if (!s.get_selected(out mod, out iter)) {",
970             "        return; // nothing seleted..",
971             "    }",
972             "      ",
973             "",
974             "",
975             "    this.activePath= \"\";      ",
976             "    print(\"GET  vnode value?\");",
977             "",
978             "    GLib.Value value;",
979             "    this.el.get_value(iter, 2, out value);",
980             "    var data = (JsRender.Node)(value.get_object());",
981             "    print(\"removing node from Render\\n\");",
982             "    if (data.parent == null) {",
983             "       _this.main_window.windowstate.file.tree = null;",
984             "    } else {",
985             "        data.remove();",
986             "    }",
987             "    print(\"removing node from Tree\\n\");    ",
988             "    s.unselect_all();",
989             "    this.el.remove(ref iter);",
990             "",
991             "    ",
992             "    ",
993             "    ",
994             "    // ",
995             "    ",
996             "    ",
997             "",
998             "",
999             "    this.activePath= \"\"; // again!?!?      ",
1000             "    //this.changed(null,true);",
1001             "    ",
1002             "    _this.changed();",
1003             "    ",
1004             "    _this.view.blockChanges = false;",
1005             "    */",
1006             "}",
1007             ""
1008            ],
1009            "| void loadFile" : [
1010             "(JsRender.JsRender f) {",
1011             "    //console.dump(f);",
1012             "    ",
1013             "    _this.drop.highlightWidget = null;",
1014             "    ",
1015             "    var m = (GLib.ListStore) this.el.model;",
1016             "\tm.remove_all();",
1017             "    _this.main_window.windowstate.leftTreeNodeSelected(null);",
1018             "    // needed???",
1019             "    _this.main_window.windowstate.file = f;",
1020             "    _this.last_error_counter = -1;",
1021             "   ",
1022             "    if (f.tree == null) {",
1023             "\t    try {",
1024             "\t        f.loadItems( );",
1025             "        } catch (Error e) {",
1026             "    \t\treturn;",
1027             "        }",
1028             "    }",
1029             "    // if it's still null?",
1030             "    if (f.tree == null) {",
1031             "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);",
1032             "    \t_this.updateErrors();",
1033             "        return;",
1034             "    }",
1035             "  \tm.append(f.tree);",
1036             "\t_this.updateErrors();",
1037             " ",
1038             "    _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
1039             "   ",
1040             "    return;",
1041             " ",
1042             "            ",
1043             "}",
1044             ""
1045            ],
1046            "| void selectNode" : [
1047             "(JsRender.Node?  node) ",
1048             "{",
1049             "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
1050             "\tif (node == null) {",
1051             "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1052             "\t\treturn;",
1053             "\t}",
1054             "\tvar row = this.nodeToRow(node);",
1055             "",
1056             "\t ",
1057             "\tif (row < 0) {",
1058             "\t\t// select none?",
1059             "\t\tGLib.debug(\"Could not find node\");",
1060             "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
1061             "\t\treturn;",
1062             "\t}",
1063             "\tGLib.debug(\"Select %d\", row);",
1064             "\ts.set_selected(row);",
1065             "\t_this.view.el.scroll_to(row, null, Gtk.ListScrollFlags.SELECT, null);",
1066             "\t//_this.node_selected(node);\t\t\t",
1067             "\t",
1068             "",
1069             "}"
1070            ]
1071           }
1072          ],
1073          "listeners" : {
1074           "selection_changed" : [
1075            "(position, n_items) => {",
1076            "",
1077            "\t",
1078            "\t\t",
1079            "\t\t//if (!this.button_is_pressed && !this.key_is_pressed) {",
1080            "\t\t\t// then event was started by some other action",
1081            "\t\t\t// which should manually trigger all the events..",
1082            "\t\t//\tprint(\"SKIPPING select - no button or key pressed\\n\");",
1083            "\t\t//\treturn;",
1084            "\t\t//}",
1085            "",
1086            "",
1087            "\t\t if (_this.view.blockChanges) { // probably not needed.. ",
1088            "\t\t\tGLib.debug(\"SKIPPING select - blockchanges set..\");     ",
1089            "\t\t   return  ;",
1090            "\t\t }",
1091            "",
1092            "\t\t  if (!_this.before_node_change( ) ) {",
1093            "\t\t\t _this.view.blockChanges = true;",
1094            "\t\t\t _this.selmodel.el.unselect_all();",
1095            "\t\t\t _this.view.blockChanges = false;",
1096            "\t\t\t ",
1097            "\t\t\t return;",
1098            "\t\t }",
1099            "\t\t if (_this.main_window.windowstate.file == null) {",
1100            "\t   \t\tGLib.debug(\"SKIPPING select windowstate file is not set...\");     ",
1101            "\t\t\treturn;",
1102            "\t\t } ",
1103            "\t\t ",
1104            "\t\t //var render = this.get('/LeftTree').getRenderer();                ",
1105            "\t\tGLib.debug(\"LEFT TREE -> view -> selection changed called\");",
1106            "\t\t",
1107            "\t\t",
1108            "\t\t// -- it appears that the selection is not updated.",
1109            "\t\t // select the node...",
1110            "\t\t //_this.selmodel.el.set_selected(row);",
1111            " ",
1112            "\t\t GLib.debug(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\");",
1113            "",
1114            "\t    var snode = _this.selmodel.getSelectedNode();",
1115            "\t    if (snode == null) {",
1116            "",
1117            "\t         GLib.debug(\"selected rows < 1\");",
1118            "\t        //??this.model.load( false);",
1119            "\t        _this.node_selected(null);",
1120            "\t        ",
1121            "\t        return   ;",
1122            "\t    }",
1123            "\t ",
1124            "\t    // why dup_?",
1125            "\t    ",
1126            "",
1127            "\t    GLib.debug (\"calling left_tree.node_selected %s\", snode.toJsonString());",
1128            "\t    _this.node_selected(snode);",
1129            "\t   ",
1130            "\t     ",
1131            "\t    ",
1132            "\t     ",
1133            "\t    // no need to scroll. it's in the view as we clicked on it.",
1134            "\t   // _this.view.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
1135            "\t    ",
1136            "\t    return  ;",
1137            "}",
1138            ""
1139           ]
1140          },
1141          "xtype" : "SingleSelection",
1142          "| JsRender.Node getNodeAt" : [
1143           "(uint row) {",
1144           "",
1145           "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1146           "   ",
1147           "   var a = tr.get_item();;   ",
1148           "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1149           "  \t",
1150           "   ",
1151           "   return (JsRender.Node)tr.get_item();",
1152           "\t ",
1153           "}"
1154          ],
1155          "| JsRender.Node? getSelectedNode" : [
1156           "() {",
1157           "  if (this.el.selected_item == null) {",
1158           "\t\treturn null;",
1159           "  }\t",
1160           "   ",
1161           "  ",
1162           "   var tr = (Gtk.TreeListRow)this.el.selected_item;",
1163           "  ",
1164           "   return (JsRender.Node)tr.get_item();",
1165           "\t ",
1166           "}"
1167          ]
1168         },
1169         {
1170          "$ xns" : "Gtk",
1171          "* pack" : "append_column",
1172          "bool expand" : true,
1173          "bool resizable" : true,
1174          "id" : "maincol",
1175          "items" : [
1176           {
1177            "$ xns" : "Gtk",
1178            "* prop" : "factory",
1179            "listeners" : {
1180             "bind" : [
1181              "(listitem) => {",
1182              "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
1183              "\t",
1184              "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
1185              "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
1186              "\t ",
1187              "\t ",
1188              "\tvar hbox = (Gtk.Box) expand.child;",
1189              " ",
1190              "\t",
1191              "\tvar img = (Gtk.Image) hbox.get_first_child();",
1192              "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
1193              "\t",
1194              "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1195              "\tvar node = (JsRender.Node) lr.get_item();",
1196              "\tif (node == null || node.fqn() == \"\") {",
1197              "\t\treturn;",
1198              "\t}",
1199              "\t",
1200              "\tnode.set_data<Gtk.Widget>(\"tree-row\", expand.get_parent().get_parent());",
1201              "\texpand.get_parent().get_parent().set_data<JsRender.Node>(\"node\", node);",
1202              "\t",
1203              "   //GLib.debug(\"node is %s\", node.get_type().name());",
1204              "// was item (1) in old layout",
1205              "",
1206              "\t",
1207              " ",
1208              " \t /* ",
1209              " \tvar ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1210              "    var clsname = node.fqn();",
1211              "    ",
1212              "    var clsb = clsname.split(\".\");",
1213              "    var sub = clsb.length > 1 ? clsb[1].down()  : \"\";",
1214              "     ",
1215              "    var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
1216              "    try { ",
1217              "    \t ",
1218              "    \t\t ",
1219              "\t\tif (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
1220              "\t\t    img.set_from_file(fn);",
1221              "\t\t \t ",
1222              "\t \t} else {",
1223              "\t \t\timg.set_from_paintable(",
1224              "\t\t\t \tic.lookup_icon (",
1225              "\t\t\t \t\t\"media-playback-stop\", null,  16,1, ",
1226              "\t    \t\t\t Gtk.TextDirection.NONE, 0",
1227              "    \t\t\t)",
1228              "\t\t\t );",
1229              "\t \t}",
1230              " \t} catch (GLib.Error e) {}",
1231              "    */",
1232              "    expand.set_hide_expander( !node.hasChildren() );",
1233              " \texpand.set_list_row(lr);",
1234              " \t",
1235              " \tnode.bind_property(\"iconResourceName\",",
1236              "                    img, \"resource\",",
1237              "                   GLib.BindingFlags.SYNC_CREATE);",
1238              " \t",
1239              " \tnode.bind_property(\"nodeTitleProp\",",
1240              "                    lbl, \"label\",",
1241              "                   GLib.BindingFlags.SYNC_CREATE);",
1242              " \tnode.bind_property(\"nodeTipProp\",",
1243              "                    lbl, \"tooltip_markup\",",
1244              "                   GLib.BindingFlags.SYNC_CREATE);",
1245              " \t// bind image...",
1246              " \t",
1247              "}",
1248              ""
1249             ],
1250             "setup" : [
1251              "(listitem) => {",
1252              "\t",
1253              "\tvar expand = new Gtk.TreeExpander();",
1254              "\t ",
1255              "\texpand.set_indent_for_depth(true);",
1256              "\texpand.set_indent_for_icon(true);",
1257              "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1258              "\tvar icon = new Gtk.Image();",
1259              "\tvar lbl = new Gtk.Label(\"\");",
1260              "\tlbl.use_markup = true;",
1261              "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1262              "\t",
1263              "\ticon.margin_end = 4;",
1264              " \tlbl.justify = Gtk.Justification.LEFT;",
1265              " \tlbl.xalign = 0;",
1266              "",
1267              "//\tlistitem.activatable = true; ??",
1268              "\t",
1269              "\thbox.append(icon);",
1270              "\thbox.append(lbl);",
1271              "\texpand.set_child(hbox);",
1272              "\t((Gtk.ListItem)listitem).set_child(expand);",
1273              "\t",
1274              "}",
1275              ""
1276             ]
1277            },
1278            "xtype" : "SignalListItemFactory"
1279           }
1280          ],
1281          "title" : "Property",
1282          "xtype" : "ColumnViewColumn"
1283         },
1284         {
1285          "$ xns" : "Gtk",
1286          "* pack" : "append_column",
1287          "int fixed_width" : 25,
1288          "items" : [
1289           {
1290            "$ xns" : "Gtk",
1291            "* prop" : "factory",
1292            "listeners" : {
1293             "bind" : [
1294              "(listitem) => {",
1295              "",
1296              " \tvar img = (Gtk.Image) ((Gtk.ListItem)listitem).get_child(); ",
1297              " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
1298              "\tvar node = (JsRender.Node) lr.get_item();",
1299              "\t",
1300              "  ",
1301              "    var ic = Gtk.IconTheme.get_for_display(_this.el.get_display());",
1302              "\timg.set_from_paintable(",
1303              "\t \tic.lookup_icon (",
1304              "\t \t\t\"list-add\", null,  16,1, ",
1305              "\t\t\t Gtk.TextDirection.NONE, 0",
1306              "\t\t)",
1307              "\t );",
1308              "\t ",
1309              " \tvar fqn = node.fqn();",
1310              "    var cn = _this.main_window.windowstate.project.palete.getChildList(fqn, false);",
1311              "",
1312              "\timg.set_visible(cn.size > 0 ? true : false);",
1313              " \t ",
1314              "}",
1315              ""
1316             ],
1317             "setup" : [
1318              "(listitem) => {",
1319              "",
1320              "\t ",
1321              "\tvar icon = new Gtk.Image();",
1322              "\t ",
1323              "\t((Gtk.ListItem)listitem).set_child(icon);",
1324              "}",
1325              ""
1326             ]
1327            },
1328            "xtype" : "SignalListItemFactory"
1329           }
1330          ],
1331          "string title" : "Add",
1332          "xtype" : "ColumnViewColumn"
1333         }
1334        ],
1335        "string name" : "left-tree-view",
1336        "xtype" : "ColumnView",
1337        "| Gtk.Widget? getRowWidgetAt" : [
1338         "(double x,  double  y, out string pos) {",
1339         "",
1340         "\tpos = \"\";",
1341         "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1342         "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1343         "\tif (w == null) {",
1344         "\t\treturn null;",
1345         "\t}",
1346         "\t",
1347         "\tvar row = w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1348         "\tif (row == null) {",
1349         "\t\treturn null;",
1350         "\t}",
1351         "\t",
1352         "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1353         "\t ",
1354         "\t",
1355         "\t",
1356         "\t//GLib.debug(\"row number is %d\", rn);",
1357         "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1358         "\t// above or belw",
1359         "\tGraphene.Rect  bounds;",
1360         "\trow.compute_bounds(this.el, out bounds);",
1361         "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1362         "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1363         "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1364         "\t//\t);",
1365         "\tvar ypos = y - bounds.get_y();",
1366         "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1367         "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1368         "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1369         "\tpos = \"over\";",
1370         "\t",
1371         "\tif (rpos > 80) {",
1372         "\t\tpos = \"below\";",
1373         "\t} else if (rpos < 20) {",
1374         "\t\tpos = \"above\";",
1375         "\t} ",
1376         "\treturn row;",
1377         " }"
1378        ],
1379        "| Gtk.Widget? getWidgetAtRowBROKE" : [
1380         "(uint row) {",
1381         "/*",
1382         "    \t",
1383         "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1384         "    \tvar colview = gesture.widget;",
1385         "    \tvar line_no = check_list_widget(colview, x,y);",
1386         "         if (line_no > -1) {",
1387         "    \t\tvar item = colview.model.get_item(line_no);",
1388         "    \t\t ",
1389         "    \t}",
1390         "    \t*/",
1391         "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1392         "        var  child = this.el.get_first_child(); ",
1393         "    \tvar line_no = -1; ",
1394         "    \tvar reading_header = true;",
1395         "\t ",
1396         "    \twhile (child != null) {",
1397         "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1398         "    \t   ",
1399         "    \t   if (reading_header) {",
1400         "\t\t\t\t",
1401         "",
1402         "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1403         "\t\t\t\t   ",
1404         "\t\t\t\t\tchild = child.get_next_sibling();",
1405         "\t\t\t\t\tcontinue;",
1406         "\t\t\t\t}",
1407         "\t\t\t\t// should be columnlistview",
1408         "\t\t\t\tchild = child.get_first_child(); ",
1409         "\t\t\t ",
1410         "\t\t\t ",
1411         "\t\t\t\t",
1412         "\t\t\t\treading_header = false;",
1413         "\t\t\t\tcontinue;",
1414         "\t\t    }",
1415         "\t\t    ",
1416         "\t\t  ",
1417         "    \t    ",
1418         "\t\t    line_no++;",
1419         "\t\t\tif (line_no == row) {",
1420         "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1421         "\t\t\t    return (Gtk.Widget)child;",
1422         "\t\t    }",
1423         "\t        child = child.get_next_sibling(); ",
1424         "    \t}",
1425         "\t\t//GLib.debug(\"Rturning null\");",
1426         "        return null;",
1427         "",
1428         " }"
1429        ],
1430        "| int getColAt" : [
1431         "(double x,  double y) {",
1432         "\t/*",
1433         "\t\t\t",
1434         "\tfrom    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1435         "    \t  ",
1436         "\t*/",
1437         "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
1438         "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
1439         "    var  child = this.el.get_first_child(); ",
1440         "\t ",
1441         "\tvar col = 0;",
1442         "\tvar offx = 0;",
1443         "\twhile (child != null) {",
1444         "\t\t",
1445         "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
1446         "\t\t\tchild = child.get_first_child();",
1447         "\t\t\tcontinue;",
1448         "\t\t}",
1449         "\t\t",
1450         "\t\t//child.get_allocation(out alloc);",
1451         "\t\tif (x <  (child.get_width() + offx)) {",
1452         "\t\t\treturn col;",
1453         "\t\t}",
1454         "\t\treturn 1;",
1455         "\t\t//offx += child.get_width();",
1456         "\t\t//col++;",
1457         "\t\t//child = child.get_next_sibling();",
1458         "\t}",
1459         "\t     ",
1460         "\t\t  ",
1461         "    return -1;",
1462         "",
1463         " }"
1464        ],
1465        "| int getRowAtOLD" : [
1466         "(double x,  double  y, out string pos) {",
1467         "",
1468         "\tpos = \"\";",
1469         "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1470         "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1471         "\tif (w == null) {",
1472         "\t\treturn -1;",
1473         "\t}",
1474         "\t",
1475         "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1476         "\tif (row == null) {",
1477         "\t\treturn -1;",
1478         "\t}",
1479         "\t",
1480         "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1481         "\t ",
1482         "\tvar rn = 0;",
1483         "\tvar cr = row;",
1484         "\t ",
1485         "\twhile (cr.get_prev_sibling() != null) {",
1486         "\t\trn++;",
1487         "\t\tcr = cr.get_prev_sibling();",
1488         "\t}",
1489         "\t",
1490         "\t//GLib.debug(\"row number is %d\", rn);",
1491         "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1492         "\t// above or belw",
1493         "\tGraphene.Rect  bounds;",
1494         "\trow.compute_bounds(this.el, out bounds);",
1495         "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1496         "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1497         "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1498         "\t//\t);",
1499         "\tvar ypos = y - bounds.get_y();",
1500         "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1501         "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1502         "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1503         "\tpos = \"over\";",
1504         "\t",
1505         "\tif (rpos > 80) {",
1506         "\t\tpos = \"below\";",
1507         "\t} else if (rpos < 20) {",
1508         "\t\tpos = \"above\";",
1509         "\t} ",
1510         "\treturn rn;",
1511         " }"
1512        ]
1513       },
1514       {
1515        "$ xns" : "Gtk",
1516        "* pack" : false,
1517        "id" : "LeftTreeMenu",
1518        "items" : [
1519         {
1520          "$ xns" : "Gtk",
1521          "* prop" : "child",
1522          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1523          "int spacing" : 0,
1524          "items" : [
1525           {
1526            "$ xns" : "Gtk",
1527            "bool has_frame" : false,
1528            "label" : "Delete Element",
1529            "listeners" : {
1530             "clicked" : [
1531              " ( ) => {",
1532              "_this.LeftTreeMenu.el.hide();",
1533              " _this.model.deleteSelected();",
1534              "_this.changed();",
1535              "}"
1536             ]
1537            },
1538            "xtype" : "Button"
1539           },
1540           {
1541            "$ xns" : "Gtk",
1542            "bool has_frame" : false,
1543            "label" : "Save as Template",
1544            "listeners" : {
1545             "clicked" : [
1546              "  () => {",
1547              "_this.LeftTreeMenu.el.hide();",
1548              "     DialogSaveTemplate.singleton().showIt(",
1549              "            (Gtk.Window) _this.el.get_root (), ",
1550              "            _this.main_window.windowstate.file.palete(), ",
1551              "            _this.getActiveElement()",
1552              "    );",
1553              "     ",
1554              "    ",
1555              "}"
1556             ]
1557            },
1558            "xtype" : "Button"
1559           },
1560           {
1561            "$ xns" : "Gtk",
1562            "bool has_frame" : false,
1563            "label" : "Save as Module",
1564            "listeners" : {
1565             "clicked" : [
1566              "  () => {",
1567              "    ",
1568              "    _this.LeftTreeMenu.el.hide();",
1569              "    var node = _this.getActiveElement();",
1570              "      ",
1571              "     ",
1572              "     var sm = DialogSaveModule.singleton();",
1573              "     ",
1574              "     ",
1575              "    sm.showIt(",
1576              "            (Gtk.Window) _this.el.get_root (), ",
1577              "            _this.main_window.windowstate.project, ",
1578              "            node",
1579              "     );",
1580              "     /*",
1581              "     gtk4 migration - disabled this part.. probably not used muchanyway",
1582              "     ",
1583              "     ",
1584              "     if (name.length < 1) {",
1585              "            return;",
1586              "  ",
1587              "     }",
1588              "     node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1589              "     node.items.clear();",
1590              "",
1591              "",
1592              "    var s = _this.view.el.get_selection();",
1593              "    ",
1594              "    print(\"GET  SELECTED?\");",
1595              "    Gtk.TreeIter iter;",
1596              "    Gtk.TreeModel mod;",
1597              "",
1598              "    ",
1599              "    if (!s.get_selected(out mod, out iter)) {",
1600              "        return; // nothing seleted..",
1601              "    }",
1602              "    Gtk.TreeIter citer;",
1603              "    var n_cn = mod.iter_n_children(iter) -1;",
1604              "    for (var i = n_cn; i > -1; i--) {",
1605              "        mod.iter_nth_child(out citer, iter, i);",
1606              "        ",
1607              "",
1608              "        print(\"removing node from Tree\\n\");    ",
1609              "    ",
1610              "        _this.model.el.remove(ref citer);",
1611              "    }",
1612              "    _this.changed();",
1613              "    _this.node_selected(node, \"tree\");",
1614              "     */",
1615              "    ",
1616              "}"
1617             ]
1618            },
1619            "xtype" : "Button"
1620           }
1621          ],
1622          "xtype" : "Box"
1623         }
1624        ],
1625        "xtype" : "Popover"
1626       }
1627      ],
1628      "xtype" : "ScrolledWindow"
1629     }
1630    ],
1631    "xtype" : "Box",
1632    "| JsRender.JsRender getActiveFile" : [
1633     "() {",
1634     "    return this.main_window.windowstate.file;",
1635     "    ",
1636     "}",
1637     ""
1638    ],
1639    "| JsRender.Node? getActiveElement" : [
1640     " () { // return path to actie node.",
1641     "",
1642     "     ",
1643     "\treturn _this.selmodel.getSelectedNode();",
1644     "    ",
1645     "    ",
1646     "}",
1647     ""
1648    ],
1649    "| void onresize" : [
1650     "() {",
1651     " ",
1652     "\t ",
1653     "\t//GLib.debug(\"Got allocation width of scrolled view %d\", allocation.width );",
1654     "//\t_this.maincol.el.set_max_width( _this.viewwin.el.get_width()  - 32 );",
1655     "}",
1656     "",
1657     ""
1658    ],
1659    "| void removeErrors" : [
1660     "() {",
1661     "\tif (this.error_widgets == null || this.error_widgets.size < 1) {",
1662     " \t\treturn;",
1663     "\t}",
1664     "\tforeach(var child in this.error_widgets) {",
1665     "\t",
1666     "\t\tif (child.has_css_class(\"node-err\")) {",
1667     "\t\t\tchild.remove_css_class(\"node-err\");",
1668     "\t\t}",
1669     "\t\tif (child.has_css_class(\"node-warn\")) {",
1670     "\t\t\tchild.remove_css_class(\"node-warn\");",
1671     "\t\t}",
1672     "\t\t",
1673     "\t\tif (child.has_css_class(\"node-depr\")) {",
1674     "\t\t\tchild.remove_css_class(\"node-depr\");",
1675     "\t\t}",
1676     "\t}",
1677     "\tthis.error_widgets  = null;",
1678     "\treturn;",
1679     "\t",
1680     "\t/*",
1681     "\tvar  child = this.view.el.get_first_child(); ",
1682     " ",
1683     "\tvar reading_header = true;",
1684     " ",
1685     "\twhile (child != null) {",
1686     "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1687     "\t   ",
1688     "\t   if (reading_header) {",
1689     "\t\t\t",
1690     "",
1691     "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1692     "\t\t\t   ",
1693     "\t\t\t\tchild = child.get_next_sibling();",
1694     "\t\t\t\tcontinue;",
1695     "\t\t\t}",
1696     "\t\t\t// should be columnlistview",
1697     "\t\t\tchild = child.get_first_child(); ",
1698     "\t\t ",
1699     "\t\t ",
1700     "\t\t\t",
1701     "\t\t\treading_header = false;",
1702     "\t\t\t continue;",
1703     "\t    }",
1704     "\t    ",
1705     "\t  \tif (child.has_css_class(\"node-err\")) {",
1706     "\t\t\tchild.remove_css_class(\"node-err\");",
1707     "\t\t}",
1708     "\t\tif (child.has_css_class(\"node-warn\")) {",
1709     "\t\t\tchild.remove_css_class(\"node-warn\");",
1710     "\t\t}",
1711     "\t\t",
1712     "\t\tif (child.has_css_class(\"node-depr\")) {",
1713     "\t\t\tchild.remove_css_class(\"node-depr\");",
1714     "\t\t}",
1715     "\t\t",
1716     "        child = child.get_next_sibling(); ",
1717     "\t}",
1718     "\t//GLib.debug(\"Rturning null\");",
1719     "\t*/",
1720     "     ",
1721     "}"
1722    ],
1723    "| void updateErrors" : [
1724     "() {",
1725     "\tvar file = this.getActiveFile();",
1726     "\tif (file == null) {",
1727     "\t\treturn;",
1728     "\t}",
1729     "\t",
1730     "\tvar ar = file.getErrors();",
1731     "\tif (ar == null || ar.size < 1) {",
1732     "\t\tif (this.last_error_counter != file.error_counter) {",
1733     "\t\t\tthis.removeErrors();",
1734     "\t\t}",
1735     "\t",
1736     "\t\tthis.last_error_counter = file.error_counter ;",
1737     "",
1738     "\t\treturn;",
1739     "\t}",
1740     " \tif (this.last_error_counter == file.error_counter) {",
1741     "\t\treturn;",
1742     "\t}",
1743     "\tthis.removeErrors();",
1744     "\tthis.error_widgets = new Gee.ArrayList<Gtk.Widget>();",
1745     "\tforeach(var diag in ar) { ",
1746     "\t ",
1747     "//        print(\"get inter\\n\");",
1748     "\t    var node= file.lineToNode( (int)diag.range.start.line) ;",
1749     "\t    if (node == null) {",
1750     "\t    \tcontinue;",
1751     "    \t}",
1752     "    \tvar w = node.get_data<Gtk.Widget>(\"tree-row\");",
1753     "    \tif (w == null) {",
1754     "    \t\treturn;",
1755     "\t\t}",
1756     "\t\tthis.error_widgets.add(w);",
1757     "\t\t// always show errors.",
1758     "\t\tvar ed = diag.category.down();",
1759     "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
1760     "\t\t\tcontinue;",
1761     "\t\t}",
1762     "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
1763     "\t\t\tw.remove_css_class(\"node-warn\");",
1764     "\t\t}",
1765     "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
1766     "\t\t\tw.remove_css_class(\"node-depr\");",
1767     "\t\t}",
1768     "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
1769     "\t\t\tw.add_css_class(\"node-\" + ed);",
1770     "\t\t}",
1771     "\t\t",
1772     "\t}",
1773     "\t",
1774     "}"
1775    ]
1776   }
1777  ],
1778  "name" : "WindowLeftTree"
1779 }