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