1 static MergeBranch _MergeBranch;
3 public class MergeBranch : Object
6 private MergeBranch _this;
8 public static MergeBranch singleton()
10 if (_MergeBranch == null) {
11 _MergeBranch= new MergeBranch();
15 public Xcls_actionsel actionsel;
16 public Xcls_actioncellrenderer actioncellrenderer;
17 public Xcls_actionmodel actionmodel;
18 public Xcls_ticketsel ticketsel;
19 public Xcls_dbcellrenderer dbcellrenderer;
20 public Xcls_dbmodel dbmodel;
21 public Xcls_name name;
25 public RooTicket? ticket;
32 this.el = new Gtk.Dialog();
39 this.el.title = "Merge Branch";
40 this.el.default_height = 200;
41 this.el.default_width = 500;
42 this.el.deletable = true;
44 var child_0 = new Xcls_VBox2( _this );
46 this.el.get_content_area().add ( child_0.el );
47 var child_1 = new Xcls_Button14( _this );
49 this.el.add_action_widget ( child_1.el , 0 );
50 var child_2 = new Xcls_Button15( _this );
52 this.el.add_action_widget ( child_2.el , 1 );
55 this.el.delete_event.connect( (self, event) => {
60 this.el.response.connect( (self, response_id) => {
62 GLib.debug("got %d", (int) response_id);
63 if (response_id == 0) {
66 GitMonitor.gitmonitor.start();
70 // have they selected a ticket..
71 // make that the current active ticket?
72 // we really need to store locally what ticket is being worked on..
73 // in theory we could be working on multiple project and not merging..
74 // -- each repo would have their active ticket (only one per repo)
75 // -- so we could just store that in there
76 // -- initial load can check the contents of the ticket files on first scan.
77 var ticket_id = _this.ticketsel.selectedTicketId();
79 if (this.repo != null) {
80 var bn = _this.name.el.get_text();
81 if (ticket_id != "" ) {
82 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
84 this.repo.createBranchNamed(bn);
89 if (this.repo != null) {
91 _this.actionsel.selectedAction(),
92 _this.ticketsel.selectedTicketId(),
93 _this.name.el.get_text()
98 _this.actionsel.selectedAction(),
99 _this.ticketsel.selectedTicketId(),
100 _this.name.el.get_text()
103 this.running = false;
107 GitMonitor.gitmonitor.start();
111 this.el.show.connect( (self) => {
118 // user defined functions
119 public void show ( RooTicket ticket, GitRepo? repo )
121 // this.el.set_gravity(Gdk.Gravity.NORTH);
125 GitMonitor.gitmonitor.stop();
127 this.ticket = ticket;
130 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
131 GLib.debug("Loading tickets");
135 _this.dbmodel.loadTickets();
136 _this.actionmodel.loadActions();
140 public class Xcls_VBox2 : Object
143 private MergeBranch _this;
149 public Xcls_VBox2(MergeBranch _owner )
152 this.el = new Gtk.VBox( true, 0 );
156 // set gobject values
157 var child_0 = new Xcls_Table3( _this );
159 this.el.pack_start ( child_0.el , false,false,0 );
162 // user defined functions
164 public class Xcls_Table3 : Object
167 private MergeBranch _this;
173 public Xcls_Table3(MergeBranch _owner )
176 this.el = new Gtk.Table( 2, 2, false );
180 // set gobject values
182 this.el.column_spacing = 2;
183 var child_0 = new Xcls_Label4( _this );
185 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
186 var child_1 = new Xcls_actionsel( _this );
188 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
189 var child_2 = new Xcls_Label8( _this );
191 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
192 var child_3 = new Xcls_ticketsel( _this );
194 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
195 var child_4 = new Xcls_Label12( _this );
197 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
198 var child_5 = new Xcls_name( _this );
200 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
203 // user defined functions
205 public class Xcls_Label4 : Object
208 private MergeBranch _this;
214 public Xcls_Label4(MergeBranch _owner )
217 this.el = new Gtk.Label( "Do what?" );
221 // set gobject values
222 this.el.justify = Gtk.Justification.RIGHT;
223 this.el.xalign = 0.900000f;
224 this.el.visible = true;
227 // user defined functions
230 public class Xcls_actionsel : Object
232 public Gtk.ComboBox el;
233 private MergeBranch _this;
240 public Xcls_actionsel(MergeBranch _owner )
243 _this.actionsel = this;
244 this.el = new Gtk.ComboBox();
247 this.loading = false;
249 // set gobject values
250 var child_0 = new Xcls_actioncellrenderer( _this );
252 this.el.pack_start ( child_0.el , true );
253 var child_1 = new Xcls_actionmodel( _this );
255 this.el.set_model ( child_1.el );
259 this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
262 this.el.changed.connect( () => {
266 _this.name.updateText();
267 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
271 // user defined functions
272 public string selectedAction () {
276 this.el.get_active_iter (out iter);
277 _this.actionmodel.el.get_value (iter, 0, out val1);
279 return (string) val1;
282 public class Xcls_actioncellrenderer : Object
284 public Gtk.CellRendererText el;
285 private MergeBranch _this;
291 public Xcls_actioncellrenderer(MergeBranch _owner )
294 _this.actioncellrenderer = this;
295 this.el = new Gtk.CellRendererText();
299 // set gobject values
302 // user defined functions
305 public class Xcls_actionmodel : Object
307 public Gtk.ListStore el;
308 private MergeBranch _this;
314 public Xcls_actionmodel(MergeBranch _owner )
317 _this.actionmodel = this;
318 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
322 // set gobject values
325 // user defined functions
326 public void loadActions () {
330 _this.actionsel.loading = true;
339 el.set_value(iter, 0, "");
340 el.set_value(iter, 1, "-- select action --");
342 _this.actionsel.el.set_active_iter(iter);
345 el.set_value(iter, 0, "CLOSE");
346 el.set_value(iter, 1, "Merge changes to master - and CLOSE ticket");
350 el.set_value(iter, 0, "LEAVE");
351 el.set_value(iter, 1, "Merge changes to master - and LEAVE ticket open");
354 el.set_value(iter, 0, "MASTER");
355 el.set_value(iter, 1, "Merge changes FROM master into this branch");
358 el.set_value(iter, 0, "EXIT");
359 el.set_value(iter, 1, "Switch back to MASTER branch - no merge");
363 _this.actionsel.loading = false;
364 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
370 public class Xcls_Label8 : Object
373 private MergeBranch _this;
379 public Xcls_Label8(MergeBranch _owner )
382 this.el = new Gtk.Label( "Select Ticket" );
386 // set gobject values
387 this.el.justify = Gtk.Justification.RIGHT;
388 this.el.xalign = 0.900000f;
389 this.el.visible = true;
392 // user defined functions
395 public class Xcls_ticketsel : Object
397 public Gtk.ComboBox el;
398 private MergeBranch _this;
405 public Xcls_ticketsel(MergeBranch _owner )
408 _this.ticketsel = this;
409 this.el = new Gtk.ComboBox();
412 this.loading = false;
414 // set gobject values
415 var child_0 = new Xcls_dbcellrenderer( _this );
417 this.el.pack_start ( child_0.el , true );
418 var child_1 = new Xcls_dbmodel( _this );
420 this.el.set_model ( child_1.el );
424 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
427 this.el.changed.connect( () => {
433 _this.name.updateText();
434 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
436 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
440 // user defined functions
441 public string selectedTicketId () {
446 this.el.get_active_iter (out iter);
447 _this.dbmodel.el.get_value (iter, 0, out val1);
450 return (string) val1;
457 public class Xcls_dbcellrenderer : Object
459 public Gtk.CellRendererText el;
460 private MergeBranch _this;
466 public Xcls_dbcellrenderer(MergeBranch _owner )
469 _this.dbcellrenderer = this;
470 this.el = new Gtk.CellRendererText();
474 // set gobject values
477 // user defined functions
480 public class Xcls_dbmodel : Object
482 public Gtk.ListStore el;
483 private MergeBranch _this;
489 public Xcls_dbmodel(MergeBranch _owner )
492 _this.dbmodel = this;
493 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
497 // set gobject values
500 // user defined functions
501 public void loadTickets () {
503 RooTicket.singleton().loadTickets("",RooTicket.Who.ME, RooTicket.Status.ACTIVE);
505 _this.ticketsel.loading = true;
512 el.set_value(iter, 0, "");
513 el.set_value(iter, 1, "-- select a ticket --");
515 _this.ticketsel.el.set_active_iter(iter);
517 if (_this.ticket != null && _this.ticket.id == "-1") {
519 el.set_value(iter, 0, "-1");
520 el.set_value(iter, 1, "Temporary Branch - No ticket specified/relivant");
521 _this.ticketsel.el.set_active_iter(iter);
527 var tickets = RooTicket.singleton().tickets;
528 foreach(var ticket in tickets) {
532 el.set_value(iter, 0, ticket.id);
533 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
534 if (_this.ticket != null && _this.ticket.id == ticket.id) {
535 _this.ticketsel.el.set_active_iter(iter);
540 _this.ticketsel.loading = false;
541 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
547 public class Xcls_Label12 : Object
550 private MergeBranch _this;
556 public Xcls_Label12(MergeBranch _owner )
559 this.el = new Gtk.Label( "Use this commit message" );
563 // set gobject values
564 this.el.justify = Gtk.Justification.RIGHT;
565 this.el.xalign = 0.900000f;
568 // user defined functions
571 public class Xcls_name : Object
574 private MergeBranch _this;
580 public Xcls_name(MergeBranch _owner )
584 this.el = new Gtk.Entry();
588 // set gobject values
589 this.el.visible = true;
592 // user defined functions
593 public void updateText () {
594 var ticket_id = _this.ticketsel.selectedTicketId();
596 RooTicket ticket = null;
597 if (ticket_id.length > 0){
598 ticket = RooTicket.singleton().getById(ticket_id);
601 var name = RooTicket.singleton().usernameLocal();
602 var action = _this.actionsel.selectedAction();
603 this.el.set_editable(true);
605 case "CLOSE": // merge changes and close..
606 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
608 case "LEAVE": // partial fix
609 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
611 case "MASTER": // merge master
612 case "EXIT": // just switch back...
613 this.el.set_editable(false);
614 this.el.set_text(""); // not relivant..
618 break; /// don't fix the text value.
626 public class Xcls_Button14 : Object
628 public Gtk.Button el;
629 private MergeBranch _this;
635 public Xcls_Button14(MergeBranch _owner )
638 this.el = new Gtk.Button();
642 // set gobject values
643 this.el.relief = Gtk.ReliefStyle.NONE;
644 this.el.label = "Cancel";
647 // user defined functions
650 public class Xcls_Button15 : Object
652 public Gtk.Button el;
653 private MergeBranch _this;
659 public Xcls_Button15(MergeBranch _owner )
662 this.el = new Gtk.Button();
666 // set gobject values
667 this.el.label = "Do Merge";
670 // user defined functions