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) {
65 // have they selected a ticket..
66 // make that the current active ticket?
67 // we really need to store locally what ticket is being worked on..
68 // in theory we could be working on multiple project and not merging..
69 // -- each repo would have their active ticket (only one per repo)
70 // -- so we could just store that in there
71 // -- initial load can check the contents of the ticket files on first scan.
72 var ticket_id = _this.ticketsel.selectedTicketId();
74 if (this.repo != null) {
75 var bn = _this.name.el.get_text();
76 if (ticket_id != "" ) {
77 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
79 this.repo.createBranchNamed(bn);
91 this.el.show.connect( (self) => {
98 // user defined functions
99 public void show ( GitRepo repo )
101 // this.el.set_gravity(Gdk.Gravity.NORTH);
107 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
108 GLib.debug("Loading tickets");
112 _this.dbmodel.loadTickets();
115 public class Xcls_VBox2 : Object
118 private NewBranch _this;
124 public Xcls_VBox2(NewBranch _owner )
127 this.el = new Gtk.VBox( true, 0 );
131 // set gobject values
132 var child_0 = new Xcls_Table3( _this );
134 this.el.pack_start ( child_0.el , false,false,0 );
137 // user defined functions
139 public class Xcls_Table3 : Object
142 private NewBranch _this;
148 public Xcls_Table3(NewBranch _owner )
151 this.el = new Gtk.Table( 2, 2, false );
155 // set gobject values
157 this.el.column_spacing = 2;
158 var child_0 = new Xcls_Label4( _this );
160 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
161 var child_1 = new Xcls_ticketsel( _this );
163 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
164 var child_2 = new Xcls_Label8( _this );
166 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
167 var child_3 = new Xcls_name( _this );
169 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
172 // user defined functions
174 public class Xcls_Label4 : Object
177 private NewBranch _this;
183 public Xcls_Label4(NewBranch _owner )
186 this.el = new Gtk.Label( "Select Ticket" );
190 // set gobject values
191 this.el.justify = Gtk.Justification.RIGHT;
192 this.el.xalign = 0.900000f;
193 this.el.visible = true;
196 // user defined functions
199 public class Xcls_ticketsel : Object
201 public Gtk.ComboBox el;
202 private NewBranch _this;
209 public Xcls_ticketsel(NewBranch _owner )
212 _this.ticketsel = this;
213 this.el = new Gtk.ComboBox();
216 this.loading = false;
218 // set gobject values
219 var child_0 = new Xcls_dbcellrenderer( _this );
221 this.el.pack_start ( child_0.el , true );
222 var child_1 = new Xcls_dbmodel( _this );
224 this.el.set_model ( child_1.el );
228 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
231 this.el.changed.connect( () => {
235 var ticket_id = this.selectedTicketId();
237 var name = RooTicket.singleton().usernameLocal();
239 if (ticket_id == "" || ticket_id == null) {
241 var dt = new DateTime.now_local();
242 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
247 var ticket = RooTicket.singleton().getById(ticket_id);
249 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
251 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
255 // user defined functions
256 public string selectedTicketId () {
261 this.el.get_active_iter (out iter);
262 _this.dbmodel.el.get_value (iter, 0, out val1);
265 return (string) val1;
272 public class Xcls_dbcellrenderer : Object
274 public Gtk.CellRendererText el;
275 private NewBranch _this;
281 public Xcls_dbcellrenderer(NewBranch _owner )
284 _this.dbcellrenderer = this;
285 this.el = new Gtk.CellRendererText();
289 // set gobject values
292 // user defined functions
295 public class Xcls_dbmodel : Object
297 public Gtk.ListStore el;
298 private NewBranch _this;
304 public Xcls_dbmodel(NewBranch _owner )
307 _this.dbmodel = this;
308 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
312 // set gobject values
315 // user defined functions
316 public void loadTickets () {
318 RooTicket.singleton().loadTickets();
320 _this.ticketsel.loading = true;
329 el.set_value(iter, 0, "");
330 el.set_value(iter, 1, "-- select a ticket --");
332 _this.ticketsel.el.set_active_iter(iter);
333 var tickets = RooTicket.singleton().tickets;
334 foreach(var ticket in tickets) {
338 el.set_value(iter, 0, ticket.id);
339 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
341 //if (data.get(i) == cur) {
342 // _this.build_module.el.set_active_iter(iter);
347 _this.ticketsel.loading = false;
348 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
354 public class Xcls_Label8 : Object
357 private NewBranch _this;
363 public Xcls_Label8(NewBranch _owner )
366 this.el = new Gtk.Label( "or use this as branch name" );
370 // set gobject values
371 this.el.justify = Gtk.Justification.RIGHT;
372 this.el.xalign = 0.900000f;
375 // user defined functions
378 public class Xcls_name : Object
381 private NewBranch _this;
387 public Xcls_name(NewBranch _owner )
391 this.el = new Gtk.Entry();
395 // set gobject values
396 this.el.visible = true;
399 // user defined functions
404 public class Xcls_Button10 : Object
406 public Gtk.Button el;
407 private NewBranch _this;
413 public Xcls_Button10(NewBranch _owner )
416 this.el = new Gtk.Button();
420 // set gobject values
421 this.el.relief = Gtk.ReliefStyle.NONE;
422 this.el.label = "Do not create Branch";
425 // user defined functions
428 public class Xcls_Button11 : Object
430 public Gtk.Button el;
431 private NewBranch _this;
437 public Xcls_Button11(NewBranch _owner )
440 this.el = new Gtk.Button();
444 // set gobject values
445 this.el.label = "Create Branch";
448 // user defined functions