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;
28 this.el = new Gtk.Dialog();
35 this.el.title = "Create a working branch ";
36 this.el.default_height = 200;
37 this.el.default_width = 500;
38 this.el.deletable = true;
40 var child_0 = new Xcls_VBox2( _this );
42 this.el.get_content_area().add ( child_0.el );
43 var child_1 = new Xcls_Button10( _this );
45 this.el.add_action_widget ( child_1.el , 0 );
46 var child_2 = new Xcls_Button11( _this );
48 this.el.add_action_widget ( child_2.el , 1 );
51 this.el.delete_event.connect( (self, event) => {
57 this.el.response.connect( (self, response_id) => {
59 GLib.debug("got %d", (int) response_id);
60 if (response_id == 0) {
63 GitMonitor.gitmonitor.start();
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();
77 if (this.repo != null) {
78 var bn = _this.name.el.get_text();
79 if (ticket_id != "" ) {
80 success = this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
82 success = this.repo.createBranchNamed(bn);
85 GitMonitor.gitmonitor.start();
94 this.el.show.connect( (self) => {
101 // user defined functions
102 public void show ( GitRepo repo )
104 // this.el.set_gravity(Gdk.Gravity.NORTH);
109 GitMonitor.gitmonitor.stop();
113 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
114 GLib.debug("Loading tickets");
118 _this.dbmodel.loadTickets();
121 public class Xcls_VBox2 : Object
124 private NewBranch _this;
130 public Xcls_VBox2(NewBranch _owner )
133 this.el = new Gtk.VBox( true, 0 );
137 // set gobject values
138 var child_0 = new Xcls_Table3( _this );
140 this.el.pack_start ( child_0.el , false,false,0 );
143 // user defined functions
145 public class Xcls_Table3 : Object
148 private NewBranch _this;
154 public Xcls_Table3(NewBranch _owner )
157 this.el = new Gtk.Table( 2, 2, false );
161 // set gobject values
163 this.el.column_spacing = 2;
164 var child_0 = new Xcls_Label4( _this );
166 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
167 var child_1 = new Xcls_ticketsel( _this );
169 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
170 var child_2 = new Xcls_Label8( _this );
172 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
173 var child_3 = new Xcls_name( _this );
175 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
178 // user defined functions
180 public class Xcls_Label4 : Object
183 private NewBranch _this;
189 public Xcls_Label4(NewBranch _owner )
192 this.el = new Gtk.Label( "Select Ticket" );
196 // set gobject values
197 this.el.justify = Gtk.Justification.RIGHT;
198 this.el.xalign = 0.900000f;
199 this.el.visible = true;
202 // user defined functions
205 public class Xcls_ticketsel : Object
207 public Gtk.ComboBox el;
208 private NewBranch _this;
215 public Xcls_ticketsel(NewBranch _owner )
218 _this.ticketsel = this;
219 this.el = new Gtk.ComboBox();
222 this.loading = false;
224 // set gobject values
225 var child_0 = new Xcls_dbcellrenderer( _this );
227 this.el.pack_start ( child_0.el , true );
228 var child_1 = new Xcls_dbmodel( _this );
230 this.el.set_model ( child_1.el );
234 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
237 this.el.changed.connect( () => {
241 var ticket_id = this.selectedTicketId();
243 var name = RooTicket.singleton().usernameLocal();
245 if (ticket_id == "" || ticket_id == null) {
247 var dt = new DateTime.now_local();
248 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
253 var ticket = RooTicket.singleton().getById(ticket_id);
255 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
257 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
261 // user defined functions
262 public string selectedTicketId () {
267 this.el.get_active_iter (out iter);
268 _this.dbmodel.el.get_value (iter, 0, out val1);
271 return (string) val1;
278 public class Xcls_dbcellrenderer : Object
280 public Gtk.CellRendererText el;
281 private NewBranch _this;
287 public Xcls_dbcellrenderer(NewBranch _owner )
290 _this.dbcellrenderer = this;
291 this.el = new Gtk.CellRendererText();
295 // set gobject values
298 // user defined functions
301 public class Xcls_dbmodel : Object
303 public Gtk.ListStore el;
304 private NewBranch _this;
310 public Xcls_dbmodel(NewBranch _owner )
313 _this.dbmodel = this;
314 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
318 // set gobject values
321 // user defined functions
322 public void loadTickets () {
324 RooTicket.singleton().loadTickets();
326 _this.ticketsel.loading = true;
335 el.set_value(iter, 0, "");
336 el.set_value(iter, 1, "-- select a ticket --");
338 _this.ticketsel.el.set_active_iter(iter);
339 var tickets = RooTicket.singleton().tickets;
340 foreach(var ticket in tickets) {
344 el.set_value(iter, 0, ticket.id);
345 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
347 //if (data.get(i) == cur) {
348 // _this.build_module.el.set_active_iter(iter);
353 _this.ticketsel.loading = false;
354 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
360 public class Xcls_Label8 : Object
363 private NewBranch _this;
369 public Xcls_Label8(NewBranch _owner )
372 this.el = new Gtk.Label( "or use this as branch name" );
376 // set gobject values
377 this.el.justify = Gtk.Justification.RIGHT;
378 this.el.xalign = 0.900000f;
381 // user defined functions
384 public class Xcls_name : Object
387 private NewBranch _this;
393 public Xcls_name(NewBranch _owner )
397 this.el = new Gtk.Entry();
401 // set gobject values
402 this.el.visible = true;
405 // user defined functions
410 public class Xcls_Button10 : Object
412 public Gtk.Button el;
413 private NewBranch _this;
419 public Xcls_Button10(NewBranch _owner )
422 this.el = new Gtk.Button();
426 // set gobject values
427 this.el.relief = Gtk.ReliefStyle.NONE;
428 this.el.label = "Do not create Branch";
431 // user defined functions
434 public class Xcls_Button11 : Object
436 public Gtk.Button el;
437 private NewBranch _this;
443 public Xcls_Button11(NewBranch _owner )
446 this.el = new Gtk.Button();
450 // set gobject values
451 this.el.label = "Create Branch";
454 // user defined functions