tests/GirTest.vala
[app.Builder.js] / 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_SeparatorMenuItem11( _this );
695             child_3.ref();
696             this.el.add (  child_3.el  );
697             var child_4 = new Xcls_MenuItem12( _this );
698             child_4.ref();
699             this.el.append (  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_SeparatorMenuItem15( _this );
707             child_7.ref();
708             this.el.add (  child_7.el  );
709             var child_8 = new Xcls_MenuItem16( _this );
710             child_8.ref();
711             this.el.append (  child_8.el  );
712             var child_9 = new Xcls_MenuItem17( _this );
713             child_9.ref();
714             this.el.append (  child_9.el  );
715         }
716
717         // user defined functions 
718     }
719     public class Xcls_MenuItem8 : Object 
720     {
721         public Gtk.MenuItem el;
722         private Xcls_LeftProps  _this;
723
724
725             // my vars (def)
726
727         // ctor 
728         public Xcls_MenuItem8(Xcls_LeftProps _owner )
729         {
730             _this = _owner;
731             this.el = new Gtk.MenuItem();
732
733             // my vars (dec)
734
735             // set gobject values
736             this.el.tooltip_markup = "Using this.get('*someid') will find any id in an application.";
737             this.el.label = "ID";
738
739             // listeners 
740             this.el.activate.connect( ()  => {
741                 _this.addProp( "prop", "id", "", "string");
742             });
743         }
744
745         // user defined functions 
746     }
747     public class Xcls_MenuItem9 : Object 
748     {
749         public Gtk.MenuItem el;
750         private Xcls_LeftProps  _this;
751
752
753             // my vars (def)
754
755         // ctor 
756         public Xcls_MenuItem9(Xcls_LeftProps _owner )
757         {
758             _this = _owner;
759             this.el = new Gtk.MenuItem();
760
761             // my vars (dec)
762
763             // set gobject values
764             this.el.tooltip_markup = "Add what type of packing is to be used";
765             this.el.label = "PACK";
766
767             // listeners 
768             this.el.activate.connect( ( ) => {
769             
770                 _this.addProp( "prop", "pack","add", "*");
771             });
772         }
773
774         // user defined functions 
775     }
776     public class Xcls_MenuItem10 : Object 
777     {
778         public Gtk.MenuItem el;
779         private Xcls_LeftProps  _this;
780
781
782             // my vars (def)
783
784         // ctor 
785         public Xcls_MenuItem10(Xcls_LeftProps _owner )
786         {
787             _this = _owner;
788             this.el = new Gtk.MenuItem();
789
790             // my vars (dec)
791
792             // set gobject values
793             this.el.tooltip_markup = "Override the init method";
794             this.el.label = "INIT";
795
796             // listeners 
797             this.el.activate.connect( ( ) => {
798             
799                 _this.addProp( "prop",  "init", "{\n\n}\n", "*" );
800             });
801         }
802
803         // user defined functions 
804     }
805     public class Xcls_SeparatorMenuItem11 : Object 
806     {
807         public Gtk.SeparatorMenuItem el;
808         private Xcls_LeftProps  _this;
809
810
811             // my vars (def)
812
813         // ctor 
814         public Xcls_SeparatorMenuItem11(Xcls_LeftProps _owner )
815         {
816             _this = _owner;
817             this.el = new Gtk.SeparatorMenuItem();
818
819             // my vars (dec)
820
821             // set gobject values
822         }
823
824         // user defined functions 
825     }
826     public class Xcls_MenuItem12 : Object 
827     {
828         public Gtk.MenuItem el;
829         private Xcls_LeftProps  _this;
830
831
832             // my vars (def)
833
834         // ctor 
835         public Xcls_MenuItem12(Xcls_LeftProps _owner )
836         {
837             _this = _owner;
838             this.el = new Gtk.MenuItem();
839
840             // my vars (dec)
841
842             // set gobject values
843             this.el.tooltip_markup = "Add a user defined string property";
844             this.el.label = "String";
845
846             // listeners 
847             this.el.activate.connect( (self) => {
848             
849                 _this.addProp( "prop", "XXXX", "","string");
850             
851             });
852         }
853
854         // user defined functions 
855     }
856     public class Xcls_MenuItem13 : Object 
857     {
858         public Gtk.MenuItem el;
859         private Xcls_LeftProps  _this;
860
861
862             // my vars (def)
863
864         // ctor 
865         public Xcls_MenuItem13(Xcls_LeftProps _owner )
866         {
867             _this = _owner;
868             this.el = new Gtk.MenuItem();
869
870             // my vars (dec)
871
872             // set gobject values
873             this.el.tooltip_markup = "Add a user defined number property";
874             this.el.label = "Number";
875
876             // listeners 
877             this.el.activate.connect( ( ) =>{
878             
879                 _this.addProp("prop",  "XXX", "0", "int");
880             });
881         }
882
883         // user defined functions 
884     }
885     public class Xcls_MenuItem14 : Object 
886     {
887         public Gtk.MenuItem el;
888         private Xcls_LeftProps  _this;
889
890
891             // my vars (def)
892
893         // ctor 
894         public Xcls_MenuItem14(Xcls_LeftProps _owner )
895         {
896             _this = _owner;
897             this.el = new Gtk.MenuItem();
898
899             // my vars (dec)
900
901             // set gobject values
902             this.el.tooltip_markup = "Add a user defined boolean property";
903             this.el.label = "Boolean";
904
905             // listeners 
906             this.el.activate.connect( ( ) =>{
907             
908                 _this.addProp( "prop", "XXX", "true", "bool");
909             });
910         }
911
912         // user defined functions 
913     }
914     public class Xcls_SeparatorMenuItem15 : Object 
915     {
916         public Gtk.SeparatorMenuItem el;
917         private Xcls_LeftProps  _this;
918
919
920             // my vars (def)
921
922         // ctor 
923         public Xcls_SeparatorMenuItem15(Xcls_LeftProps _owner )
924         {
925             _this = _owner;
926             this.el = new Gtk.SeparatorMenuItem();
927
928             // my vars (dec)
929
930             // set gobject values
931         }
932
933         // user defined functions 
934     }
935     public class Xcls_MenuItem16 : Object 
936     {
937         public Gtk.MenuItem el;
938         private Xcls_LeftProps  _this;
939
940
941             // my vars (def)
942
943         // ctor 
944         public Xcls_MenuItem16(Xcls_LeftProps _owner )
945         {
946             _this = _owner;
947             this.el = new Gtk.MenuItem();
948
949             // my vars (dec)
950
951             // set gobject values
952             this.el.tooltip_markup = "Add a user function boolean property";
953             this.el.label = "Javascript Function";
954
955             // listeners 
956             this.el.activate.connect( ( ) =>{
957             
958                 _this.addProp("prop",  "XXXX", "function() { }", "| function");
959             });
960         }
961
962         // user defined functions 
963     }
964     public class Xcls_MenuItem17 : Object 
965     {
966         public Gtk.MenuItem el;
967         private Xcls_LeftProps  _this;
968
969
970             // my vars (def)
971
972         // ctor 
973         public Xcls_MenuItem17(Xcls_LeftProps _owner )
974         {
975             _this = _owner;
976             this.el = new Gtk.MenuItem();
977
978             // my vars (dec)
979
980             // set gobject values
981             this.el.tooltip_markup = "Add a user function boolean property";
982             this.el.label = "Vala Method";
983
984             // listeners 
985             this.el.activate.connect( ( ) =>{
986             
987                 _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
988             });
989         }
990
991         // user defined functions 
992     }
993     public class Xcls_EditProps : Object 
994     {
995         public Gtk.ScrolledWindow el;
996         private Xcls_LeftProps  _this;
997
998
999             // my vars (def)
1000         public bool editing;
1001
1002         // ctor 
1003         public Xcls_EditProps(Xcls_LeftProps _owner )
1004         {
1005             _this = _owner;
1006             _this.EditProps = this;
1007             this.el = new Gtk.ScrolledWindow( null, null );
1008
1009             // my vars (dec)
1010             this.editing = false;
1011
1012             // set gobject values
1013             this.el.shadow_type = Gtk.ShadowType.IN;
1014             var child_0 = new Xcls_view( _this );
1015             child_0.ref();
1016             this.el.add (  child_0.el  );
1017
1018             // init method 
1019
1020             {
1021               
1022                this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1023             }        }
1024
1025         // user defined functions 
1026     }
1027     public class Xcls_view : Object 
1028     {
1029         public Gtk.TreeView el;
1030         private Xcls_LeftProps  _this;
1031
1032
1033             // my vars (def)
1034
1035         // ctor 
1036         public Xcls_view(Xcls_LeftProps _owner )
1037         {
1038             _this = _owner;
1039             _this.view = this;
1040             this.el = new Gtk.TreeView();
1041
1042             // my vars (dec)
1043
1044             // set gobject values
1045             this.el.tooltip_column = 5;
1046             this.el.enable_tree_lines = true;
1047             this.el.headers_visible = true;
1048             var child_0 = new Xcls_model( _this );
1049             child_0.ref();
1050             this.el.set_model (  child_0.el  );
1051             var child_1 = new Xcls_keycol( _this );
1052             child_1.ref();
1053             this.el.append_column (  child_1.el  );
1054             var child_2 = new Xcls_valcol( _this );
1055             child_2.ref();
1056             this.el.append_column (  child_2.el  );
1057             var child_3 = new Xcls_ContextMenu( _this );
1058             child_3.ref();
1059
1060             // init method 
1061
1062             {
1063                 var selection = this.el.get_selection();
1064                 selection.set_mode( Gtk.SelectionMode.SINGLE);
1065             
1066             
1067                 var description = new Pango.FontDescription();
1068                 description.set_size(8000);
1069                 this.el.modify_font(description);
1070             }
1071             // listeners 
1072             this.el.button_press_event.connect( ( ev)  => {
1073              
1074                 Gtk.TreeViewColumn col;
1075                 int cell_x;
1076                 int cell_y;
1077                 Gtk.TreePath path;
1078                 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
1079                     print("nothing selected on click");
1080                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1081                         this.el.get_selection().unselect_all();
1082             
1083                         return false;
1084                     });
1085                      _this.before_edit();
1086                     return false; //not on a element.
1087                 }
1088                 
1089                 
1090                  // right click.
1091                  if (ev.type == Gdk.EventType.2BUTTON_PRESS  && ev.button == 1 && col.title == "Name") {    
1092                     // show popup!.   
1093                     
1094              
1095                      _this.before_edit();
1096                      
1097                      _this.keyrender.el.stop_editing(false);
1098                      _this.keyrender.el.editable  =false;
1099                 
1100                      _this.valrender.el.stop_editing(false);
1101                      _this.valrender.el.editable  =false;
1102                        
1103                       _this.startEditingKey(path); 
1104                      
1105                     return false;
1106                 }
1107                 
1108                 
1109                 
1110                 
1111                  // right click.
1112                  if (ev.type == Gdk.EventType.BUTTON_PRESS  && ev.button == 3) {    
1113                     // show popup!.   
1114                     //if (col.title == "Value") {
1115                      //     _this.before_edit();
1116                      //    return false;
1117                      //}
1118             
1119                     var p = _this.ContextMenu;
1120             
1121                     p.el.set_screen(Gdk.Screen.get_default());
1122                     p.el.show_all();
1123                     p.el.popup(null, null, null,  ev.button, ev.time);
1124                     //Seed.print("click:" + res.column.title);
1125                     // select the 
1126                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1127               
1128                         this.el.get_selection().select_path(path);
1129                         return false;
1130                     });
1131                      _this.before_edit();
1132                     return false;
1133                 }
1134                 
1135                  
1136                 if (col.title != "Value") {
1137                     print("col title != Value");
1138                     
1139                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1140                         this.el.get_selection().select_path(path);
1141                         return false;
1142                     });
1143                     
1144                     _this.before_edit();
1145                       //  XObject.error("column is not value?");
1146                     return false; // ignore.. - key click.. ??? should we do this??
1147                 }
1148                 
1149                 
1150                 // if the cell can be edited with a pulldown
1151                 // then we should return true... - and let the start_editing handle it?
1152                 
1153                 
1154                 
1155                 
1156                 
1157                   
1158                //             _this.before_edit(); <<< we really need to stop the other editor..
1159                  _this.keyrender.el.stop_editing(false);
1160                 _this.keyrender.el.editable  =false;
1161                 
1162                        
1163                 return _this.startEditingValue(path); // assumes selected row..
1164                     
1165                
1166             
1167                           
1168                
1169             });
1170         }
1171
1172         // user defined functions 
1173     }
1174     public class Xcls_model : Object 
1175     {
1176         public Gtk.TreeStore el;
1177         private Xcls_LeftProps  _this;
1178
1179
1180             // my vars (def)
1181
1182         // ctor 
1183         public Xcls_model(Xcls_LeftProps _owner )
1184         {
1185             _this = _owner;
1186             _this.model = this;
1187             this.el = new Gtk.TreeStore( 7,      typeof(string),  // 0 key type
1188      typeof(string),  // 1 key
1189      typeof(string),  // 2 key (display)
1190      typeof(string),  // 3 value
1191      typeof(string),   // 4 value (display)
1192      typeof(string),   // 5 both (tooltip)     
1193      typeof(string)   // 6 key (for sorting)
1194  );
1195
1196             // my vars (dec)
1197
1198             // set gobject values
1199         }
1200
1201         // user defined functions 
1202     }
1203     public class Xcls_keycol : Object 
1204     {
1205         public Gtk.TreeViewColumn el;
1206         private Xcls_LeftProps  _this;
1207
1208
1209             // my vars (def)
1210
1211         // ctor 
1212         public Xcls_keycol(Xcls_LeftProps _owner )
1213         {
1214             _this = _owner;
1215             _this.keycol = this;
1216             this.el = new Gtk.TreeViewColumn();
1217
1218             // my vars (dec)
1219
1220             // set gobject values
1221             this.el.title = "Name";
1222             this.el.resizable = true;
1223             var child_0 = new Xcls_keyrender( _this );
1224             child_0.ref();
1225             this.el.pack_start (  child_0.el , false );
1226
1227             // init method 
1228
1229             this.el.add_attribute(_this.keyrender.el , "markup", 2 );
1230              this.el.add_attribute(_this.keyrender.el , "text", 1 );        }
1231
1232         // user defined functions 
1233     }
1234     public class Xcls_keyrender : Object 
1235     {
1236         public Gtk.CellRendererText el;
1237         private Xcls_LeftProps  _this;
1238
1239
1240             // my vars (def)
1241
1242         // ctor 
1243         public Xcls_keyrender(Xcls_LeftProps _owner )
1244         {
1245             _this = _owner;
1246             _this.keyrender = this;
1247             this.el = new Gtk.CellRendererText();
1248
1249             // my vars (dec)
1250
1251             // set gobject values
1252
1253             // listeners 
1254             this.el.editing_started.connect( (  editable, path) => {
1255             
1256                  Gtk.TreeIter  iter;
1257                 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1258                 GLib.Value gval;
1259                               
1260             
1261             
1262                  //   this.get('/LeftPanel.model').activePath  = path;
1263                 _this.model.el.get_value(iter,1, out gval);
1264                     var val = (string)gval;
1265                              
1266                     ((Gtk.Entry)editable).set_text(val);                 
1267             });
1268             this.el.edited.connect( (path, newtext) => {
1269                     print("Keyrender  - signal:edited\n");
1270                 
1271                 this.el.editable = false;
1272               
1273              
1274             
1275                     Gtk.TreeIter  iter;
1276                     _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1277                     GLib.Value gval;
1278                     
1279                      _this.model.el.get_value(iter,1, out gval);
1280                     var oldval = (string)gval;
1281                     
1282                      _this.model.el.get_value(iter,0, out gval);
1283                     var ktype = (string)gval;
1284                    
1285                     _this.model.el.set_value(iter, 1, newtext);
1286                     
1287                     if (oldval == newtext) {
1288                         return;
1289                     }
1290                     
1291                     
1292                     print("ktype: %s\n",ktype);
1293                     switch(ktype) {
1294                         case "listener":
1295                             var ov = _this.node.listeners.get(oldval);
1296                             _this.node.listeners.set(newtext, ov);
1297                             _this.node.listeners.remove(oldval);
1298                             
1299                             _this.updateIter(iter,  ktype, newtext, ov);
1300                             
1301                             break;
1302                         case "props":
1303                             var ov = _this.node.props.get(oldval);
1304                             _this.node.props.set(newtext, ov);
1305                             _this.node.props.remove(oldval);
1306                             _this.updateIter(iter,  ktype, newtext, ov);
1307                             break;
1308                      }
1309                      _this.changed();
1310                       
1311             });
1312         }
1313
1314         // user defined functions 
1315     }
1316     public class Xcls_valcol : Object 
1317     {
1318         public Gtk.TreeViewColumn el;
1319         private Xcls_LeftProps  _this;
1320
1321
1322             // my vars (def)
1323
1324         // ctor 
1325         public Xcls_valcol(Xcls_LeftProps _owner )
1326         {
1327             _this = _owner;
1328             _this.valcol = this;
1329             this.el = new Gtk.TreeViewColumn();
1330
1331             // my vars (dec)
1332
1333             // set gobject values
1334             this.el.title = "Value";
1335             this.el.resizable = true;
1336             var child_0 = new Xcls_valrender( _this );
1337             child_0.ref();
1338             this.el.pack_start (  child_0.el , true );
1339
1340             // init method 
1341
1342             {
1343                 
1344                 //     typeof(string),  // 0 key type
1345                 // typeof(string),  // 1 key
1346                 // typeof(string),  // 2 key (display)
1347                 // typeof(string),  // 3 value
1348                 // typeof(string)   // 4 value (display)
1349             
1350                 
1351                 this.el.add_attribute(_this.valrender.el , "text", 4 );
1352                 //this.el.add_attribute(_this.valrender.el , "sensitive", 4 );
1353                 //this.el.add_attribute(this.items[0].el , 'editable', 3 );
1354                       // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1355             
1356              // this.get('/LeftPanel').editableColumn= this;
1357             }        }
1358
1359         // user defined functions 
1360     }
1361     public class Xcls_valrender : Object 
1362     {
1363         public Gtk.CellRendererCombo el;
1364         private Xcls_LeftProps  _this;
1365
1366
1367             // my vars (def)
1368
1369         // ctor 
1370         public Xcls_valrender(Xcls_LeftProps _owner )
1371         {
1372             _this = _owner;
1373             _this.valrender = this;
1374             this.el = new Gtk.CellRendererCombo();
1375
1376             // my vars (dec)
1377
1378             // set gobject values
1379             this.el.editable = false;
1380             this.el.text_column = 0;
1381             this.el.has_entry = true;
1382             var child_0 = new Xcls_valrendermodel( _this );
1383             child_0.ref();
1384             this.el.model = child_0.el;
1385
1386             // listeners 
1387             this.el.editing_started.connect( ( editable, path) => {
1388                 //_this.editing = true;
1389                 print("editing started called\n");
1390                 if (!_this.allow_edit) {
1391                    
1392                      print("val - editing_Started\n");
1393                     this.el.editable = false; // make sure it's not editor...
1394                
1395                      
1396                     return;
1397                 }
1398                  _this.allow_edit =false;
1399                 
1400                
1401                  if (       this.el.has_entry ) {
1402                
1403                      Gtk.TreeIter  iter;
1404                     _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1405                     GLib.Value gval;
1406                                   
1407             
1408                   
1409                      //   this.get('/LeftPanel.model').activePath  = path;
1410                    _this.model.el.get_value(iter,3, out gval);
1411                 
1412             
1413                     var val = (string)gval;
1414                     var combo =        (Gtk.ComboBox)editable;
1415             
1416                    var entry =  (Gtk.Entry) combo.get_child();        
1417                 entry.set_text(val);
1418                 }
1419                
1420             });
1421             this.el.edited.connect( (path, newtext) => {
1422                 print("Valrender  - signal:edited\n");
1423               
1424                     this.el.editable = false;
1425             /*  
1426              m.set(iter, 
1427                             0, "listener",
1428                             1, miter.get_key(),
1429                             2, "<b>" + miter.get_key() + "</b>",
1430                             3, miter.get_value(),
1431                             4, display_value(short);
1432                         ); 
1433             
1434               */      
1435             
1436                     Gtk.TreeIter  iter;
1437                     _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1438                     GLib.Value gval;
1439                     
1440                      _this.model.el.get_value(iter,0, out gval);
1441                     var ktype = (string)gval;
1442                     
1443                     
1444                      _this.model.el.get_value(iter,3, out gval);
1445                     var oldval = (string)gval;
1446                     
1447                      _this.model.el.get_value(iter,1, out gval);
1448                     var key = (string)gval;
1449                     
1450                      
1451                     
1452                     switch(ktype) {
1453                         case "listener":
1454                             _this.node.listeners.set(key, newtext);
1455                             _this.updateIter(iter,ktype,key,newtext);
1456                             break;
1457                         case "props":
1458                             _this.node.props.set(key,newtext);
1459                             _this.updateIter(iter,ktype, key,newtext);                
1460                             break;
1461                      }
1462             //         _this.load(_this.file,_this.node);
1463                      _this.changed();
1464                       
1465             });
1466         }
1467
1468         // user defined functions 
1469         public              void setOptions (string[] ar) {
1470               var m = _this.valrendermodel.el;
1471                 m.clear();
1472              Gtk.TreeIter iret;
1473             for (var i =0; i < ar.length; i++) {
1474                     m.append(out iret);
1475                     m.set_value(iret, 0, ar[i]);
1476             }
1477         
1478         }
1479     }
1480     public class Xcls_valrendermodel : Object 
1481     {
1482         public Gtk.ListStore el;
1483         private Xcls_LeftProps  _this;
1484
1485
1486             // my vars (def)
1487
1488         // ctor 
1489         public Xcls_valrendermodel(Xcls_LeftProps _owner )
1490         {
1491             _this = _owner;
1492             _this.valrendermodel = this;
1493             this.el = new Gtk.ListStore( 1, typeof(string) );
1494
1495             // my vars (dec)
1496
1497             // set gobject values
1498         }
1499
1500         // user defined functions 
1501     }
1502     public class Xcls_ContextMenu : Object 
1503     {
1504         public Gtk.Menu el;
1505         private Xcls_LeftProps  _this;
1506
1507
1508             // my vars (def)
1509
1510         // ctor 
1511         public Xcls_ContextMenu(Xcls_LeftProps _owner )
1512         {
1513             _this = _owner;
1514             _this.ContextMenu = this;
1515             this.el = new Gtk.Menu();
1516
1517             // my vars (dec)
1518
1519             // set gobject values
1520             var child_0 = new Xcls_MenuItem27( _this );
1521             child_0.ref();
1522             this.el.append (  child_0.el  );
1523             var child_1 = new Xcls_SeparatorMenuItem28( _this );
1524             child_1.ref();
1525             this.el.append (  child_1.el  );
1526             var child_2 = new Xcls_MenuItem29( _this );
1527             child_2.ref();
1528             this.el.append (  child_2.el  );
1529         }
1530
1531         // user defined functions 
1532     }
1533     public class Xcls_MenuItem27 : Object 
1534     {
1535         public Gtk.MenuItem el;
1536         private Xcls_LeftProps  _this;
1537
1538
1539             // my vars (def)
1540
1541         // ctor 
1542         public Xcls_MenuItem27(Xcls_LeftProps _owner )
1543         {
1544             _this = _owner;
1545             this.el = new Gtk.MenuItem();
1546
1547             // my vars (dec)
1548
1549             // set gobject values
1550             this.el.label = "Edit";
1551
1552             // listeners 
1553             this.el.activate.connect( ( )  =>{
1554               
1555                 var s = _this.view.el.get_selection();
1556                 Gtk.TreeIter iter;
1557                 Gtk.TreeModel model;
1558                 s.get_selected (out  model, out  iter);
1559                 _this.startEditingKey(model.get_path(iter));
1560             });
1561         }
1562
1563         // user defined functions 
1564     }
1565     public class Xcls_SeparatorMenuItem28 : Object 
1566     {
1567         public Gtk.SeparatorMenuItem el;
1568         private Xcls_LeftProps  _this;
1569
1570
1571             // my vars (def)
1572
1573         // ctor 
1574         public Xcls_SeparatorMenuItem28(Xcls_LeftProps _owner )
1575         {
1576             _this = _owner;
1577             this.el = new Gtk.SeparatorMenuItem();
1578
1579             // my vars (dec)
1580
1581             // set gobject values
1582         }
1583
1584         // user defined functions 
1585     }
1586     public class Xcls_MenuItem29 : Object 
1587     {
1588         public Gtk.MenuItem el;
1589         private Xcls_LeftProps  _this;
1590
1591
1592             // my vars (def)
1593
1594         // ctor 
1595         public Xcls_MenuItem29(Xcls_LeftProps _owner )
1596         {
1597             _this = _owner;
1598             this.el = new Gtk.MenuItem();
1599
1600             // my vars (dec)
1601
1602             // set gobject values
1603             this.el.label = "Delete";
1604
1605             // listeners 
1606             this.el.activate.connect( ( )  =>{
1607                 _this.deleteSelected();
1608             });
1609         }
1610
1611         // user defined functions 
1612     }
1613 }