Merge lp:~jjed/software-center/smooth_search into lp:software-center

Proposed by Jjed
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jjed/software-center/smooth_search
Merge into: lp:software-center
Diff against target: 95 lines (+49/-16)
2 files modified
softwarecenter/view/appview.py (+44/-0)
softwarecenter/view/softwarepane.py (+5/-16)
To merge this branch: bzr merge lp:~jjed/software-center/smooth_search
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+23933@code.launchpad.net

Description of the change

In the current trunk, updating the searchbox causes the application view to replace its model entirely. This causes a distracting white flash while the new model loads in.

This branch reimplements set_model() in AppView so that the model is only updated, not replaced when the new model and old model are both application stores. Search is much, much less jerky now.

To test, just try searching.

NOTE: If you decide to merge this in conjunction with my custom_lists branch, the `exact`, `installable_apps`, and `existing_apps` variables must be copied at the end of the update method.

To post a comment you must log in.
743. By Jacob Johan Edwards <jacob@jacob-laptop>

Match behavior of selected apps in view to trunk.

Note that this revision strips a lot of extra checks and "redo to be sure"
patches of code from softwarepane.py's update_app_view(). I am unable to find
a situation where they are necessary, and one of them was overprotecting and
caused the bug necessitating this revision.

Revision history for this message
Michael Vogt (mvo) wrote :

Very very nice work, I love it. I created bug #570682 so that we can hopefully get it into lucid-updates too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/view/appview.py'
2--- softwarecenter/view/appview.py 2010-04-18 11:35:39 +0000
3+++ softwarecenter/view/appview.py 2010-04-23 23:46:27 +0000
4@@ -193,6 +193,37 @@
5 self.pkgname_index_map[app.pkgname] = []
6 self.pkgname_index_map[app.pkgname].append(i)
7
8+ def update(self, appstore):
9+ """ update this appstore to match data from another """
10+ # Updating instead of replacing prevents a distracting white
11+ # flash. First, match list of apps.
12+ to_update = min(len(self), len(appstore))
13+ for i in range(to_update):
14+ self.apps[i] = appstore.apps[i]
15+ self.row_changed(i, self.get_iter(i))
16+
17+ to_remove = max(0, len(self) - len(appstore))
18+ for i in range(to_remove):
19+ self.apps.pop()
20+ self.row_deleted(len(self))
21+
22+ to_add = max(0, len(appstore) - len(self))
23+ apps_to_add = appstore.apps[len(appstore) - to_add:]
24+ for app in apps_to_add:
25+ path = len(self)
26+ self.apps.append(app)
27+ self.row_inserted(path, self.get_iter(path))
28+
29+ # Next, match data about the store.
30+ self.cache = appstore.cache
31+ self.db = appstore.db
32+ self.icons = appstore.icons
33+ self.search_query = appstore.search_query
34+ self.sorted = appstore.sorted
35+ self.filter = appstore.filter
36+ self.app_index_map = appstore.app_index_map
37+ self.pkgname_index_map = appstore.pkgname_index_map
38+
39 def is_filtered_out(self, filter, doc):
40 """ apply filter and return True if the package is filtered out """
41 pkgname = self.db.get_pkgname(doc)
42@@ -937,6 +968,19 @@
43 self.backend.connect("transaction-finished", self._on_transaction_finished)
44 self.backend.connect("transaction-stopped", self._on_transaction_stopped)
45
46+ def set_model(self, new_model):
47+ # Only allow use of an AppStore model
48+ if type(new_model) != AppStore:
49+ return
50+ model = self.get_model()
51+
52+ # If there is no current model, simply set the new one.
53+ if not model:
54+ super(AppView, self).set_model(new_model)
55+ # Otherwise update the current model using the new data.
56+ else:
57+ model.update(new_model)
58+
59 def is_action_in_progress_for_selected_app(self):
60 """
61 return True if an install or remove of the current package
62
63=== modified file 'softwarecenter/view/softwarepane.py'
64--- softwarecenter/view/softwarepane.py 2010-04-13 15:54:16 +0000
65+++ softwarecenter/view/softwarepane.py 2010-04-23 23:46:27 +0000
66@@ -170,24 +170,13 @@
67 first app in the list is selected. If a row is already selected,
68 nothing is done.
69 """
70- selected_iter = None
71- selection = self.app_view.get_selection()
72 model = self.app_view.get_model()
73- if selection:
74- selected_iter = selection.get_selected()[1]
75 current_app = self.get_current_app()
76- if (model is not None and
77- model.get_iter_root() is not None
78- and selected_iter is None):
79- index=0
80- vadj = self.scroll_app_list.get_vadjustment()
81- if current_app:
82- if current_app in model.app_index_map:
83- index = model.app_index_map.get(current_app)
84- # re-select item
85- if vadj:
86- self.app_view.set_cursor(index)
87- vadj.value_changed()
88+
89+ index = 0
90+ if current_app in model.app_index_map:
91+ index = model.app_index_map.get(current_app)
92+ self.app_view.set_cursor(index)
93
94 def get_status_text(self):
95 """return user readable status text suitable for a status bar"""

Subscribers

People subscribed via source and target branches