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