1 static DialogTemplateSelect _DialogTemplateSelect;
3 public class DialogTemplateSelect : Object
6 private DialogTemplateSelect _this;
8 public static DialogTemplateSelect singleton()
10 if (_DialogTemplateSelect == null) {
11 _DialogTemplateSelect= new DialogTemplateSelect();
13 return _DialogTemplateSelect;
15 public Xcls_combo combo;
16 public Xcls_cellrenderer cellrenderer;
17 public Xcls_model model;
18 public Xcls_dbcombo dbcombo;
19 public Xcls_dbcellrenderer dbcellrenderer;
20 public Xcls_dbmodel dbmodel;
25 public DialogTemplateSelect()
28 this.el = new Gtk.Dialog();
33 this.el.title = "Add an Object";
34 this.el.default_height = 200;
35 this.el.default_width = 400;
37 var child_0 = new Xcls_VBox2( _this );
39 this.el.get_content_area().add ( child_0.el );
40 var child_1 = new Xcls_Button13( _this );
42 this.el.add_action_widget ( child_1.el , 0 );
43 var child_2 = new Xcls_Button14( _this );
45 this.el.add_action_widget ( child_2.el , 1 );
46 var child_3 = new Xcls_Button15( _this );
48 this.el.add_action_widget ( child_3.el , 2 );
51 this.el.delete_event.connect( (self, event) =>{
57 // user defined functions
58 public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {
61 var opts = pal.listTemplates(node);
62 if (opts.length() < 1) {
66 this.el.set_attached_to( pwindow);
67 this.el.set_transient_for( pwindow);
69 //opts.unshift({ path: '' , name :'Just add Element' });
70 _this.model.loadData(opts);
71 _this.combo.el.set_active(0);
74 var res = this.el.run();
76 //var ix = _this.combo.el.get_active();
78 return null; // 0 = cancel.
81 return node; // 1 = just add it..
85 _this.combo.el.get_active_iter (out iter);
87 this.model.el.get_value (iter, 0, out vfname);
90 return pal.loadTemplate((string)vfname);
93 public class Xcls_VBox2 : Object
96 private DialogTemplateSelect _this;
102 public Xcls_VBox2(DialogTemplateSelect _owner )
105 this.el = new Gtk.VBox( true, 0 );
109 // set gobject values
110 var child_0 = new Xcls_HBox3( _this );
112 this.el.pack_start ( child_0.el , false,false,0 );
113 var child_1 = new Xcls_HBox8( _this );
115 this.el.pack_start ( child_1.el , false,false,0 );
118 // user defined functions
120 public class Xcls_HBox3 : Object
123 private DialogTemplateSelect _this;
129 public Xcls_HBox3(DialogTemplateSelect _owner )
132 this.el = new Gtk.HBox( true, 0 );
136 // set gobject values
138 var child_0 = new Xcls_Label4( _this );
140 this.el.pack_start ( child_0.el , false,false );
141 var child_1 = new Xcls_combo( _this );
143 this.el.add ( child_1.el );
146 // user defined functions
148 public class Xcls_Label4 : Object
151 private DialogTemplateSelect _this;
157 public Xcls_Label4(DialogTemplateSelect _owner )
160 this.el = new Gtk.Label( "Select Template : " );
164 // set gobject values
167 // user defined functions
169 public class Xcls_combo : Object
171 public Gtk.ComboBox el;
172 private DialogTemplateSelect _this;
178 public Xcls_combo(DialogTemplateSelect _owner )
182 this.el = new Gtk.ComboBox();
186 // set gobject values
187 var child_0 = new Xcls_cellrenderer( _this );
189 this.el.pack_start ( child_0.el , true );
190 var child_1 = new Xcls_model( _this );
192 this.el.set_model ( child_1.el );
196 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
199 // user defined functions
201 public class Xcls_cellrenderer : Object
203 public Gtk.CellRendererText el;
204 private DialogTemplateSelect _this;
210 public Xcls_cellrenderer(DialogTemplateSelect _owner )
213 _this.cellrenderer = this;
214 this.el = new Gtk.CellRendererText();
218 // set gobject values
221 // user defined functions
223 public class Xcls_model : Object
225 public Gtk.ListStore el;
226 private DialogTemplateSelect _this;
232 public Xcls_model(DialogTemplateSelect _owner )
236 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
240 // set gobject values
243 // user defined functions
244 public void loadData (GLib.List<string> data) {
249 /// el.append(out iter);
252 // el.set_value(iter, 0, "");
253 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
255 for (var i = 0; i < data.length();i++) {
259 var str = data.nth_data(i);
260 var fn = Path.get_basename (str);
261 fn.replace(".json", "");
263 el.set_value(iter, 0, str);
264 el.set_value(iter, 1, fn);
267 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
271 public class Xcls_HBox8 : Object
274 private DialogTemplateSelect _this;
280 public Xcls_HBox8(DialogTemplateSelect _owner )
283 this.el = new Gtk.HBox( true, 0 );
287 // set gobject values
289 var child_0 = new Xcls_Label9( _this );
291 this.el.pack_start ( child_0.el , false,false );
292 var child_1 = new Xcls_dbcombo( _this );
294 this.el.add ( child_1.el );
297 // user defined functions
299 public class Xcls_Label9 : Object
302 private DialogTemplateSelect _this;
308 public Xcls_Label9(DialogTemplateSelect _owner )
311 this.el = new Gtk.Label( "Select Database Table : " );
315 // set gobject values
318 // user defined functions
320 public class Xcls_dbcombo : Object
322 public Gtk.ComboBox el;
323 private DialogTemplateSelect _this;
329 public Xcls_dbcombo(DialogTemplateSelect _owner )
332 _this.dbcombo = this;
333 this.el = new Gtk.ComboBox();
337 // set gobject values
338 var child_0 = new Xcls_dbcellrenderer( _this );
340 this.el.pack_start ( child_0.el , true );
341 var child_1 = new Xcls_dbmodel( _this );
343 this.el.set_model ( child_1.el );
347 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
350 // user defined functions
352 public class Xcls_dbcellrenderer : Object
354 public Gtk.CellRendererText el;
355 private DialogTemplateSelect _this;
361 public Xcls_dbcellrenderer(DialogTemplateSelect _owner )
364 _this.dbcellrenderer = this;
365 this.el = new Gtk.CellRendererText();
369 // set gobject values
372 // user defined functions
374 public class Xcls_dbmodel : Object
376 public Gtk.ListStore el;
377 private DialogTemplateSelect _this;
383 public Xcls_dbmodel(DialogTemplateSelect _owner )
386 _this.dbmodel = this;
387 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
391 // set gobject values
394 // user defined functions
395 public void loadData (Gee.ArrayList<string> data) {
400 /// el.append(out iter);
403 // el.set_value(iter, 0, "");
404 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
409 el.set_value(iter, 0, "");
410 el.set_value(iter, 1, "-- select a table --");
413 for (var i = 0; i < data.length();i++) {
418 el.set_value(iter, 0, data.get(i));
419 el.set_value(iter, 1, data.get(i));
422 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
426 public class Xcls_Button13 : Object
428 public Gtk.Button el;
429 private DialogTemplateSelect _this;
435 public Xcls_Button13(DialogTemplateSelect _owner )
438 this.el = new Gtk.Button();
442 // set gobject values
443 this.el.label = "Cancel";
446 // user defined functions
448 public class Xcls_Button14 : Object
450 public Gtk.Button el;
451 private DialogTemplateSelect _this;
457 public Xcls_Button14(DialogTemplateSelect _owner )
460 this.el = new Gtk.Button();
464 // set gobject values
465 this.el.label = "Just add it";
468 // user defined functions
470 public class Xcls_Button15 : Object
472 public Gtk.Button el;
473 private DialogTemplateSelect _this;
479 public Xcls_Button15(DialogTemplateSelect _owner )
482 this.el = new Gtk.Button();
486 // set gobject values
487 this.el.label = "OK";
490 // user defined functions