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();
116 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
117 this.el.set_default_size( 500,200); // not sure why it grows..
118 GLib.debug("Loading tickets");
122 this.el.set_keep_above(true);
123 _this.prmodel.loadProjects();
124 _this.dbmodel.loadTickets();
128 public class Xcls_VBox2 : Object
131 private NewBranch _this;
137 public Xcls_VBox2(NewBranch _owner )
140 this.el = new Gtk.VBox( true, 0 );
144 // set gobject values
145 var child_0 = new Xcls_Table3( _this );
147 this.el.pack_start ( child_0.el , false,false,0 );
150 // user defined functions
152 public class Xcls_Table3 : Object
155 private NewBranch _this;
161 public Xcls_Table3(NewBranch _owner )
164 this.el = new Gtk.Table( 5, 5, true );
168 // set gobject values
169 this.el.expand = false;
171 this.el.column_spacing = 4;
172 this.el.vexpand = false;
173 var child_0 = new Xcls_Label4( _this );
175 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
176 var child_1 = new Xcls_Label5( _this );
178 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
179 var child_2 = new Xcls_projectsel( _this );
181 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
182 var child_3 = new Xcls_ticketsel( _this );
184 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
185 var child_4 = new Xcls_Button12( _this );
187 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
188 var child_5 = new Xcls_Label13( _this );
190 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
191 var child_6 = new Xcls_name( _this );
193 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
194 var child_7 = new Xcls_Button15( _this );
196 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
197 var child_8 = new Xcls_Box16( _this );
199 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
202 // user defined functions
204 public class Xcls_Label4 : Object
207 private NewBranch _this;
213 public Xcls_Label4(NewBranch _owner )
216 this.el = new Gtk.Label( "Project" );
220 // set gobject values
221 this.el.halign = Gtk.Align.START;
222 this.el.justify = Gtk.Justification.RIGHT;
223 this.el.visible = true;
226 // user defined functions
229 public class Xcls_Label5 : Object
232 private NewBranch _this;
238 public Xcls_Label5(NewBranch _owner )
241 this.el = new Gtk.Label( "Ticket" );
245 // set gobject values
246 this.el.halign = Gtk.Align.START;
247 this.el.visible = true;
250 // user defined functions
253 public class Xcls_projectsel : Object
255 public Gtk.ComboBox el;
256 private NewBranch _this;
263 public Xcls_projectsel(NewBranch _owner )
266 _this.projectsel = this;
267 this.el = new Gtk.ComboBox.with_entry();
270 this.loading = false;
272 // set gobject values
273 var child_0 = new Xcls_prcellrenderer( _this );
275 this.el.pack_start ( child_0.el , true );
276 var child_1 = new Xcls_prmodel( _this );
278 this.el.set_model ( child_1.el );
282 this.el.set_entry_text_column(1);
285 this.el.changed.connect( () => {
286 /*if (this.loading) {
289 var ticket_id = this.selectedTicketId();
291 var name = RooTicket.singleton().usernameLocal();
293 if (ticket_id == "" || ticket_id == null) {
295 var dt = new DateTime.now_local();
296 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
301 var ticket = RooTicket.singleton().getById(ticket_id);
303 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
305 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
310 // user defined functions
311 public string selectedTicketId () {
316 this.el.get_active_iter (out iter);
317 _this.dbmodel.el.get_value (iter, 0, out val1);
320 return (string) val1;
327 public class Xcls_prcellrenderer : Object
329 public Gtk.CellRendererText el;
330 private NewBranch _this;
336 public Xcls_prcellrenderer(NewBranch _owner )
339 _this.prcellrenderer = this;
340 this.el = new Gtk.CellRendererText();
344 // set gobject values
347 // user defined functions
350 public class Xcls_prmodel : Object
352 public Gtk.ListStore el;
353 private NewBranch _this;
359 public Xcls_prmodel(NewBranch _owner )
362 _this.prmodel = this;
363 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
367 // set gobject values
370 // user defined functions
371 public void loadProjects () {
373 var rt = RooTicket.singleton();
376 _this.projectsel.loading = true;
385 el.set_value(iter, 0, "");
386 el.set_value(iter, 1, "-- select a project --");
388 _this.projectsel.el.set_active_iter(iter);
389 var projects = rt.projects;
390 foreach(var project in projects) {
394 el.set_value(iter, 0, project.id);
395 el.set_value(iter, 1, project.name );
400 _this.projectsel.loading = false;
401 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
407 public class Xcls_ticketsel : Object
409 public Gtk.ComboBox el;
410 private NewBranch _this;
417 public Xcls_ticketsel(NewBranch _owner )
420 _this.ticketsel = this;
421 this.el = new Gtk.ComboBox.with_entry();
424 this.loading = false;
426 // set gobject values
427 var child_0 = new Xcls_dbcellrenderer( _this );
429 this.el.pack_start ( child_0.el , true );
430 var child_1 = new Xcls_dbmodel( _this );
432 this.el.set_model ( child_1.el );
436 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
437 this.el.set_entry_text_column(1);
440 this.el.changed.connect( () => {
444 var ticket_id = this.selectedTicketId();
446 var name = RooTicket.singleton().usernameLocal();
448 if (ticket_id == "" || ticket_id == null) {
450 var dt = new DateTime.now_local();
451 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
456 var ticket = RooTicket.singleton().getById(ticket_id);
458 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
460 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
464 // user defined functions
465 public string selectedTicketId () {
470 this.el.get_active_iter (out iter);
471 _this.dbmodel.el.get_value (iter, 0, out val1);
474 return (string) val1;
481 public class Xcls_dbcellrenderer : Object
483 public Gtk.CellRendererText el;
484 private NewBranch _this;
490 public Xcls_dbcellrenderer(NewBranch _owner )
493 _this.dbcellrenderer = this;
494 this.el = new Gtk.CellRendererText();
498 // set gobject values
501 // user defined functions
504 public class Xcls_dbmodel : Object
506 public Gtk.ListStore el;
507 private NewBranch _this;
513 public Xcls_dbmodel(NewBranch _owner )
516 _this.dbmodel = this;
517 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
521 // set gobject values
524 // user defined functions
525 public void loadTickets () {
527 RooTicket.singleton().loadTickets();
529 _this.ticketsel.loading = true;
538 el.set_value(iter, 0, "");
539 el.set_value(iter, 1, "-- select a ticket --");
541 _this.ticketsel.el.set_active_iter(iter);
542 var tickets = RooTicket.singleton().tickets;
543 foreach(var ticket in tickets) {
547 el.set_value(iter, 0, ticket.id);
548 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
550 //if (data.get(i) == cur) {
551 // _this.build_module.el.set_active_iter(iter);
556 _this.ticketsel.loading = false;
557 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
563 public class Xcls_Button12 : Object
565 public Gtk.Button el;
566 private NewBranch _this;
572 public Xcls_Button12(NewBranch _owner )
575 this.el = new Gtk.Button();
579 // set gobject values
580 this.el.expand = false;
581 this.el.label = "New Ticket";
584 // user defined functions
587 public class Xcls_Label13 : Object
590 private NewBranch _this;
596 public Xcls_Label13(NewBranch _owner )
599 this.el = new Gtk.Label( "Use this as branch name" );
603 // set gobject values
604 this.el.halign = Gtk.Align.START;
605 this.el.justify = Gtk.Justification.RIGHT;
606 this.el.xalign = 0.900000f;
609 // user defined functions
612 public class Xcls_name : Object
615 private NewBranch _this;
621 public Xcls_name(NewBranch _owner )
625 this.el = new Gtk.Entry();
629 // set gobject values
630 this.el.visible = true;
633 // user defined functions
636 public class Xcls_Button15 : Object
638 public Gtk.Button el;
639 private NewBranch _this;
645 public Xcls_Button15(NewBranch _owner )
648 this.el = new Gtk.Button();
652 // set gobject values
653 this.el.label = "Create Branch";
658 this.el.get_style_context().add_class("suggested-action");
662 this.el.activate.connect( () => {
663 _this.el.response(1);
667 // user defined functions
670 public class Xcls_Box16 : Object
673 private NewBranch _this;
679 public Xcls_Box16(NewBranch _owner )
682 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
686 // set gobject values
687 var child_0 = new Xcls_CheckButton17( _this );
689 this.el.add ( child_0.el );
690 var child_1 = new Xcls_CheckButton18( _this );
692 this.el.add ( child_1.el );
693 var child_2 = new Xcls_Label19( _this );
695 this.el.add ( child_2.el );
698 // user defined functions
700 public class Xcls_CheckButton17 : Object
702 public Gtk.CheckButton el;
703 private NewBranch _this;
709 public Xcls_CheckButton17(NewBranch _owner )
712 this.el = new Gtk.CheckButton();
716 // set gobject values
717 this.el.label = "Show tickets not assigned to me";
720 // user defined functions
723 public class Xcls_CheckButton18 : Object
725 public Gtk.CheckButton el;
726 private NewBranch _this;
732 public Xcls_CheckButton18(NewBranch _owner )
735 this.el = new Gtk.CheckButton();
739 // set gobject values
740 this.el.label = "Show closed Tickets";
743 // user defined functions
746 public class Xcls_Label19 : Object
749 private NewBranch _this;
755 public Xcls_Label19(NewBranch _owner )
758 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
762 // set gobject values
763 this.el.halign = Gtk.Align.END;
764 this.el.hexpand = true;
765 this.el.use_markup = true;
768 this.el.activate_link.connect( (uri) => {
769 if (uri == "refresh") {
770 _this.prmodel.loadProjects();
771 _this.dbmodel.loadTickets();
777 // user defined functions