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