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