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