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 (Xcls_MainWindow mwindow, 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( mwindow.el);
67 this.el.set_transient_for( mwindow.el);
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());
77 var plug = mwindow.windowstate.webkit_plugin;
79 _this.dbcombo.el.set_active(-1);
83 var res = this.el.run();
85 //var ix = _this.combo.el.get_active();
87 return null; // 0 = cancel.
90 return node; // 1 = just add it..
93 // have they selected a table??
97 if (_this.dbcombo.el.get_active_iter (out iter)) {
98 this.dbmodel.el.get_value (iter, 0, out vfname);
99 if (plug.has_plugin(node.fqn())) {
100 var json_str = plug.show(mwindow.el, project, node.fqn(), (string)vfname);
106 if (!_this.combo.el.get_active_iter (out iter)) {
108 return node; // nothing selected...
111 this.model.el.get_value (iter, 0, out vfname);
114 return pal.loadTemplate((string)vfname);
117 public class Xcls_VBox2 : Object
120 private DialogTemplateSelect _this;
126 public Xcls_VBox2(DialogTemplateSelect _owner )
129 this.el = new Gtk.VBox( true, 0 );
133 // set gobject values
134 var child_0 = new Xcls_HBox3( _this );
136 this.el.pack_start ( child_0.el , false,false,0 );
137 var child_1 = new Xcls_HBox8( _this );
139 this.el.pack_start ( child_1.el , false,false,0 );
142 // user defined functions
144 public class Xcls_HBox3 : Object
147 private DialogTemplateSelect _this;
153 public Xcls_HBox3(DialogTemplateSelect _owner )
156 this.el = new Gtk.HBox( true, 0 );
160 // set gobject values
162 var child_0 = new Xcls_Label4( _this );
164 this.el.pack_start ( child_0.el , false,false );
165 var child_1 = new Xcls_combo( _this );
167 this.el.add ( child_1.el );
170 // user defined functions
172 public class Xcls_Label4 : Object
175 private DialogTemplateSelect _this;
181 public Xcls_Label4(DialogTemplateSelect _owner )
184 this.el = new Gtk.Label( "Select Template : " );
188 // set gobject values
191 // user defined functions
193 public class Xcls_combo : Object
195 public Gtk.ComboBox el;
196 private DialogTemplateSelect _this;
202 public Xcls_combo(DialogTemplateSelect _owner )
206 this.el = new Gtk.ComboBox();
210 // set gobject values
211 var child_0 = new Xcls_cellrenderer( _this );
213 this.el.pack_start ( child_0.el , true );
214 var child_1 = new Xcls_model( _this );
216 this.el.set_model ( child_1.el );
220 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
223 // user defined functions
225 public class Xcls_cellrenderer : Object
227 public Gtk.CellRendererText el;
228 private DialogTemplateSelect _this;
234 public Xcls_cellrenderer(DialogTemplateSelect _owner )
237 _this.cellrenderer = this;
238 this.el = new Gtk.CellRendererText();
242 // set gobject values
245 // user defined functions
247 public class Xcls_model : Object
249 public Gtk.ListStore el;
250 private DialogTemplateSelect _this;
256 public Xcls_model(DialogTemplateSelect _owner )
260 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
264 // set gobject values
267 // user defined functions
268 public void loadData (GLib.List<string> data) {
273 /// el.append(out iter);
276 // el.set_value(iter, 0, "");
277 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
279 for (var i = 0; i < data.length();i++) {
283 var str = data.nth_data(i);
284 var fn = Path.get_basename (str);
285 fn.replace(".json", "");
287 el.set_value(iter, 0, str);
288 el.set_value(iter, 1, fn);
291 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
295 public class Xcls_HBox8 : Object
298 private DialogTemplateSelect _this;
304 public Xcls_HBox8(DialogTemplateSelect _owner )
307 this.el = new Gtk.HBox( true, 0 );
311 // set gobject values
313 var child_0 = new Xcls_Label9( _this );
315 this.el.pack_start ( child_0.el , false,false );
316 var child_1 = new Xcls_dbcombo( _this );
318 this.el.add ( child_1.el );
321 // user defined functions
323 public class Xcls_Label9 : Object
326 private DialogTemplateSelect _this;
332 public Xcls_Label9(DialogTemplateSelect _owner )
335 this.el = new Gtk.Label( "Select Database Table : " );
339 // set gobject values
342 // user defined functions
344 public class Xcls_dbcombo : Object
346 public Gtk.ComboBox el;
347 private DialogTemplateSelect _this;
353 public Xcls_dbcombo(DialogTemplateSelect _owner )
356 _this.dbcombo = this;
357 this.el = new Gtk.ComboBox();
361 // set gobject values
362 var child_0 = new Xcls_dbcellrenderer( _this );
364 this.el.pack_start ( child_0.el , true );
365 var child_1 = new Xcls_dbmodel( _this );
367 this.el.set_model ( child_1.el );
371 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
374 // user defined functions
376 public class Xcls_dbcellrenderer : Object
378 public Gtk.CellRendererText el;
379 private DialogTemplateSelect _this;
385 public Xcls_dbcellrenderer(DialogTemplateSelect _owner )
388 _this.dbcellrenderer = this;
389 this.el = new Gtk.CellRendererText();
393 // set gobject values
396 // user defined functions
398 public class Xcls_dbmodel : Object
400 public Gtk.ListStore el;
401 private DialogTemplateSelect _this;
407 public Xcls_dbmodel(DialogTemplateSelect _owner )
410 _this.dbmodel = this;
411 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
415 // set gobject values
418 // user defined functions
419 public void loadData (Gee.ArrayList<string> data) {
424 /// el.append(out iter);
427 // el.set_value(iter, 0, "");
428 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
433 el.set_value(iter, 0, "");
434 el.set_value(iter, 1, "-- select a table --");
437 for (var i = 0; i < data.size;i++) {
442 el.set_value(iter, 0, data.get(i));
443 el.set_value(iter, 1, data.get(i));
446 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
450 public class Xcls_Button13 : Object
452 public Gtk.Button el;
453 private DialogTemplateSelect _this;
459 public Xcls_Button13(DialogTemplateSelect _owner )
462 this.el = new Gtk.Button();
466 // set gobject values
467 this.el.label = "Cancel";
470 // user defined functions
472 public class Xcls_Button14 : Object
474 public Gtk.Button el;
475 private DialogTemplateSelect _this;
481 public Xcls_Button14(DialogTemplateSelect _owner )
484 this.el = new Gtk.Button();
488 // set gobject values
489 this.el.label = "Just add it";
492 // user defined functions
494 public class Xcls_Button15 : Object
496 public Gtk.Button el;
497 private DialogTemplateSelect _this;
503 public Xcls_Button15(DialogTemplateSelect _owner )
506 this.el = new Gtk.Button();
510 // set gobject values
511 this.el.label = "OK";
514 // user defined functions