src/Builder4/PopoverAddProp.bjs
[roobuilder] / src / Builder4 / PopoverAddProp.vala
1 static Xcls_PopoverAddProp  _PopoverAddProp;
2
3 public class Xcls_PopoverAddProp : Object
4 {
5     public Gtk.Popover el;
6     private Xcls_PopoverAddProp  _this;
7
8     public static Xcls_PopoverAddProp singleton()
9     {
10         if (_PopoverAddProp == null) {
11             _PopoverAddProp= new Xcls_PopoverAddProp();
12         }
13         return _PopoverAddProp;
14     }
15     public Xcls_model model;
16     public Xcls_namecol namecol;
17     public Xcls_namerender namerender;
18     public Xcls_type type;
19     public Xcls_typerender typerender;
20     public Xcls_from from;
21     public Xcls_fromrender fromrender;
22
23         // my vars (def)
24     public JsRender.NodePropType ptype;
25     public signal void select (JsRender.NodeProp prop);
26     public Xcls_MainWindow mainwindow;
27     public bool active;
28
29     // ctor
30     public Xcls_PopoverAddProp()
31     {
32         _this = this;
33         this.el = new Gtk.Popover( null );
34
35         // my vars (dec)
36         this.active = false;
37
38         // set gobject values
39         this.el.width_request = 900;
40         this.el.height_request = 800;
41         this.el.hexpand = false;
42         this.el.modal = true;
43         this.el.position = Gtk.PositionType.RIGHT;
44         var child_0 = new Xcls_ScrolledWindow2( _this );
45         child_0.ref();
46         this.el.add (  child_0.el  );
47     }
48
49     // user defined functions
50     public void show (Palete.Palete pal, JsRender.NodePropType ptype, string xtype,  Gtk.Widget onbtn) {
51     
52         /// what does this do?
53         //if (this.prop_or_listener  != "" && this.prop_or_listener == prop_or_listener) {
54         //      this.prop_or_listener = "";
55         //      this.el.hide();
56         //      return;
57         //}
58         
59         
60         
61         this.ptype = ptype;
62         
63         this.model.el.clear();
64     
65         Gtk.TreeIter iter;
66         var elementList = pal.getPropertiesFor( xtype, ptype);
67          
68         //print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
69                // console.dump(elementList);
70                
71         var miter = elementList.map_iterator();
72         while (miter.next()) {
73            var p = miter.get_value();
74             
75             this.model.el.append(out iter);
76                 
77                 var prop = p.toNodeProp();
78                 
79                  
80     
81             this.model.el.set(iter,
82                     0,  prop, 
83                     1,  prop.to_property_option_markup(),
84                     2,  prop.to_property_option_tooltip(),                
85                     3,  prop.name,
86                     4,  prop.rtype,
87                     5,  p.propertyof
88                     -1
89             );
90         }
91         this.model.el.set_sort_column_id(3,Gtk.SortType.ASCENDING);    
92         
93         // set size up...
94         
95     
96         int w,h;
97         this.mainwindow.el.get_size(out w, out h);
98         
99         // left tree = 250, editor area = 500?
100         
101         // min 450?
102         // max hieght ...
103         this.el.set_size_request( 450, h);
104     
105         
106     
107         if (this.el.relative_to == null) {
108             this.el.set_relative_to(onbtn);
109         }
110         this.el.show_all();
111        
112         while(Gtk.events_pending()) { 
113                 Gtk.main_iteration();   // why?
114         }       
115      //   this.hpane.el.set_position( 0);
116     }
117     public void clear () {
118      this.model.el.clear();
119     }
120     public void hide () {
121         this.ptype = JsRender.NodePropType.NONE;
122         this.el.hide();
123     }
124     public class Xcls_ScrolledWindow2 : Object
125     {
126         public Gtk.ScrolledWindow el;
127         private Xcls_PopoverAddProp  _this;
128
129
130             // my vars (def)
131
132         // ctor
133         public Xcls_ScrolledWindow2(Xcls_PopoverAddProp _owner )
134         {
135             _this = _owner;
136             this.el = new Gtk.ScrolledWindow( null, null );
137
138             // my vars (dec)
139
140             // set gobject values
141             this.el.shadow_type = Gtk.ShadowType.IN;
142             var child_0 = new Xcls_TreeView3( _this );
143             child_0.ref();
144             this.el.add (  child_0.el  );
145
146             // init method
147
148             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
149         }
150
151         // user defined functions
152     }
153     public class Xcls_TreeView3 : Object
154     {
155         public Gtk.TreeView el;
156         private Xcls_PopoverAddProp  _this;
157
158
159             // my vars (def)
160
161         // ctor
162         public Xcls_TreeView3(Xcls_PopoverAddProp _owner )
163         {
164             _this = _owner;
165             this.el = new Gtk.TreeView();
166
167             // my vars (dec)
168
169             // set gobject values
170             this.el.tooltip_column = 2;
171             this.el.enable_tree_lines = true;
172             this.el.headers_visible = true;
173             var child_0 = new Xcls_model( _this );
174             child_0.ref();
175             this.el.set_model (  child_0.el  );
176             var child_1 = new Xcls_namecol( _this );
177             child_1.ref();
178             this.el.append_column (  child_1.el  );
179             var child_2 = new Xcls_type( _this );
180             child_2.ref();
181             this.el.append_column (  child_2.el  );
182             var child_3 = new Xcls_from( _this );
183             child_3.ref();
184             this.el.append_column (  child_3.el  );
185
186             // init method
187
188             {  
189                    var description = new Pango.FontDescription();
190                  description.set_size(10000);
191                 this.el.override_font(description);     
192                                 
193                 this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);
194              
195             
196                 
197               
198                 
199             }
200
201             //listeners
202             this.el.row_activated.connect( (path, column)  => {
203             
204                 Gtk.TreeIter iter;
205             
206             
207                 var m = _this.model;
208             
209                 m.el.get_iter(out iter,path);
210             
211              
212                 var prop = m.getValue(iter);
213              
214             
215                 // hide the popover
216                 _this.el.hide();
217                  
218                 
219                 _this.select(prop);
220              
221             });
222         }
223
224         // user defined functions
225     }
226     public class Xcls_model : Object
227     {
228         public Gtk.ListStore el;
229         private Xcls_PopoverAddProp  _this;
230
231
232             // my vars (def)
233
234         // ctor
235         public Xcls_model(Xcls_PopoverAddProp _owner )
236         {
237             _this = _owner;
238             _this.model = this;
239             this.el = new Gtk.ListStore( 6, 
240 typeof(JsRender.NodeProp),  // 0 real key
241 typeof(string),  // text display
242 typeof(string),  // tooltip
243 typeof(string),  // sortable string
244 typeof(string), // prop type
245 typeof(string) // from interface
246
247 // add later? source?
248 /* was:
249 typeof(string),  // 0 real key
250 typeof(string), // 1 real type
251 typeof(string), // 2 docs ?
252 typeof(string), // 3 visable desc
253 typeof(string), // 4 function desc
254 typeof(string) // 5 element type (event|prop)
255 */ );
256
257             // my vars (dec)
258
259             // set gobject values
260         }
261
262         // user defined functions
263         public JsRender.NodeProp getValue (Gtk.TreeIter iter)
264         {
265         
266             GLib.Value value;
267             this.el.get_value(iter, 0, out value);
268          
269             return (JsRender.NodeProp)value;
270             
271         }
272     }
273
274     public class Xcls_namecol : Object
275     {
276         public Gtk.TreeViewColumn el;
277         private Xcls_PopoverAddProp  _this;
278
279
280             // my vars (def)
281
282         // ctor
283         public Xcls_namecol(Xcls_PopoverAddProp _owner )
284         {
285             _this = _owner;
286             _this.namecol = this;
287             this.el = new Gtk.TreeViewColumn();
288
289             // my vars (dec)
290
291             // set gobject values
292             this.el.sort_column_id = 3;
293             this.el.title = "Double click to add";
294             var child_0 = new Xcls_namerender( _this );
295             child_0.ref();
296             this.el.pack_start (  child_0.el , true );
297
298             // init method
299
300             this.el.add_attribute(_this.namerender.el , "markup", 1  );
301         }
302
303         // user defined functions
304     }
305     public class Xcls_namerender : Object
306     {
307         public Gtk.CellRendererText el;
308         private Xcls_PopoverAddProp  _this;
309
310
311             // my vars (def)
312
313         // ctor
314         public Xcls_namerender(Xcls_PopoverAddProp _owner )
315         {
316             _this = _owner;
317             _this.namerender = this;
318             this.el = new Gtk.CellRendererText();
319
320             // my vars (dec)
321
322             // set gobject values
323         }
324
325         // user defined functions
326     }
327
328
329     public class Xcls_type : Object
330     {
331         public Gtk.TreeViewColumn el;
332         private Xcls_PopoverAddProp  _this;
333
334
335             // my vars (def)
336
337         // ctor
338         public Xcls_type(Xcls_PopoverAddProp _owner )
339         {
340             _this = _owner;
341             _this.type = this;
342             this.el = new Gtk.TreeViewColumn();
343
344             // my vars (dec)
345
346             // set gobject values
347             this.el.sort_column_id = 4;
348             this.el.title = "Type";
349             var child_0 = new Xcls_typerender( _this );
350             child_0.ref();
351             this.el.pack_start (  child_0.el , true );
352
353             // init method
354
355             this.el.add_attribute(_this.typerender.el , "text", 1  );
356         }
357
358         // user defined functions
359     }
360     public class Xcls_typerender : Object
361     {
362         public Gtk.CellRendererText el;
363         private Xcls_PopoverAddProp  _this;
364
365
366             // my vars (def)
367
368         // ctor
369         public Xcls_typerender(Xcls_PopoverAddProp _owner )
370         {
371             _this = _owner;
372             _this.typerender = this;
373             this.el = new Gtk.CellRendererText();
374
375             // my vars (dec)
376
377             // set gobject values
378         }
379
380         // user defined functions
381     }
382
383
384     public class Xcls_from : Object
385     {
386         public Gtk.TreeViewColumn el;
387         private Xcls_PopoverAddProp  _this;
388
389
390             // my vars (def)
391
392         // ctor
393         public Xcls_from(Xcls_PopoverAddProp _owner )
394         {
395             _this = _owner;
396             _this.from = this;
397             this.el = new Gtk.TreeViewColumn();
398
399             // my vars (dec)
400
401             // set gobject values
402             this.el.sort_column_id = 5;
403             this.el.title = "From";
404             var child_0 = new Xcls_fromrender( _this );
405             child_0.ref();
406             this.el.pack_start (  child_0.el , true );
407
408             // init method
409
410             this.el.add_attribute(_this.fromrender.el , "text", 5);
411         }
412
413         // user defined functions
414     }
415     public class Xcls_fromrender : Object
416     {
417         public Gtk.CellRendererText el;
418         private Xcls_PopoverAddProp  _this;
419
420
421             // my vars (def)
422
423         // ctor
424         public Xcls_fromrender(Xcls_PopoverAddProp _owner )
425         {
426             _this = _owner;
427             _this.fromrender = this;
428             this.el = new Gtk.CellRendererText();
429
430             // my vars (dec)
431
432             // set gobject values
433         }
434
435         // user defined functions
436     }
437
438
439
440
441 }