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 signal void complete (string result);
19 public JsRender.Node data;
20 public Project.Project project;
23 public DialogSaveModule()
26 this.el = new Gtk.Dialog();
31 this.el.default_height = 200;
32 this.el.default_width = 400;
34 var child_1 = new Xcls_Box2( _this );
36 this.el.get_content_area().append ( child_1.el );
37 var child_2 = new Xcls_Button5( _this );
39 this.el.add_action_widget ( child_2.el , 0 );
40 var child_3 = new Xcls_Button6( _this );
42 this.el.add_action_widget ( child_3.el , 1 );
45 this.el.response.connect( (response_id) => {
46 if (response_id < 1) {
51 var name = _this.name.el.get_text();
52 if (name.length < 1) {
53 Xcls_StandardErrorDialog.singleton().show(
55 "You must give the template a name. "
59 if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) )
61 Xcls_StandardErrorDialog.singleton().show(
62 _this.el.transient_for,
63 "Template Name must contain only letters dots"
68 var targetfile = project.path + "/templates/" + name + ".bjs";
71 if (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {
72 Xcls_StandardErrorDialog.singleton().show(
73 _this.el.transient_for,
74 "That file already exists"
80 f = JsRender.JsRender.factory(
84 } catch (JsRender.Error e) {
85 Xcls_StandardErrorDialog.singleton().show(
86 _this.el.transient_for,
93 f.tree = _this.data.deepClone();
104 // user defined functions
105 public void showIt (Gtk.Window parent, Project.Project project, JsRender.Node data) {
108 this.el.set_transient_for(parent);
109 this.el.modal = true;
112 this.project = project;
113 this.name.el.set_text("");
119 public class Xcls_Box2 : Object
122 private DialogSaveModule _this;
128 public Xcls_Box2(DialogSaveModule _owner )
131 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
135 // set gobject values
136 var child_1 = new Xcls_Label3( _this );
138 this.el.append ( child_1.el );
139 new Xcls_name( _this );
140 this.el.append ( _this.name.el );
143 // user defined functions
145 public class Xcls_Label3 : Object
148 private DialogSaveModule _this;
154 public Xcls_Label3(DialogSaveModule _owner )
157 this.el = new Gtk.Label( "Name" );
161 // set gobject values
164 // user defined functions
167 public class Xcls_name : Object
170 private DialogSaveModule _this;
176 public Xcls_name(DialogSaveModule _owner )
180 this.el = new Gtk.Entry();
184 // set gobject values
187 // user defined functions
191 public class Xcls_Button5 : Object
193 public Gtk.Button el;
194 private DialogSaveModule _this;
200 public Xcls_Button5(DialogSaveModule _owner )
203 this.el = new Gtk.Button();
207 // set gobject values
208 this.el.label = "Cancel";
211 // user defined functions
214 public class Xcls_Button6 : Object
216 public Gtk.Button el;
217 private DialogSaveModule _this;
223 public Xcls_Button6(DialogSaveModule _owner )
226 this.el = new Gtk.Button();
230 // set gobject values
231 this.el.label = "OK";
234 // user defined functions