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