Ticket.bjs
[gitlive] / NewBranch.vala
index 23ee674..166c8a6 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
         });
     }
 
@@ -123,14 +120,12 @@ public class NewBranch : Object
     
         this.el.show_all();
         this.el.set_keep_above(true);
-        _this.prmodel.loadProjects();
+       
         
-        var curproj = GitTicket.singleton().getProjectByRepo(repo);
-        if (curproject != null) {
-    //         _this.projectsel.selectProject(curproject);
-        }
+        var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
+         _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
         
-       _this.dbmodel.loadTickets();
+       _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
        this.el.run();
     
     }
@@ -292,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;
                }
@@ -317,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;
@@ -377,7 +379,7 @@ public class NewBranch : Object
         }
 
         // user defined functions
-        public void loadProjects () {
+        public void loadProjects (string id) {
         
             var rt = RooTicket.singleton();
             rt.loadProjects();
@@ -393,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) {
             
@@ -402,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);
+                   }   
                 
             }
             
@@ -531,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();                                    
@@ -588,6 +601,11 @@ public class NewBranch : Object
             // set gobject values
             this.el.expand = false;
             this.el.label = "New Ticket";
+
+            //listeners
+            this.el.clicked.connect( () => {
+               Ticket.singleton().show(_this.repo);
+            });
         }
 
         // user defined functions
@@ -668,7 +686,8 @@ public class NewBranch : Object
             }
 
             //listeners
-            this.el.activate.connect( () => {
+            this.el.clicked.connect( () => {
+               GLib.debug("fire response = 1");
                _this.el.response(1);
             });
         }
@@ -693,10 +712,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 );
@@ -706,7 +725,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;
@@ -715,21 +734,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;
@@ -738,15 +764,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
@@ -776,8 +810,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;
             });