Attribute changed old-javascript
[app.Builder.js] / old-javascript / Builder4 / EditProject.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/EditProject.vala  -o /tmp/EditProject
4 */
5
6
7 /* -- to test class
8 static int main (string[] args) {
9     Gtk.init (ref args);
10     new Xcls_EditProject();
11     EditProject.show_all();
12      Gtk.main ();
13     return 0;
14 }
15 */
16
17
18 public static Xcls_EditProject  EditProject;
19
20 public class Xcls_EditProject : Object 
21 {
22     public Gtk.Dialog el;
23     private Xcls_EditProject  _this;
24
25     public static Xcls_EditProject singleton()
26     {
27         if (EditProject == null) {
28             EditProject= new Xcls_EditProject();
29         }
30         return EditProject;
31     }
32     public Xcls_xtype xtype;
33     public Xcls_cellrender cellrender;
34     public Xcls_model model;
35     public Xcls_dir dir;
36
37         // my vars
38
39         // ctor 
40     public Xcls_EditProject()
41     {
42         _this = this;
43         this.el = new Gtk.Dialog();
44
45         // my vars
46
47         // set gobject values
48         this.el.border_width = 3;
49         this.el.default_height = 500;
50         this.el.default_width = 600;
51         this.el.deletable = true;
52         this.el.modal = true;
53         this.el.name = "EditProject";
54         this.el.title = "Project Properties";
55         var child_0 = new Xcls_VBox2( _this );
56         child_0.ref();
57         this.el. get_content_area().add 
58  
59  (  child_0.el  );
60         var child_1 = new Xcls_Button9( _this );
61         child_1.ref();
62         this.el.add_action_widget (  child_1.el , 1 );
63         var child_2 = new Xcls_Button10( _this );
64         child_2.ref();
65         this.el.add_action_widget (  child_2.el , 0 );
66
67         // listeners 
68         this.el.destroy_event.connect(  (self, event) => {
69           this.el.response(0);
70         //     this.el.hide();
71             return false;
72         } );
73     }
74
75     // userdefined functions 
76     public Project.Project? show() {
77               
78         
79             //[ 'xtype'  ].forEach(function(k) {
80             //    _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
81             //});
82                 // shouild set path..
83             _this.model.loadData();
84             this.el.show_all();
85             
86             var err_dialog = StandardErrorDialog.singleton();
87         
88             var id = -1;
89             while (id < 0) {
90                  id =  this.el.run();
91                  if (id < 1) {
92                         this.el.hide();
93                         return null;
94                 }
95         
96                  
97                   if (_this.xtype.getValue().length < 1) {
98                        
99                         err_dialog.show(_this.el,"You have to set Project type");             
100                         id = -1;
101                         continue;
102                     }
103                     if (_this.dir.el.get_filename().length < 1) {
104          
105                         err_dialog.show(_this.el,"You have to select a folder");             
106                         id = -1;
107                         continue;
108                     }
109                    
110             }
111             
112             this.el.hide();
113             
114             
115             
116          
117             var fn = _this.dir.el.get_filename();
118             print("add %s\n" , fn);
119             
120             var project = Project.Project.factory(_this.xtype.getValue(), fn);
121             project.save();
122             Project.projects.set(project.name,project);
123             
124             //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);
125             
126             return project;
127         
128             
129             //this.success = c.success;
130         }
131
132     // skip |xns - no return type
133     public class Xcls_VBox2 : Object 
134     {
135         public Gtk.VBox el;
136         private Xcls_EditProject  _this;
137
138
139             // my vars
140
141             // ctor 
142         public Xcls_VBox2(Xcls_EditProject _owner )
143         {
144             _this = _owner;
145             this.el = new Gtk.VBox( false, 0 );
146
147             // my vars
148
149             // set gobject values
150             var child_0 = new Xcls_HBox3( _this );
151             child_0.ref();
152             this.el.pack_start (  child_0.el , false,true,3 );
153             var child_1 = new Xcls_dir( _this );
154             child_1.ref();
155             this.el.pack_end (  child_1.el , true,true,5 );
156         }
157
158         // userdefined functions 
159
160         // skip |xns - no return type
161     }
162     public class Xcls_HBox3 : Object 
163     {
164         public Gtk.HBox el;
165         private Xcls_EditProject  _this;
166
167
168             // my vars
169
170             // ctor 
171         public Xcls_HBox3(Xcls_EditProject _owner )
172         {
173             _this = _owner;
174             this.el = new Gtk.HBox( false, 0 );
175
176             // my vars
177
178             // set gobject values
179             var child_0 = new Xcls_Label4( _this );
180             child_0.ref();
181             this.el.pack_start (  child_0.el , false,true,3 );
182             var child_1 = new Xcls_xtype( _this );
183             child_1.ref();
184             this.el.pack_end (  child_1.el , true,true,3 );
185         }
186
187         // userdefined functions 
188
189         // skip |xns - no return type
190     }
191     public class Xcls_Label4 : Object 
192     {
193         public Gtk.Label el;
194         private Xcls_EditProject  _this;
195
196
197             // my vars
198
199             // ctor 
200         public Xcls_Label4(Xcls_EditProject _owner )
201         {
202             _this = _owner;
203             this.el = new Gtk.Label( "Project type :" );
204
205             // my vars
206
207             // set gobject values
208         }
209
210         // userdefined functions 
211
212         // skip |xns - no return type
213     }
214     public class Xcls_xtype : Object 
215     {
216         public Gtk.ComboBox el;
217         private Xcls_EditProject  _this;
218
219
220             // my vars
221
222             // ctor 
223         public Xcls_xtype(Xcls_EditProject _owner )
224         {
225             _this = _owner;
226             _this.xtype = this;
227             this.el = new Gtk.ComboBox();
228
229             // my vars
230
231             // set gobject values
232             var child_0 = new Xcls_cellrender( _this );
233             child_0.ref();
234             this.el.pack_start (  child_0.el , true );
235             var child_1 = new Xcls_model( _this );
236             child_1.ref();
237             this.el.set_model (  child_1.el  );
238
239             // init method 
240              this.el.add_attribute(_this.cellrender.el , "markup", 1 );  
241              
242         }
243
244         // userdefined functions 
245
246         // skip |setValue - no return type
247         public string getValue () {
248                  var ix = this.el.get_active();
249                     if (ix < 0 ) {
250                         return "";
251                     }
252                     switch(ix) {
253                         case 0:
254                             return "Roo";
255                         case 1:
256                             return "Gtk";
257                     }
258                     return "";
259             }
260
261         // skip |xns - no return type
262     }
263     public class Xcls_cellrender : Object 
264     {
265         public Gtk.CellRendererText el;
266         private Xcls_EditProject  _this;
267
268
269             // my vars
270
271             // ctor 
272         public Xcls_cellrender(Xcls_EditProject _owner )
273         {
274             _this = _owner;
275             _this.cellrender = this;
276             this.el = new Gtk.CellRendererText();
277
278             // my vars
279
280             // set gobject values
281         }
282
283         // userdefined functions 
284
285         // skip |xns - no return type
286     }
287     public class Xcls_model : Object 
288     {
289         public Gtk.ListStore el;
290         private Xcls_EditProject  _this;
291
292
293             // my vars
294
295             // ctor 
296         public Xcls_model(Xcls_EditProject _owner )
297         {
298             _this = _owner;
299             _this.model = this;
300             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
301
302             // my vars
303
304             // set gobject values
305         }
306
307         // userdefined functions 
308         public void loadData  ( ) {
309                     this.el.clear();
310                                   
311                     Gtk.TreeIter iter;
312                             
313                     el.append(out iter);
314                     
315                     el.set_value(iter, 0, "Roo");
316                     el.set_value(iter, 1, "Roo Project");
317                      el.append(out iter);
318                     
319                     el.set_value(iter, 0, "Gtk");
320                     el.set_value(iter, 1, "Gtk Project");
321                      
322                           
323                                                  
324             }
325
326         // skip |xns - no return type
327     }
328     public class Xcls_dir : Object 
329     {
330         public Gtk.FileChooserWidget el;
331         private Xcls_EditProject  _this;
332
333
334             // my vars
335
336             // ctor 
337         public Xcls_dir(Xcls_EditProject _owner )
338         {
339             _this = _owner;
340             _this.dir = this;
341             this.el = new Gtk.FileChooserWidget( Gtk.FileChooserAction.SELECT_FOLDER );
342
343             // my vars
344
345             // set gobject values
346             this.el.create_folders = false;
347             this.el.select_multiple = false;
348         }
349
350         // userdefined functions 
351
352         // skip |xns - no return type
353     }
354     public class Xcls_Button9 : Object 
355     {
356         public Gtk.Button el;
357         private Xcls_EditProject  _this;
358
359
360             // my vars
361
362             // ctor 
363         public Xcls_Button9(Xcls_EditProject _owner )
364         {
365             _this = _owner;
366             this.el = new Gtk.Button();
367
368             // my vars
369
370             // set gobject values
371             this.el.label = "OK";
372         }
373
374         // userdefined functions 
375
376         // skip |xns - no return type
377     }
378     public class Xcls_Button10 : Object 
379     {
380         public Gtk.Button el;
381         private Xcls_EditProject  _this;
382
383
384             // my vars
385
386             // ctor 
387         public Xcls_Button10(Xcls_EditProject _owner )
388         {
389             _this = _owner;
390             this.el = new Gtk.Button();
391
392             // my vars
393
394             // set gobject values
395             this.el.label = "Cancel";
396         }
397
398         // userdefined functions 
399
400         // skip |xns - no return type
401     }
402 }