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_Button8( _this );
39 this.el.add_action_widget ( child_1.el , 0 );
40 var child_2 = new Xcls_Button9( _this );
42 this.el.add_action_widget ( child_2.el , 1 );
43 var child_3 = new Xcls_Button10( _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);
73 //var ix = _this.combo.el.get_active();
78 _this.combo.el.get_active_iter (out iter);
80 this.model.el.get_value (iter, 0, out vfname);
82 if (((string)vfname).length < 1) {
85 return pal.loadTemplate((string)vfname);
88 public class Xcls_VBox2 : Object
91 private DialogTemplateSelect _this;
97 public Xcls_VBox2(DialogTemplateSelect _owner )
100 this.el = new Gtk.VBox( true, 0 );
104 // set gobject values
105 var child_0 = new Xcls_HBox3( _this );
107 this.el.pack_start ( child_0.el , false,false,0 );
110 // user defined functions
112 public class Xcls_HBox3 : Object
115 private DialogTemplateSelect _this;
121 public Xcls_HBox3(DialogTemplateSelect _owner )
124 this.el = new Gtk.HBox( true, 0 );
128 // set gobject values
129 var child_0 = new Xcls_Label4( _this );
131 this.el.pack_start ( child_0.el , false,false );
132 var child_1 = new Xcls_combo( _this );
134 this.el.add ( child_1.el );
137 // user defined functions
139 public class Xcls_Label4 : Object
142 private DialogTemplateSelect _this;
148 public Xcls_Label4(DialogTemplateSelect _owner )
151 this.el = new Gtk.Label( "Select Template : " );
155 // set gobject values
158 // user defined functions
160 public class Xcls_combo : Object
162 public Gtk.ComboBox el;
163 private DialogTemplateSelect _this;
169 public Xcls_combo(DialogTemplateSelect _owner )
173 this.el = new Gtk.ComboBox();
177 // set gobject values
178 var child_0 = new Xcls_cellrenderer( _this );
180 this.el.pack_start ( child_0.el , true );
181 var child_1 = new Xcls_model( _this );
183 this.el.set_model ( child_1.el );
187 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
190 // user defined functions
192 public class Xcls_cellrenderer : Object
194 public Gtk.CellRendererText el;
195 private DialogTemplateSelect _this;
201 public Xcls_cellrenderer(DialogTemplateSelect _owner )
204 _this.cellrenderer = this;
205 this.el = new Gtk.CellRendererText();
209 // set gobject values
212 // user defined functions
214 public class Xcls_model : Object
216 public Gtk.ListStore el;
217 private DialogTemplateSelect _this;
223 public Xcls_model(DialogTemplateSelect _owner )
227 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
231 // set gobject values
234 // user defined functions
235 public void loadData (GLib.List<string> data) {
240 /// el.append(out iter);
243 // el.set_value(iter, 0, "");
244 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
246 for (var i = 0; i < data.length();i++) {
250 var str = data.nth_data(i);
251 var fn = Path.get_basename (str);
252 fn.replace(".json", "");
254 el.set_value(iter, 0, str);
255 el.set_value(iter, 1, fn);
258 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
262 public class Xcls_Button8 : Object
264 public Gtk.Button el;
265 private DialogTemplateSelect _this;
271 public Xcls_Button8(DialogTemplateSelect _owner )
274 this.el = new Gtk.Button();
278 // set gobject values
279 this.el.label = "Cancel";
282 // user defined functions
284 public class Xcls_Button9 : Object
286 public Gtk.Button el;
287 private DialogTemplateSelect _this;
293 public Xcls_Button9(DialogTemplateSelect _owner )
296 this.el = new Gtk.Button();
300 // set gobject values
301 this.el.label = "Just add it";
304 // user defined functions
306 public class Xcls_Button10 : Object
308 public Gtk.Button el;
309 private DialogTemplateSelect _this;
315 public Xcls_Button10(DialogTemplateSelect _owner )
318 this.el = new Gtk.Button();
322 // set gobject values
323 this.el.label = "OK";
326 // user defined functions