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

Proposed by Gary Lasker
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 Approve
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.
Revision history for this message
Michael Vogt (mvo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2010-04-06 12:46:46 +0000
+++ debian/changelog 2010-04-08 22:39:17 +0000
@@ -4,6 +4,9 @@
4 * softwarecenter/view/viewswitcher.py:4 * softwarecenter/view/viewswitcher.py:
5 - fix intermittent AttributeError if a model doesn't5 - fix intermittent AttributeError if a model doesn't
6 exist when checking node expanded state (LP: #554388)6 exist when checking node expanded state (LP: #554388)
7 * softwarecenter/view/viewswitcher.py:
8 - fix nasty list view errors when disabling partner
9 repository (LP: #556995)
7 10
8 [ Michael Vogt ]11 [ Michael Vogt ]
9 * softwarecenter/apt/aptcache.py:12 * softwarecenter/apt/aptcache.py:
@@ -14,7 +17,7 @@
14 * softwarecenter/view/appdetailsview.py:17 * softwarecenter/view/appdetailsview.py:
15 - use package name when application name is not available (LP: #549011)18 - use package name when application name is not available (LP: #549011)
1619
17 -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 06 Apr 2010 10:14:43 +020020 -- Gary Lasker <gary.lasker@canonical.com> Thu, 08 Apr 2010 18:01:20 -0400
1821
19software-center (1.1.24) lucid; urgency=low22software-center (1.1.24) lucid; urgency=low
2023
2124
=== modified file 'softwarecenter/view/channelpane.py'
--- softwarecenter/view/channelpane.py 2010-03-23 16:50:23 +0000
+++ softwarecenter/view/channelpane.py 2010-04-08 22:39:17 +0000
@@ -85,7 +85,6 @@
85 self.on_navigation_search, 85 self.on_navigation_search,
86 "search")86 "search")
87 else:87 else:
88 # FIXME: don't replace first part, just update the button in-place
89 self.navigation_bar.remove_all(keep_first_part=False)88 self.navigation_bar.remove_all(keep_first_part=False)
90 self.navigation_bar.add_with_id(self.channel.get_channel_display_name(),89 self.navigation_bar.add_with_id(self.channel.get_channel_display_name(),
91 self.on_navigation_list,90 self.on_navigation_list,
9291
=== modified file 'softwarecenter/view/viewswitcher.py'
--- softwarecenter/view/viewswitcher.py 2010-04-05 04:40:27 +0000
+++ softwarecenter/view/viewswitcher.py 2010-04-08 22:39:17 +0000
@@ -81,10 +81,14 @@
81 self.get_selection().set_select_function(self.on_treeview_selected)81 self.get_selection().set_select_function(self.on_treeview_selected)
82 self.set_level_indentation(4)82 self.set_level_indentation(4)
83 self.set_enable_search(False)83 self.set_enable_search(False)
84
85 self.selected_channel_name = None
84 86
85 self.connect("row-expanded", self.on_treeview_row_expanded)87 self.connect("row-expanded", self.on_treeview_row_expanded)
86 self.connect("row-collapsed", self.on_treeview_row_collapsed)88 self.connect("row-collapsed", self.on_treeview_row_collapsed)
87 self.connect("cursor-changed", self.on_cursor_changed)89 self.connect("cursor-changed", self.on_cursor_changed)
90
91 self.get_model().connect("channels-refreshed", self._on_channels_refreshed)
88 92
89 def on_treeview_row_expanded(self, widget, iter, path):93 def on_treeview_row_expanded(self, widget, iter, path):
90 # do nothing on a node expansion94 # do nothing on a node expansion
@@ -102,6 +106,7 @@
102 def on_cursor_changed(self, widget):106 def on_cursor_changed(self, widget):
103 (path, column) = self.get_cursor()107 (path, column) = self.get_cursor()
104 model = self.get_model()108 model = self.get_model()
109 self.selected_channel_name = model[path][ViewSwitcherList.COL_NAME]
105 action = model[path][ViewSwitcherList.COL_ACTION]110 action = model[path][ViewSwitcherList.COL_ACTION]
106 channel = model[path][ViewSwitcherList.COL_CHANNEL]111 channel = model[path][ViewSwitcherList.COL_CHANNEL]
107 self.emit("view-changed", action, channel)112 self.emit("view-changed", action, channel)
@@ -146,6 +151,16 @@
146 expanded = self.row_expanded(available_path)151 expanded = self.row_expanded(available_path)
147 return expanded152 return expanded
148153
154 def _on_channels_refreshed(self, model):
155 """
156 when channels are refreshed, the viewswitcher channel is unselected so
157 we need to reselect it
158 """
159 model = self.get_model()
160 channel_iter_to_select = model.get_channel_iter_for_name(self.selected_channel_name)
161 if channel_iter_to_select:
162 self.set_cursor(model.get_path(channel_iter_to_select))
163
149class ViewSwitcherList(gtk.TreeStore):164class ViewSwitcherList(gtk.TreeStore):
150 165
151 # columns166 # columns
@@ -165,6 +180,10 @@
165180
166 ANIMATION_PATH = "/usr/share/icons/hicolor/24x24/status/softwarecenter-progress.png"181 ANIMATION_PATH = "/usr/share/icons/hicolor/24x24/status/softwarecenter-progress.png"
167182
183 __gsignals__ = {'channels-refreshed':(gobject.SIGNAL_RUN_FIRST,
184 gobject.TYPE_NONE,
185 ())}
186
168 def __init__(self, datadir, db, icons):187 def __init__(self, datadir, db, icons):
169 gtk.TreeStore.__init__(self, AnimatedImage, str, int, gobject.TYPE_PYOBJECT)188 gtk.TreeStore.__init__(self, AnimatedImage, str, int, gobject.TYPE_PYOBJECT)
170 self.icons = icons189 self.icons = icons
@@ -215,6 +234,16 @@
215 for (i, row) in enumerate(self):234 for (i, row) in enumerate(self):
216 if row[self.COL_ACTION] == self.ACTION_ITEM_PENDING:235 if row[self.COL_ACTION] == self.ACTION_ITEM_PENDING:
217 del self[(i,)]236 del self[(i,)]
237
238 def get_channel_iter_for_name(self, channel_name):
239 channel_iter_for_name = None
240 child = self.iter_children(self.available_iter)
241 while child:
242 if self.get_value(child, self.COL_NAME) == channel_name:
243 channel_iter_for_name = child
244 break
245 child = self.iter_next(child)
246 return channel_iter_for_name
218 247
219 def _get_icon(self, icon_name):248 def _get_icon(self, icon_name):
220 if self.icons.lookup_icon(icon_name, self.ICON_SIZE, 0):249 if self.icons.lookup_icon(icon_name, self.ICON_SIZE, 0):
@@ -253,6 +282,8 @@
253 for child in iters_to_kill:282 for child in iters_to_kill:
254 self.remove(child)283 self.remove(child)
255284
285 self.emit("channels-refreshed")
286
256 def _get_channels(self):287 def _get_channels(self):
257 """288 """
258 return a list of SoftwareChannel objects in display order289 return a list of SoftwareChannel objects in display order

Subscribers

People subscribed via source and target branches