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) => {
58 this.el.response.connect( (self, response_id) => {
60 GLib.debug("got %d", (int) response_id);
61 if (response_id == 0) {
67 // have they selected a ticket..
68 // make that the current active ticket?
69 // we really need to store locally what ticket is being worked on..
70 // in theory we could be working on multiple project and not merging..
71 // -- each repo would have their active ticket (only one per repo)
72 // -- so we could just store that in there
73 // -- initial load can check the contents of the ticket files on first scan.
74 var ticket_id = _this.ticketsel.selectedTicketId();
76 if (this.repo != null) {
77 var bn = _this.name.el.get_text();
79 var res = this.repo.setActiveTicket(
80 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
83 // start the monitoring..
84 GitMonitor.gitmonitor.start();
98 this.el.show.connect( (self) => {
105 // user defined functions
106 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
108 // this.el.set_gravity(Gdk.Gravity.NORTH);
109 if (this.running) { // should not happen!!
110 GLib.error("new branch show called, when already being displayed?");
115 GitMonitor.gitmonitor.stop();
119 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
120 GLib.debug("Loading tickets");
124 this.el.set_keep_above(true);
125 _this.dbmodel.loadTickets();
129 public class Xcls_VBox2 : Object
132 private NewBranch _this;
138 public Xcls_VBox2(NewBranch _owner )
141 this.el = new Gtk.VBox( true, 0 );
145 // set gobject values
146 var child_0 = new Xcls_Table3( _this );
148 this.el.pack_start ( child_0.el , false,false,0 );
151 // user defined functions
153 public class Xcls_Table3 : Object
156 private NewBranch _this;
162 public Xcls_Table3(NewBranch _owner )
165 this.el = new Gtk.Table( 2, 2, false );
169 // set gobject values
171 this.el.column_spacing = 2;
172 var child_0 = new Xcls_Label4( _this );
174 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
175 var child_1 = new Xcls_ticketsel( _this );
177 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
178 var child_2 = new Xcls_Label8( _this );
180 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
181 var child_3 = new Xcls_name( _this );
183 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
186 // user defined functions
188 public class Xcls_Label4 : Object
191 private NewBranch _this;
197 public Xcls_Label4(NewBranch _owner )
200 this.el = new Gtk.Label( "Select Ticket" );
204 // set gobject values
205 this.el.justify = Gtk.Justification.RIGHT;
206 this.el.xalign = 0.900000f;
207 this.el.visible = true;
210 // user defined functions
213 public class Xcls_ticketsel : Object
215 public Gtk.ComboBox el;
216 private NewBranch _this;
223 public Xcls_ticketsel(NewBranch _owner )
226 _this.ticketsel = this;
227 this.el = new Gtk.ComboBox();
230 this.loading = false;
232 // set gobject values
233 var child_0 = new Xcls_dbcellrenderer( _this );
235 this.el.pack_start ( child_0.el , true );
236 var child_1 = new Xcls_dbmodel( _this );
238 this.el.set_model ( child_1.el );
242 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
245 this.el.changed.connect( () => {
249 var ticket_id = this.selectedTicketId();
251 var name = RooTicket.singleton().usernameLocal();
253 if (ticket_id == "" || ticket_id == null) {
255 var dt = new DateTime.now_local();
256 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
261 var ticket = RooTicket.singleton().getById(ticket_id);
263 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
265 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
269 // user defined functions
270 public string selectedTicketId () {
275 this.el.get_active_iter (out iter);
276 _this.dbmodel.el.get_value (iter, 0, out val1);
279 return (string) val1;
286 public class Xcls_dbcellrenderer : Object
288 public Gtk.CellRendererText el;
289 private NewBranch _this;
295 public Xcls_dbcellrenderer(NewBranch _owner )
298 _this.dbcellrenderer = this;
299 this.el = new Gtk.CellRendererText();
303 // set gobject values
306 // user defined functions
309 public class Xcls_dbmodel : Object
311 public Gtk.ListStore el;
312 private NewBranch _this;
318 public Xcls_dbmodel(NewBranch _owner )
321 _this.dbmodel = this;
322 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
326 // set gobject values
329 // user defined functions
330 public void loadTickets () {
332 RooTicket.singleton().loadTickets();
334 _this.ticketsel.loading = true;
343 el.set_value(iter, 0, "");
344 el.set_value(iter, 1, "-- select a ticket --");
346 _this.ticketsel.el.set_active_iter(iter);
347 var tickets = RooTicket.singleton().tickets;
348 foreach(var ticket in tickets) {
352 el.set_value(iter, 0, ticket.id);
353 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
355 //if (data.get(i) == cur) {
356 // _this.build_module.el.set_active_iter(iter);
361 _this.ticketsel.loading = false;
362 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
368 public class Xcls_Label8 : Object
371 private NewBranch _this;
377 public Xcls_Label8(NewBranch _owner )
380 this.el = new Gtk.Label( "or use this as branch name" );
384 // set gobject values
385 this.el.justify = Gtk.Justification.RIGHT;
386 this.el.xalign = 0.900000f;
389 // user defined functions
392 public class Xcls_name : Object
395 private NewBranch _this;
401 public Xcls_name(NewBranch _owner )
405 this.el = new Gtk.Entry();
409 // set gobject values
410 this.el.visible = true;
413 // user defined functions
418 public class Xcls_Button10 : Object
420 public Gtk.Button el;
421 private NewBranch _this;
427 public Xcls_Button10(NewBranch _owner )
430 this.el = new Gtk.Button();
434 // set gobject values
435 this.el.relief = Gtk.ReliefStyle.NONE;
436 this.el.label = "Do not create Branch";
439 // user defined functions
442 public class Xcls_Button11 : Object
444 public Gtk.Button el;
445 private NewBranch _this;
451 public Xcls_Button11(NewBranch _owner )
454 this.el = new Gtk.Button();
458 // set gobject values
459 this.el.label = "Create Branch";
462 // user defined functions