Merge lp:~gary-lasker/software-center/lp556995 into lp:software-center

Proposed by Gary Lasker on 2010-04-08
Status: Merged
Merged at revision: not available
Proposed branch: lp:~gary-lasker/software-center/lp556995
Merge into: lp:software-center
Diff against target: 115 lines (+35/-2)
3 files modified
debian/changelog (+4/-1)
softwarecenter/view/channelpane.py (+0/-1)
softwarecenter/view/viewswitcher.py (+31/-0)
To merge this branch: bzr merge lp:~gary-lasker/software-center/lp556995
Reviewer Review Type Date Requested Status
Michael Vogt 2010-04-08 Approve on 2010-04-09
Review via email: mp+23055@code.launchpad.net

Description of the change

This branch is a proposed fix for bug 556995. The failure mode is this: When the update_channel_list method of ViewSwitcherList is executed after an update-apt-xapian-index call is completed, the set of channel nodes in the ViewSwitcher tree is replaced. A side effect of this is that the previously selected item in the list becomes unselected (no item is selected), and worse, the contents of the list view breaks pretty badly (see detailed description in bug 556995).

This branch adds a "channels-refreshed" signal that is emitted by ViewSwitcherList at the end of update_channel_list and this signal is handled by a new on_channel_refreshed method in ViewSwitcher itself. When on_channel_refreshed is called, the channel node that corresponds to the previously selected channel (if there is one) is looked up by its name, and is reselected. This restores the selection immediately and refreshes the listview correctly so the list view problems described in the bug no longer occur.

Michael, please note that this branch exhibits an intermittent artifact (as I mentioned to you in IRC) where on some occasions the first navigation button is not replaced with the result that a second identical button gets appended to the first. However, I tested with Matthew's branch below and found that the problem no longer occurs:

lp:~mmcg069/software-center/pathbar-atk

So, hopefully we can merge Matthew's branch as well.

Thanks!!
Gary

To post a comment you must log in.
Michael Vogt (mvo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2010-04-06 12:46:46 +0000
3+++ debian/changelog 2010-04-08 22:39:17 +0000
4@@ -4,6 +4,9 @@
5 * softwarecenter/view/viewswitcher.py:
6 - fix intermittent AttributeError if a model doesn't
7 exist when checking node expanded state (LP: #554388)
8+ * softwarecenter/view/viewswitcher.py:
9+ - fix nasty list view errors when disabling partner
10+ repository (LP: #556995)
11
12 [ Michael Vogt ]
13 * softwarecenter/apt/aptcache.py:
14@@ -14,7 +17,7 @@
15 * softwarecenter/view/appdetailsview.py:
16 - use package name when application name is not available (LP: #549011)
17
18- -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 06 Apr 2010 10:14:43 +0200
19+ -- Gary Lasker <gary.lasker@canonical.com> Thu, 08 Apr 2010 18:01:20 -0400
20
21 software-center (1.1.24) lucid; urgency=low
22
23
24=== modified file 'softwarecenter/view/channelpane.py'
25--- softwarecenter/view/channelpane.py 2010-03-23 16:50:23 +0000
26+++ softwarecenter/view/channelpane.py 2010-04-08 22:39:17 +0000
27@@ -85,7 +85,6 @@
28 self.on_navigation_search,
29 "search")
30 else:
31- # FIXME: don't replace first part, just update the button in-place
32 self.navigation_bar.remove_all(keep_first_part=False)
33 self.navigation_bar.add_with_id(self.channel.get_channel_display_name(),
34 self.on_navigation_list,
35
36=== modified file 'softwarecenter/view/viewswitcher.py'
37--- softwarecenter/view/viewswitcher.py 2010-04-05 04:40:27 +0000
38+++ softwarecenter/view/viewswitcher.py 2010-04-08 22:39:17 +0000
39@@ -81,10 +81,14 @@
40 self.get_selection().set_select_function(self.on_treeview_selected)
41 self.set_level_indentation(4)
42 self.set_enable_search(False)
43+
44+ self.selected_channel_name = None
45
46 self.connect("row-expanded", self.on_treeview_row_expanded)
47 self.connect("row-collapsed", self.on_treeview_row_collapsed)
48 self.connect("cursor-changed", self.on_cursor_changed)
49+
50+ self.get_model().connect("channels-refreshed", self._on_channels_refreshed)
51
52 def on_treeview_row_expanded(self, widget, iter, path):
53 # do nothing on a node expansion
54@@ -102,6 +106,7 @@
55 def on_cursor_changed(self, widget):
56 (path, column) = self.get_cursor()
57 model = self.get_model()
58+ self.selected_channel_name = model[path][ViewSwitcherList.COL_NAME]
59 action = model[path][ViewSwitcherList.COL_ACTION]
60 channel = model[path][ViewSwitcherList.COL_CHANNEL]
61 self.emit("view-changed", action, channel)
62@@ -146,6 +151,16 @@
63 expanded = self.row_expanded(available_path)
64 return expanded
65
66+ def _on_channels_refreshed(self, model):
67+ """
68+ when channels are refreshed, the viewswitcher channel is unselected so
69+ we need to reselect it
70+ """
71+ model = self.get_model()
72+ channel_iter_to_select = model.get_channel_iter_for_name(self.selected_channel_name)
73+ if channel_iter_to_select:
74+ self.set_cursor(model.get_path(channel_iter_to_select))
75+
76 class ViewSwitcherList(gtk.TreeStore):
77
78 # columns
79@@ -165,6 +180,10 @@
80
81 ANIMATION_PATH = "/usr/share/icons/hicolor/24x24/status/softwarecenter-progress.png"
82
83+ __gsignals__ = {'channels-refreshed':(gobject.SIGNAL_RUN_FIRST,
84+ gobject.TYPE_NONE,
85+ ())}
86+
87 def __init__(self, datadir, db, icons):
88 gtk.TreeStore.__init__(self, AnimatedImage, str, int, gobject.TYPE_PYOBJECT)
89 self.icons = icons
90@@ -215,6 +234,16 @@
91 for (i, row) in enumerate(self):
92 if row[self.COL_ACTION] == self.ACTION_ITEM_PENDING:
93 del self[(i,)]
94+
95+ def get_channel_iter_for_name(self, channel_name):
96+ channel_iter_for_name = None
97+ child = self.iter_children(self.available_iter)
98+ while child:
99+ if self.get_value(child, self.COL_NAME) == channel_name:
100+ channel_iter_for_name = child
101+ break
102+ child = self.iter_next(child)
103+ return channel_iter_for_name
104
105 def _get_icon(self, icon_name):
106 if self.icons.lookup_icon(icon_name, self.ICON_SIZE, 0):
107@@ -253,6 +282,8 @@
108 for child in iters_to_kill:
109 self.remove(child)
110
111+ self.emit("channels-refreshed")
112+
113 def _get_channels(self):
114 """
115 return a list of SoftwareChannel objects in display order

Subscribers

People subscribed via source and target branches