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 );
42 this.el.delete_event.connect( (self, event) =>{
48 // user defined functions
49 public JsRender.Node? show (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {
52 var opts = pal.listTemplates(node);
53 if (opts.length() < 1) {
57 this.el.set_attached_to( pwindow);
58 this.el.set_transient_for( pwindow);
60 //opts.unshift({ path: '' , name :'Just add Element' });
61 _this.model.loadData(opts);
62 _this.combo.el.set_active(0);
67 //var ix = _this.combo.el.get_active();
72 _this.combo.el.get_active_iter (out iter);
74 this.model.el.get_value (iter, 0, out vfname);
76 if (((string)vfname).length < 1) {
79 return pal.loadTemplate((string)vfname);
82 public class Xcls_VBox2 : Object
85 private DialogTemplateSelect _this;
91 public Xcls_VBox2(DialogTemplateSelect _owner )
94 this.el = new Gtk.VBox( true, 0 );
99 var child_0 = new Xcls_HBox3( _this );
101 this.el.pack_start ( child_0.el , false,false,0 );
104 // user defined functions
106 public class Xcls_HBox3 : Object
109 private DialogTemplateSelect _this;
115 public Xcls_HBox3(DialogTemplateSelect _owner )
118 this.el = new Gtk.HBox( true, 0 );
122 // set gobject values
123 var child_0 = new Xcls_Label4( _this );
125 this.el.pack_start ( child_0.el , false,false );
126 var child_1 = new Xcls_combo( _this );
128 this.el.add ( child_1.el );
131 // user defined functions
133 public class Xcls_Label4 : Object
136 private DialogTemplateSelect _this;
142 public Xcls_Label4(DialogTemplateSelect _owner )
145 this.el = new Gtk.Label( "Select Template : " );
149 // set gobject values
152 // user defined functions
154 public class Xcls_combo : Object
156 public Gtk.ComboBox el;
157 private DialogTemplateSelect _this;
163 public Xcls_combo(DialogTemplateSelect _owner )
167 this.el = new Gtk.ComboBox();
171 // set gobject values
172 var child_0 = new Xcls_cellrenderer( _this );
174 this.el.pack_start ( child_0.el , true );
175 var child_1 = new Xcls_model( _this );
177 this.el.set_model ( child_1.el );
181 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 ); }
183 // user defined functions
185 public class Xcls_cellrenderer : Object
187 public Gtk.CellRendererText el;
188 private DialogTemplateSelect _this;
194 public Xcls_cellrenderer(DialogTemplateSelect _owner )
197 _this.cellrenderer = this;
198 this.el = new Gtk.CellRendererText();
202 // set gobject values
205 // user defined functions
207 public class Xcls_model : Object
209 public Gtk.ListStore el;
210 private DialogTemplateSelect _this;
216 public Xcls_model(DialogTemplateSelect _owner )
220 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
224 // set gobject values
227 // user defined functions
228 public void loadData (GLib.List<string> data) {
236 el.set_value(iter, 0, "");
237 el.set_value(iter, 1, "Just add Element");
239 for (var i = 0; i < data.length();i++) {
243 var str = data.nth_data(i);
244 var fn = Path.get_basename (str);
245 fn.replace(".json", "");
247 el.set_value(iter, 0, str);
248 el.set_value(iter, 1, fn);
251 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
255 public class Xcls_Button8 : Object
257 public Gtk.Button el;
258 private DialogTemplateSelect _this;
264 public Xcls_Button8(DialogTemplateSelect _owner )
267 this.el = new Gtk.Button();
271 // set gobject values
272 this.el.label = "OK";
275 // user defined functions