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