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 JsRender.RooDatabase(project);
76 _this.dbcombo.el.set_active(-1);
80 var res = this.el.run();
82 //var ix = _this.combo.el.get_active();
84 return null; // 0 = cancel.
87 return node; // 1 = just add it..
91 _this.combo.el.get_active_iter (out iter);
93 this.model.el.get_value (iter, 0, out vfname);
96 return pal.loadTemplate((string)vfname);
99 public class Xcls_VBox2 : Object
102 private DialogTemplateSelect _this;
108 public Xcls_VBox2(DialogTemplateSelect _owner )
111 this.el = new Gtk.VBox( true, 0 );
115 // set gobject values
116 var child_0 = new Xcls_HBox3( _this );
118 this.el.pack_start ( child_0.el , false,false,0 );
119 var child_1 = new Xcls_HBox8( _this );
121 this.el.pack_start ( child_1.el , false,false,0 );
124 // user defined functions
126 public class Xcls_HBox3 : Object
129 private DialogTemplateSelect _this;
135 public Xcls_HBox3(DialogTemplateSelect _owner )
138 this.el = new Gtk.HBox( true, 0 );
142 // set gobject values
144 var child_0 = new Xcls_Label4( _this );
146 this.el.pack_start ( child_0.el , false,false );
147 var child_1 = new Xcls_combo( _this );
149 this.el.add ( child_1.el );
152 // user defined functions
154 public class Xcls_Label4 : Object
157 private DialogTemplateSelect _this;
163 public Xcls_Label4(DialogTemplateSelect _owner )
166 this.el = new Gtk.Label( "Select Template : " );
170 // set gobject values
173 // user defined functions
175 public class Xcls_combo : Object
177 public Gtk.ComboBox el;
178 private DialogTemplateSelect _this;
184 public Xcls_combo(DialogTemplateSelect _owner )
188 this.el = new Gtk.ComboBox();
192 // set gobject values
193 var child_0 = new Xcls_cellrenderer( _this );
195 this.el.pack_start ( child_0.el , true );
196 var child_1 = new Xcls_model( _this );
198 this.el.set_model ( child_1.el );
202 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
205 // user defined functions
207 public class Xcls_cellrenderer : Object
209 public Gtk.CellRendererText el;
210 private DialogTemplateSelect _this;
216 public Xcls_cellrenderer(DialogTemplateSelect _owner )
219 _this.cellrenderer = this;
220 this.el = new Gtk.CellRendererText();
224 // set gobject values
227 // user defined functions
229 public class Xcls_model : Object
231 public Gtk.ListStore el;
232 private DialogTemplateSelect _this;
238 public Xcls_model(DialogTemplateSelect _owner )
242 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
246 // set gobject values
249 // user defined functions
250 public void loadData (GLib.List<string> data) {
255 /// el.append(out iter);
258 // el.set_value(iter, 0, "");
259 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
261 for (var i = 0; i < data.length();i++) {
265 var str = data.nth_data(i);
266 var fn = Path.get_basename (str);
267 fn.replace(".json", "");
269 el.set_value(iter, 0, str);
270 el.set_value(iter, 1, fn);
273 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
277 public class Xcls_HBox8 : Object
280 private DialogTemplateSelect _this;
286 public Xcls_HBox8(DialogTemplateSelect _owner )
289 this.el = new Gtk.HBox( true, 0 );
293 // set gobject values
295 var child_0 = new Xcls_Label9( _this );
297 this.el.pack_start ( child_0.el , false,false );
298 var child_1 = new Xcls_dbcombo( _this );
300 this.el.add ( child_1.el );
303 // user defined functions
305 public class Xcls_Label9 : Object
308 private DialogTemplateSelect _this;
314 public Xcls_Label9(DialogTemplateSelect _owner )
317 this.el = new Gtk.Label( "Select Database Table : " );
321 // set gobject values
324 // user defined functions
326 public class Xcls_dbcombo : Object
328 public Gtk.ComboBox el;
329 private DialogTemplateSelect _this;
335 public Xcls_dbcombo(DialogTemplateSelect _owner )
338 _this.dbcombo = this;
339 this.el = new Gtk.ComboBox();
343 // set gobject values
344 var child_0 = new Xcls_dbcellrenderer( _this );
346 this.el.pack_start ( child_0.el , true );
347 var child_1 = new Xcls_dbmodel( _this );
349 this.el.set_model ( child_1.el );
353 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
356 // user defined functions
358 public class Xcls_dbcellrenderer : Object
360 public Gtk.CellRendererText el;
361 private DialogTemplateSelect _this;
367 public Xcls_dbcellrenderer(DialogTemplateSelect _owner )
370 _this.dbcellrenderer = this;
371 this.el = new Gtk.CellRendererText();
375 // set gobject values
378 // user defined functions
380 public class Xcls_dbmodel : Object
382 public Gtk.ListStore el;
383 private DialogTemplateSelect _this;
389 public Xcls_dbmodel(DialogTemplateSelect _owner )
392 _this.dbmodel = this;
393 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
397 // set gobject values
400 // user defined functions
401 public void loadData (Gee.ArrayList<string> data) {
406 /// el.append(out iter);
409 // el.set_value(iter, 0, "");
410 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
415 el.set_value(iter, 0, "");
416 el.set_value(iter, 1, "-- select a table --");
419 for (var i = 0; i < data.length();i++) {
424 el.set_value(iter, 0, data.get(i));
425 el.set_value(iter, 1, data.get(i));
428 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
432 public class Xcls_Button13 : Object
434 public Gtk.Button el;
435 private DialogTemplateSelect _this;
441 public Xcls_Button13(DialogTemplateSelect _owner )
444 this.el = new Gtk.Button();
448 // set gobject values
449 this.el.label = "Cancel";
452 // user defined functions
454 public class Xcls_Button14 : Object
456 public Gtk.Button el;
457 private DialogTemplateSelect _this;
463 public Xcls_Button14(DialogTemplateSelect _owner )
466 this.el = new Gtk.Button();
470 // set gobject values
471 this.el.label = "Just add it";
474 // user defined functions
476 public class Xcls_Button15 : Object
478 public Gtk.Button el;
479 private DialogTemplateSelect _this;
485 public Xcls_Button15(DialogTemplateSelect _owner )
488 this.el = new Gtk.Button();
492 // set gobject values
493 this.el.label = "OK";
496 // user defined functions