re-apply fix for updating version on node change
[roobuilder] / src / 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 JsRender.Node data;
19     public Palete.Palete palete;
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_Box2( _this );
34         child_0.ref();
35         this.el.get_content_area().append (  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.close_request.connect( ( ) => {
45         
46                  this.el.response(Gtk.ResponseType.CANCEL);
47             return true;
48          
49         });
50         this.el.response.connect( (response_id) => {
51                  
52              if (response_id < 1) {
53                     this.el.hide();
54                      return;
55                 }
56                 
57                 var name = _this.name.el.get_text();
58                 if (name.length < 1) {
59                     Xcls_StandardErrorDialog.singleton().show(
60                          _this.el,
61                         "You must give the template a name. "
62                     );
63                     return;
64                 }
65                 if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9. ]+$", name) )
66                 {
67                     Xcls_StandardErrorDialog.singleton().show(
68                          _this.el,
69                         "Template Name must contain only letters dots"
70                     );
71                     return;
72                 }
73                 
74             this.palete.saveTemplate(name, data);
75             
76             // now we save it..
77             this.el.hide();
78                 
79         
80         });
81     }
82
83     // user defined functions
84     public void showIt (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {
85      
86                 this.palete = palete;
87             this.el.set_transient_for(parent);
88             this.el.modal = true;
89             
90               this.name.el.set_text("");
91             this.el.show();
92              
93              
94       
95        
96     }
97     public class Xcls_Box2 : Object
98     {
99         public Gtk.Box el;
100         private DialogSaveTemplate  _this;
101
102
103             // my vars (def)
104
105         // ctor
106         public Xcls_Box2(DialogSaveTemplate _owner )
107         {
108             _this = _owner;
109             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
110
111             // my vars (dec)
112
113             // set gobject values
114             var child_0 = new Xcls_Label3( _this );
115             child_0.ref();
116             this.el.append (  child_0.el  );
117             var child_1 = new Xcls_name( _this );
118             child_1.ref();
119             this.el.append (  child_1.el  );
120         }
121
122         // user defined functions
123     }
124     public class Xcls_Label3 : Object
125     {
126         public Gtk.Label el;
127         private DialogSaveTemplate  _this;
128
129
130             // my vars (def)
131
132         // ctor
133         public Xcls_Label3(DialogSaveTemplate _owner )
134         {
135             _this = _owner;
136             this.el = new Gtk.Label( "Name" );
137
138             // my vars (dec)
139
140             // set gobject values
141         }
142
143         // user defined functions
144     }
145
146     public class Xcls_name : Object
147     {
148         public Gtk.Entry el;
149         private DialogSaveTemplate  _this;
150
151
152             // my vars (def)
153
154         // ctor
155         public Xcls_name(DialogSaveTemplate _owner )
156         {
157             _this = _owner;
158             _this.name = this;
159             this.el = new Gtk.Entry();
160
161             // my vars (dec)
162
163             // set gobject values
164         }
165
166         // user defined functions
167     }
168
169
170     public class Xcls_Button5 : Object
171     {
172         public Gtk.Button el;
173         private DialogSaveTemplate  _this;
174
175
176             // my vars (def)
177
178         // ctor
179         public Xcls_Button5(DialogSaveTemplate _owner )
180         {
181             _this = _owner;
182             this.el = new Gtk.Button();
183
184             // my vars (dec)
185
186             // set gobject values
187             this.el.label = "Cancel";
188         }
189
190         // user defined functions
191     }
192
193     public class Xcls_Button6 : Object
194     {
195         public Gtk.Button el;
196         private DialogSaveTemplate  _this;
197
198
199             // my vars (def)
200
201         // ctor
202         public Xcls_Button6(DialogSaveTemplate _owner )
203         {
204             _this = _owner;
205             this.el = new Gtk.Button();
206
207             // my vars (dec)
208
209             // set gobject values
210             this.el.label = "OK";
211         }
212
213         // user defined functions
214     }
215
216 }