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) => {
56 this.el.response.connect( (self, response_id) => {
58 GLib.debug("got %d", (int) response_id);
59 if (response_id == 0) {
62 GitMonitor.gitmonitor.start();
66 // have they selected a ticket..
67 // make that the current active ticket?
68 // we really need to store locally what ticket is being worked on..
69 // in theory we could be working on multiple project and not merging..
70 // -- each repo would have their active ticket (only one per repo)
71 // -- so we could just store that in there
72 // -- initial load can check the contents of the ticket files on first scan.
73 var ticket_id = _this.ticketsel.selectedTicketId();
75 if (this.repo != null) {
76 var bn = _this.name.el.get_text();
77 if (ticket_id != "" ) {
78 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
80 this.repo.createBranchNamed(bn);
83 GitMonitor.gitmonitor.start();
92 this.el.show.connect( (self) => {
99 // user defined functions
100 public void show ( GitRepo repo )
102 // this.el.set_gravity(Gdk.Gravity.NORTH);
106 GitMonitor.gitmonitor.stop();
110 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
111 GLib.debug("Loading tickets");
115 _this.dbmodel.loadTickets();
118 public class Xcls_VBox2 : Object
121 private NewBranch _this;
127 public Xcls_VBox2(NewBranch _owner )
130 this.el = new Gtk.VBox( true, 0 );
134 // set gobject values
135 var child_0 = new Xcls_Table3( _this );
137 this.el.pack_start ( child_0.el , false,false,0 );
140 // user defined functions
142 public class Xcls_Table3 : Object
145 private NewBranch _this;
151 public Xcls_Table3(NewBranch _owner )
154 this.el = new Gtk.Table( 2, 2, false );
158 // set gobject values
160 this.el.column_spacing = 2;
161 var child_0 = new Xcls_Label4( _this );
163 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
164 var child_1 = new Xcls_ticketsel( _this );
166 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
167 var child_2 = new Xcls_Label8( _this );
169 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
170 var child_3 = new Xcls_name( _this );
172 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
175 // user defined functions
177 public class Xcls_Label4 : Object
180 private NewBranch _this;
186 public Xcls_Label4(NewBranch _owner )
189 this.el = new Gtk.Label( "Select Ticket" );
193 // set gobject values
194 this.el.justify = Gtk.Justification.RIGHT;
195 this.el.xalign = 0.900000f;
196 this.el.visible = true;
199 // user defined functions
202 public class Xcls_ticketsel : Object
204 public Gtk.ComboBox el;
205 private NewBranch _this;
212 public Xcls_ticketsel(NewBranch _owner )
215 _this.ticketsel = this;
216 this.el = new Gtk.ComboBox();
219 this.loading = false;
221 // set gobject values
222 var child_0 = new Xcls_dbcellrenderer( _this );
224 this.el.pack_start ( child_0.el , true );
225 var child_1 = new Xcls_dbmodel( _this );
227 this.el.set_model ( child_1.el );
231 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
234 this.el.changed.connect( () => {
238 var ticket_id = this.selectedTicketId();
240 var name = RooTicket.singleton().usernameLocal();
242 if (ticket_id == "" || ticket_id == null) {
244 var dt = new DateTime.now_local();
245 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
250 var ticket = RooTicket.singleton().getById(ticket_id);
252 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
254 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
258 // user defined functions
259 public string selectedTicketId () {
264 this.el.get_active_iter (out iter);
265 _this.dbmodel.el.get_value (iter, 0, out val1);
268 return (string) val1;
275 public class Xcls_dbcellrenderer : Object
277 public Gtk.CellRendererText el;
278 private NewBranch _this;
284 public Xcls_dbcellrenderer(NewBranch _owner )
287 _this.dbcellrenderer = this;
288 this.el = new Gtk.CellRendererText();
292 // set gobject values
295 // user defined functions
298 public class Xcls_dbmodel : Object
300 public Gtk.ListStore el;
301 private NewBranch _this;
307 public Xcls_dbmodel(NewBranch _owner )
310 _this.dbmodel = this;
311 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
315 // set gobject values
318 // user defined functions
319 public void loadTickets () {
321 RooTicket.singleton().loadTickets();
323 _this.ticketsel.loading = true;
332 el.set_value(iter, 0, "");
333 el.set_value(iter, 1, "-- select a ticket --");
335 _this.ticketsel.el.set_active_iter(iter);
336 var tickets = RooTicket.singleton().tickets;
337 foreach(var ticket in tickets) {
341 el.set_value(iter, 0, ticket.id);
342 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
344 //if (data.get(i) == cur) {
345 // _this.build_module.el.set_active_iter(iter);
350 _this.ticketsel.loading = false;
351 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
357 public class Xcls_Label8 : Object
360 private NewBranch _this;
366 public Xcls_Label8(NewBranch _owner )
369 this.el = new Gtk.Label( "or use this as branch name" );
373 // set gobject values
374 this.el.justify = Gtk.Justification.RIGHT;
375 this.el.xalign = 0.900000f;
378 // user defined functions
381 public class Xcls_name : Object
384 private NewBranch _this;
390 public Xcls_name(NewBranch _owner )
394 this.el = new Gtk.Entry();
398 // set gobject values
399 this.el.visible = true;
402 // user defined functions
407 public class Xcls_Button10 : Object
409 public Gtk.Button el;
410 private NewBranch _this;
416 public Xcls_Button10(NewBranch _owner )
419 this.el = new Gtk.Button();
423 // set gobject values
424 this.el.relief = Gtk.ReliefStyle.NONE;
425 this.el.label = "Do not create Branch";
428 // user defined functions
431 public class Xcls_Button11 : Object
433 public Gtk.Button el;
434 private NewBranch _this;
440 public Xcls_Button11(NewBranch _owner )
443 this.el = new Gtk.Button();
447 // set gobject values
448 this.el.label = "Create Branch";
451 // user defined functions