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) {
64 // have they selected a ticket..
65 // make that the current active ticket?
66 // we really need to store locally what ticket is being worked on..
67 // in theory we could be working on multiple project and not merging..
68 // -- each repo would have their active ticket (only one per repo)
69 // -- so we could just store that in there
70 // -- initial load can check the contents of the ticket files on first scan.
71 var ticket_id = _this.ticketsel.selectedTicketId();
73 if (this.repo != null) {
74 var bn = _this.name.el.get_text();
75 if (ticket_id != "" ) {
76 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
78 this.repo.createBranchNamed(bn);
90 this.el.show.connect( (self) => {
97 // user defined functions
98 public void show ( GitRepo repo )
100 // this.el.set_gravity(Gdk.Gravity.NORTH);
106 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
107 GLib.debug("Loading tickets");
111 _this.dbmodel.loadTickets();
114 public class Xcls_VBox2 : Object
117 private NewBranch _this;
123 public Xcls_VBox2(NewBranch _owner )
126 this.el = new Gtk.VBox( true, 0 );
130 // set gobject values
131 var child_0 = new Xcls_Table3( _this );
133 this.el.pack_start ( child_0.el , false,false,0 );
136 // user defined functions
138 public class Xcls_Table3 : Object
141 private NewBranch _this;
147 public Xcls_Table3(NewBranch _owner )
150 this.el = new Gtk.Table( 2, 2, false );
154 // set gobject values
156 this.el.column_spacing = 2;
157 var child_0 = new Xcls_Label4( _this );
159 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
160 var child_1 = new Xcls_ticketsel( _this );
162 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
163 var child_2 = new Xcls_Label8( _this );
165 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
166 var child_3 = new Xcls_name( _this );
168 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
171 // user defined functions
173 public class Xcls_Label4 : Object
176 private NewBranch _this;
182 public Xcls_Label4(NewBranch _owner )
185 this.el = new Gtk.Label( "Select Ticket" );
189 // set gobject values
190 this.el.justify = Gtk.Justification.RIGHT;
191 this.el.xalign = 0.900000f;
192 this.el.visible = true;
195 // user defined functions
198 public class Xcls_ticketsel : Object
200 public Gtk.ComboBox el;
201 private NewBranch _this;
208 public Xcls_ticketsel(NewBranch _owner )
211 _this.ticketsel = this;
212 this.el = new Gtk.ComboBox();
215 this.loading = false;
217 // set gobject values
218 var child_0 = new Xcls_dbcellrenderer( _this );
220 this.el.pack_start ( child_0.el , true );
221 var child_1 = new Xcls_dbmodel( _this );
223 this.el.set_model ( child_1.el );
227 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
230 this.el.changed.connect( () => {
234 var ticket_id = this.selectedTicketId();
236 var name = RooTicket.singleton().usernameLocal();
238 if (ticket_id == "" || ticket_id == null) {
240 var dt = new DateTime.now_local();
241 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
246 var ticket = RooTicket.singleton().getById(ticket_id);
248 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
250 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
254 // user defined functions
255 public string selectedTicketId () {
260 this.el.get_active_iter (out iter);
261 _this.dbmodel.el.get_value (iter, 0, out val1);
264 return (string) val1;
271 public class Xcls_dbcellrenderer : Object
273 public Gtk.CellRendererText el;
274 private NewBranch _this;
280 public Xcls_dbcellrenderer(NewBranch _owner )
283 _this.dbcellrenderer = this;
284 this.el = new Gtk.CellRendererText();
288 // set gobject values
291 // user defined functions
294 public class Xcls_dbmodel : Object
296 public Gtk.ListStore el;
297 private NewBranch _this;
303 public Xcls_dbmodel(NewBranch _owner )
306 _this.dbmodel = this;
307 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
311 // set gobject values
314 // user defined functions
315 public void loadTickets () {
317 RooTicket.singleton().loadTickets();
319 _this.ticketsel.loading = true;
328 el.set_value(iter, 0, "");
329 el.set_value(iter, 1, "-- select a ticket --");
331 _this.ticketsel.el.set_active_iter(iter);
332 var tickets = RooTicket.singleton().tickets;
333 foreach(var ticket in tickets) {
337 el.set_value(iter, 0, ticket.id);
338 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
340 //if (data.get(i) == cur) {
341 // _this.build_module.el.set_active_iter(iter);
346 _this.ticketsel.loading = false;
347 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
353 public class Xcls_Label8 : Object
356 private NewBranch _this;
362 public Xcls_Label8(NewBranch _owner )
365 this.el = new Gtk.Label( "or use this as branch name" );
369 // set gobject values
370 this.el.justify = Gtk.Justification.RIGHT;
371 this.el.xalign = 0.900000f;
374 // user defined functions
377 public class Xcls_name : Object
380 private NewBranch _this;
386 public Xcls_name(NewBranch _owner )
390 this.el = new Gtk.Entry();
394 // set gobject values
395 this.el.visible = true;
398 // user defined functions
403 public class Xcls_Button10 : Object
405 public Gtk.Button el;
406 private NewBranch _this;
412 public Xcls_Button10(NewBranch _owner )
415 this.el = new Gtk.Button();
419 // set gobject values
420 this.el.relief = Gtk.ReliefStyle.NONE;
421 this.el.label = "Do not create Branch";
424 // user defined functions
427 public class Xcls_Button11 : Object
429 public Gtk.Button el;
430 private NewBranch _this;
436 public Xcls_Button11(NewBranch _owner )
439 this.el = new Gtk.Button();
443 // set gobject values
444 this.el.label = "Create Branch";
447 // user defined functions