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_ticketsel ticketsel;
16 public Xcls_dbcellrenderer dbcellrenderer;
17 public Xcls_dbmodel dbmodel;
18 public Xcls_name name;
27 this.el = new Gtk.Dialog();
33 this.el.title = "Create a working branch ";
34 this.el.default_height = 200;
35 this.el.default_width = 500;
36 this.el.deletable = true;
38 var child_0 = new Xcls_VBox2( _this );
40 this.el.get_content_area().add ( child_0.el );
41 var child_1 = new Xcls_Button10( _this );
43 this.el.add_action_widget ( child_1.el , 0 );
44 var child_2 = new Xcls_Button11( _this );
46 this.el.add_action_widget ( child_2.el , 1 );
49 this.el.delete_event.connect( (self, event) => {
54 this.el.response.connect( (self, response_id) => {
56 GLib.debug("got %d", (int) response_id);
57 if (response_id == 0) {
61 // have they selected a ticket..
62 // make that the current active ticket?
63 // we really need to store locally what ticket is being worked on..
64 // in theory we could be working on multiple project and not merging..
65 // -- each repo would have their active ticket (only one per repo)
66 // -- so we could just store that in there
67 // -- initial load can check the contents of the ticket files on first scan.
68 var ticket_id = _this.ticketsel.selectedTicketId();
70 if (this.repo != null) {
71 var bn = _this.name.get_text();
72 if (ticket_id != "" ) {
73 this.repo.setActiveTicket( RooTicket.singleton.getById(ticket_id), bn);
75 this.repo.createBranchNamed(bn);
87 this.el.show.connect( (self) => {
94 // user defined functions
97 // this.el.set_gravity(Gdk.Gravity.NORTH);
99 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
100 GLib.debug("Loading tickets");
101 _this.dbmodel.loadTickets();
110 public class Xcls_VBox2 : Object
113 private NewBranch _this;
119 public Xcls_VBox2(NewBranch _owner )
122 this.el = new Gtk.VBox( true, 0 );
126 // set gobject values
127 var child_0 = new Xcls_Table3( _this );
129 this.el.pack_start ( child_0.el , false,false,0 );
132 // user defined functions
134 public class Xcls_Table3 : Object
137 private NewBranch _this;
143 public Xcls_Table3(NewBranch _owner )
146 this.el = new Gtk.Table( 2, 2, false );
150 // set gobject values
152 this.el.column_spacing = 2;
153 var child_0 = new Xcls_Label4( _this );
155 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
156 var child_1 = new Xcls_ticketsel( _this );
158 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
159 var child_2 = new Xcls_Label8( _this );
161 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
162 var child_3 = new Xcls_name( _this );
164 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
167 // user defined functions
169 public class Xcls_Label4 : Object
172 private NewBranch _this;
178 public Xcls_Label4(NewBranch _owner )
181 this.el = new Gtk.Label( "Select Ticket" );
185 // set gobject values
186 this.el.justify = Gtk.Justification.RIGHT;
187 this.el.xalign = 0.900000f;
188 this.el.visible = true;
191 // user defined functions
194 public class Xcls_ticketsel : Object
196 public Gtk.ComboBox el;
197 private NewBranch _this;
203 public Xcls_ticketsel(NewBranch _owner )
206 _this.ticketsel = this;
207 this.el = new Gtk.ComboBox();
211 // set gobject values
212 var child_0 = new Xcls_dbcellrenderer( _this );
214 this.el.pack_start ( child_0.el , true );
215 var child_1 = new Xcls_dbmodel( _this );
217 this.el.set_model ( child_1.el );
221 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
224 this.el.changed.connect( () => {
226 var ticket_id = this.selectedTicketId();
228 var name = RooTicket.singleton().usernameLocal();
230 if (ticket_id == "") {
232 var dt = new DateTime.now_local();
233 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
237 var ticket = RooTicket.singleton().getById(ticket_id);
239 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
241 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
245 // user defined functions
246 public string selectedTicketId () {
251 this.el.get_active_iter (out iter);
252 _this.dbmodel.el.get_value (iter, 0, out val1);
255 return (string) val1;
262 public class Xcls_dbcellrenderer : Object
264 public Gtk.CellRendererText el;
265 private NewBranch _this;
271 public Xcls_dbcellrenderer(NewBranch _owner )
274 _this.dbcellrenderer = this;
275 this.el = new Gtk.CellRendererText();
279 // set gobject values
282 // user defined functions
285 public class Xcls_dbmodel : Object
287 public Gtk.ListStore el;
288 private NewBranch _this;
294 public Xcls_dbmodel(NewBranch _owner )
297 _this.dbmodel = this;
298 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
302 // set gobject values
305 // user defined functions
306 public void loadTickets () {
308 RooTicket.singleton().loadTickets();
319 el.set_value(iter, 0, "");
320 el.set_value(iter, 1, "-- select a ticket --");
322 _this.build_module.el.set_active_iter(iter);
323 var tickets = RooTicket.singleton().tickets;
324 foreach(var ticket in tickets) {
329 el.set_value(iter, 0, ticket.id);
330 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
332 //if (data.get(i) == cur) {
333 // _this.build_module.el.set_active_iter(iter);
337 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
343 public class Xcls_Label8 : Object
346 private NewBranch _this;
352 public Xcls_Label8(NewBranch _owner )
355 this.el = new Gtk.Label( "or use this as branch name" );
359 // set gobject values
360 this.el.justify = Gtk.Justification.RIGHT;
361 this.el.xalign = 0.900000f;
364 // user defined functions
367 public class Xcls_name : Object
370 private NewBranch _this;
376 public Xcls_name(NewBranch _owner )
380 this.el = new Gtk.Entry();
384 // set gobject values
385 this.el.visible = true;
388 // user defined functions
393 public class Xcls_Button10 : Object
395 public Gtk.Button el;
396 private NewBranch _this;
402 public Xcls_Button10(NewBranch _owner )
405 this.el = new Gtk.Button();
409 // set gobject values
410 this.el.relief = Gtk.ReliefStyle.NONE;
411 this.el.label = "Do not create Branch";
414 // user defined functions
417 public class Xcls_Button11 : Object
419 public Gtk.Button el;
420 private NewBranch _this;
426 public Xcls_Button11(NewBranch _owner )
429 this.el = new Gtk.Button();
433 // set gobject values
434 this.el.label = "Create Branch";
437 // user defined functions