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, Project.Project project) {
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(-1);
74 var db = new Palete.RooDatabase.from_project(project);
75 _this.dbmodel.loadData(db.readTablesGee());
78 _this.dbcombo.el.set_active(-1);
82 var res = this.el.run();
84 //var ix = _this.combo.el.get_active();
86 return null; // 0 = cancel.
89 return node; // 1 = just add it..
93 _this.combo.el.get_active_iter (out iter);
95 return node; // nothing selected...
98 this.model.el.get_value (iter, 0, out vfname);
101 return pal.loadTemplate((string)vfname);
104 public class Xcls_VBox2 : Object
107 private DialogTemplateSelect _this;
113 public Xcls_VBox2(DialogTemplateSelect _owner )
116 this.el = new Gtk.VBox( true, 0 );
120 // set gobject values
121 var child_0 = new Xcls_HBox3( _this );
123 this.el.pack_start ( child_0.el , false,false,0 );
124 var child_1 = new Xcls_HBox8( _this );
126 this.el.pack_start ( child_1.el , false,false,0 );
129 // user defined functions
131 public class Xcls_HBox3 : Object
134 private DialogTemplateSelect _this;
140 public Xcls_HBox3(DialogTemplateSelect _owner )
143 this.el = new Gtk.HBox( true, 0 );
147 // set gobject values
149 var child_0 = new Xcls_Label4( _this );
151 this.el.pack_start ( child_0.el , false,false );
152 var child_1 = new Xcls_combo( _this );
154 this.el.add ( child_1.el );
157 // user defined functions
159 public class Xcls_Label4 : Object
162 private DialogTemplateSelect _this;
168 public Xcls_Label4(DialogTemplateSelect _owner )
171 this.el = new Gtk.Label( "Select Template : " );
175 // set gobject values
178 // user defined functions
180 public class Xcls_combo : Object
182 public Gtk.ComboBox el;
183 private DialogTemplateSelect _this;
189 public Xcls_combo(DialogTemplateSelect _owner )
193 this.el = new Gtk.ComboBox();
197 // set gobject values
198 var child_0 = new Xcls_cellrenderer( _this );
200 this.el.pack_start ( child_0.el , true );
201 var child_1 = new Xcls_model( _this );
203 this.el.set_model ( child_1.el );
207 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
210 // user defined functions
212 public class Xcls_cellrenderer : Object
214 public Gtk.CellRendererText el;
215 private DialogTemplateSelect _this;
221 public Xcls_cellrenderer(DialogTemplateSelect _owner )
224 _this.cellrenderer = this;
225 this.el = new Gtk.CellRendererText();
229 // set gobject values
232 // user defined functions
234 public class Xcls_model : Object
236 public Gtk.ListStore el;
237 private DialogTemplateSelect _this;
243 public Xcls_model(DialogTemplateSelect _owner )
247 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
251 // set gobject values
254 // user defined functions
255 public void loadData (GLib.List<string> data) {
260 /// el.append(out iter);
263 // el.set_value(iter, 0, "");
264 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
266 for (var i = 0; i < data.length();i++) {
270 var str = data.nth_data(i);
271 var fn = Path.get_basename (str);
272 fn.replace(".json", "");
274 el.set_value(iter, 0, str);
275 el.set_value(iter, 1, fn);
278 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
282 public class Xcls_HBox8 : Object
285 private DialogTemplateSelect _this;
291 public Xcls_HBox8(DialogTemplateSelect _owner )
294 this.el = new Gtk.HBox( true, 0 );
298 // set gobject values
300 var child_0 = new Xcls_Label9( _this );
302 this.el.pack_start ( child_0.el , false,false );
303 var child_1 = new Xcls_dbcombo( _this );
305 this.el.add ( child_1.el );
308 // user defined functions
310 public class Xcls_Label9 : Object
313 private DialogTemplateSelect _this;
319 public Xcls_Label9(DialogTemplateSelect _owner )
322 this.el = new Gtk.Label( "Select Database Table : " );
326 // set gobject values
329 // user defined functions
331 public class Xcls_dbcombo : Object
333 public Gtk.ComboBox el;
334 private DialogTemplateSelect _this;
340 public Xcls_dbcombo(DialogTemplateSelect _owner )
343 _this.dbcombo = this;
344 this.el = new Gtk.ComboBox();
348 // set gobject values
349 var child_0 = new Xcls_dbcellrenderer( _this );
351 this.el.pack_start ( child_0.el , true );
352 var child_1 = new Xcls_dbmodel( _this );
354 this.el.set_model ( child_1.el );
358 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
361 // user defined functions
363 public class Xcls_dbcellrenderer : Object
365 public Gtk.CellRendererText el;
366 private DialogTemplateSelect _this;
372 public Xcls_dbcellrenderer(DialogTemplateSelect _owner )
375 _this.dbcellrenderer = this;
376 this.el = new Gtk.CellRendererText();
380 // set gobject values
383 // user defined functions
385 public class Xcls_dbmodel : Object
387 public Gtk.ListStore el;
388 private DialogTemplateSelect _this;
394 public Xcls_dbmodel(DialogTemplateSelect _owner )
397 _this.dbmodel = this;
398 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
402 // set gobject values
405 // user defined functions
406 public void loadData (Gee.ArrayList<string> data) {
411 /// el.append(out iter);
414 // el.set_value(iter, 0, "");
415 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
420 el.set_value(iter, 0, "");
421 el.set_value(iter, 1, "-- select a table --");
424 for (var i = 0; i < data.size;i++) {
429 el.set_value(iter, 0, data.get(i));
430 el.set_value(iter, 1, data.get(i));
433 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
437 public class Xcls_Button13 : Object
439 public Gtk.Button el;
440 private DialogTemplateSelect _this;
446 public Xcls_Button13(DialogTemplateSelect _owner )
449 this.el = new Gtk.Button();
453 // set gobject values
454 this.el.label = "Cancel";
457 // user defined functions
459 public class Xcls_Button14 : Object
461 public Gtk.Button el;
462 private DialogTemplateSelect _this;
468 public Xcls_Button14(DialogTemplateSelect _owner )
471 this.el = new Gtk.Button();
475 // set gobject values
476 this.el.label = "Just add it";
479 // user defined functions
481 public class Xcls_Button15 : Object
483 public Gtk.Button el;
484 private DialogTemplateSelect _this;
490 public Xcls_Button15(DialogTemplateSelect _owner )
493 this.el = new Gtk.Button();
497 // set gobject values
498 this.el.label = "OK";
501 // user defined functions