[Pkg-bazaar-commits] ./bzr-gtk/unstable r396: Merged cleanup of the TreeView.
Daniel Schierbeck
daniel.schierbeck at gmail.com
Fri Apr 10 07:45:04 UTC 2009
------------------------------------------------------------
revno: 396
committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
branch nick: menubar
timestamp: Mon 2007-11-12 19:11:57 +0100
message:
Merged cleanup of the TreeView.
modified:
viz/treeview.py
------------------------------------------------------------
revno: 395.1.1
committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
branch nick: viz-cleanup
timestamp: Mon 2007-11-12 18:59:50 +0100
message:
Cleaned up code in the TreeView, removing instance variables.
modified:
viz/treeview.py
------------------------------------------------------------
revno: 395.1.2
committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
branch nick: viz-cleanup
timestamp: Mon 2007-11-12 19:11:12 +0100
message:
Added revision-number property to the TreeView.
modified:
viz/treeview.py
-------------- next part --------------
=== modified file 'viz/treeview.py'
--- a/viz/treeview.py 2007-11-09 17:53:26 +0000
+++ b/viz/treeview.py 2007-11-12 18:11:12 +0000
@@ -32,6 +32,22 @@
'The currently selected revision',
gobject.PARAM_READWRITE),
+ 'revision-number': (gobject.TYPE_STRING,
+ 'Revision number',
+ 'The number of the selected revision',
+ '',
+ gobject.PARAM_READABLE),
+
+ 'children': (gobject.TYPE_PYOBJECT,
+ 'Child revisions',
+ 'Children of the currently selected revision',
+ gobject.PARAM_READABLE),
+
+ 'parents': (gobject.TYPE_PYOBJECT,
+ 'Parent revisions',
+ 'Parents to the currently selected revision',
+ gobject.PARAM_READABLE),
+
'revno-column-visible': (gobject.TYPE_BOOLEAN,
'Revision number',
'Show revision number column',
@@ -72,15 +88,12 @@
self.construct_treeview()
+ self.iter = None
self.branch = branch
gobject.idle_add(self.populate, start, maxnum,
broken_line_length)
- self.revision = None
- self.children = None
- self.parents = None
-
self.connect("destroy", lambda x: self.branch.unlock())
def do_get_property(self, property):
@@ -91,7 +104,13 @@
elif property.name == 'branch':
return self.branch
elif property.name == 'revision':
- return self.revision
+ return self.model.get_value(self.iter, treemodel.REVISION)
+ elif property.name == 'revision-number':
+ return self.model.get_value(self.iter, treemodel.REVNO)
+ elif property.name == 'children':
+ return self.model.get_value(self.iter, treemodel.CHILDREN)
+ elif property.name == 'parents':
+ return self.model.get_value(self.iter, treemodel.PARENTS)
else:
raise AttributeError, 'unknown property %s' % property.name
@@ -109,7 +128,10 @@
def get_revision(self):
"""Return revision id of currently selected revision, or None."""
- return self.revision
+ return self.get_property('revision')
+
+ def set_revision(self, revision):
+ self.set_property('revision', revision)
def set_revision_id(self, revid):
"""Change the currently selected revision.
@@ -124,50 +146,44 @@
:return: list of revision ids.
"""
- return self.children
+ return self.get_property('children')
def get_parents(self):
"""Return the parents of the currently selected revision.
:return: list of revision ids.
"""
- return self.parents
+ return self.get_property('parents')
def back(self):
"""Signal handler for the Back button."""
- (path, col) = self.treeview.get_cursor()
- revision = self.model[path][treemodel.REVISION]
- parents = self.model[path][treemodel.PARENTS]
+ parents = self.get_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)
+ if same_branch(self.get_revision(), parent):
+ self.set_revision(parent)
break
else:
- self.treeview.set_cursor(self.index[parents[0]])
- self.treeview.grab_focus()
+ self.set_revision_id(parents[0])
def forward(self):
"""Signal handler for the Forward button."""
- (path, col) = self.treeview.get_cursor()
- revision = self.model[path][treemodel.REVISION]
- children = self.model[path][treemodel.CHILDREN]
+ children = self.get_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)
+ if same_branch(child, self.get_revision()):
+ self.set_revision(child)
break
else:
- self.treeview.set_cursor(self.index[children[0]])
- self.treeview.grab_focus()
+ self.set_revision_id(children[0])
def populate(self, start, maxnum, broken_line_length=None):
"""Fill the treeview with contents.
@@ -201,11 +217,13 @@
from bzrlib.plugins.gtk.diff import DiffWindow
window = DiffWindow(parent=self)
+ parents = self.get_parents()
+
if revid is None:
- revid = self.revision.revision_id
+ revid = self.get_revision().revision_id
- if parentid is None and len(self.parents) > 0:
- parentid = self.parents[0]
+ if parentid is None and len(parents) > 0:
+ parentid = parents[0]
if parentid is None:
parentid = NULL_REVISION
@@ -301,11 +319,7 @@
"""callback for when the treeview changes."""
(path, focus) = treeview.get_cursor()
if path is not None:
- iter = self.model.get_iter(path)
- self.revision = self.model.get_value(iter, treemodel.REVISION)
- self.parents = self.model.get_value(iter, treemodel.PARENTS)
- self.children = self.model.get_value(iter, treemodel.CHILDREN)
-
+ self.iter = self.model.get_iter(path)
self.emit('revision-selected')
def _on_revision_selected(self, widget, event):
More information about the Pkg-bazaar-commits
mailing list