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