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);
96 this.el.show.connect( (self) => {
103 // user defined functions
104 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
106 // this.el.set_gravity(Gdk.Gravity.NORTH);
107 if (this.running) { // should not happen!!
108 GLib.error("new branch show called, when already being displayed?");
113 GitMonitor.gitmonitor.stop();
117 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
118 GLib.debug("Loading tickets");
122 _this.dbmodel.loadTickets();
125 public class Xcls_VBox2 : Object
128 private NewBranch _this;
134 public Xcls_VBox2(NewBranch _owner )
137 this.el = new Gtk.VBox( true, 0 );
141 // set gobject values
142 var child_0 = new Xcls_Table3( _this );
144 this.el.pack_start ( child_0.el , false,false,0 );
147 // user defined functions
149 public class Xcls_Table3 : Object
152 private NewBranch _this;
158 public Xcls_Table3(NewBranch _owner )
161 this.el = new Gtk.Table( 2, 2, false );
165 // set gobject values
167 this.el.column_spacing = 2;
168 var child_0 = new Xcls_Label4( _this );
170 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
171 var child_1 = new Xcls_ticketsel( _this );
173 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
174 var child_2 = new Xcls_Label8( _this );
176 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
177 var child_3 = new Xcls_name( _this );
179 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
182 // user defined functions
184 public class Xcls_Label4 : Object
187 private NewBranch _this;
193 public Xcls_Label4(NewBranch _owner )
196 this.el = new Gtk.Label( "Select Ticket" );
200 // set gobject values
201 this.el.justify = Gtk.Justification.RIGHT;
202 this.el.xalign = 0.900000f;
203 this.el.visible = true;
206 // user defined functions
209 public class Xcls_ticketsel : Object
211 public Gtk.ComboBox el;
212 private NewBranch _this;
219 public Xcls_ticketsel(NewBranch _owner )
222 _this.ticketsel = this;
223 this.el = new Gtk.ComboBox();
226 this.loading = false;
228 // set gobject values
229 var child_0 = new Xcls_dbcellrenderer( _this );
231 this.el.pack_start ( child_0.el , true );
232 var child_1 = new Xcls_dbmodel( _this );
234 this.el.set_model ( child_1.el );
238 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
241 this.el.changed.connect( () => {
245 var ticket_id = this.selectedTicketId();
247 var name = RooTicket.singleton().usernameLocal();
249 if (ticket_id == "" || ticket_id == null) {
251 var dt = new DateTime.now_local();
252 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
257 var ticket = RooTicket.singleton().getById(ticket_id);
259 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
261 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
265 // user defined functions
266 public string selectedTicketId () {
271 this.el.get_active_iter (out iter);
272 _this.dbmodel.el.get_value (iter, 0, out val1);
275 return (string) val1;
282 public class Xcls_dbcellrenderer : Object
284 public Gtk.CellRendererText el;
285 private NewBranch _this;
291 public Xcls_dbcellrenderer(NewBranch _owner )
294 _this.dbcellrenderer = this;
295 this.el = new Gtk.CellRendererText();
299 // set gobject values
302 // user defined functions
305 public class Xcls_dbmodel : Object
307 public Gtk.ListStore el;
308 private NewBranch _this;
314 public Xcls_dbmodel(NewBranch _owner )
317 _this.dbmodel = this;
318 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
322 // set gobject values
325 // user defined functions
326 public void loadTickets () {
328 RooTicket.singleton().loadTickets();
330 _this.ticketsel.loading = true;
339 el.set_value(iter, 0, "");
340 el.set_value(iter, 1, "-- select a ticket --");
342 _this.ticketsel.el.set_active_iter(iter);
343 var tickets = RooTicket.singleton().tickets;
344 foreach(var ticket in tickets) {
348 el.set_value(iter, 0, ticket.id);
349 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
351 //if (data.get(i) == cur) {
352 // _this.build_module.el.set_active_iter(iter);
357 _this.ticketsel.loading = false;
358 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
364 public class Xcls_Label8 : Object
367 private NewBranch _this;
373 public Xcls_Label8(NewBranch _owner )
376 this.el = new Gtk.Label( "or use this as branch name" );
380 // set gobject values
381 this.el.justify = Gtk.Justification.RIGHT;
382 this.el.xalign = 0.900000f;
385 // user defined functions
388 public class Xcls_name : Object
391 private NewBranch _this;
397 public Xcls_name(NewBranch _owner )
401 this.el = new Gtk.Entry();
405 // set gobject values
406 this.el.visible = true;
409 // user defined functions
414 public class Xcls_Button10 : Object
416 public Gtk.Button el;
417 private NewBranch _this;
423 public Xcls_Button10(NewBranch _owner )
426 this.el = new Gtk.Button();
430 // set gobject values
431 this.el.relief = Gtk.ReliefStyle.NONE;
432 this.el.label = "Do not create Branch";
435 // user defined functions
438 public class Xcls_Button11 : Object
440 public Gtk.Button el;
441 private NewBranch _this;
447 public Xcls_Button11(NewBranch _owner )
450 this.el = new Gtk.Button();
454 // set gobject values
455 this.el.label = "Create Branch";
458 // user defined functions