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_build_module build_module;
16 public Xcls_dbcellrenderer dbcellrenderer;
17 public Xcls_dbmodel dbmodel;
18 public Xcls_name name;
26 this.el = new Gtk.Dialog();
31 this.el.title = "Create a working branch ";
32 this.el.default_height = 200;
33 this.el.default_width = 500;
34 this.el.deletable = true;
36 var child_0 = new Xcls_VBox2( _this );
38 this.el.get_content_area().add ( child_0.el );
39 var child_1 = new Xcls_Button10( _this );
41 this.el.add_action_widget ( child_1.el , 0 );
42 var child_2 = new Xcls_Button11( _this );
44 this.el.add_action_widget ( child_2.el , 1 );
47 this.el.delete_event.connect( (self, event) => {
52 this.el.response.connect( (self, response_id) => {
54 GLib.debug("got %d", (int) response_id);
55 if (response_id == 0) {
59 // have they selected a ticket..
60 // make that the current active ticket?
61 // we really need to store locally what ticket is being worked on..
62 // in theory we could be working on multiple project and not merging..
63 // -- each repo would have their active ticket (only one per repo)
64 // -- so we could just store that in there
65 // -- initial load can check the contents of the ticket files on first scan.
75 this.el.show.connect( (self) => {
82 // user defined functions
85 // this.el.set_gravity(Gdk.Gravity.NORTH);
87 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
88 GLib.debug("Loading tickets");
89 _this.dbmodel.loadTickets();
98 public class Xcls_VBox2 : Object
101 private NewBranch _this;
107 public Xcls_VBox2(NewBranch _owner )
110 this.el = new Gtk.VBox( true, 0 );
114 // set gobject values
115 var child_0 = new Xcls_Table3( _this );
117 this.el.pack_start ( child_0.el , false,false,0 );
120 // user defined functions
122 public class Xcls_Table3 : Object
125 private NewBranch _this;
131 public Xcls_Table3(NewBranch _owner )
134 this.el = new Gtk.Table( 2, 2, false );
138 // set gobject values
140 this.el.column_spacing = 2;
141 var child_0 = new Xcls_Label4( _this );
143 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
144 var child_1 = new Xcls_build_module( _this );
146 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
147 var child_2 = new Xcls_Label8( _this );
149 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
150 var child_3 = new Xcls_name( _this );
152 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
155 // user defined functions
157 public class Xcls_Label4 : Object
160 private NewBranch _this;
166 public Xcls_Label4(NewBranch _owner )
169 this.el = new Gtk.Label( "Select Ticket" );
173 // set gobject values
174 this.el.justify = Gtk.Justification.RIGHT;
175 this.el.xalign = 0.900000f;
176 this.el.visible = true;
179 // user defined functions
182 public class Xcls_build_module : Object
184 public Gtk.ComboBox el;
185 private NewBranch _this;
191 public Xcls_build_module(NewBranch _owner )
194 _this.build_module = this;
195 this.el = new Gtk.ComboBox();
199 // set gobject values
200 var child_0 = new Xcls_dbcellrenderer( _this );
202 this.el.pack_start ( child_0.el , true );
203 var child_1 = new Xcls_dbmodel( _this );
205 this.el.set_model ( child_1.el );
209 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
212 this.el.changed.connect( () => {
217 this.el.get_active_iter (out iter);
218 _this.dbmodel.el.get_value (iter, 0, out val1);
219 _this.dbmodel.el.get_value (iter, 1, out val2);
221 var ticket_id = (string) val1;
223 var name = RooTicket.singleton().usernameLocal();
225 if (ticket_id == "") {
227 var dt = new DateTime.now_local();
228 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
232 var ticket = RooTicket.singleton().getById(ticket_id);
234 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
236 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
240 // user defined functions
242 public class Xcls_dbcellrenderer : Object
244 public Gtk.CellRendererText el;
245 private NewBranch _this;
251 public Xcls_dbcellrenderer(NewBranch _owner )
254 _this.dbcellrenderer = this;
255 this.el = new Gtk.CellRendererText();
259 // set gobject values
262 // user defined functions
265 public class Xcls_dbmodel : Object
267 public Gtk.ListStore el;
268 private NewBranch _this;
274 public Xcls_dbmodel(NewBranch _owner )
277 _this.dbmodel = this;
278 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
282 // set gobject values
285 // user defined functions
286 public void loadTickets () {
288 RooTicket.singleton().loadTickets();
299 el.set_value(iter, 0, "");
300 el.set_value(iter, 1, "-- select a ticket --");
302 _this.build_module.el.set_active_iter(iter);
303 var tickets = RooTicket.singleton().tickets;
304 foreach(var ticket in tickets) {
309 el.set_value(iter, 0, ticket.id);
310 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
312 //if (data.get(i) == cur) {
313 // _this.build_module.el.set_active_iter(iter);
317 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
323 public class Xcls_Label8 : Object
326 private NewBranch _this;
332 public Xcls_Label8(NewBranch _owner )
335 this.el = new Gtk.Label( "or use this as branch name" );
339 // set gobject values
340 this.el.justify = Gtk.Justification.RIGHT;
341 this.el.xalign = 0.900000f;
344 // user defined functions
347 public class Xcls_name : Object
350 private NewBranch _this;
356 public Xcls_name(NewBranch _owner )
360 this.el = new Gtk.Entry();
364 // set gobject values
365 this.el.visible = true;
368 // user defined functions
373 public class Xcls_Button10 : Object
375 public Gtk.Button el;
376 private NewBranch _this;
382 public Xcls_Button10(NewBranch _owner )
385 this.el = new Gtk.Button();
389 // set gobject values
390 this.el.relief = Gtk.ReliefStyle.NONE;
391 this.el.label = "Do not create Branch";
394 // user defined functions
397 public class Xcls_Button11 : Object
399 public Gtk.Button el;
400 private NewBranch _this;
406 public Xcls_Button11(NewBranch _owner )
409 this.el = new Gtk.Button();
413 // set gobject values
414 this.el.label = "Create Branch";
417 // user defined functions