resources/RooUsage.txt
[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             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                 }
233                 return "";
234         }
235     }
236     public class Xcls_cellrender : Object
237     {
238         public Gtk.CellRendererText el;
239         private EditProject  _this;
240
241
242             // my vars (def)
243
244         // ctor
245         public Xcls_cellrender(EditProject _owner )
246         {
247             _this = _owner;
248             _this.cellrender = this;
249             this.el = new Gtk.CellRendererText();
250
251             // my vars (dec)
252
253             // set gobject values
254         }
255
256         // user defined functions
257     }
258
259     public class Xcls_model : Object
260     {
261         public Gtk.ListStore el;
262         private EditProject  _this;
263
264
265             // my vars (def)
266
267         // ctor
268         public Xcls_model(EditProject _owner )
269         {
270             _this = _owner;
271             _this.model = this;
272             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
273
274             // my vars (dec)
275
276             // set gobject values
277         }
278
279         // user defined functions
280         public void loadData ( ) {
281                 this.el.clear();
282                               
283                 Gtk.TreeIter iter;
284                         
285                 el.append(out iter);
286                 
287                 el.set_value(iter, 0, "Roo");
288                 el.set_value(iter, 1, "Roo Project");
289                  el.append(out iter);
290                 
291                 el.set_value(iter, 0, "Gtk");
292                 el.set_value(iter, 1, "Gtk Project");
293                  
294                       
295                                              
296         }
297     }
298
299
300
301     public class Xcls_dir : Object
302     {
303         public Gtk.FileChooserWidget el;
304         private EditProject  _this;
305
306
307             // my vars (def)
308
309         // ctor
310         public Xcls_dir(EditProject _owner )
311         {
312             _this = _owner;
313             _this.dir = this;
314             this.el = new Gtk.FileChooserWidget( Gtk.FileChooserAction.SELECT_FOLDER );
315
316             // my vars (dec)
317
318             // set gobject values
319             this.el.expand = true;
320             this.el.create_folders = false;
321             this.el.select_multiple = false;
322         }
323
324         // user defined functions
325     }
326
327
328     public class Xcls_Button9 : Object
329     {
330         public Gtk.Button el;
331         private EditProject  _this;
332
333
334             // my vars (def)
335
336         // ctor
337         public Xcls_Button9(EditProject _owner )
338         {
339             _this = _owner;
340             this.el = new Gtk.Button();
341
342             // my vars (dec)
343
344             // set gobject values
345             this.el.label = "OK";
346         }
347
348         // user defined functions
349     }
350
351     public class Xcls_Button10 : Object
352     {
353         public Gtk.Button el;
354         private EditProject  _this;
355
356
357             // my vars (def)
358
359         // ctor
360         public Xcls_Button10(EditProject _owner )
361         {
362             _this = _owner;
363             this.el = new Gtk.Button();
364
365             // my vars (dec)
366
367             // set gobject values
368             this.el.label = "Cancel";
369         }
370
371         // user defined functions
372     }
373
374 }