NewBranch.bjs
[gitlive] / NewBranch.vala
1 static NewBranch  _NewBranch;
2
3 public class NewBranch : Object
4 {
5     public Gtk.Dialog el;
6     private NewBranch  _this;
7
8     public static NewBranch singleton()
9     {
10         if (_NewBranch == null) {
11             _NewBranch= new NewBranch();
12         }
13         return _NewBranch;
14     }
15     public Xcls_build_module build_module;
16     public Xcls_dbcellrenderer dbcellrenderer;
17     public Xcls_dbmodel dbmodel;
18     public Xcls_name name;
19
20         // my vars (def)
21
22     // ctor
23     public NewBranch()
24     {
25         _this = this;
26         this.el = new Gtk.Dialog();
27
28         // my vars (dec)
29
30         // set gobject values
31         this.el.title = "Create a working branch ";
32         this.el.default_height = 200;
33         this.el.default_width = 500;
34         this.el.deletable = true;
35         this.el.modal = true;
36         var child_0 = new Xcls_VBox2( _this );
37         child_0.ref();
38         this.el.get_content_area().add (  child_0.el  );
39         var child_1 = new Xcls_Button10( _this );
40         child_1.ref();
41         this.el.add_action_widget (  child_1.el , 0 );
42         var child_2 = new Xcls_Button11( _this );
43         child_2.ref();
44         this.el.add_action_widget (  child_2.el , 1 );
45
46         //listeners
47         this.el.delete_event.connect( (self, event) => {
48             this.el.hide();
49             return true; 
50             //test  
51         });
52         this.el.response.connect( (self, response_id) =>  { 
53           
54                  GLib.debug("got %d", (int) response_id);
55         });
56         this.el.show.connect( (self)  => {
57          
58          
59                 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
60             
61          
62             
63             this.el.show_all();
64                 GLib.debug("Loading tickets");
65                 _this.dbmodel.loadTickets();
66                     
67         
68           this.el.run();
69           //test
70         });
71     }
72
73     // user defined functions
74     public   void show ( ) 
75     {
76          // this.el.set_gravity(Gdk.Gravity.NORTH);
77         
78         
79           
80     }
81     public class Xcls_VBox2 : Object
82     {
83         public Gtk.VBox el;
84         private NewBranch  _this;
85
86
87             // my vars (def)
88
89         // ctor
90         public Xcls_VBox2(NewBranch _owner )
91         {
92             _this = _owner;
93             this.el = new Gtk.VBox( true, 0 );
94
95             // my vars (dec)
96
97             // set gobject values
98             var child_0 = new Xcls_Table3( _this );
99             child_0.ref();
100             this.el.pack_start (  child_0.el , false,false,0 );
101         }
102
103         // user defined functions
104     }
105     public class Xcls_Table3 : Object
106     {
107         public Gtk.Table el;
108         private NewBranch  _this;
109
110
111             // my vars (def)
112
113         // ctor
114         public Xcls_Table3(NewBranch _owner )
115         {
116             _this = _owner;
117             this.el = new Gtk.Table( 2, 2, true );
118
119             // my vars (dec)
120
121             // set gobject values
122             var child_0 = new Xcls_Label4( _this );
123             child_0.ref();
124             this.el.attach_defaults (  child_0.el , 0,1,0,1 );
125             var child_1 = new Xcls_build_module( _this );
126             child_1.ref();
127             this.el.attach_defaults (  child_1.el , 1,2,0,1 );
128             var child_2 = new Xcls_Label8( _this );
129             child_2.ref();
130             this.el.attach_defaults (  child_2.el , 0,1,1,2 );
131             var child_3 = new Xcls_name( _this );
132             child_3.ref();
133             this.el.attach_defaults (  child_3.el , 1,2,1,2 );
134         }
135
136         // user defined functions
137     }
138     public class Xcls_Label4 : Object
139     {
140         public Gtk.Label el;
141         private NewBranch  _this;
142
143
144             // my vars (def)
145
146         // ctor
147         public Xcls_Label4(NewBranch _owner )
148         {
149             _this = _owner;
150             this.el = new Gtk.Label( "Select Ticket" );
151
152             // my vars (dec)
153
154             // set gobject values
155             this.el.justify = Gtk.Justification.RIGHT;
156             this.el.xalign = 0.900000f;
157             this.el.visible = true;
158         }
159
160         // user defined functions
161     }
162
163     public class Xcls_build_module : Object
164     {
165         public Gtk.ComboBox el;
166         private NewBranch  _this;
167
168
169             // my vars (def)
170
171         // ctor
172         public Xcls_build_module(NewBranch _owner )
173         {
174             _this = _owner;
175             _this.build_module = this;
176             this.el = new Gtk.ComboBox();
177
178             // my vars (dec)
179
180             // set gobject values
181             var child_0 = new Xcls_dbcellrenderer( _this );
182             child_0.ref();
183             this.el.pack_start (  child_0.el , true );
184             var child_1 = new Xcls_dbmodel( _this );
185             child_1.ref();
186             this.el.set_model (  child_1.el  );
187
188             // init method
189
190             this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
191         }
192
193         // user defined functions
194     }
195     public class Xcls_dbcellrenderer : Object
196     {
197         public Gtk.CellRendererText el;
198         private NewBranch  _this;
199
200
201             // my vars (def)
202
203         // ctor
204         public Xcls_dbcellrenderer(NewBranch _owner )
205         {
206             _this = _owner;
207             _this.dbcellrenderer = this;
208             this.el = new Gtk.CellRendererText();
209
210             // my vars (dec)
211
212             // set gobject values
213         }
214
215         // user defined functions
216     }
217
218     public class Xcls_dbmodel : Object
219     {
220         public Gtk.ListStore el;
221         private NewBranch  _this;
222
223
224             // my vars (def)
225
226         // ctor
227         public Xcls_dbmodel(NewBranch _owner )
228         {
229             _this = _owner;
230             _this.dbmodel = this;
231             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
232
233             // my vars (dec)
234
235             // set gobject values
236         }
237
238         // user defined functions
239         public void loadTickets () {
240         
241             RooTicket.singleton().loadTickets();
242             
243             
244         
245             this.el.clear();                                    
246             Gtk.TreeIter iter;
247             var el = this.el;
248             
249             el.append(out iter);
250         
251             
252             el.set_value(iter, 0, "");
253             el.set_value(iter, 1, "-- select a ticket --");
254             
255             _this.build_module.el.set_active_iter(iter);
256             var tickets = RooTicket.singleton().tickets;
257             foreach(var ticket in tickets) {
258             
259         
260                 el.append(out iter);
261                 
262                 el.set_value(iter, 0, ticket.id);
263                 el.set_value(iter, 1, "#%s %s %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
264                 
265                 //if (data.get(i) == cur) {
266                  //   _this.build_module.el.set_active_iter(iter);
267                // }
268                 
269             }
270              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
271                                              
272         }
273     }
274
275
276     public class Xcls_Label8 : Object
277     {
278         public Gtk.Label el;
279         private NewBranch  _this;
280
281
282             // my vars (def)
283
284         // ctor
285         public Xcls_Label8(NewBranch _owner )
286         {
287             _this = _owner;
288             this.el = new Gtk.Label( "or use this as branch name" );
289
290             // my vars (dec)
291
292             // set gobject values
293             this.el.justify = Gtk.Justification.RIGHT;
294             this.el.xalign = 0.900000f;
295         }
296
297         // user defined functions
298     }
299
300     public class Xcls_name : Object
301     {
302         public Gtk.Entry el;
303         private NewBranch  _this;
304
305
306             // my vars (def)
307
308         // ctor
309         public Xcls_name(NewBranch _owner )
310         {
311             _this = _owner;
312             _this.name = this;
313             this.el = new Gtk.Entry();
314
315             // my vars (dec)
316
317             // set gobject values
318             this.el.visible = true;
319         }
320
321         // user defined functions
322     }
323
324
325
326     public class Xcls_Button10 : Object
327     {
328         public Gtk.Button el;
329         private NewBranch  _this;
330
331
332             // my vars (def)
333
334         // ctor
335         public Xcls_Button10(NewBranch _owner )
336         {
337             _this = _owner;
338             this.el = new Gtk.Button();
339
340             // my vars (dec)
341
342             // set gobject values
343             this.el.relief = Gtk.ReliefStyle.NONE;
344             this.el.label = "Do not create Branch";
345         }
346
347         // user defined functions
348     }
349
350     public class Xcls_Button11 : Object
351     {
352         public Gtk.Button el;
353         private NewBranch  _this;
354
355
356             // my vars (def)
357
358         // ctor
359         public Xcls_Button11(NewBranch _owner )
360         {
361             _this = _owner;
362             this.el = new Gtk.Button();
363
364             // my vars (dec)
365
366             // set gobject values
367             this.el.label = "Create Branch";
368         }
369
370         // user defined functions
371     }
372
373 }