fix last merge - highlight support
[roobuilder] / src / Builder4 / WindowLeftProps.vala
1 static Xcls_LeftProps  _LeftProps;
2
3 public class Xcls_LeftProps : Object
4 {
5         public Gtk.Box el;
6         private Xcls_LeftProps  _this;
7
8         public static Xcls_LeftProps singleton()
9         {
10                 if (_LeftProps == null) {
11                     _LeftProps= new Xcls_LeftProps();
12                 }
13                 return _LeftProps;
14         }
15         public Xcls_AddPropertyPopup AddPropertyPopup;
16         public Xcls_EditProps EditProps;
17         public Xcls_view view;
18         public Xcls_deletemenu deletemenu;
19         public Xcls_selmodel selmodel;
20         public Xcls_model model;
21         public Xcls_keycol keycol;
22         public Xcls_valcol valcol;
23         public Xcls_ContextMenu ContextMenu;
24
25                 // my vars (def)
26         public bool loading;
27         public bool allow_edit;
28         public signal void show_add_props (string type);
29         public signal bool stop_editor ();
30         public Xcls_MainWindow main_window;
31         public int last_error_counter;
32         public signal void changed ();
33         public JsRender.JsRender file;
34         public JsRender.Node node;
35         public signal void show_editor (JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop);
36
37         // ctor
38         public Xcls_LeftProps()
39         {
40                 _this = this;
41                 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
42
43                 // my vars (dec)
44                 this.loading = false;
45                 this.allow_edit = false;
46                 this.main_window = null;
47                 this.last_error_counter = -1;
48
49                 // set gobject values
50                 this.el.homogeneous = false   ;
51                 this.el.hexpand = true;
52                 this.el.vexpand = true;
53                 var child_1 = new Xcls_Box2( _this );
54                 child_1.ref();
55                 this.el.append( child_1.el );
56                 new Xcls_EditProps( _this );
57                 this.el.append( _this.EditProps.el );
58         }
59
60         // user defined functions
61         public string keySortFormat (string key) {
62             // listeners first - with 0
63             // specials
64             if (key[0] == '*') {
65                 return "1 " + key;
66             }
67             // functions
68             
69             var bits = key.split(" ");
70             
71             if (key[0] == '|') {
72                 return "2 " + bits[bits.length -1];
73             }
74             // signals
75             if (key[0] == '@') {
76                 return "3 " + bits[bits.length -1];
77             }
78                 
79             // props
80             if (key[0] == '#') {
81                 return "4 " + bits[bits.length -1];
82             }
83             // the rest..
84             return "5 " + bits[bits.length -1];    
85         
86         
87         
88         }
89         public void updateErrors () {
90                 var file = this.file;
91                 var ar = file.getErrors();
92                 if (ar.size < 1) {
93                         this.removeErrors();
94                         this.last_error_counter = file.error_counter ;
95         
96                         return;
97                 }
98                 if (this.last_error_counter == file.error_counter) {
99                         return;
100                 }
101                 this.removeErrors();
102                 
103                 foreach(var diag in ar) { 
104                 
105                          
106         //        print("get inter\n");
107                     var node= file.lineToNode( (int)diag.range.start.line) ;
108                     if (node == null || node.oid != this.node.oid) {
109                         continue;
110                 }
111                 var prop = node.lineToProp( (int)diag.range.start.line) ;
112                 
113                 var row = _this.selmodel.propToRow(prop);
114                 if (row < 0) {
115                         continue;
116                         }
117                 var w = this.view.getWidgetAtRow(row);
118                 if (w == null) {
119                         return;
120                         }
121                                 var ed = diag.category.down();
122                         if (ed != "err" && w.has_css_class("node-err")) {
123                                 continue;
124                         }
125                         if (ed == "err" && w.has_css_class("node-warn")) {
126                                 w.remove_css_class("node-warn");
127                         }
128                         if (ed == "err" && w.has_css_class("node-depr")) {
129                                 w.remove_css_class("node-depr");
130                         }
131                         if (!w.has_css_class("node-"+ ed)) {
132                                 w.add_css_class("node-" + ed);
133                         }
134                         
135                 }
136                 
137         }
138         public string keyFormat (string val, string type) {
139             
140             // Glib.markup_escape_text(val);
141         
142             if (type == "listener") {
143                 return "<span font_weight=\"bold\" color=\"#660000\">" + 
144                     GLib.Markup.escape_text(val) +
145                      "</span>";
146             }
147             // property..
148             if (val.length < 1) {
149                 return "<span  color=\"#FF0000\">--empty--</span>";
150             }
151             
152             //@ = signal
153             //$ = property with 
154             //# - object properties
155             //* = special
156             // all of these... - display value is last element..
157             var ar = val.strip().split(" ");
158             
159             
160             var dval = GLib.Markup.escape_text(ar[ar.length-1]);
161             
162             
163             
164             
165             switch(val[0]) {
166                 case '@': // signal // just bold balck?
167                     if (dval[0] == '@') {
168                         dval = dval.substring(1);
169                     }
170                 
171                     return @"<span  font_weight=\"bold\">@ $dval</span>";        
172                 case '#': // object properties?
173                     if (dval[0] == '#') {
174                         dval = dval.substring(1);
175                     }
176                     return @"<span  font_weight=\"bold\">$dval</span>";
177                 case '*': // special
178                     if (dval[0] == '*') {
179                         dval = dval.substring(1);
180                     }
181                     return @"<span   color=\"#0000CC\" font_weight=\"bold\">$dval</span>";            
182                 case '$':
183                     if (dval[0] == '$') {
184                         dval = dval.substring(1);
185                     }
186                     return @"<span   style=\"italic\">$dval</span>";
187                case '|': // user defined methods
188                     if (dval[0] == '|') {
189                         dval = dval.substring(1);
190                     }
191                     return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
192                     
193                       
194                     
195                 default:
196                     return dval;
197             }
198               
199             
200         
201         }
202         public void deleteSelected () {
203             
204                         return;
205                         /*
206                 
207                 Gtk.TreeIter iter;
208                 Gtk.TreeModel mod;
209                 
210                 var s = this.view.el.get_selection();
211                 s.get_selected(out mod, out iter);
212                      
213                       
214                 GLib.Value gval;
215                 mod.get_value(iter, 0 , out gval);
216                 var prop = (JsRender.NodeProp)gval;
217                 if (prop == null) {
218                         this.load(this.file, this.node);    
219                         return;
220                 }
221                 // stop editor after fetching property - otherwise prop is null.
222                 this.stop_editor();
223                 
224                         
225                 switch(prop.ptype) {
226                     case JsRender.NodePropType.LISTENER:
227                         this.node.listeners.unset(prop.to_index_key());
228                         break;
229                         
230                     default:
231                         this.node.props.unset(prop.to_index_key());
232                         break;
233                 }
234                 this.load(this.file, this.node);
235                 
236                 _this.changed();
237                 */
238         }
239         public void removeErrors () {
240                 var  child = this.view.el.get_first_child(); 
241          
242                 var reading_header = true;
243          
244                 while (child != null) {
245                         GLib.debug("Got %s", child.get_type().name());
246                    
247                    if (reading_header) {
248                                 
249         
250                                 if (child.get_type().name() != "GtkColumnListView") {
251                                    
252                                         child = child.get_next_sibling();
253                                         continue;
254                                 }
255                                 // should be columnlistview
256                                 child = child.get_first_child(); 
257                          
258                          
259                                 
260                                 reading_header = false;
261                                  
262                     }
263                     
264                         if (!child.has_css_class("node-err")) {
265                                 child.remove_css_class("node-err");
266                         }
267                         if (!child.has_css_class("node-warn")) {
268                                 child.remove_css_class("node-warn");
269                         }
270                         
271                         if (!child.has_css_class("node-depr")) {
272                                 child.remove_css_class("node-depr");
273                         }
274                         
275                 child = child.get_next_sibling(); 
276                 }
277                 //GLib.debug("Rturning null");
278              
279         }
280         public void a_addProp (JsRender.NodeProp prop) {
281               // info includes key, val, skel, etype..
282               //console.dump(info);
283                 //type = info.type.toLowerCase();
284                 //var data = this.toJS();
285                   
286                       
287             if (prop.ptype == JsRender.NodePropType.LISTENER) {
288                 if (this.node.listeners.has_key(prop.name)) {
289                     return;
290                 }
291                 this.node.listeners.set(prop.name,prop);
292             } else  {
293                  assert(this.node != null);
294                  assert(this.node.props != null);
295                 if (this.node.props.has_key(prop.to_index_key())) {
296                     return;
297                 }
298                 this.node.props.set(prop.to_index_key(),prop);
299             }
300                     
301               
302             // add a row???
303             this.load(this.file, this.node);
304             
305             
306              
307             
308             GLib.debug("trying to find new iter");
309          
310             
311                       
312         }
313         public void load (JsRender.JsRender file, JsRender.Node? node) 
314         {
315                 // not sure when to initialize this - we should do it on setting main window really.    
316                 
317                 this.loading = true;
318             if (this.view.popover == null) {
319                            this.view.popover = new Xcls_PopoverProperty();
320                            this.view.popover.mainwindow = _this.main_window;
321                 }
322             
323             
324             if (this.node != null) {
325                 this.node.dupeProps(); // ensures removeall will not do somethign silly
326                 
327             }
328             
329             GLib.debug("load leftprops\n");
330         
331             this.node = node;
332             this.file = file;
333             
334          
335             this.model.el.remove_all();
336                       
337             //this.get('/RightEditor').el.hide();
338             if (node ==null) {
339                 return ;
340             }
341             node.loadProps(this.model.el); 
342             
343             
344            //GLib.debug("clear selection\n");
345            
346                 this.loading = false;
347             this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
348             this.updateErrors();
349            // clear selection?
350           //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
351            
352            // this.view.el.get_selection().unselect_all();
353            
354           // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
355           // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
356            
357         }
358         public class Xcls_Box2 : Object
359         {
360                 public Gtk.Box el;
361                 private Xcls_LeftProps  _this;
362
363
364                         // my vars (def)
365
366                 // ctor
367                 public Xcls_Box2(Xcls_LeftProps _owner )
368                 {
369                         _this = _owner;
370                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
371
372                         // my vars (dec)
373
374                         // set gobject values
375                         this.el.hexpand = true;
376                         var child_1 = new Xcls_Label3( _this );
377                         child_1.ref();
378                         this.el.append( child_1.el );
379                         var child_2 = new Xcls_Button4( _this );
380                         child_2.ref();
381                         this.el.append( child_2.el );
382                         var child_3 = new Xcls_Button5( _this );
383                         child_3.ref();
384                         this.el.append( child_3.el );
385                         var child_4 = new Xcls_Button6( _this );
386                         child_4.ref();
387                         this.el.append( child_4.el );
388                 }
389
390                 // user defined functions
391         }
392         public class Xcls_Label3 : Object
393         {
394                 public Gtk.Label el;
395                 private Xcls_LeftProps  _this;
396
397
398                         // my vars (def)
399
400                 // ctor
401                 public Xcls_Label3(Xcls_LeftProps _owner )
402                 {
403                         _this = _owner;
404                         this.el = new Gtk.Label( "Add:" );
405
406                         // my vars (dec)
407
408                         // set gobject values
409                         this.el.margin_end = 5;
410                         this.el.margin_start = 5;
411                 }
412
413                 // user defined functions
414         }
415
416         public class Xcls_Button4 : Object
417         {
418                 public Gtk.Button el;
419                 private Xcls_LeftProps  _this;
420
421
422                         // my vars (def)
423                 public bool always_show_image;
424
425                 // ctor
426                 public Xcls_Button4(Xcls_LeftProps _owner )
427                 {
428                         _this = _owner;
429                         this.el = new Gtk.Button();
430
431                         // my vars (dec)
432                         this.always_show_image = true;
433
434                         // set gobject values
435                         this.el.icon_name = "format-justify-left";
436                         this.el.hexpand = true;
437                         this.el.tooltip_text = "Add Property";
438                         this.el.label = "Property";
439
440                         //listeners
441                         this.el.clicked.connect( ( ) => {
442                             
443                              _this.main_window.windowstate.showProps(
444                                 _this.view.el, 
445                                         JsRender.NodePropType.PROP
446                                 );
447                           
448                         });
449                 }
450
451                 // user defined functions
452         }
453
454         public class Xcls_Button5 : Object
455         {
456                 public Gtk.Button el;
457                 private Xcls_LeftProps  _this;
458
459
460                         // my vars (def)
461                 public bool always_show_image;
462
463                 // ctor
464                 public Xcls_Button5(Xcls_LeftProps _owner )
465                 {
466                         _this = _owner;
467                         this.el = new Gtk.Button();
468
469                         // my vars (dec)
470                         this.always_show_image = true;
471
472                         // set gobject values
473                         this.el.icon_name = "appointment-new";
474                         this.el.hexpand = true;
475                         this.el.tooltip_text = "Add Event Code";
476                         this.el.label = "Event";
477
478                         //listeners
479                         this.el.clicked.connect( ( ) => {
480                             
481                          
482                            _this.main_window.windowstate.showProps(
483                                         _this.view.el, 
484                                         JsRender.NodePropType.LISTENER
485                                 );
486                         
487                          
488                         });
489                 }
490
491                 // user defined functions
492         }
493
494         public class Xcls_Button6 : Object
495         {
496                 public Gtk.Button el;
497                 private Xcls_LeftProps  _this;
498
499
500                         // my vars (def)
501                 public bool always_show_image;
502
503                 // ctor
504                 public Xcls_Button6(Xcls_LeftProps _owner )
505                 {
506                         _this = _owner;
507                         this.el = new Gtk.Button();
508
509                         // my vars (dec)
510                         this.always_show_image = true;
511
512                         // set gobject values
513                         this.el.icon_name = "list-add";
514                         this.el.hexpand = true;
515                         this.el.label = "Other";
516                         new Xcls_AddPropertyPopup( _this );
517
518                         //listeners
519                         this.el.clicked.connect( ( ) => {
520                           //_this.before_edit();
521                           
522                                 
523                             var p = _this.AddPropertyPopup;
524                             
525                          //     Gtk.Allocation rect;
526                                 //this.el.get_allocation(out rect);
527                                 if (p.el.parent == null) {
528                                          p.el.set_parent(this.el);
529                                  }
530                             //p.el.set_pointing_to(rect);
531                                 p.el.show();
532                                 p.el.set_position(Gtk.PositionType.BOTTOM);
533                                 p.el.autohide = true;
534                              return;
535                         
536                         });
537                 }
538
539                 // user defined functions
540         }
541         public class Xcls_AddPropertyPopup : Object
542         {
543                 public Gtk.Popover el;
544                 private Xcls_LeftProps  _this;
545
546
547                         // my vars (def)
548
549                 // ctor
550                 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
551                 {
552                         _this = _owner;
553                         _this.AddPropertyPopup = this;
554                         this.el = new Gtk.Popover();
555
556                         // my vars (dec)
557
558                         // set gobject values
559                         this.el.autohide = true;
560                         var child_1 = new Xcls_Box8( _this );
561                         this.el.child = child_1.el;
562                 }
563
564                 // user defined functions
565         }
566         public class Xcls_Box8 : Object
567         {
568                 public Gtk.Box el;
569                 private Xcls_LeftProps  _this;
570
571
572                         // my vars (def)
573
574                 // ctor
575                 public Xcls_Box8(Xcls_LeftProps _owner )
576                 {
577                         _this = _owner;
578                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
579
580                         // my vars (dec)
581
582                         // set gobject values
583                         var child_1 = new Xcls_Button9( _this );
584                         child_1.ref();
585                         this.el.append( child_1.el );
586                         var child_2 = new Xcls_Button10( _this );
587                         child_2.ref();
588                         this.el.append( child_2.el );
589                         var child_3 = new Xcls_Button11( _this );
590                         child_3.ref();
591                         this.el.append( child_3.el );
592                         var child_4 = new Xcls_Button12( _this );
593                         child_4.ref();
594                         this.el.append( child_4.el );
595                         var child_5 = new Xcls_Button13( _this );
596                         child_5.ref();
597                         this.el.append( child_5.el );
598                         var child_6 = new Xcls_Separator14( _this );
599                         child_6.ref();
600                         this.el.append( child_6.el );
601                         var child_7 = new Xcls_Button15( _this );
602                         child_7.ref();
603                         this.el.append( child_7.el );
604                         var child_8 = new Xcls_Button16( _this );
605                         child_8.ref();
606                         this.el.append( child_8.el );
607                         var child_9 = new Xcls_Button17( _this );
608                         child_9.ref();
609                         this.el.append( child_9.el );
610                         var child_10 = new Xcls_Separator18( _this );
611                         child_10.ref();
612                         this.el.append( child_10.el );
613                         var child_11 = new Xcls_Button19( _this );
614                         child_11.ref();
615                         this.el.append( child_11.el );
616                         var child_12 = new Xcls_Button20( _this );
617                         child_12.ref();
618                         this.el.append( child_12.el );
619                         var child_13 = new Xcls_Button21( _this );
620                         child_13.ref();
621                         this.el.append( child_13.el );
622                         var child_14 = new Xcls_Separator22( _this );
623                         child_14.ref();
624                         this.el.append( child_14.el );
625                         var child_15 = new Xcls_Button23( _this );
626                         child_15.ref();
627                         this.el.append( child_15.el );
628                         var child_16 = new Xcls_Button24( _this );
629                         child_16.ref();
630                         this.el.append( child_16.el );
631                         var child_17 = new Xcls_Button25( _this );
632                         child_17.ref();
633                         this.el.append( child_17.el );
634                 }
635
636                 // user defined functions
637         }
638         public class Xcls_Button9 : Object
639         {
640                 public Gtk.Button el;
641                 private Xcls_LeftProps  _this;
642
643
644                         // my vars (def)
645
646                 // ctor
647                 public Xcls_Button9(Xcls_LeftProps _owner )
648                 {
649                         _this = _owner;
650                         this.el = new Gtk.Button();
651
652                         // my vars (dec)
653
654                         // set gobject values
655                         this.el.tooltip_markup = "Using _this.{ID} will map to this element";
656                         this.el.label = "id: _this.{ID} (Vala)";
657
658                         //listeners
659                         this.el.clicked.connect( ()  => {
660                                 _this.AddPropertyPopup.el.hide();
661                                 // is this userdef or special??
662                                 var add = new JsRender.NodeProp.prop("id");
663                                 if (_this.node.has_prop_key(add)) {
664                                         return;
665                                 }
666                                 
667                                 _this.node.add_prop( add );
668                                 
669                                 _this.view.editProp( add );
670                                 
671                                 
672                         });
673                 }
674
675                 // user defined functions
676         }
677
678         public class Xcls_Button10 : Object
679         {
680                 public Gtk.Button el;
681                 private Xcls_LeftProps  _this;
682
683
684                         // my vars (def)
685
686                 // ctor
687                 public Xcls_Button10(Xcls_LeftProps _owner )
688                 {
689                         _this = _owner;
690                         this.el = new Gtk.Button();
691
692                         // my vars (dec)
693
694                         // set gobject values
695                         this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
696                         this.el.label = "pack: Pack method (Vala)";
697
698                         //listeners
699                         this.el.clicked.connect( ( ) => {
700                          
701                         
702                                 _this.AddPropertyPopup.el.hide();
703                                 // is this userdef or special??
704                                 var add = new JsRender.NodeProp.special("pack", "add");
705                                 if (_this.node.has_prop_key(add)) {
706                                         return;
707                                 }
708                                 
709                                 _this.node.add_prop( add );
710                                 
711                                 _this.view.editProp( add );
712                                 
713                         
714                         });
715                 }
716
717                 // user defined functions
718         }
719
720         public class Xcls_Button11 : Object
721         {
722                 public Gtk.Button el;
723                 private Xcls_LeftProps  _this;
724
725
726                         // my vars (def)
727
728                 // ctor
729                 public Xcls_Button11(Xcls_LeftProps _owner )
730                 {
731                         _this = _owner;
732                         this.el = new Gtk.Button();
733
734                         // my vars (dec)
735
736                         // set gobject values
737                         this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
738                         this.el.label = "ctor: Alterative to default contructor (Vala)";
739
740                         //listeners
741                         this.el.clicked.connect( ( ) => {
742                            
743                          _this.AddPropertyPopup.el.hide();
744                                 // is this userdef or special??
745                                 var add = new JsRender.NodeProp.special("ctor");
746                                 if (_this.node.has_prop_key(add)) {
747                                         return;
748                                 }
749                                 
750                                 _this.node.add_prop( add );
751                                 
752                                 _this.view.editProp( add );
753                                 
754                         });
755                 }
756
757                 // user defined functions
758         }
759
760         public class Xcls_Button12 : Object
761         {
762                 public Gtk.Button el;
763                 private Xcls_LeftProps  _this;
764
765
766                         // my vars (def)
767
768                 // ctor
769                 public Xcls_Button12(Xcls_LeftProps _owner )
770                 {
771                         _this = _owner;
772                         this.el = new Gtk.Button();
773
774                         // my vars (dec)
775
776                         // set gobject values
777                         this.el.tooltip_markup = "This code is called after the ctor";
778                         this.el.label = "init: initialziation code (vala)";
779
780                         //listeners
781                         this.el.clicked.connect( ( ) => {
782                             
783                          _this.AddPropertyPopup.el.hide();
784                                 // is this userdef or special??
785                                 var add =  new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
786                                 if (_this.node.has_prop_key(add)) {
787                                         return;
788                                 }
789                                 
790                                 _this.node.add_prop( add );
791                                 
792                                 _this.view.editProp( add );
793                         });
794                 }
795
796                 // user defined functions
797         }
798
799         public class Xcls_Button13 : Object
800         {
801                 public Gtk.Button el;
802                 private Xcls_LeftProps  _this;
803
804
805                         // my vars (def)
806
807                 // ctor
808                 public Xcls_Button13(Xcls_LeftProps _owner )
809                 {
810                         _this = _owner;
811                         this.el = new Gtk.Button();
812
813                         // my vars (dec)
814
815                         // set gobject values
816                         this.el.tooltip_markup = "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n";
817                         this.el.label = "cms-id: (Roo JS/Pman library)";
818
819                         //listeners
820                         this.el.clicked.connect( ()  => {
821                            
822                          _this.AddPropertyPopup.el.hide();
823                                 // is this userdef or special??
824                                 var add =   new JsRender.NodeProp.prop("cms-id","string", "" ) ;
825                                 if (_this.node.has_prop_key(add)) {
826                                         return;
827                                 }
828                                 
829                                 _this.node.add_prop( add );
830                                 
831                                 _this.view.editProp( add );
832                             
833                         });
834                 }
835
836                 // user defined functions
837         }
838
839         public class Xcls_Separator14 : Object
840         {
841                 public Gtk.Separator el;
842                 private Xcls_LeftProps  _this;
843
844
845                         // my vars (def)
846
847                 // ctor
848                 public Xcls_Separator14(Xcls_LeftProps _owner )
849                 {
850                         _this = _owner;
851                         this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
852
853                         // my vars (dec)
854
855                         // set gobject values
856                 }
857
858                 // user defined functions
859         }
860
861         public class Xcls_Button15 : Object
862         {
863                 public Gtk.Button el;
864                 private Xcls_LeftProps  _this;
865
866
867                         // my vars (def)
868
869                 // ctor
870                 public Xcls_Button15(Xcls_LeftProps _owner )
871                 {
872                         _this = _owner;
873                         this.el = new Gtk.Button();
874
875                         // my vars (dec)
876
877                         // set gobject values
878                         this.el.tooltip_markup = "Add a user defined string property";
879                         this.el.label = "String";
880
881                         //listeners
882                         this.el.clicked.connect( (self) => {
883                              _this.AddPropertyPopup.el.hide();
884                                 _this.view.popover.show(
885                                         _this.view.el, 
886                                         _this.node, 
887                                          new JsRender.NodeProp.prop("", "string", "") ,
888                                         -1,  
889                                         true
890                                 );
891                          
892                         });
893                 }
894
895                 // user defined functions
896         }
897
898         public class Xcls_Button16 : Object
899         {
900                 public Gtk.Button el;
901                 private Xcls_LeftProps  _this;
902
903
904                         // my vars (def)
905
906                 // ctor
907                 public Xcls_Button16(Xcls_LeftProps _owner )
908                 {
909                         _this = _owner;
910                         this.el = new Gtk.Button();
911
912                         // my vars (dec)
913
914                         // set gobject values
915                         this.el.tooltip_markup = "Add a user defined number property";
916                         this.el.label = "Number";
917
918                         //listeners
919                         this.el.clicked.connect( ( ) =>{
920                               _this.AddPropertyPopup.el.hide();
921                               
922                                _this.view.popover.show(
923                                         _this.view.el, 
924                                         _this.node, 
925                                          new JsRender.NodeProp.prop("", "int", "0") ,
926                                         -1,  
927                                         true
928                                 );
929                          
930                         });
931                 }
932
933                 // user defined functions
934         }
935
936         public class Xcls_Button17 : Object
937         {
938                 public Gtk.Button el;
939                 private Xcls_LeftProps  _this;
940
941
942                         // my vars (def)
943
944                 // ctor
945                 public Xcls_Button17(Xcls_LeftProps _owner )
946                 {
947                         _this = _owner;
948                         this.el = new Gtk.Button();
949
950                         // my vars (dec)
951
952                         // set gobject values
953                         this.el.tooltip_markup = "Add a user defined boolean property";
954                         this.el.label = "Boolean";
955
956                         //listeners
957                         this.el.clicked.connect( ( ) =>{
958                           
959                                      _this.AddPropertyPopup.el.hide();
960                            _this.view.popover.show(
961                                         _this.view.el, 
962                                         _this.node, 
963                                          new JsRender.NodeProp.prop("", "bool", "true") ,
964                                         -1,  
965                                         true
966                                 ); 
967                          
968                         });
969                 }
970
971                 // user defined functions
972         }
973
974         public class Xcls_Separator18 : Object
975         {
976                 public Gtk.Separator el;
977                 private Xcls_LeftProps  _this;
978
979
980                         // my vars (def)
981
982                 // ctor
983                 public Xcls_Separator18(Xcls_LeftProps _owner )
984                 {
985                         _this = _owner;
986                         this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
987
988                         // my vars (dec)
989
990                         // set gobject values
991                 }
992
993                 // user defined functions
994         }
995
996         public class Xcls_Button19 : Object
997         {
998                 public Gtk.Button el;
999                 private Xcls_LeftProps  _this;
1000
1001
1002                         // my vars (def)
1003
1004                 // ctor
1005                 public Xcls_Button19(Xcls_LeftProps _owner )
1006                 {
1007                         _this = _owner;
1008                         this.el = new Gtk.Button();
1009
1010                         // my vars (dec)
1011
1012                         // set gobject values
1013                         this.el.tooltip_markup = "Add a user function boolean property";
1014                         this.el.label = "Javascript Function";
1015
1016                         //listeners
1017                         this.el.clicked.connect( ( ) =>{
1018                           _this.AddPropertyPopup.el.hide(); 
1019                            _this.view.popover.show(
1020                                         _this.view.el, 
1021                                         _this.node, 
1022                                          new JsRender.NodeProp.jsmethod("") ,
1023                                         -1,  
1024                                         true
1025                                 );
1026                         
1027                          
1028                         });
1029                 }
1030
1031                 // user defined functions
1032         }
1033
1034         public class Xcls_Button20 : Object
1035         {
1036                 public Gtk.Button el;
1037                 private Xcls_LeftProps  _this;
1038
1039
1040                         // my vars (def)
1041
1042                 // ctor
1043                 public Xcls_Button20(Xcls_LeftProps _owner )
1044                 {
1045                         _this = _owner;
1046                         this.el = new Gtk.Button();
1047
1048                         // my vars (dec)
1049
1050                         // set gobject values
1051                         this.el.tooltip_markup = "Add a user function boolean property";
1052                         this.el.label = "Vala Method";
1053
1054                         //listeners
1055                         this.el.clicked.connect( ( ) =>{
1056                         _this.AddPropertyPopup.el.hide();
1057                             _this.view.popover.show(
1058                                         _this.view.el, 
1059                                         _this.node, 
1060                                          new JsRender.NodeProp.valamethod("") ,
1061                                         -1,  
1062                                         true
1063                                 ); 
1064                         });
1065                 }
1066
1067                 // user defined functions
1068         }
1069
1070         public class Xcls_Button21 : Object
1071         {
1072                 public Gtk.Button el;
1073                 private Xcls_LeftProps  _this;
1074
1075
1076                         // my vars (def)
1077
1078                 // ctor
1079                 public Xcls_Button21(Xcls_LeftProps _owner )
1080                 {
1081                         _this = _owner;
1082                         this.el = new Gtk.Button();
1083
1084                         // my vars (dec)
1085
1086                         // set gobject values
1087                         this.el.tooltip_markup = "Add a vala signal";
1088                         this.el.label = "Vala Signal";
1089
1090                         //listeners
1091                         this.el.clicked.connect( ( ) =>{
1092                           _this.AddPropertyPopup.el.hide();
1093                           _this.view.popover.show(
1094                                         _this.view.el, 
1095                                         _this.node, 
1096                                          new JsRender.NodeProp.sig("" ) ,
1097                                         -1,  
1098                                         true
1099                                 );    
1100                         });
1101                 }
1102
1103                 // user defined functions
1104         }
1105
1106         public class Xcls_Separator22 : Object
1107         {
1108                 public Gtk.Separator el;
1109                 private Xcls_LeftProps  _this;
1110
1111
1112                         // my vars (def)
1113
1114                 // ctor
1115                 public Xcls_Separator22(Xcls_LeftProps _owner )
1116                 {
1117                         _this = _owner;
1118                         this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1119
1120                         // my vars (dec)
1121
1122                         // set gobject values
1123                 }
1124
1125                 // user defined functions
1126         }
1127
1128         public class Xcls_Button23 : Object
1129         {
1130                 public Gtk.Button el;
1131                 private Xcls_LeftProps  _this;
1132
1133
1134                         // my vars (def)
1135
1136                 // ctor
1137                 public Xcls_Button23(Xcls_LeftProps _owner )
1138                 {
1139                         _this = _owner;
1140                         this.el = new Gtk.Button();
1141
1142                         // my vars (dec)
1143
1144                         // set gobject values
1145                         this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1146                         this.el.label = "Flexy - If";
1147
1148                         //listeners
1149                         this.el.clicked.connect( ( ) =>{
1150                                 _this.AddPropertyPopup.el.hide();
1151                                 _this.view.popover.show(
1152                                         _this.view.el, 
1153                                         _this.node, 
1154                                          new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1155                                         -1,  
1156                                         true
1157                                 );
1158                         
1159                         
1160                         });
1161                 }
1162
1163                 // user defined functions
1164         }
1165
1166         public class Xcls_Button24 : Object
1167         {
1168                 public Gtk.Button el;
1169                 private Xcls_LeftProps  _this;
1170
1171
1172                         // my vars (def)
1173
1174                 // ctor
1175                 public Xcls_Button24(Xcls_LeftProps _owner )
1176                 {
1177                         _this = _owner;
1178                         this.el = new Gtk.Button();
1179
1180                         // my vars (dec)
1181
1182                         // set gobject values
1183                         this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1184                         this.el.label = "Flexy - Include";
1185
1186                         //listeners
1187                         this.el.clicked.connect( ( ) =>{
1188                                 _this.AddPropertyPopup.el.hide();
1189                                 _this.view.popover.show(
1190                                         _this.view.el, 
1191                                         _this.node, 
1192                                          new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1193                                         -1,  
1194                                         true
1195                                 );
1196                         
1197                           
1198                         });
1199                 }
1200
1201                 // user defined functions
1202         }
1203
1204         public class Xcls_Button25 : Object
1205         {
1206                 public Gtk.Button el;
1207                 private Xcls_LeftProps  _this;
1208
1209
1210                         // my vars (def)
1211
1212                 // ctor
1213                 public Xcls_Button25(Xcls_LeftProps _owner )
1214                 {
1215                         _this = _owner;
1216                         this.el = new Gtk.Button();
1217
1218                         // my vars (dec)
1219
1220                         // set gobject values
1221                         this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1222                         this.el.label = "Flexy - Foreach";
1223
1224                         //listeners
1225                         this.el.clicked.connect( ( ) =>{
1226                                 _this.AddPropertyPopup.el.hide();
1227                                 _this.view.popover.show(
1228                                         _this.view.el, 
1229                                         _this.node, 
1230                                          new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1231                                         -1,  
1232                                         true
1233                                 );
1234                           
1235                         });
1236                 }
1237
1238                 // user defined functions
1239         }
1240
1241
1242
1243
1244
1245         public class Xcls_EditProps : Object
1246         {
1247                 public Gtk.ScrolledWindow el;
1248                 private Xcls_LeftProps  _this;
1249
1250
1251                         // my vars (def)
1252                 public bool editing;
1253
1254                 // ctor
1255                 public Xcls_EditProps(Xcls_LeftProps _owner )
1256                 {
1257                         _this = _owner;
1258                         _this.EditProps = this;
1259                         this.el = new Gtk.ScrolledWindow();
1260
1261                         // my vars (dec)
1262                         this.editing = false;
1263
1264                         // set gobject values
1265                         this.el.hexpand = true;
1266                         this.el.vexpand = true;
1267                         new Xcls_view( _this );
1268                         this.el.set_child ( _this.view.el  );
1269
1270                         // init method
1271
1272                         {
1273                           
1274                            this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1275                         }
1276                 }
1277
1278                 // user defined functions
1279         }
1280         public class Xcls_view : Object
1281         {
1282                 public Gtk.ColumnView el;
1283                 private Xcls_LeftProps  _this;
1284
1285
1286                         // my vars (def)
1287                 public Gtk.CssProvider css;
1288                 public Xcls_PopoverProperty popover;
1289
1290                 // ctor
1291                 public Xcls_view(Xcls_LeftProps _owner )
1292                 {
1293                         _this = _owner;
1294                         _this.view = this;
1295                         new Xcls_selmodel( _this );
1296                         this.el = new Gtk.ColumnView( _this.selmodel.el );
1297
1298                         // my vars (dec)
1299                         this.popover = null;
1300
1301                         // set gobject values
1302                         this.el.name = "leftprops-view";
1303                         this.el.single_click_activate = false;
1304                         this.el.hexpand = true;
1305                         this.el.vexpand = true;
1306                         this.el.show_row_separators = true;
1307                         new Xcls_deletemenu( _this );
1308                         var child_3 = new Xcls_GestureClick31( _this );
1309                         child_3.ref();
1310                         this.el.add_controller(  child_3.el );
1311                         var child_4 = new Xcls_GestureClick32( _this );
1312                         child_4.ref();
1313                         this.el.add_controller(  child_4.el );
1314                         new Xcls_keycol( _this );
1315                         this.el.append_column ( _this.keycol.el  );
1316                         new Xcls_valcol( _this );
1317                         this.el.append_column ( _this.valcol.el  );
1318                         new Xcls_ContextMenu( _this );
1319
1320                         // init method
1321
1322                         {
1323                          
1324                                 this.css = new Gtk.CssProvider();
1325                                  
1326                                         this.css.load_from_string("
1327                         #leftprops-view { font-size: 12px;}
1328                                  
1329                         #leftprops-view  dropdown button { 
1330                                                 min-height: 16px;                        
1331                                                 outline-offset : 0;
1332                                         }
1333                         #leftprops-view cell dropdown label  {
1334                                         padding-top:0px;
1335                                         padding-bottom:0px;
1336                         }
1337                         #leftprops-view cell   { 
1338                                         padding-top:2px;
1339                                         padding-bottom:2px;
1340                                         }
1341                         #leftprops-view cell label,  #leftprops-view cell editablelable {
1342                                         padding-top:4px;
1343                                         padding-bottom:4px;
1344                         }");
1345                          
1346                                         Gtk.StyleContext.add_provider_for_display(
1347                                         this.el.get_display(),
1348                                         this.css,
1349                                         Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1350                                 );
1351                                         
1352                            
1353                         }
1354                 }
1355
1356                 // user defined functions
1357                 public Gtk.Widget? getWidgetAtRow (uint row) {
1358                 /*
1359                         
1360                 from            https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1361                         var colview = gesture.widget;
1362                         var line_no = check_list_widget(colview, x,y);
1363                          if (line_no > -1) {
1364                                 var item = colview.model.get_item(line_no);
1365                                  
1366                         }
1367                         */
1368                                 GLib.debug("Get Widget At Row %d", (int)row);
1369                         var  child = this.el.get_first_child(); 
1370                         var line_no = -1; 
1371                         var reading_header = true;
1372                 
1373                         while (child != null) {
1374                                         GLib.debug("Got %s", child.get_type().name());
1375                             if (reading_header) {
1376                                          
1377                                            
1378                                                 if (child.get_type().name() != "GtkColumnListView") {
1379                                                         child = child.get_next_sibling();
1380                                                         continue;
1381                                                 }
1382                                                 child = child.get_first_child(); 
1383                                                 reading_header = false;
1384                                                 continue;
1385                                 }
1386                                     if (child.get_type().name() != "GtkColumnViewRowWidget") {
1387                                     child = child.get_next_sibling();
1388                                     continue;
1389                                     }
1390                                     line_no++;
1391                                         if (line_no == row) {
1392                                                 GLib.debug("Returning widget %s", child.get_type().name());
1393                                             return (Gtk.Widget)child;
1394                                     }
1395                                 child = child.get_next_sibling(); 
1396                         }
1397                                 GLib.debug("Rturning null");
1398                         return null;
1399                 
1400                  }
1401                 public void editProp (JsRender.NodeProp prop) 
1402                 {
1403                         var sm = _this.selmodel.el;
1404                  
1405                                 var sr = -1;
1406                                 GLib.debug("finding node");
1407                                 _this.selmodel.selectProp(prop);
1408                                 
1409                                 for (var i = 0 ; i < sm.n_items; i++) {
1410                                         var r = (JsRender.NodeProp)sm.get_item(i);
1411                                         if (r.equals(prop)) {
1412                                                 sr = i;
1413                                                 break;
1414                                         }
1415                                 }
1416                                 if (sr < 0) {
1417                                         GLib.debug("finding node - cant find it");
1418                                                         
1419                                         return;
1420                                 }
1421                                 var r = this.getWidgetAtRow(sr);
1422                                 GLib.debug("r = %s", r.get_type().name());
1423                                 var ca = r.get_first_child();
1424                                 var ll = (Gtk.Label)ca.get_first_child();
1425                                 var cb = ca.get_next_sibling();
1426                                 var b = cb.get_first_child();
1427                                 var e = (Gtk.EditableLabel) b.get_first_child();
1428                                 var l = (Gtk.Label) e.get_next_sibling();
1429                                 var d = (Gtk.DropDown) l.get_next_sibling();
1430                                 
1431                                 GLib.debug("row key = %s", ll.label);
1432                                 if (e.get_visible()) {
1433                                         _this.stop_editor();
1434                                         e.start_editing();
1435                                         //GLib.Timeout.add_once(500, () => {
1436                                         //      var st = (Gtk.Stack) e.get_first_child();
1437                                         //      var ed = (Gtk.Entry) st.get_visible_child();
1438                                         //      ed.grab_focus_without_selecting();
1439                                         //});
1440                                         return;
1441                                 }
1442                                 if (d.get_visible()) {
1443                                         _this.stop_editor();
1444                                         d.activate();
1445                                         return;
1446                                 }
1447                                 if (l.get_visible()) {
1448                                         _this.stop_editor();
1449                                 _this.show_editor(_this.file, prop.parent, prop);
1450                                 
1451                                 }
1452                                 
1453                                 
1454                                 
1455                                 //gtkcolumnviewrowwidget
1456                                   // cell widet
1457                                   // cell widget
1458                                         // box
1459                                                 // entry / label / dropdown
1460                                                 
1461                                  
1462                 }
1463                 public int getColAt (double x,  double y) {
1464                 /*
1465                         
1466                 from            https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1467                           
1468                         */
1469                                 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1470                         var  child = this.el.get_first_child(); 
1471                          
1472                         var col = 0;
1473                         var offx = 0;
1474                         while (child != null) {
1475                                         GLib.debug("Got %s", child.get_type().name());
1476                                         
1477                                         if (child.get_type().name() == "GtkColumnViewRowWidget") {
1478                                                 child = child.get_first_child();
1479                                                 continue;
1480                                         }
1481                                         
1482                                         //child.get_allocation(out alloc);
1483                                         if (x <  (child.get_width() + offx)) {
1484                                                 return col;
1485                                         }
1486                                         offx += child.get_width();
1487                                         col++;
1488                                         child = child.get_next_sibling();
1489                                 }
1490                              
1491                                           
1492                         return -1;
1493                 
1494                  }
1495                 public int getRowAt (double x,  double in_y, out string pos) {
1496                 
1497                 
1498                          
1499                 
1500                 /*
1501                         
1502                 from            https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1503                         var colview = gesture.widget;
1504                         var line_no = check_list_widget(colview, x,y);
1505                          if (line_no > -1) {
1506                                 var item = colview.model.get_item(line_no);
1507                                  
1508                         }
1509                         */
1510                                  
1511                                 
1512                                 //GLib.debug("offset = %d  y = %d", (int) voff, (int) in_y);
1513                         var y = in_y + _this.EditProps.el.vadjustment.value; 
1514                         var  child = this.el.get_first_child(); 
1515                         //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1516                         var line_no = -1; 
1517                         var reading_header = true;
1518                         var real_y = 0;
1519                         var header_height  = 0;
1520                         pos = "none";
1521                         var h = 0;
1522                         while (child != null) {
1523                                         //GLib.debug("Got %s", child.get_type().name());
1524                             if (reading_header) {
1525                                                 
1526                 
1527                                                 if (child.get_type().name() != "GtkColumnListView") {
1528                                                 h += child.get_height();
1529                                                         child = child.get_next_sibling();
1530                                                         continue;
1531                                                 }
1532                                                 // should be columnlistview
1533                                                 child = child.get_first_child(); 
1534                                             GLib.debug("header height=%d", h);
1535                                                 header_height =  h;
1536                                                 
1537                                                 reading_header = false;
1538                                                 
1539                                 }
1540                                 
1541                                     if (child.get_type().name() != "GtkColumnViewRowWidget") {
1542                                     child = child.get_next_sibling();
1543                                     continue;
1544                                     }
1545                                     
1546                                         if (y < header_height) {
1547                                         return -1;
1548                                 }
1549                                     
1550                                     line_no++;
1551                                         var hh = child.get_height();
1552                                         //child.get_allocation(out alloc);
1553                                         //GLib.debug("got cell xy = %d,%d  w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1554                                         //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1555                                         
1556                                         //      child.visible ? "VIS" : "hidden");
1557                 
1558                                     if (y >  (header_height + real_y) && y <= (header_height +  real_y + hh) ) {
1559                                         if (y > ( header_height + real_y + (hh * 0.8))) {
1560                                                 pos = "below";
1561                                         } else if (y > ( header_height + real_y + (hh * 0.2))) {
1562                                                 pos = "over";
1563                                         } else {
1564                                                 pos = "above";
1565                                                 }
1566                                          GLib.debug("getRowAt return : %d, %s", line_no, pos);
1567                                             return line_no;
1568                                     }
1569                  
1570                 
1571                                     if (real_y + hh > y) {
1572                                         return -1;
1573                                 }
1574                                 real_y += hh;
1575                                 child = child.get_next_sibling(); 
1576                         }
1577                         return -1;
1578                 
1579                  }
1580         }
1581         public class Xcls_deletemenu : Object
1582         {
1583                 public Gtk.Popover el;
1584                 private Xcls_LeftProps  _this;
1585
1586
1587                         // my vars (def)
1588
1589                 // ctor
1590                 public Xcls_deletemenu(Xcls_LeftProps _owner )
1591                 {
1592                         _this = _owner;
1593                         _this.deletemenu = this;
1594                         this.el = new Gtk.Popover();
1595
1596                         // my vars (dec)
1597
1598                         // set gobject values
1599                         var child_1 = new Xcls_Box29( _this );
1600                         this.el.child = child_1.el;
1601                 }
1602
1603                 // user defined functions
1604         }
1605         public class Xcls_Box29 : Object
1606         {
1607                 public Gtk.Box el;
1608                 private Xcls_LeftProps  _this;
1609
1610
1611                         // my vars (def)
1612
1613                 // ctor
1614                 public Xcls_Box29(Xcls_LeftProps _owner )
1615                 {
1616                         _this = _owner;
1617                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1618
1619                         // my vars (dec)
1620
1621                         // set gobject values
1622                         var child_1 = new Xcls_Button30( _this );
1623                         child_1.ref();
1624                         this.el.append( child_1.el );
1625                 }
1626
1627                 // user defined functions
1628         }
1629         public class Xcls_Button30 : Object
1630         {
1631                 public Gtk.Button el;
1632                 private Xcls_LeftProps  _this;
1633
1634
1635                         // my vars (def)
1636
1637                 // ctor
1638                 public Xcls_Button30(Xcls_LeftProps _owner )
1639                 {
1640                         _this = _owner;
1641                         this.el = new Gtk.Button();
1642
1643                         // my vars (dec)
1644
1645                         // set gobject values
1646                         this.el.label = "Delete";
1647
1648                         //listeners
1649                         this.el.clicked.connect( ( ) => {
1650                                 
1651                         
1652                                 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1653                         
1654                                 _this.deletemenu.el.hide();
1655                                 _this.node.remove_prop(n);
1656                         });
1657                 }
1658
1659                 // user defined functions
1660         }
1661
1662
1663
1664         public class Xcls_GestureClick31 : Object
1665         {
1666                 public Gtk.GestureClick el;
1667                 private Xcls_LeftProps  _this;
1668
1669
1670                         // my vars (def)
1671
1672                 // ctor
1673                 public Xcls_GestureClick31(Xcls_LeftProps _owner )
1674                 {
1675                         _this = _owner;
1676                         this.el = new Gtk.GestureClick();
1677
1678                         // my vars (dec)
1679
1680                         // set gobject values
1681
1682                         //listeners
1683                         this.el.pressed.connect( (n_press, in_x, in_y) => {
1684                         
1685                                 GLib.debug("Prssed %d", (int)  this.el.get_current_button());
1686                                 
1687                                 var col = _this.view.getColAt(in_x, in_y);
1688                                 if (col != 0) {
1689                                         return;
1690                                 }
1691                                 string pos;
1692                                 var row = _this.view.getRowAt(in_x, in_y, out pos);
1693                                 
1694                                 if (row < 0) {
1695                                         return;
1696                         
1697                                 }
1698                                 GLib.debug("hit row %d", row);
1699                                 var prop = _this.selmodel.getPropAt(row);
1700                                 _this.selmodel.selectProp(prop);
1701                         
1702                                 //var point_at = _this.view.getWidgetAtRow(row);
1703                                 
1704                                         // need to shift down, as ev.y does not inclucde header apparently..
1705                                 // or popover might be trying to do a central?
1706                         //       _this.view.editPropertyDetails(prop, (int) in_y + 12); 
1707                                  _this.stop_editor();
1708                              _this.view.popover.show(
1709                                                 _this.view.el, 
1710                                                 _this.node, prop,  
1711                                          (int)in_y);
1712                             
1713                             
1714                               
1715                         });
1716                 }
1717
1718                 // user defined functions
1719         }
1720
1721         public class Xcls_GestureClick32 : Object
1722         {
1723                 public Gtk.GestureClick el;
1724                 private Xcls_LeftProps  _this;
1725
1726
1727                         // my vars (def)
1728
1729                 // ctor
1730                 public Xcls_GestureClick32(Xcls_LeftProps _owner )
1731                 {
1732                         _this = _owner;
1733                         this.el = new Gtk.GestureClick();
1734
1735                         // my vars (dec)
1736
1737                         // set gobject values
1738                         this.el.button = 3;
1739
1740                         //listeners
1741                         this.el.pressed.connect( (n_press, in_x, in_y) => {
1742                         
1743                                 
1744                                  
1745                                 string pos;
1746                                 var row = _this.view.getRowAt(in_x, in_y, out pos);
1747                                 
1748                                 if (row < 0) {
1749                                         return;
1750                         
1751                                 }
1752                                 
1753                                 _this.stop_editor();
1754                                 GLib.debug("hit row %d", row);
1755                                 var prop = _this.selmodel.getPropAt(row);
1756                                 _this.selmodel.selectProp(prop);
1757                                 
1758                                 
1759                                 
1760                                 GLib.debug("Prssed %d", (int)  this.el.get_current_button());
1761                                 //_this.deletemenu.el.set_parent(_this.view.el);
1762                                 if (_this.deletemenu.el.parent == null) {
1763                                         _this.deletemenu.el.set_parent(_this.main_window.el);
1764                                 }
1765                                 
1766                                 
1767                                  
1768                                 _this.deletemenu.el.set_offset(
1769                                                 (int)in_x  - _this.view.el.get_width() ,
1770                                                 (int)in_y - _this.view.el.get_height()
1771                                         );
1772                                 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM); 
1773                             _this.deletemenu.el.popup();
1774                               
1775                         });
1776                 }
1777
1778                 // user defined functions
1779         }
1780
1781         public class Xcls_selmodel : Object
1782         {
1783                 public Gtk.SingleSelection el;
1784                 private Xcls_LeftProps  _this;
1785
1786
1787                         // my vars (def)
1788
1789                 // ctor
1790                 public Xcls_selmodel(Xcls_LeftProps _owner )
1791                 {
1792                         _this = _owner;
1793                         _this.selmodel = this;
1794                         new Xcls_model( _this );
1795                         this.el = new Gtk.SingleSelection( _this.model.el );
1796
1797                         // my vars (dec)
1798
1799                         // set gobject values
1800                         this.el.can_unselect = true;
1801                 }
1802
1803                 // user defined functions
1804                 public int propToRow (JsRender.NodeProp prop) {
1805                         for (var i = 0 ; i < this.el.n_items; i++) {
1806                                 var r = (JsRender.NodeProp)this.el.get_item(i);
1807                                 if (r.equals(prop)) {
1808                                         return i;
1809                                         
1810                                 }
1811                         }
1812                         return -1;
1813                          
1814                 }
1815                 public void startEditing (JsRender.NodeProp prop) {
1816                         // should we call select?? - caller does int (from windowstate)
1817                         
1818                 }
1819                 public void selectProp (JsRender.NodeProp prop) {
1820                         for (var i = 0 ; i < this.el.n_items; i++) {
1821                                 var r = (JsRender.NodeProp)this.el.get_item(i);
1822                                 if (r.equals(prop)) {
1823                                         this.el.selected = i;
1824                                         return;
1825                                 }
1826                         }
1827                          
1828                 }
1829                 public JsRender.NodeProp getPropAt (uint row) {
1830                 
1831                         return   (JsRender.NodeProp) this.el.get_item(row);
1832                 
1833                          
1834                 }
1835         }
1836         public class Xcls_model : Object
1837         {
1838                 public GLib.ListStore el;
1839                 private Xcls_LeftProps  _this;
1840
1841
1842                         // my vars (def)
1843
1844                 // ctor
1845                 public Xcls_model(Xcls_LeftProps _owner )
1846                 {
1847                         _this = _owner;
1848                         _this.model = this;
1849                         this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
1850
1851                         // my vars (dec)
1852
1853                         // set gobject values
1854                 }
1855
1856                 // user defined functions
1857         }
1858
1859
1860         public class Xcls_keycol : Object
1861         {
1862                 public Gtk.ColumnViewColumn el;
1863                 private Xcls_LeftProps  _this;
1864
1865
1866                         // my vars (def)
1867
1868                 // ctor
1869                 public Xcls_keycol(Xcls_LeftProps _owner )
1870                 {
1871                         _this = _owner;
1872                         _this.keycol = this;
1873                         var child_1 = new Xcls_SignalListItemFactory36( _this );
1874                         child_1.ref();
1875                         this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
1876
1877                         // my vars (dec)
1878
1879                         // set gobject values
1880                         this.el.id = "keycol";
1881                         this.el.expand = true;
1882                         this.el.resizable = true;
1883                 }
1884
1885                 // user defined functions
1886         }
1887         public class Xcls_SignalListItemFactory36 : Object
1888         {
1889                 public Gtk.SignalListItemFactory el;
1890                 private Xcls_LeftProps  _this;
1891
1892
1893                         // my vars (def)
1894
1895                 // ctor
1896                 public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner )
1897                 {
1898                         _this = _owner;
1899                         this.el = new Gtk.SignalListItemFactory();
1900
1901                         // my vars (dec)
1902
1903                         // set gobject values
1904
1905                         //listeners
1906                         this.el.setup.connect( (listitem) => {
1907                                 var lbl = new Gtk.Label("");
1908                                 ((Gtk.ListItem)listitem).set_child(lbl);
1909                                 lbl.justify = Gtk.Justification.LEFT;
1910                                 lbl.xalign = 1;
1911                                 lbl.use_markup = true;
1912                                 lbl.ellipsize = Pango.EllipsizeMode.START;
1913                                 /*lbl.changed.connect(() => {
1914                                         // notify and save the changed value...
1915                                         //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
1916                                  
1917                                 //prop.val = lbl.text;
1918                                 //_this.updateIter(iter,prop);
1919                                 _this.changed();
1920                                 });
1921                                 */
1922                                 ((Gtk.ListItem)listitem).activatable = true;
1923                         });
1924                         this.el.bind.connect( (listitem) => {
1925                          var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
1926                          var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1927                         
1928                         
1929                         item.bind_property("to_display_name_prop",
1930                                             lb, "label",
1931                                            GLib.BindingFlags.SYNC_CREATE);
1932                         item.bind_property("to_tooltip_name_prop",
1933                                             lb, "tooltip_markup",
1934                                            GLib.BindingFlags.SYNC_CREATE);
1935                         // was item (1) in old layout
1936                          
1937                         
1938                         });
1939                 }
1940
1941                 // user defined functions
1942         }
1943
1944
1945         public class Xcls_valcol : Object
1946         {
1947                 public Gtk.ColumnViewColumn el;
1948                 private Xcls_LeftProps  _this;
1949
1950
1951                         // my vars (def)
1952
1953                 // ctor
1954                 public Xcls_valcol(Xcls_LeftProps _owner )
1955                 {
1956                         _this = _owner;
1957                         _this.valcol = this;
1958                         var child_1 = new Xcls_SignalListItemFactory38( _this );
1959                         child_1.ref();
1960                         this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
1961
1962                         // my vars (dec)
1963
1964                         // set gobject values
1965                         this.el.id = "valcol";
1966                         this.el.expand = true;
1967                         this.el.resizable = true;
1968                 }
1969
1970                 // user defined functions
1971         }
1972         public class Xcls_SignalListItemFactory38 : Object
1973         {
1974                 public Gtk.SignalListItemFactory el;
1975                 private Xcls_LeftProps  _this;
1976
1977
1978                         // my vars (def)
1979                 public bool is_setting;
1980
1981                 // ctor
1982                 public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner )
1983                 {
1984                         _this = _owner;
1985                         this.el = new Gtk.SignalListItemFactory();
1986
1987                         // my vars (dec)
1988                         this.is_setting = false;
1989
1990                         // set gobject values
1991
1992                         //listeners
1993                         this.el.setup.connect( (listitem) => {
1994                                 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1995                                 var elbl  = new Gtk.EditableLabel("");
1996                                 elbl.hexpand = true;
1997                                 hb.append(elbl);
1998                                 var lbl  = new Gtk.Label("");
1999                                 hb.append(lbl);
2000                                 lbl.hexpand = true;
2001                                 lbl.use_markup = true;
2002                                 lbl.xalign =0;
2003                                 lbl.ellipsize = Pango.EllipsizeMode.END;
2004                                 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2005                                 cb.hexpand = true;
2006                          
2007                                 hb.append(cb);
2008                                 ((Gtk.ListItem)listitem).set_child(hb);
2009                                  
2010                                  var ef = new Gtk.EventControllerFocus();
2011                                  ef.enter.connect(() => {
2012                                          _this.stop_editor();
2013                                           var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2014                                          _this.selmodel.selectProp(prop);               
2015                                  });
2016                                  elbl.add_controller(ef);
2017                                  
2018                                  
2019                                   // dropdown??? - stop editing, and highliht node
2020                                  var tb = (Gtk.ToggleButton) cb.get_first_child();
2021                                  tb.clicked.connect(() => {
2022                                          var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2023                                                 
2024                                          _this.stop_editor();
2025                                          _this.selmodel.selectProp(prop);
2026                                          
2027                                  });
2028                                 elbl.changed.connect(() => {
2029                                         // notify and save the changed value...
2030                                         
2031                                 //_this.updateIter(iter,prop);
2032                                 // this should happen automatically
2033                                 
2034                                 if (!_this.loading && !this.is_setting) {
2035                                             var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2036                                                  
2037                                          
2038                                             prop.val = elbl.text;
2039                                          GLib.debug("calling changed");
2040                                         _this.changed();
2041                                        
2042                                 }
2043                                 
2044                                 });
2045                                 
2046                                 
2047                                 cb.notify["selected"].connect(() => {
2048                                         // dropdown selection changed.
2049                                         
2050                                         
2051                                         
2052                                 //_this.updateIter(iter,prop);
2053                                 if (!_this.loading && !this.is_setting) {
2054                                             var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2055                                             var model = (Gtk.StringList)cb.model;
2056                                             prop.val =   model.get_string(cb.selected);
2057                                             GLib.debug("property set to %s", prop.val);
2058                                         GLib.debug("calling changed");
2059                                         _this.changed();
2060                                          
2061                                 }
2062                                 
2063                                         
2064                                 });
2065                                 var gc = new Gtk.GestureClick();
2066                                 lbl.add_controller(gc);
2067                                 gc.pressed.connect(() => {
2068                                         var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2069                                          _this.stop_editor();
2070                                     _this.show_editor(_this.file, prop.parent, prop);
2071                                 });
2072                                   
2073                                 
2074                                 
2075                         });
2076                         this.el.bind.connect( (listitem) => {
2077                                  this.is_setting = true;
2078                         
2079                         
2080                                 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2081                          
2082                                 
2083                                 
2084                                 
2085                                 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2086                                 var lbl = (Gtk.Label) elbl.get_next_sibling();
2087                                 var cb  = (Gtk.DropDown) lbl.get_next_sibling();
2088                                 // decide if it's a combo or editable text..
2089                                 var model = (Gtk.StringList) cb.model;
2090                          
2091                                 elbl.hide();
2092                                 lbl.hide();
2093                                 cb.hide();
2094                                 
2095                                 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2096                                 //GLib.debug("prop = %s", prop.get_type().name());
2097                                 //GLib.debug("prop.val = %s", prop.val);
2098                                 //GLib.debug("prop.key = %s", prop.to_display_name());
2099                                  
2100                             var use_textarea =  prop.useTextArea();
2101                             
2102                             
2103                             var pal = _this.file.project.palete;
2104                                 
2105                             string[] opts;
2106                             var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2107                             
2108                             if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2109                                 use_textarea = true;
2110                             }
2111                             
2112                             
2113                             if (use_textarea) {
2114                                 prop.bind_property("val_short",
2115                                             lbl, "label",
2116                                            GLib.BindingFlags.SYNC_CREATE);
2117                                 prop.bind_property("val_tooltip",
2118                                             lbl, "tooltip_markup",
2119                                            GLib.BindingFlags.SYNC_CREATE);
2120                                 lbl.show();
2121                                         this.is_setting = false;        
2122                                 return;
2123                                 
2124                             }
2125                              
2126                                 
2127                                 
2128                                 
2129                                 
2130                                 // others... - fill in options for true/false?
2131                                    // GLib.debug (ktype.up());
2132                             if (has_opts) {
2133                                 
2134                                         while(model.get_n_items() > 0) {
2135                                                 model.remove(0);
2136                                         }
2137                                         cb.show();
2138                                         // can not remove - hopefully always empty.
2139                                         var sel = -1;
2140                                         for(var i = 0; i < opts.length; i ++) {
2141                                                 model.append( opts[i]);
2142                                                 // not sure this is a great idea... 
2143                                                 if (opts[i].down() == prop.val.down()) {
2144                                                         sel = i;
2145                                                 }
2146                                         }
2147                                         GLib.debug("Set selected item to %d", sel);
2148                                         cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION); 
2149                                         this.is_setting = false;        
2150                                         return ;
2151                             }
2152                                                           
2153                                 // see if type is a Enum.
2154                                 // triggers a changed event
2155                          
2156                                 elbl.set_text(prop.val);
2157                          
2158                                 elbl.show();
2159                                 this.is_setting = false;                         
2160                                 
2161                                 
2162                                 
2163                          
2164                         
2165                         });
2166                 }
2167
2168                 // user defined functions
2169         }
2170
2171
2172         public class Xcls_ContextMenu : Object
2173         {
2174                 public Gtk.Popover el;
2175                 private Xcls_LeftProps  _this;
2176
2177
2178                         // my vars (def)
2179
2180                 // ctor
2181                 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2182                 {
2183                         _this = _owner;
2184                         _this.ContextMenu = this;
2185                         this.el = new Gtk.Popover();
2186
2187                         // my vars (dec)
2188
2189                         // set gobject values
2190                         var child_1 = new Xcls_Box40( _this );
2191                         this.el.child = child_1.el;
2192                 }
2193
2194                 // user defined functions
2195         }
2196         public class Xcls_Box40 : Object
2197         {
2198                 public Gtk.Box el;
2199                 private Xcls_LeftProps  _this;
2200
2201
2202                         // my vars (def)
2203
2204                 // ctor
2205                 public Xcls_Box40(Xcls_LeftProps _owner )
2206                 {
2207                         _this = _owner;
2208                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2209
2210                         // my vars (dec)
2211
2212                         // set gobject values
2213                         var child_1 = new Xcls_Button41( _this );
2214                         child_1.ref();
2215                         this.el.append( child_1.el );
2216                 }
2217
2218                 // user defined functions
2219         }
2220         public class Xcls_Button41 : Object
2221         {
2222                 public Gtk.Button el;
2223                 private Xcls_LeftProps  _this;
2224
2225
2226                         // my vars (def)
2227
2228                 // ctor
2229                 public Xcls_Button41(Xcls_LeftProps _owner )
2230                 {
2231                         _this = _owner;
2232                         this.el = new Gtk.Button();
2233
2234                         // my vars (dec)
2235
2236                         // set gobject values
2237                         this.el.label = "Delete";
2238
2239                         //listeners
2240                         this.el.activate.connect( ( )  =>{
2241                                 _this.deleteSelected();
2242                                 
2243                         });
2244                 }
2245
2246                 // user defined functions
2247         }
2248
2249
2250
2251
2252
2253 }