NewBranch.bjs
[gitlive] / NewBranch.vala
index 6b2c345..8a3bfe7 100644 (file)
@@ -12,6 +12,9 @@ public class NewBranch : Object
         }
         return _NewBranch;
     }
+    public Xcls_label_select_ticket label_select_ticket;
+    public Xcls_label_create_ticket label_create_ticket;
+    public Xcls_label_quick_commit label_quick_commit;
     public Xcls_projectsel projectsel;
     public Xcls_prcellrenderer prcellrenderer;
     public Xcls_prmodel prmodel;
@@ -19,6 +22,7 @@ public class NewBranch : Object
     public Xcls_dbcellrenderer dbcellrenderer;
     public Xcls_dbmodel dbmodel;
     public Xcls_name name;
+    public Xcls_createbtn createbtn;
     public Xcls_btn_not_me btn_not_me;
     public Xcls_btn_closed btn_closed;
     public Xcls_scrolled_window scrolled_window;
@@ -49,6 +53,9 @@ public class NewBranch : Object
         var child_0 = new Xcls_Box2( _this );
         child_0.ref();
         this.el.get_content_area().add (  child_0.el  );
+        var child_1 = new Xcls_Notebook3( _this );
+        child_1.ref();
+        this.el.add (  child_1.el  );
 
         //listeners
         this.el.delete_event.connect( (self, event) => {
@@ -59,11 +66,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?
@@ -72,6 +77,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) {
@@ -86,7 +99,7 @@ public class NewBranch : Object
                                 
                         }
             }
-            
+             
         
             this.running = false; 
         
@@ -127,13 +140,15 @@ public class NewBranch : Object
          _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
         
        _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
