Attribute changed old-javascript
[app.Builder.js] / old-javascript / 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_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     // 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_HBox2 : Object 
100     {
101         public Gtk.HBox el;
102         private DialogSaveModule  _this;
103
104
105             // my vars (def)
106
107         // ctor 
108         public Xcls_HBox2(DialogSaveModule _owner )
109         {
110             _this = _owner;
111             this.el = new Gtk.HBox( true, 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     public class Xcls_name : Object 
148     {
149         public Gtk.Entry el;
150         private DialogSaveModule  _this;
151
152
153             // my vars (def)
154
155         // ctor 
156         public Xcls_name(DialogSaveModule _owner )
157         {
158             _this = _owner;
159             _this.name = this;
160             this.el = new Gtk.Entry();
161
162             // my vars (dec)
163
164             // set gobject values
165         }
166
167         // user defined functions 
168     }
169     public class Xcls_Button5 : Object 
170     {
171         public Gtk.Button el;
172         private DialogSaveModule  _this;
173
174
175             // my vars (def)
176
177         // ctor 
178         public Xcls_Button5(DialogSaveModule _owner )
179         {
180             _this = _owner;
181             this.el = new Gtk.Button();
182
183             // my vars (dec)
184
185             // set gobject values
186             this.el.label = "Cancel";
187         }
188
189         // user defined functions 
190     }
191     public class Xcls_Button6 : Object 
192     {
193         public Gtk.Button el;
194         private DialogSaveModule  _this;
195
196
197             // my vars (def)
198
199         // ctor 
200         public Xcls_Button6(DialogSaveModule _owner )
201         {
202             _this = _owner;
203             this.el = new Gtk.Button();
204
205             // my vars (dec)
206
207             // set gobject values
208             this.el.label = "OK";
209         }
210
211         // user defined functions 
212     }
213 }