From: Alan Knowles Date: Wed, 31 Oct 2018 08:22:47 +0000 (+0800) Subject: NewBranch.bjs X-Git-Url: http://git.roojs.org/?p=gitlive;a=commitdiff_plain;h=55e9325349365ed19eb69c73ea4a8f9759c5c056 NewBranch.bjs NewBranch.vala --- diff --git a/NewBranch.bjs b/NewBranch.bjs index 53dc270f..4ecfa425 100644 --- a/NewBranch.bjs +++ b/NewBranch.bjs @@ -10,13 +10,14 @@ { "listeners" : { "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", - "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t \n\t \treturn;\n\t}\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\n\t\n\n\t \n\t \n\t \n\n\t \n}", + "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id == 0) {\n\t _this.el.hide();\t \n\t \treturn;\n\t}\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton.getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\n\t\n\n\t \n\t \n\t \n\n\t \n}", "show" : "(self) => {\n \n\n //test\n}" }, "default_width" : 500, "$ deletable" : true, "title" : "Create a working branch ", "xtype" : "Dialog", + "# GitRepo? repo" : "null", "| void show" : "( ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n \t_this.dbmodel.loadTickets();\n\n this.el.show_all();\n\n\n \n \n \n}", "default_height" : 200, "$ xns" : "Gtk", @@ -49,13 +50,14 @@ }, { "listeners" : { - "changed" : "() => {\n\tGtk.TreeIter iter;\n\tValue val1;\n\tValue val2;\n \n\tthis.el.get_active_iter (out iter);\n\t_this.dbmodel.el.get_value (iter, 0, out val1);\n\t_this.dbmodel.el.get_value (iter, 1, out val2);\n\n\tvar ticket_id = (string) val1;\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\t\n\tif (ticket_id == \"\") {\n\t\n\t\tvar dt = new DateTime.now_local();\n\t\t_this.name.el.set_text(\"wip_%s_%s\".printf(name,dt.format(\"%Y_%b_%d\")));\n\t\treturn;\n\t}\n\t\n\tvar ticket = RooTicket.singleton().getById(ticket_id);\n \n\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\t\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}" + "changed" : "() => {\n\n\tvar ticket_id = this.selectedTicketId();\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\t\n\tif (ticket_id == \"\") {\n\t\n\t\tvar dt = new DateTime.now_local();\n\t\t_this.name.el.set_text(\"wip_%s_%s\".printf(name,dt.format(\"%Y_%b_%d\")));\n\t\treturn;\n\t}\n\t\n\tvar ticket = RooTicket.singleton().getById(ticket_id);\n \n\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\t\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}" }, - "id" : "build_module", + "id" : "ticketsel", "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", "* pack" : "attach_defaults,1,2,0,1", "xtype" : "ComboBox", "$ xns" : "Gtk", + "| string selectedTicketId" : "() {\nGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.dbmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", "items" : [ { "id" : "dbcellrenderer", diff --git a/NewBranch.vala b/NewBranch.vala index e65ba333..f4df8dc0 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -12,12 +12,13 @@ public class NewBranch : Object } return _NewBranch; } - public Xcls_build_module build_module; + public Xcls_ticketsel ticketsel; public Xcls_dbcellrenderer dbcellrenderer; public Xcls_dbmodel dbmodel; public Xcls_name name; // my vars (def) + public GitRepo? repo; // ctor public NewBranch() @@ -26,6 +27,7 @@ public class NewBranch : Object this.el = new Gtk.Dialog(); // my vars (dec) + this.repo = null; // set gobject values this.el.title = "Create a working branch "; @@ -63,6 +65,16 @@ 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. + var ticket_id = _this.ticketsel.selectedTicketId(); + + if (this.repo != null) { + var bn = _this.name.get_text(); + if (ticket_id != "" ) { + this.repo.setActiveTicket( RooTicket.singleton.getById(ticket_id), bn); + } else { + this.repo.createBranchNamed(bn); + } + } @@ -141,7 +153,7 @@ public class NewBranch : Object var child_0 = new Xcls_Label4( _this ); child_0.ref(); this.el.attach_defaults ( child_0.el , 0,1,0,1 ); - var child_1 = new Xcls_build_module( _this ); + var child_1 = new Xcls_ticketsel( _this ); child_1.ref(); this.el.attach_defaults ( child_1.el , 1,2,0,1 ); var child_2 = new Xcls_Label8( _this ); @@ -179,7 +191,7 @@ public class NewBranch : Object // user defined functions } - public class Xcls_build_module : Object + public class Xcls_ticketsel : Object { public Gtk.ComboBox el; private NewBranch _this; @@ -188,10 +200,10 @@ public class NewBranch : Object // my vars (def) // ctor - public Xcls_build_module(NewBranch _owner ) + public Xcls_ticketsel(NewBranch _owner ) { _this = _owner; - _this.build_module = this; + _this.ticketsel = this; this.el = new Gtk.ComboBox(); // my vars (dec) @@ -210,15 +222,8 @@ public class NewBranch : Object //listeners this.el.changed.connect( () => { - Gtk.TreeIter iter; - Value val1; - Value val2; - - this.el.get_active_iter (out iter); - _this.dbmodel.el.get_value (iter, 0, out val1); - _this.dbmodel.el.get_value (iter, 1, out val2); - var ticket_id = (string) val1; + var ticket_id = this.selectedTicketId(); var name = RooTicket.singleton().usernameLocal(); @@ -238,6 +243,21 @@ public class NewBranch : Object } // user defined functions + public string selectedTicketId () { + Gtk.TreeIter iter; + Value val1; + + + this.el.get_active_iter (out iter); + _this.dbmodel.el.get_value (iter, 0, out val1); + + + return (string) val1; + + + + + } } public class Xcls_dbcellrenderer : Object {