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