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();
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);
84 GitMonitor.gitmonitor.start();
93 this.el.show.connect( (self) => {
100 // user defined functions
101 public void show ( GitRepo repo )
103 // this.el.set_gravity(Gdk.Gravity.NORTH);
108 GitMonitor.gitmonitor.stop();
112 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
113 GLib.debug("Loading tickets");
117 _this.dbmodel.loadTickets();
120 public class Xcls_VBox2 : Object
123 private NewBranch _this;
129 public Xcls_VBox2(NewBranch _owner )
132 this.el = new Gtk.VBox( true, 0 );
136 // set gobject values
137 var child_0 = new Xcls_Table3( _this );
139 this.el.pack_start ( child_0.el , false,false,0 );
142 // user defined functions
144 public class Xcls_Table3 : Object
147 private NewBranch _this;
153 public Xcls_Table3(NewBranch _owner )
156 this.el = new Gtk.Table( 2, 2, false );
160 // set gobject values
162 this.el.column_spacing = 2;
163 var child_0 = new Xcls_Label4( _this );
165 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
166 var child_1 = new Xcls_ticketsel( _this );
168 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
169 var child_2 = new Xcls_Label8( _this );
171 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
172 var child_3 = new Xcls_name( _this );
174 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
177 // user defined functions
179 public class Xcls_Label4 : Object
182 private NewBranch _this;
188 public Xcls_Label4(NewBranch _owner )
191 this.el = new Gtk.Label( "Select Ticket" );
195 // set gobject values
196 this.el.justify = Gtk.Justification.RIGHT;
197 this.el.xalign = 0.900000f;
198 this.el.visible = true;
201 // user defined functions
204 public class Xcls_ticketsel : Object
206 public Gtk.ComboBox el;
207 private NewBranch _this;
214 public Xcls_ticketsel(NewBranch _owner )
217 _this.ticketsel = this;
218 this.el = new Gtk.ComboBox();
221 this.loading = false;
223 // set gobject values
224 var child_0 = new Xcls_dbcellrenderer( _this );
226 this.el.pack_start ( child_0.el , true );
227 var child_1 = new Xcls_dbmodel( _this );
229 this.el.set_model ( child_1.el );
233 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
236 this.el.changed.connect( () => {
240 var ticket_id = this.selectedTicketId();
242 var name = RooTicket.singleton().usernameLocal();
244 if (ticket_id == "" || ticket_id == null) {
246 var dt = new DateTime.now_local();
247 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
252 var ticket = RooTicket.singleton().getById(ticket_id);
254 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
256 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
260 // user defined functions
261 public string selectedTicketId () {
266 this.el.get_active_iter (out iter);
267 _this.dbmodel.el.get_value (iter, 0, out val1);
270 return (string) val1;
277 public class Xcls_dbcellrenderer : Object
279 public Gtk.CellRendererText el;
280 private NewBranch _this;
286 public Xcls_dbcellrenderer(NewBranch _owner )
289 _this.dbcellrenderer = this;
290 this.el = new Gtk.CellRendererText();
294 // set gobject values
297 // user defined functions
300 public class Xcls_dbmodel : Object
302 public Gtk.ListStore el;
303 private NewBranch _this;
309 public Xcls_dbmodel(NewBranch _owner )
312 _this.dbmodel = this;
313 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
317 // set gobject values
320 // user defined functions
321 public void loadTickets () {
323 RooTicket.singleton().loadTickets();
325 _this.ticketsel.loading = true;
334 el.set_value(iter, 0, "");
335 el.set_value(iter, 1, "-- select a ticket --");
337 _this.ticketsel.el.set_active_iter(iter);
338 var tickets = RooTicket.singleton().tickets;
339 foreach(var ticket in tickets) {
343 el.set_value(iter, 0, ticket.id);
344 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
346 //if (data.get(i) == cur) {
347 // _this.build_module.el.set_active_iter(iter);
352 _this.ticketsel.loading = false;
353 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
359 public class Xcls_Label8 : Object
362 private NewBranch _this;
368 public Xcls_Label8(NewBranch _owner )
371 this.el = new Gtk.Label( "or use this as branch name" );
375 // set gobject values
376 this.el.justify = Gtk.Justification.RIGHT;
377 this.el.xalign = 0.900000f;
380 // user defined functions
383 public class Xcls_name : Object
386 private NewBranch _this;
392 public Xcls_name(NewBranch _owner )
396 this.el = new Gtk.Entry();
400 // set gobject values
401 this.el.visible = true;
404 // user defined functions
409 public class Xcls_Button10 : Object
411 public Gtk.Button el;
412 private NewBranch _this;
418 public Xcls_Button10(NewBranch _owner )
421 this.el = new Gtk.Button();
425 // set gobject values
426 this.el.relief = Gtk.ReliefStyle.NONE;
427 this.el.label = "Do not create Branch";
430 // user defined functions
433 public class Xcls_Button11 : Object
435 public Gtk.Button el;
436 private NewBranch _this;
442 public Xcls_Button11(NewBranch _owner )
445 this.el = new Gtk.Button();
449 // set gobject values
450 this.el.label = "Create Branch";
453 // user defined functions