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);
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 );
139 // user defined functions
141 public class Xcls_Label4 : Object
144 private DialogTemplateSelect _this;
150 public Xcls_Label4(DialogTemplateSelect _owner )
153 this.el = new Gtk.Label( "Select Template : " );
157 // set gobject values
160 // user defined functions
162 public class Xcls_combo : Object
164 public Gtk.ComboBox el;
165 private DialogTemplateSelect _this;
171 public Xcls_combo(DialogTemplateSelect _owner )
175 this.el = new Gtk.ComboBox();
179 // set gobject values
180 var child_0 = new Xcls_cellrenderer( _this );
182 this.el.pack_start ( child_0.el , true );
183 var child_1 = new Xcls_model( _this );
185 this.el.set_model ( child_1.el );
189 this.el.add_attribute(_this.cellrenderer.el , "markup", 1 );
192 // user defined functions
194 public class Xcls_cellrenderer : Object
196 public Gtk.CellRendererText el;
197 private DialogTemplateSelect _this;
203 public Xcls_cellrenderer(DialogTemplateSelect _owner )
206 _this.cellrenderer = this;
207 this.el = new Gtk.CellRendererText();
211 // set gobject values
214 // user defined functions
216 public class Xcls_model : Object
218 public Gtk.ListStore el;
219 private DialogTemplateSelect _this;
225 public Xcls_model(DialogTemplateSelect _owner )
229 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
233 // set gobject values
236 // user defined functions
237 public void loadData (GLib.List<string> data) {
242 /// el.append(out iter);
245 // el.set_value(iter, 0, "");
246 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
248 for (var i = 0; i < data.length();i++) {
252 var str = data.nth_data(i);
253 var fn = Path.get_basename (str);
254 fn.replace(".json", "");
256 el.set_value(iter, 0, str);
257 el.set_value(iter, 1, fn);
260 this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);
264 public class Xcls_Button8 : Object
266 public Gtk.Button el;
267 private DialogTemplateSelect _this;
273 public Xcls_Button8(DialogTemplateSelect _owner )
276 this.el = new Gtk.Button();
280 // set gobject values
281 this.el.label = "Cancel";
284 // user defined functions
286 public class Xcls_Button9 : Object
288 public Gtk.Button el;
289 private DialogTemplateSelect _this;
295 public Xcls_Button9(DialogTemplateSelect _owner )
298 this.el = new Gtk.Button();
302 // set gobject values
303 this.el.label = "Just add it";
306 // user defined functions
308 public class Xcls_Button10 : Object
310 public Gtk.Button el;
311 private DialogTemplateSelect _this;
317 public Xcls_Button10(DialogTemplateSelect _owner )
320 this.el = new Gtk.Button();
324 // set gobject values
325 this.el.label = "OK";
328 // user defined functions