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_Box2( _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_Box2 : Object
113     {
114         public Gtk.Box el;
115         private EditProject  _this;
116
117
118             // my vars (def)
119
120         // ctor
121         public Xcls_Box2(EditProject _owner )
122         {
123             _this = _owner;
124             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
125
126             // my vars (dec)
127
128             // set gobject values
129             this.el.homogeneous = false;
130             var child_0 = new Xcls_Box3( _this );
131             child_0.ref();
132             this.el.pack_start (  child_0.el , false,true,3 );
133             var child_1 = new Xcls_dir( _this );
134             child_1.ref();
135             this.el.pack_end (  child_1.el , true,true,5 );
136         }
137
138         // user defined functions
139     }
140     public class Xcls_Box3 : Object
141     {
142         public Gtk.Box el;
143         private EditProject  _this;
144
145
146             // my vars (def)
147
148         // ctor
149         public Xcls_Box3(EditProject _owner )
150         {
151             _this = _owner;
152             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
153
154             // my vars (dec)
155
156             // set gobject values
157             this.el.homogeneous = false;
158             var child_0 = new Xcls_Label4( _this );
159             child_0.ref();
160             this.el.pack_start (  child_0.el , false,true,3 );
161             var child_1 = new Xcls_xtype( _this );
162             child_1.ref();
163             this.el.pack_end (  child_1.el , true,true,3 );
164         }
165
166         // user defined functions
167     }
168     public class Xcls_Label4 : Object
169     {
170         public Gtk.Label el;
171         private EditProject  _this;
172
173
174             // my vars (def)
175
176         // ctor
177         public Xcls_Label4(EditProject _owner )
178         {
179             _this = _owner;
180             this.el = new Gtk.Label( "Project type :" );
181
182             // my vars (dec)
183
184             // set gobject values
185         }
186
187         // user defined functions
188     }
189
190     public class Xcls_xtype : Object
191     {
192         public Gtk.ComboBox el;
193         private EditProject  _this;
194
195
196             // my vars (def)
197
198         // ctor
199         public Xcls_xtype(EditProject _owner )
200         {
201             _this = _owner;
202             _this.xtype = this;
203             this.el = new Gtk.ComboBox();
204
205             // my vars (dec)
206
207             // set gobject values
208             var child_0 = new Xcls_cellrender( _this );
209             child_0.ref();
210             this.el.pack_start (  child_0.el , true );
211             var child_1 = new Xcls_model( _this );
212             child_1.ref();
213             this.el.set_model (  child_1.el  );
214
215             // init method
216
217             this.el.add_attribute(_this.cellrender.el , "markup", 1 );
218         }
219
220         // user defined functions
221         public string getValue () {
222              var ix = this.el.get_active();
223                 if (ix < 0 ) {
224                     return "";
225                 }
226                 switch(ix) {
227                     case 0:
228                         return "Roo";
229                     case 1:
230                         return "Gtk";
231                 }
232                 return "";
233         }
234     }
235     public class Xcls_cellrender : Object
236     {
237         public Gtk.CellRendererText el;
238         private EditProject  _this;
239
240
241             // my vars (def)
242
243         // ctor
244         public Xcls_cellrender(EditProject _owner )
245         {
246             _this = _owner;
247             _this.cellrender = this;
248             this.el = new Gtk.CellRendererText();
249
250             // my vars (dec)
251
252             // set gobject values
253         }
254
255         // user defined functions
256     }
257
258     public class Xcls_model : Object
259     {
260         public Gtk.ListStore el;
261         private EditProject  _this;
262
263
264             // my vars (def)
265
266         // ctor
267         public Xcls_model(EditProject _owner )
268         {
269             _this = _owner;
270             _this.model = this;
271             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
272
273             // my vars (dec)
274
275             // set gobject values
276         }
277
278         // user defined functions
279         public void loadData ( ) {
280                 this.el.clear();
281                               
282                 Gtk.TreeIter iter;
283                         
284                 el.append(out iter);
285                 
286                 el.set_value(iter, 0, "Roo");
287                 el.set_value(iter, 1, "Roo Project");
288                  el.append(out iter);
289                 
290                 el.set_value(iter, 0, "Gtk");
291                 el.set_value(iter, 1, "Gtk Project");
292                  
293                       
294                                              
295         }
296     }
297
298
299
300     public class Xcls_dir : Object
301     {
302         public Gtk.FileChooserWidget el;
303         private EditProject  _this;
304
305
306             // my vars (def)
307
308         // ctor
309         public Xcls_dir(EditProject _owner )
310         {
311             _this = _owner;
312             _this.dir = this;
313             this.el = new Gtk.FileChooserWidget( Gtk.FileChooserAction.SELECT_FOLDER );
314
315             // my vars (dec)
316
317             // set gobject values
318             this.el.create_folders = false;
319             this.el.select_multiple = false;
320         }
321
322         // user defined functions
323     }
324
325
326     public class Xcls_Button9 : Object
327     {
328         public Gtk.Button el;
329         private EditProject  _this;
330
331
332             // my vars (def)
333
334         // ctor
335         public Xcls_Button9(EditProject _owner )
336         {
337             _this = _owner;
338             this.el = new Gtk.Button();
339
340             // my vars (dec)
341
342             // set gobject values
343             this.el.label = "OK";
344         }
345
346         // user defined functions
347     }
348
349     public class Xcls_Button10 : Object
350     {
351         public Gtk.Button el;
352         private EditProject  _this;
353
354
355             // my vars (def)
356
357         // ctor
358         public Xcls_Button10(EditProject _owner )
359         {
360             _this = _owner;
361             this.el = new Gtk.Button();
362
363             // my vars (dec)
364
365             // set gobject values
366             this.el.label = "Cancel";
367         }
368
369         // user defined functions
370     }
371
372 }