src/Builder4/DialogTemplateSelect.bjs
[app.Builder.js] / src / Builder4 / DialogTemplateSelect.vala
1 static DialogTemplateSelect  _DialogTemplateSelect;
2
3 public class DialogTemplateSelect : Object 
4 {
5     public Gtk.Dialog el;
6     private DialogTemplateSelect  _this;
7
8     public static DialogTemplateSelect singleton()
9     {
10         if (_DialogTemplateSelect == null) {
11             _DialogTemplateSelect= new DialogTemplateSelect();
12         }
13         return _DialogTemplateSelect;
14     }
15     public Xcls_combo combo;
16     public Xcls_cellrenderer cellrenderer;
17     public Xcls_model model;
18     public Xcls_combo combo;
19     public Xcls_cellrenderer cellrenderer;
20     public Xcls_model model;
21
22         // my vars (def)
23
24     // ctor 
25     public DialogTemplateSelect()
26     {
27         _this = this;
28         this.el = new Gtk.Dialog();
29
30         // my vars (dec)
31
32         // set gobject values
33         this.el.title = "Add an Object";
34         this.el.default_height = 200;
35         this.el.default_width = 400;
36         this.el.modal = true;
37         var child_0 = new Xcls_VBox2( _this );
38         child_0.ref();
39         this.el.get_content_area().add (  child_0.el  );
40         var child_1 = new Xcls_Button12( _this );
41         child_1.ref();
42         this.el.add_action_widget (  child_1.el , 0 );
43         var child_2 = new Xcls_Button13( _this );
44         child_2.ref();
45         this.el.add_action_widget (  child_2.el , 1 );
46         var child_3 = new Xcls_Button14( _this );
47         child_3.ref();
48         this.el.add_action_widget (  child_3.el , 2 );
49
50         // listeners 
51         this.el.delete_event.connect( (self, event)  =>{
52             this.el.hide();
53             return true;
54         });
55     }
56
57     // user defined functions 
58     public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {
59         
60         this.el.show_all();
61         var opts = pal.listTemplates(node);
62         if (opts.length() < 1) {
63             this.el.hide();
64             return node;
65         }
66         this.el.set_attached_to( pwindow);
67          this.el.set_transient_for( pwindow);
68         
69         //opts.unshift({ path: '' , name :'Just add Element' });
70          _this.model.loadData(opts);
71          _this.combo.el.set_active(0);
72          
73        
74         var res = this.el.run();
75         this.el.hide();    
76         //var ix = _this.combo.el.get_active();
77         if (res < 1 ) {
78             return null; // 0 = cancel.
79         }
80         if (res < 2 ) {
81             return node; // 1 = just add it..
82         }
83         
84        Gtk.TreeIter iter;
85         _this.combo.el.get_active_iter (out iter);
86         Value vfname;
87         this.model.el.get_value (iter, 0, out vfname);
88         
89         
90         return pal.loadTemplate((string)vfname);
91     
92     }
93     public class Xcls_VBox2 : Object 
94     {
95         public Gtk.VBox el;
96         private DialogTemplateSelect  _this;
97
98
99             // my vars (def)
100
101         // ctor 
102         public Xcls_VBox2(DialogTemplateSelect _owner )
103         {
104             _this = _owner;
105             this.el = new Gtk.VBox( true, 0 );
106
107             // my vars (dec)
108
109             // set gobject values
110             var child_0 = new Xcls_HBox3( _this );
111             child_0.ref();
112             this.el.pack_start (  child_0.el , false,false,0 );
113         }
114
115         // user defined functions 
116     }
117     public class Xcls_HBox3 : Object 
118     {
119         public Gtk.HBox el;
120         private DialogTemplateSelect  _this;
121
122
123             // my vars (def)
124
125         // ctor 
126         public Xcls_HBox3(DialogTemplateSelect _owner )
127         {
128             _this = _owner;
129             this.el = new Gtk.HBox( true, 0 );
130
131             // my vars (dec)
132
133             // set gobject values
134             var child_0 = new Xcls_Label4( _this );
135             child_0.ref();
136             this.el.pack_start (  child_0.el , false,false );
137             var child_1 = new Xcls_combo( _this );
138             child_1.ref();
139             this.el.add (  child_1.el  );
140             var child_2 = new Xcls_Label8( _this );
141             child_2.ref();
142             this.el.pack_start (  child_2.el , false,false );
143             var child_3 = new Xcls_combo( _this );
144             child_3.ref();
145             this.el.add (  child_3.el  );
146         }
147
148         // user defined functions 
149     }
150     public class Xcls_Label4 : Object 
151     {
152         public Gtk.Label el;
153         private DialogTemplateSelect  _this;
154
155
156             // my vars (def)
157
158         // ctor 
159         public Xcls_Label4(DialogTemplateSelect _owner )
160         {
161             _this = _owner;
162             this.el = new Gtk.Label( "Select Template : " );
163
164             // my vars (dec)
165
166             // set gobject values
167         }
168
169         // user defined functions 
170     }
171     public class Xcls_combo : Object 
172     {
173         public Gtk.ComboBox el;
174         private DialogTemplateSelect  _this;
175
176
177             // my vars (def)
178
179         // ctor 
180         public Xcls_combo(DialogTemplateSelect _owner )
181         {
182             _this = _owner;
183             _this.combo = this;
184             this.el = new Gtk.ComboBox();
185
186             // my vars (dec)
187
188             // set gobject values
189             var child_0 = new Xcls_cellrenderer( _this );
190             child_0.ref();
191             this.el.pack_start (  child_0.el , true );
192             var child_1 = new Xcls_model( _this );
193             child_1.ref();
194             this.el.set_model (  child_1.el  );
195
196             // init method 
197
198             this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
199         }
200
201         // user defined functions 
202     }
203     public class Xcls_cellrenderer : Object 
204     {
205         public Gtk.CellRendererText el;
206         private DialogTemplateSelect  _this;
207
208
209             // my vars (def)
210
211         // ctor 
212         public Xcls_cellrenderer(DialogTemplateSelect _owner )
213         {
214             _this = _owner;
215             _this.cellrenderer = this;
216             this.el = new Gtk.CellRendererText();
217
218             // my vars (dec)
219
220             // set gobject values
221         }
222
223         // user defined functions 
224     }
225     public class Xcls_model : Object 
226     {
227         public Gtk.ListStore el;
228         private DialogTemplateSelect  _this;
229
230
231             // my vars (def)
232
233         // ctor 
234         public Xcls_model(DialogTemplateSelect _owner )
235         {
236             _this = _owner;
237             _this.model = this;
238             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
239
240             // my vars (dec)
241
242             // set gobject values
243         }
244
245         // user defined functions 
246         public void loadData (GLib.List<string> data) {
247             this.el.clear();                                    
248             Gtk.TreeIter iter;
249             var el = this.el;
250             
251            /// el.append(out iter);
252             
253              
254            // el.set_value(iter, 0, "");
255            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
256             
257             for (var i = 0; i < data.length();i++) {
258             
259         
260                 el.append(out iter);
261                 var str = data.nth_data(i);
262                 var fn = Path.get_basename (str);
263                 fn.replace(".json", "");
264                 
265                 el.set_value(iter, 0, str);
266                 el.set_value(iter, 1, fn);
267                 
268             }
269             this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);          
270                                              
271         }
272     }
273     public class Xcls_Label8 : Object 
274     {
275         public Gtk.Label el;
276         private DialogTemplateSelect  _this;
277
278
279             // my vars (def)
280
281         // ctor 
282         public Xcls_Label8(DialogTemplateSelect _owner )
283         {
284             _this = _owner;
285             this.el = new Gtk.Label( "Select Database Table : " );
286
287             // my vars (dec)
288
289             // set gobject values
290         }
291
292         // user defined functions 
293     }
294     public class Xcls_combo : Object 
295     {
296         public Gtk.ComboBox el;
297         private DialogTemplateSelect  _this;
298
299
300             // my vars (def)
301
302         // ctor 
303         public Xcls_combo(DialogTemplateSelect _owner )
304         {
305             _this = _owner;
306             _this.combo = this;
307             this.el = new Gtk.ComboBox();
308
309             // my vars (dec)
310
311             // set gobject values
312             var child_0 = new Xcls_cellrenderer( _this );
313             child_0.ref();
314             this.el.pack_start (  child_0.el , true );
315             var child_1 = new Xcls_model( _this );
316             child_1.ref();
317             this.el.set_model (  child_1.el  );
318
319             // init method 
320
321             this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
322         }
323
324         // user defined functions 
325     }
326     public class Xcls_cellrenderer : Object 
327     {
328         public Gtk.CellRendererText el;
329         private DialogTemplateSelect  _this;
330
331
332             // my vars (def)
333
334         // ctor 
335         public Xcls_cellrenderer(DialogTemplateSelect _owner )
336         {
337             _this = _owner;
338             _this.cellrenderer = this;
339             this.el = new Gtk.CellRendererText();
340
341             // my vars (dec)
342
343             // set gobject values
344         }
345
346         // user defined functions 
347     }
348     public class Xcls_model : Object 
349     {
350         public Gtk.ListStore el;
351         private DialogTemplateSelect  _this;
352
353
354             // my vars (def)
355
356         // ctor 
357         public Xcls_model(DialogTemplateSelect _owner )
358         {
359             _this = _owner;
360             _this.model = this;
361             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
362
363             // my vars (dec)
364
365             // set gobject values
366         }
367
368         // user defined functions 
369         public void loadData (GLib.List<string> data) {
370             this.el.clear();                                    
371             Gtk.TreeIter iter;
372             var el = this.el;
373             
374            /// el.append(out iter);
375             
376              
377            // el.set_value(iter, 0, "");
378            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
379             
380             for (var i = 0; i < data.length();i++) {
381             
382         
383                 el.append(out iter);
384                 var str = data.nth_data(i);
385                 var fn = Path.get_basename (str);
386                 fn.replace(".json", "");
387                 
388                 el.set_value(iter, 0, str);
389                 el.set_value(iter, 1, fn);
390                 
391             }
392             this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);          
393                                              
394         }
395     }
396     public class Xcls_Button12 : Object 
397     {
398         public Gtk.Button el;
399         private DialogTemplateSelect  _this;
400
401
402             // my vars (def)
403
404         // ctor 
405         public Xcls_Button12(DialogTemplateSelect _owner )
406         {
407             _this = _owner;
408             this.el = new Gtk.Button();
409
410             // my vars (dec)
411
412             // set gobject values
413             this.el.label = "Cancel";
414         }
415
416         // user defined functions 
417     }
418     public class Xcls_Button13 : Object 
419     {
420         public Gtk.Button el;
421         private DialogTemplateSelect  _this;
422
423
424             // my vars (def)
425
426         // ctor 
427         public Xcls_Button13(DialogTemplateSelect _owner )
428         {
429             _this = _owner;
430             this.el = new Gtk.Button();
431
432             // my vars (dec)
433
434             // set gobject values
435             this.el.label = "Just add it";
436         }
437
438         // user defined functions 
439     }
440     public class Xcls_Button14 : Object 
441     {
442         public Gtk.Button el;
443         private DialogTemplateSelect  _this;
444
445
446             // my vars (def)
447
448         // ctor 
449         public Xcls_Button14(DialogTemplateSelect _owner )
450         {
451             _this = _owner;
452             this.el = new Gtk.Button();
453
454             // my vars (dec)
455
456             // set gobject values
457             this.el.label = "OK";
458         }
459
460         // user defined functions 
461     }
462 }