RepoStatusPopover.bjs
[gitlive] / NewBranch.vala
index fafb5f9..86fc32a 100644 (file)
@@ -19,6 +19,8 @@ public class NewBranch : Object
     public Xcls_dbcellrenderer dbcellrenderer;
     public Xcls_dbmodel dbmodel;
     public Xcls_name name;
+    public Xcls_btn_not_me btn_not_me;
+    public Xcls_btn_closed btn_closed;
 
         // my vars (def)
     public GitRepo? repo;
@@ -91,11 +93,6 @@ public class NewBranch : Object
                 
         
                 
-        });
-        this.el.show.connect( (self)  => {
-         
-        
-          //test
         });
     }
 
@@ -113,6 +110,9 @@ 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..
         GLib.debug("Loading tickets"); 
@@ -120,8 +120,12 @@ public class NewBranch : Object
     
         this.el.show_all();
         this.el.set_keep_above(true);
-        _this.prmodel.loadProjects();
-       _this.dbmodel.loadTickets();
+       
+        
+        var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
+         _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
+        
+       _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
        this.el.run();
     
     }
@@ -283,6 +287,13 @@ public class NewBranch : Object
 
             //listeners
             this.el.changed.connect( () => {
+               if (this.loading) {
+                       return;
+               }
+               var project_id = this.selectedProjectId();
+               _this.dbmodel.loadTickets(project_id);
+               
+               
                /*if (this.loading) {
                        return;
                }
@@ -308,13 +319,13 @@ public class NewBranch : Object
         }
 
         // user defined functions
-        public string selectedTicketId () {
-        Gtk.TreeIter iter;
+        public string selectedProjectId () {
+               Gtk.TreeIter iter;
                Value val1;
          
          
                this.el.get_active_iter (out iter);
-               _this.dbmodel.el.get_value (iter, 0, out val1);
+               _this.prmodel.el.get_value (iter, 0, out val1);
          
         
                return  (string) val1;
@@ -368,7 +379,7 @@ public class NewBranch : Object
         }
 
         // user defined functions
-        public void loadProjects () {
+        public void loadProjects (string id) {
         
             var rt = RooTicket.singleton();
             rt.loadProjects();
@@ -384,8 +395,9 @@ public class NewBranch : Object
             
             el.set_value(iter, 0, "");
             el.set_value(iter, 1, "-- select a project --");
-            
-            _this.projectsel.el.set_active_iter(iter);
+            if (id == "") {
+                   _this.projectsel.el.set_active_iter(iter);
+            }
             var projects = rt.projects;
             foreach(var project in projects) {
             
@@ -393,7 +405,9 @@ public class NewBranch : Object
                 
                 el.set_value(iter, 0, project.id);
                 el.set_value(iter, 1,  project.name );
-                
+                if (id == project.id) {
+                          _this.projectsel.el.set_active_iter(iter);
+                   }   
                 
             }
             
@@ -522,10 +536,18 @@ public class NewBranch : Object
         }
 
         // user defined functions
-        public void loadTickets () {
+        public void loadTickets (string project_id) {
         
-            RooTicket.singleton().loadTickets();
+        
+            
+            // fixme .. get project id from selection..
             
+             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.ticketsel.loading = true;
         
             this.el.clear();                                    
@@ -659,7 +681,8 @@ public class NewBranch : Object
             }
 
             //listeners
-            this.el.activate.connect( () => {
+            this.el.clicked.connect( () => {
+               GLib.debug("fire response = 1");
                _this.el.response(1);
             });
         }
@@ -684,10 +707,10 @@ public class NewBranch : Object
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_CheckButton17( _this );
+            var child_0 = new Xcls_btn_not_me( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
-            var child_1 = new Xcls_CheckButton18( _this );
+            var child_1 = new Xcls_btn_closed( _this );
             child_1.ref();
             this.el.add (  child_1.el  );
             var child_2 = new Xcls_Label19( _this );
@@ -697,7 +720,7 @@ public class NewBranch : Object
 
         // user defined functions
     }
-    public class Xcls_CheckButton17 : Object
+    public class Xcls_btn_not_me : Object
     {
         public Gtk.CheckButton el;
         private NewBranch  _this;
@@ -706,21 +729,28 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_CheckButton17(NewBranch _owner )
+        public Xcls_btn_not_me(NewBranch _owner )
         {
             _this = _owner;
+            _this.btn_not_me = this;
             this.el = new Gtk.CheckButton();
 
             // my vars (dec)
 
             // set gobject values
             this.el.label = "Show tickets not assigned to me";
+
+            //listeners
+            this.el.toggled.connect( () => {
+               var project_id = _this.projectsel.selectedProjectId();
+               _this.dbmodel.loadTickets(project_id);  
+            });
         }
 
         // user defined functions
     }
 
-    public class Xcls_CheckButton18 : Object
+    public class Xcls_btn_closed : Object
     {
         public Gtk.CheckButton el;
         private NewBranch  _this;
@@ -729,15 +759,23 @@ public class NewBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_CheckButton18(NewBranch _owner )
+        public Xcls_btn_closed(NewBranch _owner )
         {
             _this = _owner;
+            _this.btn_closed = this;
             this.el = new Gtk.CheckButton();
 
             // my vars (dec)
 
             // set gobject values
             this.el.label = "Show closed Tickets";
+
+            //listeners
+            this.el.toggled.connect( () => {
+               var project_id = _this.projectsel.selectedProjectId();
+               _this.dbmodel.loadTickets(project_id);  
+                
+            });
         }
 
         // user defined functions
@@ -767,8 +805,10 @@ public class NewBranch : Object
             //listeners
             this.el.activate_link.connect( (uri) => {
                if (uri == "refresh") {
-                       _this.prmodel.loadProjects();
-                       _this.dbmodel.loadTickets();            
+                       var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
+                        _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
+            
+                       _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);            
                }
                return true;
             });