Attribute changed old-javascript
[app.Builder.js] / old-javascript / Builder4 / DialogSaveTemplate.vala
1 static DialogSaveTemplate  _DialogSaveTemplate;
2
3 public class DialogSaveTemplate : Object 
4 {
5     public Gtk.Dialog el;
6     private DialogSaveTemplate  _this;
7
8     public static DialogSaveTemplate singleton()
9     {
10         if (_DialogSaveTemplate == null) {
11             _DialogSaveTemplate= new DialogSaveTemplate();
12         }
13         return _DialogSaveTemplate;
14     }
15     public Xcls_name name;
16
17         // my vars (def)
18     public Palete.Palete palete;
19     public JsRender.Node data;
20
21     // ctor 
22     public DialogSaveTemplate()
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_HBox2( _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
51     // user defined functions 
52     public    void show (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {
53      
54         
55             this.el.set_transient_for(parent);
56             this.el.modal = true;
57             
58               this.name.el.set_text("");
59             this.el.show_all();
60              var   name = "";
61             while (true) {
62                 var response_id = this.el.run();
63                 if (response_id < 1) {
64                     this.el.hide();
65                      return;
66                 }
67                 
68                 name = _this.name.el.get_text();
69                 if (name.length < 1) {
70                     StandardErrorDialog.singleton().show(
71                          _this.el,
72                         "You must give the template a name. "
73                     );
74                     continue;
75                 }
76                 if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9. ]+$", name) )
77                 {
78                     StandardErrorDialog.singleton().show(
79                          _this.el,
80                         "Template Name must contain only letters dots"
81                     );
82                     continue;
83                 }
84                 break;
85             }
86             palete.saveTemplate(name, data);
87             
88             // now we save it..
89             this.el.hide();
90             
91             
92       
93        
94     }
95     public class Xcls_HBox2 : Object 
96     {
97         public Gtk.HBox el;
98         private DialogSaveTemplate  _this;
99
100
101             // my vars (def)
102
103         // ctor 
104         public Xcls_HBox2(DialogSaveTemplate _owner )
105         {
106             _this = _owner;
107             this.el = new Gtk.HBox( true, 0 );
108
109             // my vars (dec)
110
111             // set gobject values
112             var child_0 = new Xcls_Label3( _this );
113             child_0.ref();
114             this.el.add (  child_0.el  );
115             var child_1 = new Xcls_name( _this );
116             child_1.ref();
117             this.el.add (  child_1.el  );
118         }
119
120         // user defined functions 
121     }
122     public class Xcls_Label3 : Object 
123     {
124         public Gtk.Label el;
125         private DialogSaveTemplate  _this;
126
127
128             // my vars (def)
129
130         // ctor 
131         public Xcls_Label3(DialogSaveTemplate _owner )
132         {
133             _this = _owner;
134             this.el = new Gtk.Label( "Name" );
135
136             // my vars (dec)
137
138             // set gobject values
139         }
140
141         // user defined functions 
142     }
143     public class Xcls_name : Object 
144     {
145         public Gtk.Entry el;
146         private DialogSaveTemplate  _this;
147
148
149             // my vars (def)
150
151         // ctor 
152         public Xcls_name(DialogSaveTemplate _owner )
153         {
154             _this = _owner;
155             _this.name = this;
156             this.el = new Gtk.Entry();
157
158             // my vars (dec)
159
160             // set gobject values
161         }
162
163         // user defined functions 
164     }
165     public class Xcls_Button5 : Object 
166     {
167         public Gtk.Button el;
168         private DialogSaveTemplate  _this;
169
170
171             // my vars (def)
172
173         // ctor 
174         public Xcls_Button5(DialogSaveTemplate _owner )
175         {
176             _this = _owner;
177             this.el = new Gtk.Button();
178
179             // my vars (dec)
180
181             // set gobject values
182             this.el.label = "Cancel";
183         }
184
185         // user defined functions 
186     }
187     public class Xcls_Button6 : Object 
188     {
189         public Gtk.Button el;
190         private DialogSaveTemplate  _this;
191
192
193             // my vars (def)
194
195         // ctor 
196         public Xcls_Button6(DialogSaveTemplate _owner )
197         {
198             _this = _owner;
199             this.el = new Gtk.Button();
200
201             // my vars (dec)
202
203             // set gobject values
204             this.el.label = "OK";
205         }
206
207         // user defined functions 
208     }
209 }