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;
27 this.el = new Gtk.Dialog();
33 this.el.title = "Create a working branch ";
34 this.el.default_height = 200;
35 this.el.default_width = 500;
36 this.el.deletable = true;
38 var child_0 = new Xcls_VBox2( _this );
40 this.el.get_content_area().add ( child_0.el );
41 var child_1 = new Xcls_Button10( _this );
43 this.el.add_action_widget ( child_1.el , 0 );
44 var child_2 = new Xcls_Button11( _this );
46 this.el.add_action_widget ( child_2.el , 1 );
49 this.el.delete_event.connect( (self, event) => {
54 this.el.response.connect( (self, response_id) => {
56 GLib.debug("got %d", (int) response_id);
57 if (response_id == 0) {
61 // have they selected a ticket..
62 // make that the current active ticket?
63 // we really need to store locally what ticket is being worked on..
64 // in theory we could be working on multiple project and not merging..
65 // -- each repo would have their active ticket (only one per repo)
66 // -- so we could just store that in there
67 // -- initial load can check the contents of the ticket files on first scan.
68 var ticket_id = _this.ticketsel.selectedTicketId();
70 if (this.repo != null) {
71 var bn = _this.name.el.get_text();
72 if (ticket_id != "" ) {
73 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
75 this.repo.createBranchNamed(bn);
87 this.el.show.connect( (self) => {
94 // user defined functions
95 public void show ( GitRepo repo )
97 // this.el.set_gravity(Gdk.Gravity.NORTH);
101 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
102 GLib.debug("Loading tickets");
103 _this.dbmodel.loadTickets();
112 public class Xcls_VBox2 : Object
115 private NewBranch _this;
121 public Xcls_VBox2(NewBranch _owner )
124 this.el = new Gtk.VBox( true, 0 );
128 // set gobject values
129 var child_0 = new Xcls_Table3( _this );
131 this.el.pack_start ( child_0.el , false,false,0 );
134 // user defined functions
136 public class Xcls_Table3 : Object
139 private NewBranch _this;
145 public Xcls_Table3(NewBranch _owner )
148 this.el = new Gtk.Table( 2, 2, false );
152 // set gobject values
154 this.el.column_spacing = 2;
155 var child_0 = new Xcls_Label4( _this );
157 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
158 var child_1 = new Xcls_ticketsel( _this );
160 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
161 var child_2 = new Xcls_Label8( _this );
163 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
164 var child_3 = new Xcls_name( _this );
166 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
169 // user defined functions
171 public class Xcls_Label4 : Object
174 private NewBranch _this;
180 public Xcls_Label4(NewBranch _owner )
183 this.el = new Gtk.Label( "Select Ticket" );
187 // set gobject values
188 this.el.justify = Gtk.Justification.RIGHT;
189 this.el.xalign = 0.900000f;
190 this.el.visible = true;
193 // user defined functions
196 public class Xcls_ticketsel : Object
198 public Gtk.ComboBox el;
199 private NewBranch _this;
205 public Xcls_ticketsel(NewBranch _owner )
208 _this.ticketsel = this;
209 this.el = new Gtk.ComboBox();
213 // set gobject values
214 var child_0 = new Xcls_dbcellrenderer( _this );
216 this.el.pack_start ( child_0.el , true );
217 var child_1 = new Xcls_dbmodel( _this );
219 this.el.set_model ( child_1.el );
223 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
226 this.el.changed.connect( () => {
228 var ticket_id = this.selectedTicketId();
230 var name = RooTicket.singleton().usernameLocal();
232 if (ticket_id == "") {
234 var dt = new DateTime.now_local();
235 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
239 var ticket = RooTicket.singleton().getById(ticket_id);
241 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
243 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
247 // user defined functions
248 public string selectedTicketId () {
253 this.el.get_active_iter (out iter);
254 _this.dbmodel.el.get_value (iter, 0, out val1);
257 return (string) val1;
264 public class Xcls_dbcellrenderer : Object
266 public Gtk.CellRendererText el;
267 private NewBranch _this;
273 public Xcls_dbcellrenderer(NewBranch _owner )
276 _this.dbcellrenderer = this;
277 this.el = new Gtk.CellRendererText();
281 // set gobject values
284 // user defined functions
287 public class Xcls_dbmodel : Object
289 public Gtk.ListStore el;
290 private NewBranch _this;
296 public Xcls_dbmodel(NewBranch _owner )
299 _this.dbmodel = this;
300 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
304 // set gobject values
307 // user defined functions
308 public void loadTickets () {
310 RooTicket.singleton().loadTickets();
321 el.set_value(iter, 0, "");
322 el.set_value(iter, 1, "-- select a ticket --");
324 _this.ticketsel.el.set_active_iter(iter);
325 var tickets = RooTicket.singleton().tickets;
326 foreach(var ticket in tickets) {
331 el.set_value(iter, 0, ticket.id);
332 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
334 //if (data.get(i) == cur) {
335 // _this.build_module.el.set_active_iter(iter);
339 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
345 public class Xcls_Label8 : Object
348 private NewBranch _this;
354 public Xcls_Label8(NewBranch _owner )
357 this.el = new Gtk.Label( "or use this as branch name" );
361 // set gobject values
362 this.el.justify = Gtk.Justification.RIGHT;
363 this.el.xalign = 0.900000f;
366 // user defined functions
369 public class Xcls_name : Object
372 private NewBranch _this;
378 public Xcls_name(NewBranch _owner )
382 this.el = new Gtk.Entry();
386 // set gobject values
387 this.el.visible = true;
390 // user defined functions
395 public class Xcls_Button10 : Object
397 public Gtk.Button el;
398 private NewBranch _this;
404 public Xcls_Button10(NewBranch _owner )
407 this.el = new Gtk.Button();
411 // set gobject values
412 this.el.relief = Gtk.ReliefStyle.NONE;
413 this.el.label = "Do not create Branch";
416 // user defined functions
419 public class Xcls_Button11 : Object
421 public Gtk.Button el;
422 private NewBranch _this;
428 public Xcls_Button11(NewBranch _owner )
431 this.el = new Gtk.Button();
435 // set gobject values
436 this.el.label = "Create Branch";
439 // user defined functions