src/Builder4/WindowLeftProps.bjs
[app.Builder.js] / src / Builder4 / WindowLeftProps.vala
1 static Xcls_LeftProps  _LeftProps;
2
3 public class Xcls_LeftProps : Object 
4 {
5     public Gtk.VBox 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_model model;
19     public Xcls_keycol keycol;
20     public Xcls_keyrender keyrender;
21     public Xcls_valcol valcol;
22     public Xcls_valrender valrender;
23     public Xcls_valrendermodel valrendermodel;
24     public Xcls_ContextMenu ContextMenu;
25
26         // my vars (def)
27     public bool allow_edit;
28     public JsRender.JsRender file;
29     public signal bool stop_editor ();
30     public signal void show_editor (JsRender.JsRender file, JsRender.Node node, string type, string key);
31     public signal void changed ();
32     public signal void show_add_props (string type);
33     public Xcls_MainWindow main_window;
34     public JsRender.Node node;
35
36     // ctor 
37     public Xcls_LeftProps()
38     {
39         _this = this;
40         this.el = new Gtk.VBox( false   , 0 );
41
42         // my vars (dec)
43         this.allow_edit = false;
44         this.main_window = null;
45
46         // set gobject values
47         var child_0 = new Xcls_HBox2( _this );
48         child_0.ref();
49         this.el.pack_start (  child_0.el , false,true,0 );
50         var child_1 = new Xcls_EditProps( _this );
51         child_1.ref();
52         this.el.pack_end (  child_1.el , true,true,0 );
53     }
54
55     // user defined functions 
56     public              void before_edit ()
57     {
58     
59         print("before edit - stop editing\n");
60         
61       // these do not appear to trigger save...
62         _this.keyrender.el.stop_editing(false);
63         _this.keyrender.el.editable  =false;
64     
65         _this.valrender.el.stop_editing(false);
66         _this.valrender.el.editable  =false;    
67         
68         
69     // technicall stop the popup editor..
70     
71     }
72     public              string keySortFormat (string key) {
73         // listeners first - with 0
74         // specials
75         if (key[0] == '*') {
76             return "1 " + key;
77         }
78         // functions
79         
80         var bits = key.split(" ");
81         
82         if (key[0] == '|') {
83             return "2 " + bits[bits.length -1];
84         }
85         // signals
86         if (key[0] == '@') {
87             return "3 " + bits[bits.length -1];
88         }
89             
90         // props
91         if (key[0] == '#') {
92             return "4 " + bits[bits.length -1];
93         }
94         // the rest..
95         return "5 " + bits[bits.length -1];    
96     
97     
98     
99     }
100     public              void finish_editing () {
101          // 
102         this.before_edit();
103     }
104     public              bool startEditingValue ( Gtk.TreePath path) {
105     
106         // ONLY return true if editing is allowed - eg. combo..
107         
108                 print("start editing?\n");
109                 if (!this.stop_editor()) {
110                     print("stop editor failed\n");
111                     return false;
112                 }
113                 
114                 Gtk.TreeIter iter;
115     
116                 var mod = this.model.el;
117                 mod.get_iter (out iter, path);
118                  
119                 /*
120                     m.set(iter, 
121                             0, "listener",
122                             1, miter.get_key(),
123                             2, "<b>" + miter.get_key() + "</b>",
124                             3, miter.get_value()
125                         ); 
126                  
127                 */
128                 GLib.Value gval;
129                 mod.get_value(iter, 3 , out gval);
130                 var val = (string)gval;
131             
132                 mod.get_value(iter, 1 , out gval);
133                 var key = (string)gval;
134                 var type_ar = key.split(" ");
135                 
136                 
137                 
138                 mod.get_value(iter, 0 , out gval);
139                 var type = (string)gval;
140                 
141                
142                 
143                 var use_textarea = false;
144     
145                 //------------ things that require the text editor...
146                 
147                 if (type == "listener") {
148                     use_textarea = true;
149                 }
150                 if (key.length > 0 && key[0] == '|') { // user defined method
151                     use_textarea = true;
152                 }
153                 if (key.length > 0 && key[0] == '$') { // raw string
154                     use_textarea = true;
155                 }
156                 if (key.length > 0 && key == "* init") {
157                     use_textarea = true;
158                 }
159                 if (val.length > 40) { // long value...
160                     use_textarea = true;
161                 }
162                 
163                 
164                 
165                 if (use_textarea) {
166                     print("Call show editor\n");
167                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
168                         this.view.el.get_selection().select_path(path);
169                         
170                         this.show_editor(file, node, type, key);
171                         
172                         return false;
173                     });
174                    
175                     
176                     return false;
177                 }
178                 // others... - fill in options for true/false?
179                print("turn on editing %s \n" , mod.get_path(iter).to_string());
180                
181                    print (type_ar[0].up());
182                     if (type_ar.length > 1 && (
183                             type_ar[0].up() == "BOOLEAN"
184                             ||
185                             type_ar[0].up() == "BOOL"                        
186                         )) {
187                             print("start editing try/false)???");
188                             this.valrender.el.has_entry = false;
189                             string[] opts =  { "true", "false" };
190                             this.valrender.setOptions(opts);
191                             
192                             this.valrender.el.has_entry = false;
193                             this.valrender.el.editable = true;
194                              this.allow_edit  = true;
195                              GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
196                                  this.view.el.set_cursor_on_cell(
197                                     path,
198                                     this.valcol.el,
199                                     this.valrender.el,
200                                     true
201                                 );
202                                 return false;
203                             });
204                             return true;
205                     }
206                                           
207                     
208                
209                  string[] opts =  {  };
210                 this.valrender.setOptions(opts);
211                
212                GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
213                     
214                     // at this point - work out the type...
215                     // if its' a combo... then show the options..
216                     this.valrender.el.has_entry = true;
217                     
218                     this.valrender.el.editable = true;            
219                 
220                     
221                     this.allow_edit  = true;
222                     
223                     
224                     
225                     
226     
227                     this.view.el.set_cursor_on_cell(
228                         path,
229                         this.valcol.el,
230                         this.valrender.el,
231                         true
232                     );
233                     return false;
234                 });
235                 return false;
236             }
237     public              void load (JsRender.JsRender file, JsRender.Node? node) 
238     {
239         print("load leftprops\n");
240         this.before_edit();
241         this.node = node;
242         this.file = file;
243         
244      
245         this.model.el.clear();
246                   
247         //this.get('/RightEditor').el.hide();
248         if (node ==null) {
249             return ;
250         }
251          
252         
253     
254         //var provider = this.get('/LeftTree').getPaleteProvider();
255         Gtk.TreeIter iter;
256         
257         //typeof(string),  // 0 key type
258          //typeof(string),  // 1 key
259          //typeof(string),  // 2 key (display)
260          //typeof(string),  // 3 value
261          //typeof(string),  // 4 value (display)
262          //typeof(string),  // 5 both (tooltip)
263         
264         
265         
266         
267         // really need a way to sort the hashmap...
268         var m = this.model.el;
269         
270         var miter = node.listeners.map_iterator();
271         var i = 0;
272         
273         while(miter.next()) {
274             i++;
275             m.append(out iter,null);
276             
277             this.updateIter(iter,  "listener", miter.get_key(), miter.get_value());
278             
279              
280          }
281          
282           
283         miter = node.props.map_iterator();
284         
285         
286        while(miter.next()) {
287                i++;
288             m.append(out iter,null);
289              this.updateIter(iter,  "prop", miter.get_key(), miter.get_value());
290              
291        }
292        print("clear selection\n");
293        // clear selection?
294        this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..
295        
296        this.view.el.get_selection().unselect_all();
297        
298            var pane = _this.main_window.editpane.el;
299         var try_size = (i * 25) + 60; // est. 20px per line + 40px header
300         
301         // max 80%...
302         pane.set_position( 
303              ((try_size * 1.0f) /  (pane.max_position * 1.0f))  > 0.8f  ? 
304             (int) (pane.max_position * 0.2f) :
305             pane.max_position-try_size);
306         
307        
308     }
309     public              string keyFormat (string val, string type) {
310         
311         // Glib.markup_escape_text(val);
312     
313         if (type == "listener") {
314             return "<span font_weight=\"bold\" color=\"#660000\">" + 
315                 GLib.Markup.escape_text(val) +
316                  "</span>";
317         }
318         // property..
319         if (val.length < 1) {
320             return "<span  color=\"#FF0000\">--empty--</span>";
321         }
322         
323         //@ = signal
324         //$ = property with 
325         //# - object properties
326         //* = special
327         // all of these... - display value is last element..
328         var ar = val.strip().split(" ");
329         
330         
331         var dval = GLib.Markup.escape_text(ar[ar.length-1]);
332         
333         
334         
335         
336         switch(val[0]) {
337             case '@': // signal // just bold balck?
338                 if (dval[0] == '@') {
339                     dval = dval.substring(1);
340                 }
341             
342                 return @"<span  font_weight=\"bold\">@ $dval</span>";        
343             case '#': // object properties?
344                 if (dval[0] == '#') {
345                     dval = dval.substring(1);
346                 }
347                 return @"<span  font_weight=\"bold\">$dval</span>";
348             case '*': // special
349                 if (dval[0] == '*') {
350                     dval = dval.substring(1);
351                 }
352                 return @"<span   color=\"#0000CC\" font_weight=\"bold\">$dval</span>";            
353             case '$':
354                 if (dval[0] == '$') {
355                     dval = dval.substring(1);
356                 }
357                 return @"<span   style=\"italic\">$dval</span>";
358            case '|': // user defined methods
359                 if (dval[0] == '|') {
360                     dval = dval.substring(1);
361                 }
362                 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
363                 
364                   
365                 
366             default:
367                 return dval;
368         }
369           
370         
371     
372     }
373     public              void deleteSelected () {
374         
375             Gtk.TreeIter iter;
376             Gtk.TreeModel mod;
377             
378             var s = this.view.el.get_selection();
379             s.get_selected(out mod, out iter);
380                  
381                   
382             GLib.Value gval;
383             mod.get_value(iter, 0 , out gval);
384             var type = (string)gval;
385             
386             mod.get_value(iter, 1 , out gval);
387             var key = (string)gval;
388             
389             switch(type) {
390                 case "listener":
391                     this.node.listeners.remove(key);
392                     break;
393                     
394                 case "props":
395                     this.node.props.remove(key);
396                     break;
397             }
398             this.load(this.file, this.node);
399             
400             _this.changed();
401     }
402     public              void startEditingKey ( Gtk.TreePath path) {
403         
404          if (!this.stop_editor()) {
405             return;
406          }
407       
408         // others... - fill in options for true/false?
409         
410            
411         GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
412             this.allow_edit  = true;
413             this.keyrender.el.editable = true;
414          
415             this.view.el.set_cursor_on_cell(
416                 path,
417                 this.keycol.el,
418                 this.keyrender.el,
419                 true
420             );
421                    
422             return false;
423         });
424           
425         
426     }
427     public              void addProp (string in_type, string key, string value, string value_type) {
428           // info includes key, val, skel, etype..
429           //console.dump(info);
430             //type = info.type.toLowerCase();
431             //var data = this.toJS();
432               
433         var type = in_type == "signals" ? "listener" : in_type;
434           
435         var fkey = (value_type.length > 0 ? value_type + " " : "") + key;
436                   
437         if (type == "listener") {
438             if (this.node.listeners.has_key(key)) {
439                 return;
440             }
441             this.node.listeners.set(key,value);
442         } else  {
443         
444             if (this.node.props.has_key(fkey)) {
445                 return;
446             }
447             this.node.props.set(fkey,value);
448         }
449                
450           
451         // add a row???
452         this.load(this.file, this.node);
453         
454         
455         
456         /// need to find the row which I've just added..
457         
458         
459         var s = this.view.el.get_selection();
460         s.unselect_all();
461         
462         print("trying to find new iter");
463       
464         this.model.el.foreach((model, path, iter) => {
465             GLib.Value gval;
466         
467             this.model.el.get_value(iter, 0 , out gval);
468             if ((string)gval != type) {
469                 print("not type: %s = %s\n", (string)gval , type);
470                 return false;
471             }
472             this.model.el.get_value(iter, 1 , out gval);
473             if ((string)gval != fkey) {
474                 print("not key: %s = %s\n", (string)gval , fkey);
475                 return false;
476             }
477             // delay this?
478             GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {
479             
480                 this.startEditingValue(this.model.el.get_path(iter));
481                 return false;
482             });
483             //s.select_iter(iter);
484             return true; 
485         });
486         
487         
488         
489                   
490     }
491     public              void updateIter (Gtk.TreeIter iter,  string type, string key, string value) {
492     
493         print("update Iter %s, %s\n", key,value);
494         //typeof(string),  // 0 key type
495          //typeof(string),  // 1 key
496          //typeof(string),  // 2 key (display)
497          //typeof(string),  // 3 value
498          //typeof(string),  // 4 value (display)
499          //typeof(string),  // 5 both (tooltip)
500          //typeof(string),  // 6 key (sort)
501         
502         var dl = value.strip().split("\n");
503     
504         var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0];
505         
506         if (type == "listener") {
507          
508            
509             
510             this.model.el.set(iter, 
511                     0, type,
512                 1, key,
513                 2, this.keyFormat(key ,type),
514                 3, value,
515                 4, dis_val,
516                 5, "<tt>" +  GLib.Markup.escape_text(key + " " +value) + "</tt>",
517                 6,  "0 " + key
518             ); 
519             return;
520         }
521         
522     
523     
524         this.model.el.set(iter, 
525                 0, "props",
526                 1, key,
527                 2,  this.keyFormat(key , "prop"),
528                 3, value,
529                 4, dis_val,
530                  5, "<tt>" + GLib.Markup.escape_text(key + " " + value) + "</tt>",
531                  6,  this.keySortFormat(key)
532             ); 
533     }
534     public class Xcls_HBox2 : Object 
535     {
536         public Gtk.HBox el;
537         private Xcls_LeftProps  _this;
538
539
540             // my vars (def)
541
542         // ctor 
543         public Xcls_HBox2(Xcls_LeftProps _owner )
544         {
545             _this = _owner;
546             this.el = new Gtk.HBox( true, 0 );
547
548             // my vars (dec)
549
550             // set gobject values
551             var child_0 = new Xcls_Button3( _this );
552             child_0.ref();
553             this.el.add (  child_0.el  );
554         }
555
556         // user defined functions 
557     }
558     public class Xcls_Button3 : Object 
559     {
560         public Gtk.Button el;
561         private Xcls_LeftProps  _this;
562
563
564             // my vars (def)
565
566         // ctor 
567         public Xcls_Button3(Xcls_LeftProps _owner )
568         {
569             _this = _owner;
570             this.el = new Gtk.Button();
571
572             // my vars (dec)
573
574             // set gobject values
575             var child_0 = new Xcls_HBox4( _this );
576             child_0.ref();
577             this.el.add (  child_0.el  );
578             var child_1 = new Xcls_AddPropertyPopup( _this );
579             child_1.ref();
580
581             // listeners 
582             this.el.button_press_event.connect( (self, ev) => {
583                 _this.before_edit();
584                 
585                     
586                 var p = _this.AddPropertyPopup;
587                 p.el.set_screen(Gdk.Screen.get_default());
588                 p.el.show_all();
589                  p.el.popup(null, null, null, ev.button, ev.time);
590                  return true;
591             });
592         }
593
594         // user defined functions 
595     }
596     public class Xcls_HBox4 : Object 
597     {
598         public Gtk.HBox el;
599         private Xcls_LeftProps  _this;
600
601
602             // my vars (def)
603
604         // ctor 
605         public Xcls_HBox4(Xcls_LeftProps _owner )
606         {
607             _this = _owner;
608             this.el = new Gtk.HBox( true, 0 );
609
610             // my vars (dec)
611
612             // set gobject values
613             var child_0 = new Xcls_Image5( _this );
614             child_0.ref();
615             this.el.add (  child_0.el  );
616             var child_1 = new Xcls_Label6( _this );
617             child_1.ref();
618             this.el.add (  child_1.el  );
619         }
620
621         // user defined functions 
622     }
623     public class Xcls_Image5 : Object 
624     {
625         public Gtk.Image el;
626         private Xcls_LeftProps  _this;
627
628
629             // my vars (def)
630
631         // ctor 
632         public Xcls_Image5(Xcls_LeftProps _owner )
633         {
634             _this = _owner;
635             this.el = new Gtk.Image();
636
637             // my vars (dec)
638
639             // set gobject values
640             this.el.stock = Gtk.STOCK_ADD;
641             this.el.icon_size = Gtk.IconSize.MENU;
642         }
643
644         // user defined functions 
645     }
646     public class Xcls_Label6 : Object 
647     {
648         public Gtk.Label el;
649         private Xcls_LeftProps  _this;
650
651
652             // my vars (def)
653
654         // ctor 
655         public Xcls_Label6(Xcls_LeftProps _owner )
656         {
657             _this = _owner;
658             this.el = new Gtk.Label( "Other" );
659
660             // my vars (dec)
661
662             // set gobject values
663         }
664
665         // user defined functions 
666     }
667     public class Xcls_AddPropertyPopup : Object 
668     {
669         public Gtk.Menu el;
670         private Xcls_LeftProps  _this;
671
672
673             // my vars (def)
674
675         // ctor 
676         public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
677         {
678             _this = _owner;
679             _this.AddPropertyPopup = this;
680             this.el = new Gtk.Menu();
681
682             // my vars (dec)
683
684             // set gobject values
685             var child_0 = new Xcls_MenuItem8( _this );
686             child_0.ref();
687             this.el.append (  child_0.el  );
688             var child_1 = new Xcls_MenuItem9( _this );
689             child_1.ref();
690             this.el.append (  child_1.el  );
691             var child_2 = new Xcls_MenuItem10( _this );
692             child_2.ref();
693             this.el.append (  child_2.el  );
694             var child_3 = new Xcls_MenuItem11( _this );
695             child_3.ref();
696             this.el.append (  child_3.el  );
697             var child_4 = new Xcls_SeparatorMenuItem12( _this );
698             child_4.ref();
699             this.el.add (  child_4.el  );
700             var child_5 = new Xcls_MenuItem13( _this );
701             child_5.ref();
702             this.el.append (  child_5.el  );
703             var child_6 = new Xcls_MenuItem14( _this );
704             child_6.ref();
705             this.el.append (  child_6.el  );
706             var child_7 = new Xcls_MenuItem15( _this );
707             child_7.ref();
708             this.el.append (  child_7.el  );
709             var child_8 = new Xcls_SeparatorMenuItem16( _this );
710             child_8.ref();
711             this.el.add (  child_8.el  );
712             var child_9 = new Xcls_MenuItem17( _this );
713             child_9.ref();
714             this.el.append (  child_9.el  );
715             var child_10 = new Xcls_MenuItem18( _this );
716             child_10.ref();
717             this.el.append (  child_10.el  );
718             var child_11 = new Xcls_MenuItem19( _this );
719             child_11.ref();
720             this.el.append (  child_11.el  );
721         }
722
723         // user defined functions 
724     }
725     public class Xcls_MenuItem8 : Object 
726     {
727         public Gtk.MenuItem el;
728         private Xcls_LeftProps  _this;
729
730
731             // my vars (def)
732
733         // ctor 
734         public Xcls_MenuItem8(Xcls_LeftProps _owner )
735         {
736             _this = _owner;
737             this.el = new Gtk.MenuItem();
738
739             // my vars (dec)
740
741             // set gobject values
742             this.el.tooltip_markup = "Using _this.{ID} will map to this element";
743             this.el.label = "id: _this.{ID} (Vala)";
744
745             // listeners 
746             this.el.activate.connect( ()  => {
747                 _this.addProp( "prop", "id", "", "");
748             });
749         }
750
751         // user defined functions 
752     }
753     public class Xcls_MenuItem9 : Object 
754     {
755         public Gtk.MenuItem el;
756         private Xcls_LeftProps  _this;
757
758
759             // my vars (def)
760
761         // ctor 
762         public Xcls_MenuItem9(Xcls_LeftProps _owner )
763         {
764             _this = _owner;
765             this.el = new Gtk.MenuItem();
766
767             // my vars (dec)
768
769             // set gobject values
770             this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
771             this.el.label = "pack: Pack method (Vala)";
772
773             // listeners 
774             this.el.activate.connect( ( ) => {
775             
776                 _this.addProp( "prop", "pack","add", "*");
777             });
778         }
779
780         // user defined functions 
781     }
782     public class Xcls_MenuItem10 : Object 
783     {
784         public Gtk.MenuItem el;
785         private Xcls_LeftProps  _this;
786
787
788             // my vars (def)
789
790         // ctor 
791         public Xcls_MenuItem10(Xcls_LeftProps _owner )
792         {
793             _this = _owner;
794             this.el = new Gtk.MenuItem();
795
796             // my vars (dec)
797
798             // set gobject values
799             this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
800             this.el.label = "ctor: Alterative to default contructor";
801
802             // listeners 
803             this.el.activate.connect( ( ) => {
804             
805                 _this.addProp( "prop", "ctor","", "*");
806             });
807         }
808
809         // user defined functions 
810     }
811     public class Xcls_MenuItem11 : Object 
812     {
813         public Gtk.MenuItem el;
814         private Xcls_LeftProps  _this;
815
816
817             // my vars (def)
818
819         // ctor 
820         public Xcls_MenuItem11(Xcls_LeftProps _owner )
821         {
822             _this = _owner;
823             this.el = new Gtk.MenuItem();
824
825             // my vars (dec)
826
827             // set gobject values
828             this.el.tooltip_markup = "This code is called after the ctor";
829             this.el.label = "init: initialziation code (vala)";
830
831             // listeners 
832             this.el.activate.connect( ( ) => {
833             
834                 _this.addProp( "prop",  "init", "{\n\n}\n", "*" );
835             });
836         }
837
838         // user defined functions 
839     }
840     public class Xcls_SeparatorMenuItem12 : Object 
841     {
842         public Gtk.SeparatorMenuItem el;
843         private Xcls_LeftProps  _this;
844
845
846             // my vars (def)
847
848         // ctor 
849         public Xcls_SeparatorMenuItem12(Xcls_LeftProps _owner )
850         {
851             _this = _owner;
852             this.el = new Gtk.SeparatorMenuItem();
853
854             // my vars (dec)
855
856             // set gobject values
857         }
858
859         // user defined functions 
860     }
861     public class Xcls_MenuItem13 : Object 
862     {
863         public Gtk.MenuItem el;
864         private Xcls_LeftProps  _this;
865
866
867             // my vars (def)
868
869         // ctor 
870         public Xcls_MenuItem13(Xcls_LeftProps _owner )
871         {
872             _this = _owner;
873             this.el = new Gtk.MenuItem();
874
875             // my vars (dec)
876
877             // set gobject values
878             this.el.tooltip_markup = "Add a user defined string property";
879             this.el.label = "String";
880
881             // listeners 
882             this.el.activate.connect( (self) => {
883             
884                 _this.addProp( "prop", "XXXX", "","string");
885             
886             });
887         }
888
889         // user defined functions 
890     }
891     public class Xcls_MenuItem14 : Object 
892     {
893         public Gtk.MenuItem el;
894         private Xcls_LeftProps  _this;
895
896
897             // my vars (def)
898
899         // ctor 
900         public Xcls_MenuItem14(Xcls_LeftProps _owner )
901         {
902             _this = _owner;
903             this.el = new Gtk.MenuItem();
904
905             // my vars (dec)
906
907             // set gobject values
908             this.el.tooltip_markup = "Add a user defined number property";
909             this.el.label = "Number";
910
911             // listeners 
912             this.el.activate.connect( ( ) =>{
913             
914                 _this.addProp("prop",  "XXX", "0", "int");
915             });
916         }
917
918         // user defined functions 
919     }
920     public class Xcls_MenuItem15 : Object 
921     {
922         public Gtk.MenuItem el;
923         private Xcls_LeftProps  _this;
924
925
926             // my vars (def)
927
928         // ctor 
929         public Xcls_MenuItem15(Xcls_LeftProps _owner )
930         {
931             _this = _owner;
932             this.el = new Gtk.MenuItem();
933
934             // my vars (dec)
935
936             // set gobject values
937             this.el.tooltip_markup = "Add a user defined boolean property";
938             this.el.label = "Boolean";
939
940             // listeners 
941             this.el.activate.connect( ( ) =>{
942             
943                 _this.addProp( "prop", "XXX", "true", "bool");
944             });
945         }
946
947         // user defined functions 
948     }
949     public class Xcls_SeparatorMenuItem16 : Object 
950     {
951         public Gtk.SeparatorMenuItem el;
952         private Xcls_LeftProps  _this;
953
954
955             // my vars (def)
956
957         // ctor 
958         public Xcls_SeparatorMenuItem16(Xcls_LeftProps _owner )
959         {
960             _this = _owner;
961             this.el = new Gtk.SeparatorMenuItem();
962
963             // my vars (dec)
964
965             // set gobject values
966         }
967
968         // user defined functions 
969     }
970     public class Xcls_MenuItem17 : Object 
971     {
972         public Gtk.MenuItem el;
973         private Xcls_LeftProps  _this;
974
975
976             // my vars (def)
977
978         // ctor 
979         public Xcls_MenuItem17(Xcls_LeftProps _owner )
980         {
981             _this = _owner;
982             this.el = new Gtk.MenuItem();
983
984             // my vars (dec)
985
986             // set gobject values
987             this.el.tooltip_markup = "Add a user function boolean property";
988             this.el.label = "Javascript Function";
989
990             // listeners 
991             this.el.activate.connect( ( ) =>{
992             
993                 _this.addProp("prop",  "XXXX", "function() { }", "| function");
994             });
995         }
996
997         // user defined functions 
998     }
999     public class Xcls_MenuItem18 : Object 
1000     {
1001         public Gtk.MenuItem el;
1002         private Xcls_LeftProps  _this;
1003
1004
1005             // my vars (def)
1006
1007         // ctor 
1008         public Xcls_MenuItem18(Xcls_LeftProps _owner )
1009         {
1010             _this = _owner;
1011             this.el = new Gtk.MenuItem();
1012
1013             // my vars (dec)
1014
1015             // set gobject values
1016             this.el.tooltip_markup = "Add a user function boolean property";
1017             this.el.label = "Vala Method";
1018
1019             // listeners 
1020             this.el.activate.connect( ( ) =>{
1021             
1022                 _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
1023             });
1024         }
1025
1026         // user defined functions 
1027     }
1028     public class Xcls_MenuItem19 : Object 
1029     {
1030         public Gtk.MenuItem el;
1031         private Xcls_LeftProps  _this;
1032
1033
1034             // my vars (def)
1035
1036         // ctor 
1037         public Xcls_MenuItem19(Xcls_LeftProps _owner )
1038         {
1039             _this = _owner;
1040             this.el = new Gtk.MenuItem();
1041
1042             // my vars (dec)
1043
1044             // set gobject values
1045             this.el.tooltip_markup = "Add a vala signal";
1046             this.el.label = "Vala Signal";
1047
1048             // listeners 
1049             this.el.activate.connect( ( ) =>{
1050             
1051                 _this.addProp( "prop", "XXXX", "()", "@ void");
1052             });
1053         }
1054
1055         // user defined functions 
1056     }
1057     public class Xcls_EditProps : Object 
1058     {
1059         public Gtk.ScrolledWindow el;
1060         private Xcls_LeftProps  _this;
1061
1062
1063             // my vars (def)
1064         public bool editing;
1065
1066         // ctor 
1067         public Xcls_EditProps(Xcls_LeftProps _owner )
1068         {
1069             _this = _owner;
1070             _this.EditProps = this;
1071             this.el = new Gtk.ScrolledWindow( null, null );
1072
1073             // my vars (dec)
1074             this.editing = false;
1075
1076             // set gobject values
1077             this.el.shadow_type = Gtk.ShadowType.IN;
1078             var child_0 = new Xcls_view( _this );
1079             child_0.ref();
1080             this.el.add (  child_0.el  );
1081
1082             // init method 
1083
1084             {
1085               
1086                this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1087             }        }
1088
1089         // user defined functions 
1090     }
1091     public class Xcls_view : Object 
1092     {
1093         public Gtk.TreeView el;
1094         private Xcls_LeftProps  _this;
1095
1096
1097             // my vars (def)
1098
1099         // ctor 
1100         public Xcls_view(Xcls_LeftProps _owner )
1101         {
1102             _this = _owner;
1103             _this.view = this;
1104             this.el = new Gtk.TreeView();
1105
1106             // my vars (dec)
1107
1108             // set gobject values
1109             this.el.tooltip_column = 5;
1110             this.el.enable_tree_lines = true;
1111             this.el.headers_visible = true;
1112             var child_0 = new Xcls_model( _this );
1113             child_0.ref();
1114             this.el.set_model (  child_0.el  );
1115             var child_1 = new Xcls_keycol( _this );
1116             child_1.ref();
1117             this.el.append_column (  child_1.el  );
1118             var child_2 = new Xcls_valcol( _this );
1119             child_2.ref();
1120             this.el.append_column (  child_2.el  );
1121             var child_3 = new Xcls_ContextMenu( _this );
1122             child_3.ref();
1123
1124             // init method 
1125
1126             {
1127                 var selection = this.el.get_selection();
1128                 selection.set_mode( Gtk.SelectionMode.SINGLE);
1129             
1130             
1131                 var description = new Pango.FontDescription();
1132                 description.set_size(8000);
1133                 this.el.modify_font(description);
1134             }
1135             // listeners 
1136             this.el.button_press_event.connect( ( ev)  => {
1137              
1138                 Gtk.TreeViewColumn col;
1139                 int cell_x;
1140                 int cell_y;
1141                 Gtk.TreePath path;
1142                 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
1143                     print("nothing selected on click");
1144                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1145                         this.el.get_selection().unselect_all();
1146             
1147                         return false;
1148                     });
1149                      _this.before_edit();
1150                     return false; //not on a element.
1151                 }
1152                 
1153                 
1154                  // right click.
1155                  if (ev.type == Gdk.EventType.2BUTTON_PRESS  && ev.button == 1 && col.title == "Name") {    
1156                     // show popup!.   
1157                     
1158              
1159                      _this.before_edit();
1160                      
1161                      _this.keyrender.el.stop_editing(false);
1162                      _this.keyrender.el.editable  =false;
1163                 
1164                      _this.valrender.el.stop_editing(false);
1165                      _this.valrender.el.editable  =false;
1166                        
1167                       _this.startEditingKey(path); 
1168                      
1169                     return false;
1170                 }
1171                 
1172                 
1173                 
1174                 
1175                  // right click.
1176                  if (ev.type == Gdk.EventType.BUTTON_PRESS  && ev.button == 3) {    
1177                     // show popup!.   
1178                     //if (col.title == "Value") {
1179                      //     _this.before_edit();
1180                      //    return false;
1181                      //}
1182             
1183                     var p = _this.ContextMenu;
1184             
1185                     p.el.set_screen(Gdk.Screen.get_default());
1186                     p.el.show_all();
1187                     p.el.popup(null, null, null,  ev.button, ev.time);
1188                     //Seed.print("click:" + res.column.title);
1189                     // select the 
1190                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1191               
1192                         this.el.get_selection().select_path(path);
1193                         return false;
1194                     });
1195                      _this.before_edit();
1196                     return false;
1197                 }
1198                 
1199                  
1200                 if (col.title != "Value") {
1201                     print("col title != Value");
1202                     
1203                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1204                         this.el.get_selection().select_path(path);
1205                         return false;
1206                     });
1207                     
1208                     _this.before_edit();
1209                       //  XObject.error("column is not value?");
1210                     return false; // ignore.. - key click.. ??? should we do this??
1211                 }
1212                 
1213                 
1214                 // if the cell can be edited with a pulldown
1215                 // then we should return true... - and let the start_editing handle it?
1216                 
1217                 
1218                 
1219                 
1220                 
1221                   
1222                //             _this.before_edit(); <<< we really need to stop the other editor..
1223                  _this.keyrender.el.stop_editing(false);
1224                 _this.keyrender.el.editable  =false;
1225                 
1226                        
1227                 return _this.startEditingValue(path); // assumes selected row..
1228                     
1229                
1230             
1231                           
1232                
1233             });
1234         }
1235
1236         // user defined functions 
1237     }
1238     public class Xcls_model : Object 
1239     {
1240         public Gtk.TreeStore el;
1241         private Xcls_LeftProps  _this;
1242
1243
1244             // my vars (def)
1245
1246         // ctor 
1247         public Xcls_model(Xcls_LeftProps _owner )
1248         {
1249             _this = _owner;
1250             _this.model = this;
1251             this.el = new Gtk.TreeStore( 7,      typeof(string),  // 0 key type
1252      typeof(string),  // 1 key
1253      typeof(string),  // 2 key (display)
1254      typeof(string),  // 3 value
1255      typeof(string),   // 4 value (display)
1256      typeof(string),   // 5 both (tooltip)     
1257      typeof(string)   // 6 key (for sorting)
1258  );
1259
1260             // my vars (dec)
1261
1262             // set gobject values
1263         }
1264
1265         // user defined functions 
1266     }
1267     public class Xcls_keycol : Object 
1268     {
1269         public Gtk.TreeViewColumn el;
1270         private Xcls_LeftProps  _this;
1271
1272
1273             // my vars (def)
1274
1275         // ctor 
1276         public Xcls_keycol(Xcls_LeftProps _owner )
1277         {
1278             _this = _owner;
1279             _this.keycol = this;
1280             this.el = new Gtk.TreeViewColumn();
1281
1282             // my vars (dec)
1283
1284             // set gobject values
1285             this.el.title = "Name";
1286             this.el.resizable = true;
1287             var child_0 = new Xcls_keyrender( _this );
1288             child_0.ref();
1289             this.el.pack_start (  child_0.el , false );
1290
1291             // init method 
1292
1293             this.el.add_attribute(_this.keyrender.el , "markup", 2 );
1294              this.el.add_attribute(_this.keyrender.el , "text", 1 );        }
1295
1296         // user defined functions 
1297     }
1298     public class Xcls_keyrender : Object 
1299     {
1300         public Gtk.CellRendererText el;
1301         private Xcls_LeftProps  _this;
1302
1303
1304             // my vars (def)
1305
1306         // ctor 
1307         public Xcls_keyrender(Xcls_LeftProps _owner )
1308         {
1309             _this = _owner;
1310             _this.keyrender = this;
1311             this.el = new Gtk.CellRendererText();
1312
1313             // my vars (dec)
1314
1315             // set gobject values
1316
1317             // listeners 
1318             this.el.editing_started.connect( (  editable, path) => {
1319             
1320                  Gtk.TreeIter  iter;
1321                 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1322                 GLib.Value gval;
1323                               
1324             
1325             
1326                  //   this.get('/LeftPanel.model').activePath  = path;
1327                 _this.model.el.get_value(iter,1, out gval);
1328                     var val = (string)gval;
1329                              
1330                     ((Gtk.Entry)editable).set_text(val);                 
1331             });
1332             this.el.edited.connect( (path, newtext) => {
1333                     print("Keyrender  - signal:edited\n");
1334                 
1335                 this.el.editable = false;
1336               
1337              
1338             
1339                     Gtk.TreeIter  iter;
1340                     _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1341                     GLib.Value gval;
1342                     
1343                      _this.model.el.get_value(iter,1, out gval);
1344                     var oldval = (string)gval;
1345                     
1346                      _this.model.el.get_value(iter,0, out gval);
1347                     var ktype = (string)gval;
1348                    
1349                     _this.model.el.set_value(iter, 1, newtext);
1350                     
1351                     if (oldval == newtext) {
1352                         return;
1353                     }
1354                     
1355                     
1356                     print("ktype: %s\n",ktype);
1357                     switch(ktype) {
1358                         case "listener":
1359                             var ov = _this.node.listeners.get(oldval);
1360                             _this.node.listeners.set(newtext, ov);
1361                             _this.node.listeners.remove(oldval);
1362                             
1363                             _this.updateIter(iter,  ktype, newtext, ov);
1364                             
1365                             break;
1366                         case "props":
1367                             var ov = _this.node.props.get(oldval);
1368                             _this.node.props.set(newtext, ov);
1369                             _this.node.props.remove(oldval);
1370                             _this.updateIter(iter,  ktype, newtext, ov);
1371                             break;
1372                      }
1373                      _this.changed();
1374                       
1375             });
1376         }
1377
1378         // user defined functions 
1379     }
1380     public class Xcls_valcol : Object 
1381     {
1382         public Gtk.TreeViewColumn el;
1383         private Xcls_LeftProps  _this;
1384
1385
1386             // my vars (def)
1387
1388         // ctor 
1389         public Xcls_valcol(Xcls_LeftProps _owner )
1390         {
1391             _this = _owner;
1392             _this.valcol = this;
1393             this.el = new Gtk.TreeViewColumn();
1394
1395             // my vars (dec)
1396
1397             // set gobject values
1398             this.el.title = "Value";
1399             this.el.resizable = true;
1400             var child_0 = new Xcls_valrender( _this );
1401             child_0.ref();
1402             this.el.pack_start (  child_0.el , true );
1403
1404             // init method 
1405
1406             {
1407                 
1408                 //     typeof(string),  // 0 key type
1409                 // typeof(string),  // 1 key
1410                 // typeof(string),  // 2 key (display)
1411                 // typeof(string),  // 3 value
1412                 // typeof(string)   // 4 value (display)
1413             
1414                 
1415                 this.el.add_attribute(_this.valrender.el , "text", 4 );
1416                 //this.el.add_attribute(_this.valrender.el , "sensitive", 4 );
1417                 //this.el.add_attribute(this.items[0].el , 'editable', 3 );
1418                       // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1419             
1420              // this.get('/LeftPanel').editableColumn= this;
1421             }        }
1422
1423         // user defined functions 
1424     }
1425     public class Xcls_valrender : Object 
1426     {
1427         public Gtk.CellRendererCombo el;
1428         private Xcls_LeftProps  _this;
1429
1430
1431             // my vars (def)
1432
1433         // ctor 
1434         public Xcls_valrender(Xcls_LeftProps _owner )
1435         {
1436             _this = _owner;
1437             _this.valrender = this;
1438             this.el = new Gtk.CellRendererCombo();
1439
1440             // my vars (dec)
1441
1442             // set gobject values
1443             this.el.editable = false;
1444             this.el.text_column = 0;
1445             this.el.has_entry = true;
1446             var child_0 = new Xcls_valrendermodel( _this );
1447             child_0.ref();
1448             this.el.model = child_0.el;
1449
1450             // listeners 
1451             this.el.editing_started.connect( ( editable, path) => {
1452                 //_this.editing = true;
1453                 print("editing started called\n");
1454                 if (!_this.allow_edit) {
1455                    
1456                      print("val - editing_Started\n");
1457                     this.el.editable = false; // make sure it's not editor...
1458                
1459                      
1460                     return;
1461                 }
1462                  _this.allow_edit =false;
1463                 
1464                
1465                  if (       this.el.has_entry ) {
1466                
1467                      Gtk.TreeIter  iter;
1468                     _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1469                     GLib.Value gval;
1470                                   
1471             
1472                   
1473                      //   this.get('/LeftPanel.model').activePath  = path;
1474                    _this.model.el.get_value(iter,3, out gval);
1475                 
1476             
1477                     var val = (string)gval;
1478                     var combo =        (Gtk.ComboBox)editable;
1479             
1480                    var entry =  (Gtk.Entry) combo.get_child();        
1481                 entry.set_text(val);
1482                 }
1483                
1484             });
1485             this.el.edited.connect( (path, newtext) => {
1486                 print("Valrender  - signal:edited\n");
1487               
1488                     this.el.editable = false;
1489             /*  
1490              m.set(iter, 
1491                             0, "listener",
1492                             1, miter.get_key(),
1493                             2, "<b>" + miter.get_key() + "</b>",
1494                             3, miter.get_value(),
1495                             4, display_value(short);
1496                         ); 
1497             
1498               */      
1499             
1500                     Gtk.TreeIter  iter;
1501                     _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1502                     GLib.Value gval;
1503                     
1504                      _this.model.el.get_value(iter,0, out gval);
1505                     var ktype = (string)gval;
1506                     
1507                     
1508                      _this.model.el.get_value(iter,3, out gval);
1509                     var oldval = (string)gval;
1510                     
1511                      _this.model.el.get_value(iter,1, out gval);
1512                     var key = (string)gval;
1513                     
1514                      
1515                     
1516                     switch(ktype) {
1517                         case "listener":
1518                             _this.node.listeners.set(key, newtext);
1519                             _this.updateIter(iter,ktype,key,newtext);
1520                             break;
1521                         case "props":
1522                             _this.node.props.set(key,newtext);
1523                             _this.updateIter(iter,ktype, key,newtext);                
1524                             break;
1525                      }
1526             //         _this.load(_this.file,_this.node);
1527                      _this.changed();
1528                       
1529             });
1530         }
1531
1532         // user defined functions 
1533         public              void setOptions (string[] ar) {
1534               var m = _this.valrendermodel.el;
1535                 m.clear();
1536              Gtk.TreeIter iret;
1537             for (var i =0; i < ar.length; i++) {
1538                     m.append(out iret);
1539                     m.set_value(iret, 0, ar[i]);
1540             }
1541         
1542         }
1543     }
1544     public class Xcls_valrendermodel : Object 
1545     {
1546         public Gtk.ListStore el;
1547         private Xcls_LeftProps  _this;
1548
1549
1550             // my vars (def)
1551
1552         // ctor 
1553         public Xcls_valrendermodel(Xcls_LeftProps _owner )
1554         {
1555             _this = _owner;
1556             _this.valrendermodel = this;
1557             this.el = new Gtk.ListStore( 1, typeof(string) );
1558
1559             // my vars (dec)
1560
1561             // set gobject values
1562         }
1563
1564         // user defined functions 
1565     }
1566     public class Xcls_ContextMenu : Object 
1567     {
1568         public Gtk.Menu el;
1569         private Xcls_LeftProps  _this;
1570
1571
1572             // my vars (def)
1573
1574         // ctor 
1575         public Xcls_ContextMenu(Xcls_LeftProps _owner )
1576         {
1577             _this = _owner;
1578             _this.ContextMenu = this;
1579             this.el = new Gtk.Menu();
1580
1581             // my vars (dec)
1582
1583             // set gobject values
1584             var child_0 = new Xcls_MenuItem29( _this );
1585             child_0.ref();
1586             this.el.append (  child_0.el  );
1587             var child_1 = new Xcls_SeparatorMenuItem30( _this );
1588             child_1.ref();
1589             this.el.append (  child_1.el  );
1590             var child_2 = new Xcls_MenuItem31( _this );
1591             child_2.ref();
1592             this.el.append (  child_2.el  );
1593         }
1594
1595         // user defined functions 
1596     }
1597     public class Xcls_MenuItem29 : Object 
1598     {
1599         public Gtk.MenuItem el;
1600         private Xcls_LeftProps  _this;
1601
1602
1603             // my vars (def)
1604
1605         // ctor 
1606         public Xcls_MenuItem29(Xcls_LeftProps _owner )
1607         {
1608             _this = _owner;
1609             this.el = new Gtk.MenuItem();
1610
1611             // my vars (dec)
1612
1613             // set gobject values
1614             this.el.label = "Edit";
1615
1616             // listeners 
1617             this.el.activate.connect( ( )  =>{
1618               
1619                 var s = _this.view.el.get_selection();
1620                 Gtk.TreeIter iter;
1621                 Gtk.TreeModel model;
1622                 s.get_selected (out  model, out  iter);
1623                 _this.startEditingKey(model.get_path(iter));
1624             });
1625         }
1626
1627         // user defined functions 
1628     }
1629     public class Xcls_SeparatorMenuItem30 : Object 
1630     {
1631         public Gtk.SeparatorMenuItem el;
1632         private Xcls_LeftProps  _this;
1633
1634
1635             // my vars (def)
1636
1637         // ctor 
1638         public Xcls_SeparatorMenuItem30(Xcls_LeftProps _owner )
1639         {
1640             _this = _owner;
1641             this.el = new Gtk.SeparatorMenuItem();
1642
1643             // my vars (dec)
1644
1645             // set gobject values
1646         }
1647
1648         // user defined functions 
1649     }
1650     public class Xcls_MenuItem31 : Object 
1651     {
1652         public Gtk.MenuItem el;
1653         private Xcls_LeftProps  _this;
1654
1655
1656             // my vars (def)
1657
1658         // ctor 
1659         public Xcls_MenuItem31(Xcls_LeftProps _owner )
1660         {
1661             _this = _owner;
1662             this.el = new Gtk.MenuItem();
1663
1664             // my vars (dec)
1665
1666             // set gobject values
1667             this.el.label = "Delete";
1668
1669             // listeners 
1670             this.el.activate.connect( ( )  =>{
1671                 _this.deleteSelected();
1672             });
1673         }
1674
1675         // user defined functions 
1676     }
1677 }