Test.GtkWriter.vala.c
[app.Builder.js] / Builder4 / DialogSaveTemplate.vala
1 /* -- to compile
2 valac  --pkg gio-2.0  --pkg posix  --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0  --pkg  libwnck-3.0 \
3     /tmp/DialogSaveTemplate.vala  -o /tmp/DialogSaveTemplate
4 */
5
6
7 /* -- to test class
8 static int main (string[] args) {
9     Gtk.init (ref args);
10     new Xcls_DialogSaveTemplate();
11     DialogSaveTemplate.show_all();
12      Gtk.main ();
13     return 0;
14 }
15 */
16
17
18 public static Xcls_DialogSaveTemplate  DialogSaveTemplate;
19
20 public class Xcls_DialogSaveTemplate
21 {
22     public Gtk.Dialog el;
23     private static Xcls_DialogSaveTemplate  _this;
24
25     public Xcls_name name;
26
27         // my vars
28     public JsRender.Node data;
29     public Palete.Palete palete;
30
31         // ctor 
32     public Xcls_DialogSaveTemplate()
33     {
34         this.el = new Gtk.Dialog();
35         _this = this;
36         DialogSaveTemplate = this;
37
38         // my vars
39
40         // set gobject values
41         this.el.default_height = 200;
42         this.el.default_width = 400;
43         this.el.modal = true;
44         var child_0 = new Xcls_HBox2();
45         this.el.add (  child_0.el  );
46         var child_1 = new Xcls_Button5();
47         this.el.add_action_widget (  child_1.el , 0 );
48         var child_2 = new Xcls_Button6();
49         this.el.add_action_widget (  child_2.el , 1 );
50
51         // listeners 
52         this.el.delete_event.connect(  (self, event) => {
53             this.el.hide();
54             return true;
55         } );
56         this.el.response.connect( (self, response_id) => {
57         
58             if (response_id < 1) {
59                 this.el.hide();
60                  return;
61             }
62             var name = _this.name.el.get_text();
63             if (name.length < 1) {
64                 StandardErrorDialog.show(
65                     "You must give the template a name. "
66                 );
67                 return;
68             }
69             if (!Regex.match_simple ("^[A-Za-z]+$", name) || 
70                 !Regex.match_simple ("^[A-Za-z ]+$", name) )
71             {
72                 StandardErrorDialog.show(
73                     "Template Nane must contain only letters and spaces. "
74                 );
75                  return;
76             }
77             _this.palete.saveTemplate(name, _this.data);
78             // now we save it..
79             this.el.hide();
80             
81         } );
82     }
83
84     // userdefined functions 
85
86     // skip listeners - not pipe 
87
88     // skip .JsRender.Node:data - already used 
89
90     // skip .Palete.Palete:palete - already used 
91
92     // skip default_height - already used 
93
94     // skip default_width - already used 
95
96     // skip xtype - not pipe 
97
98     // skip |modal - already used 
99     public void show (Palete.Palete palete, JsRender.Node data) {
100             _this.data = data;
101             _this.palete = palete;
102             _this.name.el.set_text("");
103             this.el.show_all();
104         }
105
106     // skip |xns - no return type
107
108     // skip items - not pipe 
109
110     // skip id - not pipe 
111
112     // skip xvala_cls - not pipe 
113
114     // skip xvala_xcls - not pipe 
115
116     // skip xvala_id - not pipe 
117     public class Xcls_HBox2
118     {
119         public Gtk.HBox el;
120
121             // my vars
122
123             // ctor 
124         public Xcls_HBox2()
125         {
126             this.el = new Gtk.HBox( true, 0 );
127
128             // my vars
129
130             // set gobject values
131             var child_0 = new Xcls_Label3();
132             this.el.add (  child_0.el  );
133             var child_1 = new Xcls_name();
134             this.el.add (  child_1.el  );
135         }
136
137         // userdefined functions 
138
139         // skip xtype - not pipe 
140
141         // skip |pack - already used 
142
143         // skip |xns - no return type
144
145         // skip items - not pipe 
146
147         // skip xvala_cls - not pipe 
148
149         // skip xvala_xcls - not pipe 
150
151         // skip xvala_id - not pipe 
152     }
153     public class Xcls_Label3
154     {
155         public Gtk.Label el;
156
157             // my vars
158
159             // ctor 
160         public Xcls_Label3()
161         {
162             this.el = new Gtk.Label( "Name" );
163
164             // my vars
165
166             // set gobject values
167
168             // listeners 
169         }
170
171         // userdefined functions 
172
173         // skip label - already used 
174
175         // skip pack - not pipe 
176
177         // skip xtype - not pipe 
178
179         // skip |xns - no return type
180
181         // skip listeners - not pipe 
182
183         // skip xvala_cls - not pipe 
184
185         // skip xvala_xcls - not pipe 
186
187         // skip xvala_id - not pipe 
188     }
189     public class Xcls_name
190     {
191         public Gtk.Entry el;
192
193             // my vars
194
195             // ctor 
196         public Xcls_name()
197         {
198             this.el = new Gtk.Entry();
199             _this.name = this;
200
201             // my vars
202
203             // set gobject values
204         }
205
206         // userdefined functions 
207
208         // skip id - not pipe 
209
210         // skip pack - not pipe 
211
212         // skip xtype - not pipe 
213
214         // skip |xns - no return type
215
216         // skip xvala_cls - not pipe 
217
218         // skip xvala_xcls - not pipe 
219
220         // skip xvala_id - not pipe 
221     }
222     public class Xcls_Button5
223     {
224         public Gtk.Button el;
225
226             // my vars
227
228             // ctor 
229         public Xcls_Button5()
230         {
231             this.el = new Gtk.Button();
232
233             // my vars
234
235             // set gobject values
236             this.el.label = "Cancel";
237         }
238
239         // userdefined functions 
240
241         // skip label - already used 
242
243         // skip pack - not pipe 
244
245         // skip xtype - not pipe 
246
247         // skip |xns - no return type
248
249         // skip xvala_cls - not pipe 
250
251         // skip xvala_xcls - not pipe 
252
253         // skip xvala_id - not pipe 
254     }
255     public class Xcls_Button6
256     {
257         public Gtk.Button el;
258
259             // my vars
260
261             // ctor 
262         public Xcls_Button6()
263         {
264             this.el = new Gtk.Button();
265
266             // my vars
267
268             // set gobject values
269             this.el.label = "OK";
270         }
271
272         // userdefined functions 
273
274         // skip label - already used 
275
276         // skip pack - not pipe 
277
278         // skip xtype - not pipe 
279
280         // skip |xns - no return type
281
282         // skip xvala_cls - not pipe 
283
284         // skip xvala_xcls - not pipe 
285
286         // skip xvala_id - not pipe 
287     }
288 }