1 static DialogSaveTemplate _DialogSaveTemplate;
3 public class DialogSaveTemplate : Object
6 private DialogSaveTemplate _this;
8 public static DialogSaveTemplate singleton()
10 if (_DialogSaveTemplate == null) {
11 _DialogSaveTemplate= new DialogSaveTemplate();
13 return _DialogSaveTemplate;
15 public Xcls_name name;
18 public Palete.Palete palete;
19 public JsRender.Node data;
22 public DialogSaveTemplate()
25 this.el = new Gtk.Dialog();
30 this.el.default_height = 200;
31 this.el.default_width = 400;
33 var child_0 = new Xcls_Box2( _this );
35 this.el.get_content_area().add ( child_0.el );
36 var child_1 = new Xcls_Button5( _this );
38 this.el.add_action_widget ( child_1.el , 0 );
39 var child_2 = new Xcls_Button6( _this );
41 this.el.add_action_widget ( child_2.el , 1 );
44 this.el.delete_event.connect( (self, event) => {
45 this.el.response(Gtk.ResponseType.CANCEL);
51 // user defined functions
52 public void show (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {
55 this.el.set_transient_for(parent);
58 this.name.el.set_text("");
62 var response_id = this.el.run();
63 if (response_id < 1) {
68 name = _this.name.el.get_text();
69 if (name.length < 1) {
70 StandardErrorDialog.singleton().show(
72 "You must give the template a name. "
76 if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9. ]+$", name) )
78 StandardErrorDialog.singleton().show(
80 "Template Name must contain only letters dots"
86 palete.saveTemplate(name, data);
95 public class Xcls_Box2 : Object
98 private DialogSaveTemplate _this;
104 public Xcls_Box2(DialogSaveTemplate _owner )
107 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
111 // set gobject values
112 var child_0 = new Xcls_Label3( _this );
114 this.el.add ( child_0.el );
115 var child_1 = new Xcls_name( _this );
117 this.el.add ( child_1.el );
120 // user defined functions
122 public class Xcls_Label3 : Object
125 private DialogSaveTemplate _this;
131 public Xcls_Label3(DialogSaveTemplate _owner )
134 this.el = new Gtk.Label( "Name" );
138 // set gobject values
141 // user defined functions
144 public class Xcls_name : Object
147 private DialogSaveTemplate _this;
153 public Xcls_name(DialogSaveTemplate _owner )
157 this.el = new Gtk.Entry();
161 // set gobject values
164 // user defined functions
168 public class Xcls_Button5 : Object
170 public Gtk.Button el;
171 private DialogSaveTemplate _this;
177 public Xcls_Button5(DialogSaveTemplate _owner )
180 this.el = new Gtk.Button();
184 // set gobject values
185 this.el.label = "Cancel";
188 // user defined functions
191 public class Xcls_Button6 : Object
193 public Gtk.Button el;
194 private DialogSaveTemplate _this;
200 public Xcls_Button6(DialogSaveTemplate _owner )
203 this.el = new Gtk.Button();
207 // set gobject values
208 this.el.label = "OK";
211 // user defined functions