NewBranch.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 31 Oct 2018 08:22:47 +0000 (16:22 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 31 Oct 2018 08:22:47 +0000 (16:22 +0800)
NewBranch.vala

NewBranch.bjs
NewBranch.vala

index 53dc270..4ecfa42 100644 (file)
   {
    "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",
         },
         {
          "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",
index e65ba33..f4df8dc 100644 (file)
@@ -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
     {