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;
22 public Xcls_scrolled_window scrolled_window;
23 public Xcls_view view;
27 public RooTicket? ticket;
34 this.el = new Gtk.Dialog();
41 this.el.title = "Merge Branch";
42 this.el.default_height = 200;
43 this.el.default_width = 500;
44 this.el.deletable = true;
46 var child_0 = new Xcls_Box2( _this );
48 this.el.get_content_area().add ( child_0.el );
49 var child_1 = new Xcls_Button16( _this );
51 this.el.add_action_widget ( child_1.el , 0 );
52 var child_2 = new Xcls_Button17( _this );
54 this.el.add_action_widget ( child_2.el , 1 );
57 this.el.delete_event.connect( (self, event) => {
62 this.el.response.connect( (self, response_id) => {
64 GLib.debug("got %d", (int) response_id);
65 if (response_id < 1) {
68 GitMonitor.gitmonitor.start();
72 // have they selected a ticket..
73 // make that the current active ticket?
74 // we really need to store locally what ticket is being worked on..
75 // in theory we could be working on multiple project and not merging..
76 // -- each repo would have their active ticket (only one per repo)
77 // -- so we could just store that in there
78 // -- initial load can check the contents of the ticket files on first scan.
79 var ticket_id = _this.ticketsel.selectedTicketId();
81 if (this.repo != null) {
82 var bn = _this.name.el.get_text();
83 if (ticket_id != "" ) {
84 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
86 this.repo.createBranchNamed(bn);
91 if (this.repo != null) {
93 _this.actionsel.selectedAction(),
94 _this.ticketsel.selectedTicketId(),
95 _this.name.el.get_text()
100 _this.actionsel.selectedAction(),
101 _this.ticketsel.selectedTicketId(),
102 _this.name.el.get_text()
105 this.running = false;
109 GitMonitor.gitmonitor.start();
113 this.el.show.connect( (self) => {
120 // user defined functions
121 public void show ( RooTicket ticket, GitRepo? repo )
123 // this.el.set_gravity(Gdk.Gravity.NORTH);
127 GitMonitor.gitmonitor.stop();
129 this.ticket = ticket;
132 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
133 GLib.debug("Loading tickets");
137 _this.dbmodel.loadTickets();
138 _this.actionmodel.loadActions();
139 _this.view.loadTicket(ticket.id);
142 public class Xcls_Box2 : Object
145 private MergeBranch _this;
151 public Xcls_Box2(MergeBranch _owner )
154 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
158 // set gobject values
159 var child_0 = new Xcls_Table3( _this );
161 this.el.pack_start ( child_0.el , false,false,0 );
162 var child_1 = new Xcls_scrolled_window( _this );
164 this.el.add ( child_1.el );
167 // user defined functions
169 public class Xcls_Table3 : Object
172 private MergeBranch _this;
178 public Xcls_Table3(MergeBranch _owner )
181 this.el = new Gtk.Table( 2, 2, false );
185 // set gobject values
187 this.el.column_spacing = 2;
188 this.el.vexpand = false;
189 var child_0 = new Xcls_Label4( _this );
191 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
192 var child_1 = new Xcls_actionsel( _this );
194 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
195 var child_2 = new Xcls_Label8( _this );
197 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
198 var child_3 = new Xcls_ticketsel( _this );
200 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
201 var child_4 = new Xcls_Label12( _this );
203 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
204 var child_5 = new Xcls_name( _this );
206 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
209 // user defined functions
211 public class Xcls_Label4 : Object
214 private MergeBranch _this;
220 public Xcls_Label4(MergeBranch _owner )
223 this.el = new Gtk.Label( "Do what?" );
227 // set gobject values
228 this.el.justify = Gtk.Justification.RIGHT;
229 this.el.xalign = 0.900000f;
230 this.el.visible = true;
233 // user defined functions
236 public class Xcls_actionsel : Object
238 public Gtk.ComboBox el;
239 private MergeBranch _this;
246 public Xcls_actionsel(MergeBranch _owner )
249 _this.actionsel = this;
250 this.el = new Gtk.ComboBox();
253 this.loading = false;
255 // set gobject values
256 var child_0 = new Xcls_actioncellrenderer( _this );
258 this.el.pack_start ( child_0.el , true );
259 var child_1 = new Xcls_actionmodel( _this );
261 this.el.set_model ( child_1.el );
265 this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
268 this.el.changed.connect( () => {
272 _this.name.updateText();
273 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
277 // user defined functions
278 public string selectedAction () {
282 this.el.get_active_iter (out iter);
283 _this.actionmodel.el.get_value (iter, 0, out val1);
285 return (string) val1;
288 public class Xcls_actioncellrenderer : Object
290 public Gtk.CellRendererText el;
291 private MergeBranch _this;
297 public Xcls_actioncellrenderer(MergeBranch _owner )
300 _this.actioncellrenderer = this;
301 this.el = new Gtk.CellRendererText();
305 // set gobject values
308 // user defined functions
311 public class Xcls_actionmodel : Object
313 public Gtk.ListStore el;
314 private MergeBranch _this;
320 public Xcls_actionmodel(MergeBranch _owner )
323 _this.actionmodel = this;
324 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
328 // set gobject values
331 // user defined functions
332 public void loadActions () {
336 _this.actionsel.loading = true;
345 el.set_value(iter, 0, "");
346 el.set_value(iter, 1, "-- select action --");
348 _this.actionsel.el.set_active_iter(iter);
351 el.set_value(iter, 0, "CLOSE");
352 el.set_value(iter, 1, "Merge changes to master - and CLOSE ticket");
356 el.set_value(iter, 0, "LEAVE");
357 el.set_value(iter, 1, "Merge changes to master - and LEAVE ticket open");
360 el.set_value(iter, 0, "MASTER");
361 el.set_value(iter, 1, "Merge changes FROM master into this branch");
364 el.set_value(iter, 0, "EXIT");
365 el.set_value(iter, 1, "Switch back to MASTER branch - no merge");
369 _this.actionsel.loading = false;
370 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
376 public class Xcls_Label8 : Object
379 private MergeBranch _this;
385 public Xcls_Label8(MergeBranch _owner )
388 this.el = new Gtk.Label( "Select Ticket" );
392 // set gobject values
393 this.el.justify = Gtk.Justification.RIGHT;
394 this.el.xalign = 0.900000f;
395 this.el.visible = true;
398 // user defined functions
401 public class Xcls_ticketsel : Object
403 public Gtk.ComboBox el;
404 private MergeBranch _this;
411 public Xcls_ticketsel(MergeBranch _owner )
414 _this.ticketsel = this;
415 this.el = new Gtk.ComboBox();
420 // set gobject values
421 var child_0 = new Xcls_dbcellrenderer( _this );
423 this.el.pack_start ( child_0.el , true );
424 var child_1 = new Xcls_dbmodel( _this );
426 this.el.set_model ( child_1.el );
430 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
433 this.el.changed.connect( () => {
437 _this.view.loadTicket(this.selectedTicketId());
439 _this.name.updateText();
440 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
442 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
446 // user defined functions
447 public string selectedTicketId () {
452 this.el.get_active_iter (out iter);
453 _this.dbmodel.el.get_value (iter, 0, out val1);
456 return (string) val1;
463 public class Xcls_dbcellrenderer : Object
465 public Gtk.CellRendererText el;
466 private MergeBranch _this;
472 public Xcls_dbcellrenderer(MergeBranch _owner )
475 _this.dbcellrenderer = this;
476 this.el = new Gtk.CellRendererText();
480 // set gobject values
483 // user defined functions
486 public class Xcls_dbmodel : Object
488 public Gtk.ListStore el;
489 private MergeBranch _this;
495 public Xcls_dbmodel(MergeBranch _owner )
498 _this.dbmodel = this;
499 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
503 // set gobject values
506 // user defined functions
507 public void loadTickets () {
509 RooTicket.singleton().loadTickets("",RooTicket.Who.ME, RooTicket.Status.ACTIVE);
511 _this.ticketsel.loading = true;
518 el.set_value(iter, 0, "");
519 el.set_value(iter, 1, "-- select a ticket --");
521 _this.ticketsel.el.set_active_iter(iter);
523 if (_this.ticket != null && _this.ticket.id == "-1") {
525 el.set_value(iter, 0, "-1");
526 el.set_value(iter, 1, "Temporary Branch - No ticket specified/relivant");
527 _this.ticketsel.el.set_active_iter(iter);
533 var tickets = RooTicket.singleton().tickets;
534 foreach(var ticket in tickets) {
538 el.set_value(iter, 0, ticket.id);
539 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
540 if (_this.ticket != null && _this.ticket.id == ticket.id) {
541 _this.ticketsel.el.set_active_iter(iter);
546 _this.ticketsel.loading = false;
547 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
553 public class Xcls_Label12 : Object
556 private MergeBranch _this;
562 public Xcls_Label12(MergeBranch _owner )
565 this.el = new Gtk.Label( "Use this commit message" );
569 // set gobject values
570 this.el.justify = Gtk.Justification.RIGHT;
571 this.el.xalign = 0.900000f;
574 // user defined functions
577 public class Xcls_name : Object
580 private MergeBranch _this;
586 public Xcls_name(MergeBranch _owner )
590 this.el = new Gtk.Entry();
594 // set gobject values
595 this.el.visible = true;
598 // user defined functions
599 public void updateText () {
600 var ticket_id = _this.ticketsel.selectedTicketId();
602 RooTicket ticket = null;
603 if (ticket_id.length > 0){
604 ticket = RooTicket.singleton().getById(ticket_id);
607 var name = RooTicket.singleton().usernameLocal();
608 var action = _this.actionsel.selectedAction();
609 this.el.set_editable(true);
611 case "CLOSE": // merge changes and close..
612 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
614 case "LEAVE": // partial fix
615 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
617 case "MASTER": // merge master
618 case "EXIT": // just switch back...
619 this.el.set_editable(false);
620 this.el.set_text(""); // not relivant..
624 break; /// don't fix the text value.
631 public class Xcls_scrolled_window : Object
633 public Gtk.ScrolledWindow el;
634 private MergeBranch _this;
640 public Xcls_scrolled_window(MergeBranch _owner )
643 _this.scrolled_window = this;
644 this.el = new Gtk.ScrolledWindow( null, null );
648 // set gobject values
649 this.el.height_request = 500;
650 this.el.vexpand = true;
651 var child_0 = new Xcls_view( _this );
653 this.el.add ( child_0.el );
658 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
662 // user defined functions
664 public class Xcls_view : Object
666 public WebKit.WebView el;
667 private MergeBranch _this;
673 public Xcls_view(MergeBranch _owner )
677 this.el = new WebKit.WebView();
681 // set gobject values
684 // user defined functions
685 public void loadTicket (string tid) {
687 _this.el.get_size(out w, out h);
690 _this.scrolled_window.el.hide();
691 _this.el.resize(w, 150);
693 _this.scrolled_window.el.show();
694 _this.el.resize(w, 800);
697 var rs = RooTicket.singleton();
698 var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid);
699 var hd = uri.get_http_headers();
700 var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
701 hd.append("Authorization", "Basic %s".printf(authCode));
703 this.el.load_request(uri);
709 public class Xcls_Button16 : Object
711 public Gtk.Button el;
712 private MergeBranch _this;
718 public Xcls_Button16(MergeBranch _owner )
721 this.el = new Gtk.Button();
725 // set gobject values
726 this.el.relief = Gtk.ReliefStyle.NONE;
727 this.el.label = "Cancel";
730 // user defined functions
733 public class Xcls_Button17 : Object
735 public Gtk.Button el;
736 private MergeBranch _this;
742 public Xcls_Button17(MergeBranch _owner )
745 this.el = new Gtk.Button();
749 // set gobject values
750 this.el.label = "Do Merge";
753 // user defined functions