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