1 static NewBranch _NewBranch;
3 public class NewBranch : Object
6 private NewBranch _this;
8 public static NewBranch singleton()
10 if (_NewBranch == null) {
11 _NewBranch= new NewBranch();
15 public Xcls_build_module build_module;
16 public Xcls_dbcellrenderer dbcellrenderer;
17 public Xcls_dbmodel dbmodel;
18 public Xcls_name name;
26 this.el = new Gtk.Dialog();
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;
36 var child_0 = new Xcls_VBox2( _this );
38 this.el.get_content_area().add ( child_0.el );
39 var child_1 = new Xcls_Button10( _this );
41 this.el.add_action_widget ( child_1.el , 0 );
42 var child_2 = new Xcls_Button11( _this );
44 this.el.add_action_widget ( child_2.el , 1 );
47 this.el.delete_event.connect( (self, event) => {
52 this.el.response.connect( (self, response_id) => {
54 GLib.debug("got %d", (int) response_id);
58 this.el.show.connect( (self) => {
65 // user defined functions
68 // this.el.set_gravity(Gdk.Gravity.NORTH);
70 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
71 GLib.debug("Loading tickets");
72 _this.dbmodel.loadTickets();
81 public class Xcls_VBox2 : Object
84 private NewBranch _this;
90 public Xcls_VBox2(NewBranch _owner )
93 this.el = new Gtk.VBox( true, 0 );
98 var child_0 = new Xcls_Table3( _this );
100 this.el.pack_start ( child_0.el , false,false,0 );
103 // user defined functions
105 public class Xcls_Table3 : Object
108 private NewBranch _this;
114 public Xcls_Table3(NewBranch _owner )
117 this.el = new Gtk.Table( 2, 2, false );
121 // set gobject values
123 this.el.column_spacing = 2;
124 var child_0 = new Xcls_Label4( _this );
126 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
127 var child_1 = new Xcls_build_module( _this );
129 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
130 var child_2 = new Xcls_Label8( _this );
132 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
133 var child_3 = new Xcls_name( _this );
135 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
138 // user defined functions
140 public class Xcls_Label4 : Object
143 private NewBranch _this;
149 public Xcls_Label4(NewBranch _owner )
152 this.el = new Gtk.Label( "Select Ticket" );
156 // set gobject values
157 this.el.justify = Gtk.Justification.RIGHT;
158 this.el.xalign = 0.900000f;
159 this.el.visible = true;
162 // user defined functions
165 public class Xcls_build_module : Object
167 public Gtk.ComboBox el;
168 private NewBranch _this;
174 public Xcls_build_module(NewBranch _owner )
177 _this.build_module = this;
178 this.el = new Gtk.ComboBox();
182 // set gobject values
183 var child_0 = new Xcls_dbcellrenderer( _this );
185 this.el.pack_start ( child_0.el , true );
186 var child_1 = new Xcls_dbmodel( _this );
188 this.el.set_model ( child_1.el );
192 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
195 this.el.changed.connect( () => {
200 this.el.get_active_iter (out iter);
201 _this.dbmodel.el.get_value (iter, 0, out val1);
202 _this.dbmodel.el.get_value (iter, 1, out val2);
204 var ticket_id = (string) val1;
206 var name = RooTicket.singleton().usernameLocal();
208 if (ticket_id == "") {
210 var dt = new DateTime.now_local();
211 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
215 var ticket = RooTicket.singleton().getById(ticket_id);
217 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
219 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
223 // user defined functions
225 public class Xcls_dbcellrenderer : Object
227 public Gtk.CellRendererText el;
228 private NewBranch _this;
234 public Xcls_dbcellrenderer(NewBranch _owner )
237 _this.dbcellrenderer = this;
238 this.el = new Gtk.CellRendererText();
242 // set gobject values
245 // user defined functions
248 public class Xcls_dbmodel : Object
250 public Gtk.ListStore el;
251 private NewBranch _this;
257 public Xcls_dbmodel(NewBranch _owner )
260 _this.dbmodel = this;
261 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
265 // set gobject values
268 // user defined functions
269 public void loadTickets () {
271 RooTicket.singleton().loadTickets();
282 el.set_value(iter, 0, "");
283 el.set_value(iter, 1, "-- select a ticket --");
285 _this.build_module.el.set_active_iter(iter);
286 var tickets = RooTicket.singleton().tickets;
287 foreach(var ticket in tickets) {
292 el.set_value(iter, 0, ticket.id);
293 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
295 //if (data.get(i) == cur) {
296 // _this.build_module.el.set_active_iter(iter);
300 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
306 public class Xcls_Label8 : Object
309 private NewBranch _this;
315 public Xcls_Label8(NewBranch _owner )
318 this.el = new Gtk.Label( "or use this as branch name" );
322 // set gobject values
323 this.el.justify = Gtk.Justification.RIGHT;
324 this.el.xalign = 0.900000f;
327 // user defined functions
330 public class Xcls_name : Object
333 private NewBranch _this;
339 public Xcls_name(NewBranch _owner )
343 this.el = new Gtk.Entry();
347 // set gobject values
348 this.el.visible = true;
351 // user defined functions
356 public class Xcls_Button10 : Object
358 public Gtk.Button el;
359 private NewBranch _this;
365 public Xcls_Button10(NewBranch _owner )
368 this.el = new Gtk.Button();
372 // set gobject values
373 this.el.relief = Gtk.ReliefStyle.NONE;
374 this.el.label = "Do not create Branch";
377 // user defined functions
380 public class Xcls_Button11 : Object
382 public Gtk.Button el;
383 private NewBranch _this;
389 public Xcls_Button11(NewBranch _owner )
392 this.el = new Gtk.Button();
396 // set gobject values
397 this.el.label = "Create Branch";
400 // user defined functions