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;
23 public Gee.ArrayList<GitMonitorQueue> queue;
29 this.el = new Gtk.Dialog();
37 this.el.title = "Create a working branch ";
38 this.el.default_height = 200;
39 this.el.default_width = 500;
40 this.el.deletable = true;
42 var child_0 = new Xcls_VBox2( _this );
44 this.el.get_content_area().add ( child_0.el );
45 var child_1 = new Xcls_Button10( _this );
47 this.el.add_action_widget ( child_1.el , 0 );
48 var child_2 = new Xcls_Button11( _this );
50 this.el.add_action_widget ( child_2.el , 1 );
53 this.el.delete_event.connect( (self, event) => {
59 this.el.response.connect( (self, response_id) => {
61 GLib.debug("got %d", (int) response_id);
62 if (response_id == 0) {
65 GitMonitor.gitmonitor.start();
69 // have they selected a ticket..
70 // make that the current active ticket?
71 // we really need to store locally what ticket is being worked on..
72 // in theory we could be working on multiple project and not merging..
73 // -- each repo would have their active ticket (only one per repo)
74 // -- so we could just store that in there
75 // -- initial load can check the contents of the ticket files on first scan.
76 var ticket_id = _this.ticketsel.selectedTicketId();
79 if (this.repo != null) {
80 var bn = _this.name.el.get_text();
81 if (ticket_id != "" ) {
82 success = this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
84 success = this.repo.createBranchNamed(bn);
88 GitMonitor.gitmonitor.restoreQueue( this.queue );
89 GitMonitor.gitmonitor.runQueue();
90 GitMonitor.gitmonitor.start();
97 this.el.show.connect( (self) => {
104 // user defined functions
105 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
107 // this.el.set_gravity(Gdk.Gravity.NORTH);
108 if (this.running) { // should not happen!!
109 GLib.error("new branch show called, when already being displayed?");
114 GitMonitor.gitmonitor.stop();
118 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
119 GLib.debug("Loading tickets");
123 _this.dbmodel.loadTickets();
126 public class Xcls_VBox2 : Object
129 private NewBranch _this;
135 public Xcls_VBox2(NewBranch _owner )
138 this.el = new Gtk.VBox( true, 0 );
142 // set gobject values
143 var child_0 = new Xcls_Table3( _this );
145 this.el.pack_start ( child_0.el , false,false,0 );
148 // user defined functions
150 public class Xcls_Table3 : Object
153 private NewBranch _this;
159 public Xcls_Table3(NewBranch _owner )
162 this.el = new Gtk.Table( 2, 2, false );
166 // set gobject values
168 this.el.column_spacing = 2;
169 var child_0 = new Xcls_Label4( _this );
171 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
172 var child_1 = new Xcls_ticketsel( _this );
174 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
175 var child_2 = new Xcls_Label8( _this );
177 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
178 var child_3 = new Xcls_name( _this );
180 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
183 // user defined functions
185 public class Xcls_Label4 : Object
188 private NewBranch _this;
194 public Xcls_Label4(NewBranch _owner )
197 this.el = new Gtk.Label( "Select Ticket" );
201 // set gobject values
202 this.el.justify = Gtk.Justification.RIGHT;
203 this.el.xalign = 0.900000f;
204 this.el.visible = true;
207 // user defined functions
210 public class Xcls_ticketsel : Object
212 public Gtk.ComboBox el;
213 private NewBranch _this;
220 public Xcls_ticketsel(NewBranch _owner )
223 _this.ticketsel = this;
224 this.el = new Gtk.ComboBox();
227 this.loading = false;
229 // set gobject values
230 var child_0 = new Xcls_dbcellrenderer( _this );
232 this.el.pack_start ( child_0.el , true );
233 var child_1 = new Xcls_dbmodel( _this );
235 this.el.set_model ( child_1.el );
239 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
242 this.el.changed.connect( () => {
246 var ticket_id = this.selectedTicketId();
248 var name = RooTicket.singleton().usernameLocal();
250 if (ticket_id == "" || ticket_id == null) {
252 var dt = new DateTime.now_local();
253 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
258 var ticket = RooTicket.singleton().getById(ticket_id);
260 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
262 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
266 // user defined functions
267 public string selectedTicketId () {
272 this.el.get_active_iter (out iter);
273 _this.dbmodel.el.get_value (iter, 0, out val1);
276 return (string) val1;
283 public class Xcls_dbcellrenderer : Object
285 public Gtk.CellRendererText el;
286 private NewBranch _this;
292 public Xcls_dbcellrenderer(NewBranch _owner )
295 _this.dbcellrenderer = this;
296 this.el = new Gtk.CellRendererText();
300 // set gobject values
303 // user defined functions
306 public class Xcls_dbmodel : Object
308 public Gtk.ListStore el;
309 private NewBranch _this;
315 public Xcls_dbmodel(NewBranch _owner )
318 _this.dbmodel = this;
319 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
323 // set gobject values
326 // user defined functions
327 public void loadTickets () {
329 RooTicket.singleton().loadTickets();
331 _this.ticketsel.loading = true;
340 el.set_value(iter, 0, "");
341 el.set_value(iter, 1, "-- select a ticket --");
343 _this.ticketsel.el.set_active_iter(iter);
344 var tickets = RooTicket.singleton().tickets;
345 foreach(var ticket in tickets) {
349 el.set_value(iter, 0, ticket.id);
350 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
352 //if (data.get(i) == cur) {
353 // _this.build_module.el.set_active_iter(iter);
358 _this.ticketsel.loading = false;
359 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
365 public class Xcls_Label8 : Object
368 private NewBranch _this;
374 public Xcls_Label8(NewBranch _owner )
377 this.el = new Gtk.Label( "or use this as branch name" );
381 // set gobject values
382 this.el.justify = Gtk.Justification.RIGHT;
383 this.el.xalign = 0.900000f;
386 // user defined functions
389 public class Xcls_name : Object
392 private NewBranch _this;
398 public Xcls_name(NewBranch _owner )
402 this.el = new Gtk.Entry();
406 // set gobject values
407 this.el.visible = true;
410 // user defined functions
415 public class Xcls_Button10 : Object
417 public Gtk.Button el;
418 private NewBranch _this;
424 public Xcls_Button10(NewBranch _owner )
427 this.el = new Gtk.Button();
431 // set gobject values
432 this.el.relief = Gtk.ReliefStyle.NONE;
433 this.el.label = "Do not create Branch";
436 // user defined functions
439 public class Xcls_Button11 : Object
441 public Gtk.Button el;
442 private NewBranch _this;
448 public Xcls_Button11(NewBranch _owner )
451 this.el = new Gtk.Button();
455 // set gobject values
456 this.el.label = "Create Branch";
459 // user defined functions