-    
-       if (tid != "") {
+       _this.createbtn.updateState();
+       
+       _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();
@@ -156,7 +171,136 @@ public class NewBranch : Object
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_Table3( _this );
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_Notebook3 : Object
+    {
+        public Gtk.Notebook el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Notebook3(NewBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Notebook();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.vexpand = true;
+            var child_0 = new Xcls_label_select_ticket( _this );
+            child_0.ref();
+            var child_1 = new Xcls_label_create_ticket( _this );
+            child_1.ref();
+            var child_2 = new Xcls_label_quick_commit( _this );
+            child_2.ref();
+            var child_3 = new Xcls_Box7( _this );
+            child_3.ref();
+            this.el.append_page (  child_3.el , _this.label_select_ticket.el );
+            var child_4 = new Xcls_Box27( _this );
+            child_4.ref();
+            this.el.append_page (  child_4.el , _this.label_create_ticket.el );
+            var child_5 = new Xcls_Box28( _this );
+            child_5.ref();
+            this.el.append_page (  child_5.el , _this.label_quick_commit.el );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_label_select_ticket : Object
+    {
+        public Gtk.Label el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_select_ticket(NewBranch _owner )
+        {
+            _this = _owner;
+            _this.label_select_ticket = this;
+            this.el = new Gtk.Label( "Select Existing Ticket to work on" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_label_create_ticket : Object
+    {
+        public Gtk.Label el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_create_ticket(NewBranch _owner )
+        {
+            _this = _owner;
+            _this.label_create_ticket = this;
+            this.el = new Gtk.Label( "Create a new Ticket" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_label_quick_commit : Object
+    {
+        public Gtk.Label el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_quick_commit(NewBranch _owner )
+        {
+            _this = _owner;
+            _this.label_quick_commit = this;
+            this.el = new Gtk.Label( "Quick Commit" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_Box7 : Object
+    {
+        public Gtk.Box el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box7(NewBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+            var child_0 = new Xcls_Table8( _this );
             child_0.ref();
             this.el.pack_start (  child_0.el , false,false,0 );
             var child_1 = new Xcls_scrolled_window( _this );
@@ -166,7 +310,7 @@ public class NewBranch : Object
 
         // user defined functions
     }
-    public class Xcls_Table3 : Object
+    public class Xcls_Table8 : Object
     {
         public Gtk.Table el;
         private NewBranch  _this;
@@ -175,7 +319,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Table3(NewBranch _owner )
+        public Xcls_Table8(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Table( 5, 5, true );
@@ -187,10 +331,10 @@ public class NewBranch : Object
             this.el.margin = 2;
             this.el.column_spacing = 4;
             this.el.vexpand = false;
-            var child_0 = new Xcls_Label4( _this );
+            var child_0 = new Xcls_Label9( _this );
             child_0.ref();
             this.el.attach_defaults (  child_0.el , 0,1,0,1 );
-            var child_1 = new Xcls_Label5( _this );
+            var child_1 = new Xcls_Label10( _this );
             child_1.ref();
             this.el.attach_defaults (  child_1.el , 1,2,0,1 );
             var child_2 = new Xcls_projectsel( _this );
@@ -199,26 +343,26 @@ public class NewBranch : Object
             var child_3 = new Xcls_ticketsel( _this );
             child_3.ref();
             this.el.attach_defaults (  child_3.el , 1,4,1,2 );
-            var child_4 = new Xcls_Button12( _this );
+            var child_4 = new Xcls_Button17( _this );
             child_4.ref();
             this.el.attach_defaults (  child_4.el , 4,5,1,2 );
-            var child_5 = new Xcls_Label13( _this );
+            var child_5 = new Xcls_Label18( _this );
             child_5.ref();
             this.el.attach_defaults (  child_5.el , 0,1,3,4 );
             var child_6 = new Xcls_name( _this );
             child_6.ref();
             this.el.attach_defaults (  child_6.el , 0,4,4,5 );
-            var child_7 = new Xcls_Button15( _this );
+            var child_7 = new Xcls_createbtn( _this );
             child_7.ref();
             this.el.attach_defaults (  child_7.el , 4,5,4,5 );
-            var child_8 = new Xcls_Box16( _this );
+            var child_8 = new Xcls_Box21( _this );
             child_8.ref();
             this.el.attach_defaults (  child_8.el , 0,5,2,3 );
         }
 
         // user defined functions
     }
-    public class Xcls_Label4 : Object
+    public class Xcls_Label9 : Object
     {
         public Gtk.Label el;
         private NewBranch  _this;
@@ -227,7 +371,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Label4(NewBranch _owner )
+        public Xcls_Label9(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Project" );
@@ -243,7 +387,7 @@ public class NewBranch : Object
         // user defined functions
     }
 
-    public class Xcls_Label5 : Object
+    public class Xcls_Label10 : Object
     {
         public Gtk.Label el;
         private NewBranch  _this;
@@ -252,7 +396,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Label5(NewBranch _owner )
+        public Xcls_Label10(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Ticket" );
@@ -461,6 +605,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( () => {
@@ -471,11 +616,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");
+                       _this.createbtn.updateState();
                        return;
                }
                
@@ -486,6 +635,8 @@ public class NewBranch : Object
                _this.scrolled_window.el.show();
                 
                _this.view.loadTicket(ticket.id);
+               _this.createbtn.updateState();
+               
                //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
             });
         }
@@ -582,7 +733,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);
@@ -597,7 +748,7 @@ public class NewBranch : Object
     }
 
 
-    public class Xcls_Button12 : Object
+    public class Xcls_Button17 : Object
     {
         public Gtk.Button el;
         private NewBranch  _this;
@@ -606,7 +757,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Button12(NewBranch _owner )
+        public Xcls_Button17(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Button();
@@ -628,7 +779,7 @@ public class NewBranch : Object
         // user defined functions
     }
 
-    public class Xcls_Label13 : Object
+    public class Xcls_Label18 : Object
     {
         public Gtk.Label el;
         private NewBranch  _this;
@@ -637,7 +788,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Label13(NewBranch _owner )
+        public Xcls_Label18(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Use this as branch name" );
@@ -677,7 +828,7 @@ public class NewBranch : Object
         // user defined functions
     }
 
-    public class Xcls_Button15 : Object
+    public class Xcls_createbtn : Object
     {
         public Gtk.Button el;
         private NewBranch  _this;
@@ -686,9 +837,10 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Button15(NewBranch _owner )
+        public Xcls_createbtn(NewBranch _owner )
         {
             _this = _owner;
+            _this.createbtn = this;
             this.el = new Gtk.Button();
 
             // my vars (dec)
@@ -704,15 +856,36 @@ 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);
             });
         }
 
         // user defined functions
+        public void updateState () {
+        
+               var ticket_id = _this.ticketsel.selectedTicketId();
+               
+               if (ticket_id == "") {
+                       this.el.set_sensitive(false);
+                       return;
+               }
+         
+               this.el.set_sensitive(true);
+         
+        }
     }
 
-    public class Xcls_Box16 : Object
+    public class Xcls_Box21 : Object
     {
         public Gtk.Box el;
         private NewBranch  _this;
@@ -721,7 +894,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Box16(NewBranch _owner )
+        public Xcls_Box21(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
@@ -735,7 +908,7 @@ public class NewBranch : Object
             var child_1 = new Xcls_btn_closed( _this );
             child_1.ref();
             this.el.add (  child_1.el  );
-            var child_2 = new Xcls_Label19( _this );
+            var child_2 = new Xcls_Label24( _this );
             child_2.ref();
             this.el.add (  child_2.el  );
         }
@@ -803,7 +976,7 @@ public class NewBranch : Object
         // user defined functions
     }
 
-    public class Xcls_Label19 : Object
+    public class Xcls_Label24 : Object
     {
         public Gtk.Label el;
         private NewBranch  _this;
@@ -812,7 +985,7 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Label19(NewBranch _owner )
+        public Xcls_Label24(NewBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
@@ -920,4 +1093,51 @@ public class NewBranch : Object
 
 
 
+    public class Xcls_Box27 : Object
+    {
+        public Gtk.Box el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box27(NewBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_Box28 : Object
+    {
+        public Gtk.Box el;
+        private NewBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box28(NewBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+        }
+
+        // user defined functions
+    }
+
+
 }