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();
78 if (ticket_id != "" ) {
79 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
81 this.repo.createBranchNamed(bn);
93 this.el.show.connect( (self) => {
100 // user defined functions
101 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
103 // this.el.set_gravity(Gdk.Gravity.NORTH);
104 if (this.running) { // should not happen!!
105 GLib.error("new branch show called, when already being displayed?");
110 GitMonitor.gitmonitor.stop();
114 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
115 GLib.debug("Loading tickets");
119 _this.dbmodel.loadTickets();
122 public class Xcls_VBox2 : Object
125 private NewBranch _this;
131 public Xcls_VBox2(NewBranch _owner )
134 this.el = new Gtk.VBox( true, 0 );
138 // set gobject values
139 var child_0 = new Xcls_Table3( _this );
141 this.el.pack_start ( child_0.el , false,false,0 );
144 // user defined functions
146 public class Xcls_Table3 : Object
149 private NewBranch _this;
155 public Xcls_Table3(NewBranch _owner )
158 this.el = new Gtk.Table( 2, 2, false );
162 // set gobject values
164 this.el.column_spacing = 2;
165 var child_0 = new Xcls_Label4( _this );
167 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
168 var child_1 = new Xcls_ticketsel( _this );
170 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
171 var child_2 = new Xcls_Label8( _this );
173 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
174 var child_3 = new Xcls_name( _this );
176 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
179 // user defined functions
181 public class Xcls_Label4 : Object
184 private NewBranch _this;
190 public Xcls_Label4(NewBranch _owner )
193 this.el = new Gtk.Label( "Select Ticket" );
197 // set gobject values
198 this.el.justify = Gtk.Justification.RIGHT;
199 this.el.xalign = 0.900000f;
200 this.el.visible = true;
203 // user defined functions
206 public class Xcls_ticketsel : Object
208 public Gtk.ComboBox el;
209 private NewBranch _this;
216 public Xcls_ticketsel(NewBranch _owner )
219 _this.ticketsel = this;
220 this.el = new Gtk.ComboBox();
223 this.loading = false;
225 // set gobject values
226 var child_0 = new Xcls_dbcellrenderer( _this );
228 this.el.pack_start ( child_0.el , true );
229 var child_1 = new Xcls_dbmodel( _this );
231 this.el.set_model ( child_1.el );
235 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
238 this.el.changed.connect( () => {
242 var ticket_id = this.selectedTicketId();
244 var name = RooTicket.singleton().usernameLocal();
246 if (ticket_id == "" || ticket_id == null) {
248 var dt = new DateTime.now_local();
249 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
254 var ticket = RooTicket.singleton().getById(ticket_id);
256 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
258 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
262 // user defined functions
263 public string selectedTicketId () {
268 this.el.get_active_iter (out iter);
269 _this.dbmodel.el.get_value (iter, 0, out val1);
272 return (string) val1;
279 public class Xcls_dbcellrenderer : Object
281 public Gtk.CellRendererText el;
282 private NewBranch _this;
288 public Xcls_dbcellrenderer(NewBranch _owner )
291 _this.dbcellrenderer = this;
292 this.el = new Gtk.CellRendererText();
296 // set gobject values
299 // user defined functions
302 public class Xcls_dbmodel : Object
304 public Gtk.ListStore el;
305 private NewBranch _this;
311 public Xcls_dbmodel(NewBranch _owner )
314 _this.dbmodel = this;
315 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
319 // set gobject values
322 // user defined functions
323 public void loadTickets () {
325 RooTicket.singleton().loadTickets();
327 _this.ticketsel.loading = true;
336 el.set_value(iter, 0, "");
337 el.set_value(iter, 1, "-- select a ticket --");
339 _this.ticketsel.el.set_active_iter(iter);
340 var tickets = RooTicket.singleton().tickets;
341 foreach(var ticket in tickets) {
345 el.set_value(iter, 0, ticket.id);
346 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
348 //if (data.get(i) == cur) {
349 // _this.build_module.el.set_active_iter(iter);
354 _this.ticketsel.loading = false;
355 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
361 public class Xcls_Label8 : Object
364 private NewBranch _this;
370 public Xcls_Label8(NewBranch _owner )
373 this.el = new Gtk.Label( "or use this as branch name" );
377 // set gobject values
378 this.el.justify = Gtk.Justification.RIGHT;
379 this.el.xalign = 0.900000f;
382 // user defined functions
385 public class Xcls_name : Object
388 private NewBranch _this;
394 public Xcls_name(NewBranch _owner )
398 this.el = new Gtk.Entry();
402 // set gobject values
403 this.el.visible = true;
406 // user defined functions
411 public class Xcls_Button10 : Object
413 public Gtk.Button el;
414 private NewBranch _this;
420 public Xcls_Button10(NewBranch _owner )
423 this.el = new Gtk.Button();
427 // set gobject values
428 this.el.relief = Gtk.ReliefStyle.NONE;
429 this.el.label = "Do not create Branch";
432 // user defined functions
435 public class Xcls_Button11 : Object
437 public Gtk.Button el;
438 private NewBranch _this;
444 public Xcls_Button11(NewBranch _owner )
447 this.el = new Gtk.Button();
451 // set gobject values
452 this.el.label = "Create Branch";
455 // user defined functions