Merge lp:~mmcg069/software-center/Bug888463 into lp:software-center

Proposed by Matthew McGowan
Status: Merged
Merged at revision: 2554
Proposed branch: lp:~mmcg069/software-center/Bug888463
Merge into: lp:software-center
Diff against target: 103 lines (+30/-17)
1 file modified
softwarecenter/ui/gtk3/widgets/apptreeview.py (+30/-17)
To merge this branch: bzr merge lp:~mmcg069/software-center/Bug888463
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Michael Vogt Pending
Review via email: mp+81820@code.launchpad.net

Description of the change

A possible fix for Bug#888463.

Rows outside of the visible range do not currently get their height property updated when requested. Overcome this by checking if row is not in visible range when height update requested; if true, store the row for a time when it re-enters the visible range, and only then process the height update.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Does the trick, thanks Matt!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/widgets/apptreeview.py'
2--- softwarecenter/ui/gtk3/widgets/apptreeview.py 2011-11-09 10:09:16 +0000
3+++ softwarecenter/ui/gtk3/widgets/apptreeview.py 2011-11-10 09:50:26 +0000
4@@ -18,8 +18,8 @@
5 from softwarecenter.backend import get_install_backend
6 from softwarecenter.netstatus import (get_network_watcher,
7 network_state_is_connected)
8-from softwarecenter.ui.gtk3.models.appstore2 import (AppGenericStore,
9- CategoryRowReference)
10+from softwarecenter.ui.gtk3.models.appstore2 import (
11+ AppGenericStore, CategoryRowReference)
12
13
14 class AppTreeView(Gtk.TreeView):
15@@ -43,6 +43,7 @@
16 self.pressed = False
17 self.focal_btn = None
18 self._action_block_list = []
19+ self._needs_collapse = []
20 self.expanded_path = None
21
22 #~ # if this hacked mode is available everything will be fast
23@@ -126,24 +127,32 @@
24 if vadjustment:
25 vadjustment.set_value(0)
26 self.expanded_path = None
27+ self._needs_collapse = []
28 if self.appmodel:
29 self.appmodel.clear()
30
31 def expand_path(self, path):
32 if path is not None and not isinstance(path, Gtk.TreePath):
33- raise TypeError, "Expects Gtk.TreePath or None, got %s" % type(path)
34+ raise TypeError, ("Expects Gtk.TreePath or None, got %s" %
35+ type(path))
36
37 model = self.get_model()
38 old = self.expanded_path
39 self.expanded_path = path
40
41 if old is not None:
42- try:
43- # lazy solution to Bug #846204
44- model.row_changed(old, model.get_iter(old))
45- except:
46- msg = "apptreeview.expand_path: Supplied 'old' path is an invalid tree path: '%s'" % old
47- logging.debug(msg)
48+ ok, start, end = self.get_visible_range()
49+ if (ok and start.compare(old) != -1 or
50+ end.compare(old) != 1):
51+ self._needs_collapse.append(old)
52+ else:
53+ try: # try... a lazy solution to Bug #846204
54+ model.row_changed(old, model.get_iter(old))
55+ except:
56+ msg = ("apptreeview.expand_path: Supplied 'old' "
57+ "path is an invalid tree path: '%s'" % old)
58+ logging.debug(msg)
59+
60 if path == None: return
61
62 model.row_changed(path, model.get_iter(path))
63@@ -313,8 +322,8 @@
64 else:
65 action_btn.set_state(Gtk.StateFlags.NORMAL)
66
67- #~ self.emit("application-selected", self.appmodel.get_application(app))
68- self.app_view.emit("application-selected", self.appmodel.get_application(app))
69+ self.app_view.emit(
70+ "application-selected", self.appmodel.get_application(app))
71 return False
72
73 def _on_row_activated(self, view, path, column, tr):
74@@ -456,8 +465,16 @@
75 indices = path.get_indices()
76 model.load_range(indices, 5)
77
78- is_active = path == self.expanded_path
79- cell.set_property('isactive', is_active)
80+ if path in self._needs_collapse:
81+ # collapse rows that were outside the visible range and
82+ # thus not immediately collapsed when expand_path was called
83+ cell.set_property('isactive', False)
84+ i = self._needs_collapse.index(path)
85+ del self._needs_collapse[i]
86+ model.row_changed(path, it)
87+ return
88+
89+ cell.set_property('isactive', path == self.expanded_path)
90 return
91
92 def _app_activated_cb(self, btn, btn_id, app, store, path):
93@@ -561,10 +578,6 @@
94 return self.get_path_at_pos(x, y)[0] == self.get_cursor()[0]
95
96
97-
98-
99-
100-
101 def get_query_from_search_entry(search_term):
102 if not search_term:
103 return xapian.Query("")