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