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;
22 public DialogTemplateSelect()
25 this.el = new Gtk.Dialog();
30 this.el.title = "Add an Object";
31 this.el.default_height = 200;
32 this.el.default_width = 400;
34 var child_0 = new Xcls_VBox2( _this );
36 this.el.get_content_area().add ( child_0.el );
37 var child_1 = new Xcls_Button9( _this );
39 this.el.add_action_widget ( child_1.el , 0 );
40 var child_2 = new Xcls_Button10( _this );
42 this.el.add_action_widget ( child_2.el , 1 );
43 var child_3 = new Xcls_Button11( _this );
45 this.el.add_action_widget ( child_3.el , 2 );
48 this.el.delete_event.connect( (self, event) =>{
54 // user defined functions
55 public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {
58 var opts = pal.listTemplates(node);
59 if (opts.length() < 1) {
63 this.el.set_attached_to( pwindow);
64 this.el.set_transient_for( pwindow);
66 //opts.unshift({ path: '' , name :'Just add Element' });
67 _this.model.loadData(opts);
68 _this.combo.el.set_active(0);
71 var res = this.el.run();
73 //var ix = _this.combo.el.get_active();
75 return null; // 0 = cancel.
78 return node; // 1 = just add it..
82 _this.combo.el.get_active_iter (out iter);
84 this.model.el.get_value (iter, 0, out vfname);
87 return pal.loadTemplate((string)vfname);
90 public class Xcls_VBox2 : Object
93 private DialogTemplateSelect _this;
99 public Xcls_VBox2(DialogTemplateSelect _owner )
102 this.el = new Gtk.VBox( true, 0 );
106 // set gobject values
107 var child_0 = new Xcls_HBox3( _this );
109 this.el.pack_start ( child_0.el , false,false,0 );
112 // user defined functions
114 public class Xcls_HBox3 : Object
117 private DialogTemplateSelect _this;
123 public Xcls_HBox3(DialogTemplateSelect _owner )
126 this.el = new Gtk.HBox( true, 0 );
130 // set gobject values
131 var child_0 = new Xcls_Label4( _this );
133 this.el.pack_start ( child_0.el , false,false );
134 var child_1 = new Xcls_combo( _this );
136 this.el.add ( child_1.el );
137 var child_2 = new Xcls_Label8( _this );
139 this.el.pack_start ( child_2.el , false,false );
142 // user defined functions
144 public class Xcls_Label4 : Object
147 private DialogTemplateSelect _this;
153 public Xcls_Label4(DialogTemplateSelect _owner )
156 this.el = new Gtk.Label( "Select Template : " );
160 // set gobject values
163 // user defined functions
165 public class Xcls_combo : Object
167 public Gtk.ComboBox el;
168 private DialogTemplateSelect _this;
174 public Xcls_combo(DialogTemplateSelect _owner )
178 this.el = new Gtk.ComboBox();
182 // set gobject values
183 var child_0 = new Xcls_cellrenderer( _this );
185 this.el.pack_start ( child_0.el , true );
186 var child_1 = new Xcls_model( _this );
188 this.el.set_model ( child_1.el );
192 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
195 // user defined functions
197 public class Xcls_cellrenderer : Object
199 public Gtk.CellRendererText el;
200 private DialogTemplateSelect _this;
206 public Xcls_cellrenderer(DialogTemplateSelect _owner )
209 _this.cellrenderer = this;
210 this.el = new Gtk.CellRendererText();
214 // set gobject values
217 // user defined functions
219 public class Xcls_model : Object
221 public Gtk.ListStore el;
222 private DialogTemplateSelect _this;
228 public Xcls_model(DialogTemplateSelect _owner )
232 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
236 // set gobject values
239 // user defined functions
240 public void loadData (GLib.List<string> data) {
245 /// el.append(out iter);
248 // el.set_value(iter, 0, "");
249 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
251 for (var i = 0; i < data.length();i++) {
255 var str = data.nth_data(i);
256 var fn = Path.get_basename (str);
257 fn.replace(".json", "");
259 el.set_value(iter, 0, str);
260 el.set_value(iter, 1, fn);
263 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
267 public class Xcls_Label8 : Object
270 private DialogTemplateSelect _this;
276 public Xcls_Label8(DialogTemplateSelect _owner )
279 this.el = new Gtk.Label( "Select Template : " );
283 // set gobject values
286 // user defined functions
288 public class Xcls_Button9 : Object
290 public Gtk.Button el;
291 private DialogTemplateSelect _this;
297 public Xcls_Button9(DialogTemplateSelect _owner )
300 this.el = new Gtk.Button();
304 // set gobject values
305 this.el.label = "Cancel";
308 // user defined functions
310 public class Xcls_Button10 : Object
312 public Gtk.Button el;
313 private DialogTemplateSelect _this;
319 public Xcls_Button10(DialogTemplateSelect _owner )
322 this.el = new Gtk.Button();
326 // set gobject values
327 this.el.label = "Just add it";
330 // user defined functions
332 public class Xcls_Button11 : Object
334 public Gtk.Button el;
335 private DialogTemplateSelect _this;
341 public Xcls_Button11(DialogTemplateSelect _owner )
344 this.el = new Gtk.Button();
348 // set gobject values
349 this.el.label = "OK";
352 // user defined functions