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