Merge lp://staging/~alexlauni/groundcontrol/bugfix-lp-520613 into lp://staging/groundcontrol

Proposed by Alex Launi
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~alexlauni/groundcontrol/bugfix-lp-520613
Merge into: lp://staging/groundcontrol
Diff against target: 41 lines (+22/-0)
1 file modified
GroundControl/branches.py (+22/-0)
To merge this branch: bzr merge lp://staging/~alexlauni/groundcontrol/bugfix-lp-520613
Reviewer Review Type Date Requested Status
Martin Owens Approve
Review via email: mp+19276@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

Implements the BranchView tree with a ListStore model to allow it to be sorted, to make sure that series focus branches are always at the top of the view.

Revision history for this message
Martin Owens (doctormo) wrote :

This looks like a brilliant fix and it teaches me some things about how list view models work.

But I would like to see some of this logic make it's way into the gtkviews.py so that it's available to other listing UIs such as project listing and bug listing.

At the moment you've taken to removing the super calls and doing everything in branches.py, I'd like to chat about what you found out from your research into the problem to make sure that I don't make the same mistakes.

review: Needs Fixing
Revision history for this message
Alex Launi (alexlauni) wrote :

It should be pretty easy to modify gtkviews.py to make this type of thing
easier for other subclasses. I'll make some changes and resubmit.

On Feb 13, 2010 6:21 PM, "Martin Owens" <email address hidden> wrote:

Review: Needs Fixing
This looks like a brilliant fix and it teaches me some things about how list
view models work.

But I would like to see some of this logic make it's way into the
gtkviews.py so that it's available to other listing UIs such as project
listing and bug listing.

At the moment you've taken to removing the super calls and doing everything
in branches.py, I'd like to chat about what you found out from your research
into the problem to make sure that I don't make the same mistakes.

--
https://code.launchpad.net/~alexlauni/groundcontrol/bugfix-lp-520613/+merge/19276You
are the ow...

210. By Alex Launi

revert to using TreeStore in branches.py and attaching sort func to that

211. By Alex Launi

merge trunk

Revision history for this message
Martin Owens (doctormo) wrote :

Wonderful, merged in.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GroundControl/branches.py'
2--- GroundControl/branches.py 2010-02-10 21:14:06 +0000
3+++ GroundControl/branches.py 2010-02-14 00:19:14 +0000
4@@ -19,6 +19,7 @@
5 """
6
7 # Import standard python libs
8+import gobject
9 import gtk
10 import gtk.gdk
11 import logging
12@@ -279,8 +280,29 @@
13 img2 = img.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR)
14 cell.set_property("pixbuf", img2)
15 cell.set_property("visible", True)
16+
17+ def sort_branches_func(model, iter1, iter2):
18+ """Sorts branches so that development series branch is first, followed
19+ by series focus branches"""
20+ FOCUS_NONE, FOCUS_SERIES, FOCUS_DEVEL = range(3)
21+ branches = (model.get_value(iter1, 0), model.get_value(iter2, 0))
22+ focuses = list()
23+
24+ for branch in branches:
25+ if branch.develop:
26+ focuses.append(FOCUS_DEVEL)
27+ elif branch.series:
28+ focuses.append(FOCUS_SERIES)
29+ else:
30+ focuses.append(FOCUS_NONE)
31
32+ return focuses[1] - focuses[0]
33+
34 svlist = super(BranchView, self).setup()
35+ model = svlist.get_model()
36+ model.set_sort_func(0, sort_branches_func)
37+ model.set_sort_column_id(0, gtk.SORT_ASCENDING)
38+
39 column = gtk.TreeViewColumn((_("%s Branches") % self._name))
40 column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
41 column.set_expand(True)

Subscribers

People subscribed via source and target branches