resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / DialogSaveModule.vala
1 static DialogSaveModule  _DialogSaveModule;
2
3 public class DialogSaveModule : Object
4 {
5     public Gtk.Dialog el;
6     private DialogSaveModule  _this;
7
8     public static DialogSaveModule singleton()
9     {
10         if (_DialogSaveModule == null) {
11             _DialogSaveModule= new DialogSaveModule();
12         }
13         return _DialogSaveModule;
14     }
15     public Xcls_name name;
16
17         // my vars (def)
18     public Project.Project project;
19     public JsRender.Node data;
20
21     // ctor
22     public DialogSaveModule()
23     {
24         _this = this;
25         this.el = new Gtk.Dialog();
26
27         // my vars (dec)
28
29         // set gobject values
30         this.el.default_height = 200;
31         this.el.default_width = 400;
32         this.el.modal = true;
33         var child_0 = new Xcls_Box2( _this );
34         child_0.ref();
35         this.el.get_content_area().add (  child_0.el  );
36         var child_1 = new Xcls_Button5( _this );
37         child_1.ref();
38         this.el.add_action_widget (  child_1.el , 0 );
39         var child_2 = new Xcls_Button6( _this );
40         child_2.ref();
41         this.el.add_action_widget (  child_2.el , 1 );
42
43         //listeners
44         this.el.delete_event.connect( (self, event) => {
45             this.el.response(Gtk.ResponseType.CANCEL);
46             return true;
47         });
48     }
49
50     // user defined functions
51     public   string show (Gtk.Window parent, Project.Project project, JsRender.Node data) {
52      
53          
54         this.el.set_transient_for(parent);
55         this.el.modal = true;
56         
57         this.data = data;
58         this.project = project;
59         this.name.el.set_text("");
60         this.el.show_all();
61          var   name = "";
62         while (true) {
63             var response_id = this.el.run();
64             if (response_id < 1) {
65                 this.el.hide();
66                  return "";
67             }
68             
69             name = _this.name.el.get_text();
70             if (name.length < 1) {
71                 StandardErrorDialog.singleton().show(
72                      _this.el,
73                     "You must give the template a name. "
74                 );
75                 continue;
76             }
77             if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) )
78             {
79                 StandardErrorDialog.singleton().show(
80                      _this.el,
81                     "Template Name must contain only letters dots"
82                 );
83                 continue;
84             }
85             break;
86         }
87         var f = project.newFile(name);
88         f.tree =  _this.data.deepClone();
89         f.save();
90         
91         // now we save it..
92         this.el.hide();
93         
94         return name;
95         
96         
97         
98     }
99     public class Xcls_Box2 : Object
100     {
101         public Gtk.Box el;
102         private DialogSaveModule  _this;
103
104
105             // my vars (def)
106
107         // ctor
108         public Xcls_Box2(DialogSaveModule _owner )
109         {
110             _this = _owner;
111             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
112
113             // my vars (dec)
114
115             // set gobject values
116             var child_0 = new Xcls_Label3( _this );
117             child_0.ref();
118             this.el.add (  child_0.el  );
119             var child_1 = new Xcls_name( _this );
120             child_1.ref();
121             this.el.add (  child_1.el  );
122         }
123
124         // user defined functions
125     }
126     public class Xcls_Label3 : Object
127     {
128         public Gtk.Label el;
129         private DialogSaveModule  _this;
130
131
132             // my vars (def)
133
134         // ctor
135         public Xcls_Label3(DialogSaveModule _owner )
136         {
137             _this = _owner;
138             this.el = new Gtk.Label( "Name" );
139
140             // my vars (dec)
141
142             // set gobject values
143         }
144
145         // user defined functions
146     }
147
148     public class Xcls_name : Object
149     {
150         public Gtk.Entry el;
151         private DialogSaveModule  _this;
152
153
154             // my vars (def)
155
156         // ctor
157         public Xcls_name(DialogSaveModule _owner )
158         {
159             _this = _owner;
160             _this.name = this;
161             this.el = new Gtk.Entry();
162
163             // my vars (dec)
164
165             // set gobject values
166         }
167
168         // user defined functions
169     }
170
171
172     public class Xcls_Button5 : Object
173     {
174         public Gtk.Button el;
175         private DialogSaveModule  _this;
176
177
178             // my vars (def)
179
180         // ctor
181         public Xcls_Button5(DialogSaveModule _owner )
182         {
183             _this = _owner;
184             this.el = new Gtk.Button();
185
186             // my vars (dec)
187
188             // set gobject values
189             this.el.label = "Cancel";
190         }
191
192         // user defined functions
193     }
194
195     public class Xcls_Button6 : Object
196     {
197         public Gtk.Button el;
198         private DialogSaveModule  _this;
199
200
201             // my vars (def)
202
203         // ctor
204         public Xcls_Button6(DialogSaveModule _owner )
205         {
206             _this = _owner;
207             this.el = new Gtk.Button();
208
209             // my vars (dec)
210
211             // set gobject values
212             this.el.label = "OK";
213         }
214
215         // user defined functions
216     }
217
218 }