[Pkg-bazaar-commits] ./bzr-gtk/unstable r304: Made forward/back buttons work again.

Daniel Schierbeck daniel.schierbeck at gmail.com
Fri Apr 10 07:45:24 UTC 2009


------------------------------------------------------------
revno: 304
committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
branch nick: revhistoryview
timestamp: Sat 2007-10-20 23:43:04 +0200
message:
  Made forward/back buttons work again.
modified:
  viz/branchwin.py
  viz/treeview.py
-------------- next part --------------
=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2007-10-20 21:38:23 +0000
+++ b/viz/branchwin.py	2007-10-20 21:43:04 +0000
@@ -185,39 +185,11 @@
 
     def _back_clicked_cb(self, *args):
         """Callback for when the back button is clicked."""
-        (path, col) = self.treeview.get_cursor()
-        revision = self.model[path][treemodel.REVISION]
-        parents = self.model[path][treemodel.PARENTS]
-        if not len(parents):
-            return
-
-        for parent_id in parents:
-            parent_index = self.index[parent_id]
-            parent = self.model[parent_index][treemodel.REVISION]
-            if same_branch(revision, parent):
-                self.treeview.set_cursor(parent_index)
-                break
-        else:
-            self.treeview.set_cursor(self.index[parents[0]])
-        self.treeview.grab_focus()
-
+        self.treeview.back()
+        
     def _fwd_clicked_cb(self, *args):
         """Callback for when the forward button is clicked."""
-        (path, col) = self.treeview.get_cursor()
-        revision = self.model[path][treemodel.REVISION]
-        children = self.model[path][treemodel.CHILDREN]
-        if not len(children):
-            return
-
-        for child_id in children:
-            child_index = self.index[child_id]
-            child = self.model[child_index][treemodel.REVISION]
-            if same_branch(child, revision):
-                self.treeview.set_cursor(child_index)
-                break
-        else:
-            self.treeview.set_cursor(self.index[children[0]])
-        self.treeview.grab_focus()
+        self.treeview.forward()
 
     def _go_clicked_cb(self, revid):
         """Callback for when the go button for a parent is clicked."""

=== modified file 'viz/treeview.py'
--- a/viz/treeview.py	2007-10-20 21:38:23 +0000
+++ b/viz/treeview.py	2007-10-20 21:43:04 +0000
@@ -39,6 +39,63 @@
     def get_parents(self):
         return self.parents
 
+    def set_branch(self, branch, start, maxnum):
+        self.branch = branch
+
+        gobject.idle_add(self.populate, start, maxnum)
+
+    def back(self):
+        (path, col) = self.treeview.get_cursor()
+        revision = self.model[path][treemodel.REVISION]
+        parents = self.model[path][treemodel.PARENTS]
+        if not len(parents):
+            return
+
+        for parent_id in parents:
+            parent_index = self.index[parent_id]
+            parent = self.model[parent_index][treemodel.REVISION]
+            if same_branch(revision, parent):
+                self.treeview.set_cursor(parent_index)
+                break
+        else:
+            self.treeview.set_cursor(self.index[parents[0]])
+        self.treeview.grab_focus()
+
+    def forward(self):
+        (path, col) = self.treeview.get_cursor()
+        revision = self.model[path][treemodel.REVISION]
+        children = self.model[path][treemodel.CHILDREN]
+        if not len(children):
+            return
+
+        for child_id in children:
+            child_index = self.index[child_id]
+            child = self.model[child_index][treemodel.REVISION]
+            if same_branch(child, revision):
+                self.treeview.set_cursor(child_index)
+                break
+        else:
+            self.treeview.set_cursor(self.index[children[0]])
+        self.treeview.grab_focus()
+
+    def populate(self, start, maxnum):
+        self.branch.lock_read()
+
+        (linegraphdata, index, columns_len) = linegraph(self.branch,
+                                                        start,
+                                                        maxnum)
+
+        self.model = TreeModel(self.branch, linegraphdata)
+        self.graph_cell.columns_len = columns_len
+        width = self.graph_cell.get_size(self.treeview)[2]
+        self.graph_column.set_fixed_width(width)
+        self.graph_column.set_max_width(width)
+        self.index = index
+        self.treeview.set_model(self.model)
+        self.treeview.set_cursor(0)
+
+        return False
+
     def construct_treeview(self):
         self.treeview = gtk.TreeView()
 
@@ -102,29 +159,6 @@
         column.add_attribute(cell, "text", treemodel.COMMITER)
         self.treeview.append_column(column)
 
-    def set_branch(self, branch, start, maxnum):
-        self.branch = branch
-
-        gobject.idle_add(self.populate, start, maxnum)
-
-    def populate(self, start, maxnum):
-        self.branch.lock_read()
-
-        (linegraphdata, index, columns_len) = linegraph(self.branch,
-                                                        start,
-                                                        maxnum)
-
-        self.model = TreeModel(self.branch, linegraphdata)
-        self.graph_cell.columns_len = columns_len
-        width = self.graph_cell.get_size(self.treeview)[2]
-        self.graph_column.set_fixed_width(width)
-        self.graph_column.set_max_width(width)
-        self.index = index
-        self.treeview.set_model(self.model)
-        self.treeview.get_selection().select_path(0)
-
-        return False
-    
     def _on_selection_changed(self, selection, *args):
         """callback for when the treeview changes."""
         (model, selected_rows) = selection.get_selected_rows()



More information about the Pkg-bazaar-commits mailing list