X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=NewBranch.vala;h=bd6fedd2a5612630f0148228833eb03ac34d83fe;hp=643489b24a0b7470fd3df880710e07e4a5c5fd50;hb=3ca10752a9d585c7d1f731322f9e1174493cc9e0;hpb=424eebf8a96c11d28b3da871c3e1560638d3511f diff --git a/NewBranch.vala b/NewBranch.vala index 643489b2..bd6fedd2 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -21,6 +21,8 @@ public class NewBranch : Object public Xcls_name name; public Xcls_btn_not_me btn_not_me; public Xcls_btn_closed btn_closed; + public Xcls_scrolled_window scrolled_window; + public Xcls_view view; // my vars (def) public GitRepo? repo; @@ -40,11 +42,11 @@ public class NewBranch : Object // set gobject values this.el.title = "Create a working branch "; - this.el.default_height = 200; + this.el.default_height = 500; this.el.default_width = 500; this.el.deletable = true; this.el.modal = true; - var child_0 = new Xcls_VBox2( _this ); + var child_0 = new Xcls_Box2( _this ); child_0.ref(); this.el.get_content_area().add ( child_0.el ); @@ -57,11 +59,9 @@ public class NewBranch : Object this.el.response.connect( (self, response_id) => { GLib.debug("got %d", (int) response_id); - if (response_id < 1) { - _this.el.hide(); - this.running = false; - return; - } + + + // have they selected a ticket.. // make that the current active ticket? @@ -70,6 +70,14 @@ public class NewBranch : Object // -- each repo would have their active ticket (only one per repo) // -- so we could just store that in there // -- initial load can check the contents of the ticket files on first scan. + + + if (response_id < 1) { + _this.el.hide(); + this.running = false; + return; + } + var ticket_id = _this.ticketsel.selectedTicketId(); if (this.repo != null) { @@ -84,7 +92,7 @@ public class NewBranch : Object } } - + this.running = false; @@ -110,8 +118,7 @@ public class NewBranch : Object this.repo = repo; - - + this.el.move((Gdk.Screen.width() / 2)- 250 ,0); this.el.set_default_size( 500,200); // not sure why it grows.. @@ -122,26 +129,35 @@ public class NewBranch : Object this.el.set_keep_above(true); - var curproj = RooTicket.singleton().getProjectByRepo(this.repo); + var curproj = RooProject.getProjectByRepo(this.repo); _this.prmodel.loadProjects(curproj == null ? "" : curproj.id); _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid); + _this.ticketsel.el.get_child().get_style_context().remove_class("warning"); + if (tid != "") { + var name = RooTicket.singleton().usernameLocal(); + var ticket = RooTicket.singleton().getById(tid); + _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName())); + } else { + _this.ticketsel.el.get_child().get_style_context().add_class("warning"); + } + _this.view.loadTicket(tid); this.el.run(); } - public class Xcls_VBox2 : Object + public class Xcls_Box2 : Object { - public Gtk.VBox el; + public Gtk.Box el; private NewBranch _this; // my vars (def) // ctor - public Xcls_VBox2(NewBranch _owner ) + public Xcls_Box2(NewBranch _owner ) { _this = _owner; - this.el = new Gtk.VBox( true, 0 ); + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); // my vars (dec) @@ -149,6 +165,9 @@ public class NewBranch : Object var child_0 = new Xcls_Table3( _this ); child_0.ref(); this.el.pack_start ( child_0.el , false,false,0 ); + var child_1 = new Xcls_scrolled_window( _this ); + child_1.ref(); + this.el.add ( child_1.el ); } // user defined functions @@ -381,8 +400,7 @@ public class NewBranch : Object // user defined functions public void loadProjects (string id) { - var rt = RooTicket.singleton(); - rt.loadProjects(); + _this.projectsel.loading = true; @@ -398,8 +416,8 @@ public class NewBranch : Object if (id == "") { _this.projectsel.el.set_active_iter(iter); } - var projects = rt.projects; - foreach(var project in projects) { + + foreach(var project in RooProject.projects()) { el.append(out iter); @@ -449,6 +467,7 @@ public class NewBranch : Object //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 ); this.el.set_entry_text_column(1); + this.el.get_child().set_sensitive(false); //listeners this.el.changed.connect( () => { @@ -459,10 +478,15 @@ public class NewBranch : Object var name = RooTicket.singleton().usernameLocal(); + this.el.get_child().get_style_context().remove_class("warning"); if (ticket_id == "" || ticket_id == null) { var dt = new DateTime.now_local(); _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d"))); + _this.view.loadTicket(""); + + this.el.get_child().get_style_context().add_class("warning"); + return; } @@ -470,7 +494,9 @@ public class NewBranch : Object var ticket = RooTicket.singleton().getById(ticket_id); _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName())); - + _this.scrolled_window.el.show(); + + _this.view.loadTicket(ticket.id); //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2); }); } @@ -544,8 +570,8 @@ public class NewBranch : Object RooTicket.singleton().loadTickets( project_id, - _this.btn_not_me.el.active ? RooTicket.NotMe.TRUE : RooTicket.NotMe.FALSE, - _this.btn_closed.el.active ? RooTicket.Closed.TRUE : RooTicket.Closed.FALSE + _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME, + _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE ); _this.ticketsel.loading = true; @@ -567,7 +593,7 @@ public class NewBranch : Object el.append(out iter); el.set_value(iter, 0, ticket.id); - el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary)); + el.set_value(iter, 1, "#%s %s".printf( ticket.id, ticket.summary)); if (ticket.id == tid) { _this.ticketsel.el.set_active_iter(iter); @@ -601,6 +627,13 @@ public class NewBranch : Object // set gobject values this.el.expand = false; this.el.label = "New Ticket"; + + //listeners + this.el.clicked.connect( () => { + _this.el.response(-1); + Ticket.singleton().show(_this.repo); + + }); } // user defined functions @@ -682,7 +715,16 @@ public class NewBranch : Object //listeners this.el.clicked.connect( () => { + GLib.debug("fire response = 1"); + + var ticket_id = _this.ticketsel.selectedTicketId(); + + if (ticket_id == "") { + _this.ticketsel.el.get_child().get_style_context().add_class("warning"); + return; + } + _this.el.response(1); }); } @@ -805,7 +847,8 @@ public class NewBranch : Object //listeners this.el.activate_link.connect( (uri) => { if (uri == "refresh") { - var curproj = RooTicket.singleton().getProjectByRepo(_this.repo); + RooProject.reload(); + var curproj = RooProject.getProjectByRepo(_this.repo); _this.prmodel.loadProjects(curproj == null ? "": curproj.id); _this.dbmodel.loadTickets(curproj == null ? "": curproj.id); @@ -819,5 +862,82 @@ public class NewBranch : Object + public class Xcls_scrolled_window : Object + { + public Gtk.ScrolledWindow el; + private NewBranch _this; + + + // my vars (def) + + // ctor + public Xcls_scrolled_window(NewBranch _owner ) + { + _this = _owner; + _this.scrolled_window = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.height_request = 500; + this.el.vexpand = true; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + { + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + } + + // user defined functions + } + public class Xcls_view : Object + { + public WebKit.WebView el; + private NewBranch _this; + + + // my vars (def) + + // ctor + public Xcls_view(NewBranch _owner ) + { + _this = _owner; + _this.view = this; + this.el = new WebKit.WebView(); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + public void loadTicket (string tid) { + int h,w; + _this.el.get_size(out w, out h); + + if (tid == "") { + _this.scrolled_window.el.hide(); + _this.el.resize(w, 150); + } else { + _this.scrolled_window.el.show(); + _this.el.resize(w, 800); + } + + var rs = RooTicket.singleton(); + var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid); + var hd = uri.get_http_headers(); + var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data); + hd.append("Authorization", "Basic %s".printf(authCode)); + + this.el.load_request(uri); + } + } + + }