1 static DialogSaveModule _DialogSaveModule;
3 public class DialogSaveModule : Object
6 private DialogSaveModule _this;
8 public static DialogSaveModule singleton()
10 if (_DialogSaveModule == null) {
11 _DialogSaveModule= new DialogSaveModule();
13 return _DialogSaveModule;
15 public Xcls_name name;
18 public Project.Project project;
19 public JsRender.Node data;
22 public DialogSaveModule()
25 this.el = new Gtk.Dialog();
30 this.el.default_height = 200;
31 this.el.default_width = 400;
33 var child_0 = new Xcls_HBox2( _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);
50 // user defined functions
51 public string show (Gtk.Window parent, Project.Project project, JsRender.Node data) {
54 this.el.set_transient_for(parent);
58 this.project = project;
59 this.name.el.set_text("");
63 var response_id = this.el.run();
64 if (response_id < 1) {
69 name = _this.name.el.get_text();
70 if (name.length < 1) {
71 StandardErrorDialog.singleton().show(
73 "You must give the template a name. "
77 if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) )
79 StandardErrorDialog.singleton().show(
81 "Template Name must contain only letters dots"
87 var f = project.newFile(name);
88 f.tree = _this.data.deepClone();
99 public class Xcls_HBox2 : Object
102 private DialogSaveModule _this;
108 public Xcls_HBox2(DialogSaveModule _owner )
111 this.el = new Gtk.HBox( true, 0 );
115 // set gobject values
116 var child_0 = new Xcls_Label3( _this );
118 this.el.add ( child_0.el );
119 var child_1 = new Xcls_name( _this );
121 this.el.add ( child_1.el );
124 // user defined functions
126 public class Xcls_Label3 : Object
129 private DialogSaveModule _this;
135 public Xcls_Label3(DialogSaveModule _owner )
138 this.el = new Gtk.Label( "Name" );
142 // set gobject values
145 // user defined functions
147 public class Xcls_name : Object
150 private DialogSaveModule _this;
156 public Xcls_name(DialogSaveModule _owner )
160 this.el = new Gtk.Entry();
164 // set gobject values
167 // user defined functions
169 public class Xcls_Button5 : Object
171 public Gtk.Button el;
172 private DialogSaveModule _this;
178 public Xcls_Button5(DialogSaveModule _owner )
181 this.el = new Gtk.Button();
185 // set gobject values
186 this.el.label = "Cancel";
189 // user defined functions
191 public class Xcls_Button6 : Object
193 public Gtk.Button el;
194 private DialogSaveModule _this;
200 public Xcls_Button6(DialogSaveModule _owner )
203 this.el = new Gtk.Button();
207 // set gobject values
208 this.el.label = "OK";
211 // user defined functions