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_projectsel projectsel;
16 public Xcls_prcellrenderer prcellrenderer;
17 public Xcls_prmodel prmodel;
18 public Xcls_ticketsel ticketsel;
19 public Xcls_dbcellrenderer dbcellrenderer;
20 public Xcls_dbmodel dbmodel;
21 public Xcls_name name;
26 public Gee.ArrayList<GitMonitorQueue> queue;
32 this.el = new Gtk.Dialog();
40 this.el.title = "Create a working branch ";
41 this.el.default_height = 200;
42 this.el.default_width = 500;
43 this.el.deletable = true;
45 var child_0 = new Xcls_VBox2( _this );
47 this.el.get_content_area().add ( child_0.el );
50 this.el.delete_event.connect( (self, event) => {
55 this.el.response.connect( (self, response_id) => {
57 GLib.debug("got %d", (int) response_id);
58 if (response_id < 1) {
64 // have they selected a ticket..
65 // make that the current active ticket?
66 // we really need to store locally what ticket is being worked on..
67 // in theory we could be working on multiple project and not merging..
68 // -- each repo would have their active ticket (only one per repo)
69 // -- so we could just store that in there
70 // -- initial load can check the contents of the ticket files on first scan.
71 var ticket_id = _this.ticketsel.selectedTicketId();
73 if (this.repo != null) {
74 var bn = _this.name.el.get_text();
76 var res = this.repo.setActiveTicket(
77 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
80 // start the monitoring..
81 GitMonitor.gitmonitor.start();
95 this.el.show.connect( (self) => {
102 // user defined functions
103 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
105 // this.el.set_gravity(Gdk.Gravity.NORTH);
106 if (this.running) { // should not happen!!
107 GLib.error("new branch show called, when already being displayed?");
112 GitMonitor.gitmonitor.stop();
119 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
120 this.el.set_default_size( 500,200); // not sure why it grows..
121 GLib.debug("Loading tickets");
125 this.el.set_keep_above(true);
126 _this.prmodel.loadProjects();
128 var curproj = GitTicket.singleton().getProjectByRepo(repo);
129 if (curproject != null) {
130 // _this.projectsel.selectProject(curproject);
133 _this.dbmodel.loadTickets();
137 public class Xcls_VBox2 : Object
140 private NewBranch _this;
146 public Xcls_VBox2(NewBranch _owner )
149 this.el = new Gtk.VBox( true, 0 );
153 // set gobject values
154 var child_0 = new Xcls_Table3( _this );
156 this.el.pack_start ( child_0.el , false,false,0 );
159 // user defined functions
161 public class Xcls_Table3 : Object
164 private NewBranch _this;
170 public Xcls_Table3(NewBranch _owner )
173 this.el = new Gtk.Table( 5, 5, true );
177 // set gobject values
178 this.el.expand = false;
180 this.el.column_spacing = 4;
181 this.el.vexpand = false;
182 var child_0 = new Xcls_Label4( _this );
184 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
185 var child_1 = new Xcls_Label5( _this );
187 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
188 var child_2 = new Xcls_projectsel( _this );
190 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
191 var child_3 = new Xcls_ticketsel( _this );
193 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
194 var child_4 = new Xcls_Button12( _this );
196 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
197 var child_5 = new Xcls_Label13( _this );
199 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
200 var child_6 = new Xcls_name( _this );
202 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
203 var child_7 = new Xcls_Button15( _this );
205 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
206 var child_8 = new Xcls_Box16( _this );
208 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
211 // user defined functions
213 public class Xcls_Label4 : Object
216 private NewBranch _this;
222 public Xcls_Label4(NewBranch _owner )
225 this.el = new Gtk.Label( "Project" );
229 // set gobject values
230 this.el.halign = Gtk.Align.START;
231 this.el.justify = Gtk.Justification.RIGHT;
232 this.el.visible = true;
235 // user defined functions
238 public class Xcls_Label5 : Object
241 private NewBranch _this;
247 public Xcls_Label5(NewBranch _owner )
250 this.el = new Gtk.Label( "Ticket" );
254 // set gobject values
255 this.el.halign = Gtk.Align.START;
256 this.el.visible = true;
259 // user defined functions
262 public class Xcls_projectsel : Object
264 public Gtk.ComboBox el;
265 private NewBranch _this;
272 public Xcls_projectsel(NewBranch _owner )
275 _this.projectsel = this;
276 this.el = new Gtk.ComboBox.with_entry();
279 this.loading = false;
281 // set gobject values
282 var child_0 = new Xcls_prcellrenderer( _this );
284 this.el.pack_start ( child_0.el , true );
285 var child_1 = new Xcls_prmodel( _this );
287 this.el.set_model ( child_1.el );
291 this.el.set_entry_text_column(1);
294 this.el.changed.connect( () => {
295 /*if (this.loading) {
298 var ticket_id = this.selectedTicketId();
300 var name = RooTicket.singleton().usernameLocal();
302 if (ticket_id == "" || ticket_id == null) {
304 var dt = new DateTime.now_local();
305 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
310 var ticket = RooTicket.singleton().getById(ticket_id);
312 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
314 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
319 // user defined functions
320 public string selectedTicketId () {
325 this.el.get_active_iter (out iter);
326 _this.dbmodel.el.get_value (iter, 0, out val1);
329 return (string) val1;
336 public class Xcls_prcellrenderer : Object
338 public Gtk.CellRendererText el;
339 private NewBranch _this;
345 public Xcls_prcellrenderer(NewBranch _owner )
348 _this.prcellrenderer = this;
349 this.el = new Gtk.CellRendererText();
353 // set gobject values
356 // user defined functions
359 public class Xcls_prmodel : Object
361 public Gtk.ListStore el;
362 private NewBranch _this;
368 public Xcls_prmodel(NewBranch _owner )
371 _this.prmodel = this;
372 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
376 // set gobject values
379 // user defined functions
380 public void loadProjects () {
382 var rt = RooTicket.singleton();
385 _this.projectsel.loading = true;
394 el.set_value(iter, 0, "");
395 el.set_value(iter, 1, "-- select a project --");
397 _this.projectsel.el.set_active_iter(iter);
398 var projects = rt.projects;
399 foreach(var project in projects) {
403 el.set_value(iter, 0, project.id);
404 el.set_value(iter, 1, project.name );
409 _this.projectsel.loading = false;
410 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
416 public class Xcls_ticketsel : Object
418 public Gtk.ComboBox el;
419 private NewBranch _this;
426 public Xcls_ticketsel(NewBranch _owner )
429 _this.ticketsel = this;
430 this.el = new Gtk.ComboBox.with_entry();
433 this.loading = false;
435 // set gobject values
436 var child_0 = new Xcls_dbcellrenderer( _this );
438 this.el.pack_start ( child_0.el , true );
439 var child_1 = new Xcls_dbmodel( _this );
441 this.el.set_model ( child_1.el );
445 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
446 this.el.set_entry_text_column(1);
449 this.el.changed.connect( () => {
453 var ticket_id = this.selectedTicketId();
455 var name = RooTicket.singleton().usernameLocal();
457 if (ticket_id == "" || ticket_id == null) {
459 var dt = new DateTime.now_local();
460 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
465 var ticket = RooTicket.singleton().getById(ticket_id);
467 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
469 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
473 // user defined functions
474 public string selectedTicketId () {
479 this.el.get_active_iter (out iter);
480 _this.dbmodel.el.get_value (iter, 0, out val1);
483 return (string) val1;
490 public class Xcls_dbcellrenderer : Object
492 public Gtk.CellRendererText el;
493 private NewBranch _this;
499 public Xcls_dbcellrenderer(NewBranch _owner )
502 _this.dbcellrenderer = this;
503 this.el = new Gtk.CellRendererText();
507 // set gobject values
510 // user defined functions
513 public class Xcls_dbmodel : Object
515 public Gtk.ListStore el;
516 private NewBranch _this;
522 public Xcls_dbmodel(NewBranch _owner )
525 _this.dbmodel = this;
526 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
530 // set gobject values
533 // user defined functions
534 public void loadTickets () {
536 RooTicket.singleton().loadTickets();
538 _this.ticketsel.loading = true;
547 el.set_value(iter, 0, "");
548 el.set_value(iter, 1, "-- select a ticket --");
550 _this.ticketsel.el.set_active_iter(iter);
551 var tickets = RooTicket.singleton().tickets;
552 foreach(var ticket in tickets) {
556 el.set_value(iter, 0, ticket.id);
557 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
559 //if (data.get(i) == cur) {
560 // _this.build_module.el.set_active_iter(iter);
565 _this.ticketsel.loading = false;
566 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
572 public class Xcls_Button12 : Object
574 public Gtk.Button el;
575 private NewBranch _this;
581 public Xcls_Button12(NewBranch _owner )
584 this.el = new Gtk.Button();
588 // set gobject values
589 this.el.expand = false;
590 this.el.label = "New Ticket";
593 // user defined functions
596 public class Xcls_Label13 : Object
599 private NewBranch _this;
605 public Xcls_Label13(NewBranch _owner )
608 this.el = new Gtk.Label( "Use this as branch name" );
612 // set gobject values
613 this.el.halign = Gtk.Align.START;
614 this.el.justify = Gtk.Justification.RIGHT;
615 this.el.xalign = 0.900000f;
618 // user defined functions
621 public class Xcls_name : Object
624 private NewBranch _this;
630 public Xcls_name(NewBranch _owner )
634 this.el = new Gtk.Entry();
638 // set gobject values
639 this.el.visible = true;
642 // user defined functions
645 public class Xcls_Button15 : Object
647 public Gtk.Button el;
648 private NewBranch _this;
654 public Xcls_Button15(NewBranch _owner )
657 this.el = new Gtk.Button();
661 // set gobject values
662 this.el.label = "Create Branch";
667 this.el.get_style_context().add_class("suggested-action");
671 this.el.activate.connect( () => {
672 _this.el.response(1);
676 // user defined functions
679 public class Xcls_Box16 : Object
682 private NewBranch _this;
688 public Xcls_Box16(NewBranch _owner )
691 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
695 // set gobject values
696 var child_0 = new Xcls_CheckButton17( _this );
698 this.el.add ( child_0.el );
699 var child_1 = new Xcls_CheckButton18( _this );
701 this.el.add ( child_1.el );
702 var child_2 = new Xcls_Label19( _this );
704 this.el.add ( child_2.el );
707 // user defined functions
709 public class Xcls_CheckButton17 : Object
711 public Gtk.CheckButton el;
712 private NewBranch _this;
718 public Xcls_CheckButton17(NewBranch _owner )
721 this.el = new Gtk.CheckButton();
725 // set gobject values
726 this.el.label = "Show tickets not assigned to me";
729 // user defined functions
732 public class Xcls_CheckButton18 : Object
734 public Gtk.CheckButton el;
735 private NewBranch _this;
741 public Xcls_CheckButton18(NewBranch _owner )
744 this.el = new Gtk.CheckButton();
748 // set gobject values
749 this.el.label = "Show closed Tickets";
752 // user defined functions
755 public class Xcls_Label19 : Object
758 private NewBranch _this;
764 public Xcls_Label19(NewBranch _owner )
767 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
771 // set gobject values
772 this.el.halign = Gtk.Align.END;
773 this.el.hexpand = true;
774 this.el.use_markup = true;
777 this.el.activate_link.connect( (uri) => {
778 if (uri == "refresh") {
779 _this.prmodel.loadProjects();
780 _this.dbmodel.loadTickets();
786 // user defined functions