Merge lp:~didrocks/software-center/smarter-app-filtering-level into lp:software-center
- smarter-app-filtering-level
- Merge into trunk
Proposed by
Didier Roche-Tolomelli
Status: | Merged |
---|---|
Merged at revision: | 1245 |
Proposed branch: | lp:~didrocks/software-center/smarter-app-filtering-level |
Merge into: | lp:software-center |
Diff against target: |
190 lines (+29/-19) 6 files modified
softwarecenter/view/appview.py (+16/-6) softwarecenter/view/availablepane.py (+1/-1) softwarecenter/view/catview_gtk.py (+2/-2) softwarecenter/view/channelpane.py (+2/-2) softwarecenter/view/softwarepane.py (+5/-5) test/test_appview.py (+3/-3) |
To merge this branch: | bzr merge lp:~didrocks/software-center/smarter-app-filtering-level |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mohamed Amine Ilidrissi (community) | Approve | ||
software-store-developers | Pending | ||
Review via email: mp+37366@code.launchpad.net |
Commit message
Description of the change
Add as discussed the new levels of control for nonapp_visible switch in AppStore. More info in the commit message.
To post a comment you must log in.
- 1244. By Didier Roche-Tolomelli
-
fix an encoded 'always' to the constant in the test
Revision history for this message
Mohamed Amine Ilidrissi (ilidrissi.amine) wrote : | # |
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote : | # |
Yeah, for now, you will have nothing more in Software-Center itself as I don't activate this new mode. In OneConf, you will have access to it and the difference is already noticeable.
The change has already been discussed with Michael previous week.
Revision history for this message
Mohamed Amine Ilidrissi (ilidrissi.amine) wrote : | # |
> Yeah, for now, you will have nothing more in Software-Center itself as I don't
> activate this new mode. In OneConf, you will have access to it and the
> difference is already noticeable.
>
> The change has already been discussed with Michael previous week.
Thanks for this insight! Besides, the code looks good.
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-09-29 17:45:55 +0000 | |||
3 | +++ softwarecenter/view/appview.py 2010-10-02 21:16:44 +0000 | |||
4 | @@ -97,11 +97,15 @@ | |||
5 | 97 | # the default result size for a search | 97 | # the default result size for a search |
6 | 98 | DEFAULT_SEARCH_LIMIT = 200 | 98 | DEFAULT_SEARCH_LIMIT = 200 |
7 | 99 | 99 | ||
8 | 100 | (NONAPPS_ALWAYS_VISIBLE, | ||
9 | 101 | NONAPPS_MAYBE_VISIBLE, | ||
10 | 102 | NONAPPS_NEVER_VISIBLE) = range (3) | ||
11 | 103 | |||
12 | 100 | def __init__(self, cache, db, icons, search_query=None, | 104 | def __init__(self, cache, db, icons, search_query=None, |
13 | 101 | limit=DEFAULT_SEARCH_LIMIT, | 105 | limit=DEFAULT_SEARCH_LIMIT, |
14 | 102 | sortmode=SORT_UNSORTED, filter=None, exact=False, | 106 | sortmode=SORT_UNSORTED, filter=None, exact=False, |
15 | 103 | icon_size=ICON_SIZE, global_icon_cache=True, | 107 | icon_size=ICON_SIZE, global_icon_cache=True, |
17 | 104 | nonapps_visible=False): | 108 | nonapps_visible=NONAPPS_MAYBE_VISIBLE): |
18 | 105 | """ | 109 | """ |
19 | 106 | Initalize a AppStore. | 110 | Initalize a AppStore. |
20 | 107 | 111 | ||
21 | @@ -117,6 +121,11 @@ | |||
22 | 117 | - `exact`: If true, indexes of queries without matches will be | 121 | - `exact`: If true, indexes of queries without matches will be |
23 | 118 | maintained in the store (useful to show e.g. a row | 122 | maintained in the store (useful to show e.g. a row |
24 | 119 | with "??? not found") | 123 | with "??? not found") |
25 | 124 | - `nonapps_visible`: decide whether adding non apps in the model or not. | ||
26 | 125 | Can be NONAPPS_ALWAYS_VISIBLE/NONAPPS_MAYBE_VISIBLE | ||
27 | 126 | /NONAPPS_NEVER_VISIBLE | ||
28 | 127 | (NONAPPS_MAYBE_VISIBLE will return non apps result | ||
29 | 128 | if no matching apps is found) | ||
30 | 120 | """ | 129 | """ |
31 | 121 | gtk.GenericTreeModel.__init__(self) | 130 | gtk.GenericTreeModel.__init__(self) |
32 | 122 | self._logger = logging.getLogger("softwarecenter.view.appstore") | 131 | self._logger = logging.getLogger("softwarecenter.view.appstore") |
33 | @@ -176,7 +185,7 @@ | |||
34 | 176 | for q in self.search_query: | 185 | for q in self.search_query: |
35 | 177 | self._logger.debug("using query: '%s'" % q) | 186 | self._logger.debug("using query: '%s'" % q) |
36 | 178 | enquire = xapian.Enquire(self.db.xapiandb) | 187 | enquire = xapian.Enquire(self.db.xapiandb) |
38 | 179 | if not self.nonapps_visible: | 188 | if self.nonapps_visible != self.NONAPPS_ALWAYS_VISIBLE: |
39 | 180 | enquire.set_query(xapian.Query(xapian.Query.OP_AND_NOT, | 189 | enquire.set_query(xapian.Query(xapian.Query.OP_AND_NOT, |
40 | 181 | q, xapian.Query("ATapplication"))) | 190 | q, xapian.Query("ATapplication"))) |
41 | 182 | 191 | ||
42 | @@ -228,7 +237,7 @@ | |||
43 | 228 | # FIXME: falsely assuming that apps come before nonapps | 237 | # FIXME: falsely assuming that apps come before nonapps |
44 | 229 | if not appname: | 238 | if not appname: |
45 | 230 | added = pkgname in already_added | 239 | added = pkgname in already_added |
47 | 231 | if self.nonapps_visible and not added: | 240 | if self.nonapps_visible == self.NONAPPS_ALWAYS_VISIBLE and not added: |
48 | 232 | self.nonapp_pkgs += 1 | 241 | self.nonapp_pkgs += 1 |
49 | 233 | if appname or not added: | 242 | if appname or not added: |
50 | 234 | if self.sortmode == SORT_BY_ALPHABET: | 243 | if self.sortmode == SORT_BY_ALPHABET: |
51 | @@ -251,11 +260,12 @@ | |||
52 | 251 | app = Application("", pkgname) | 260 | app = Application("", pkgname) |
53 | 252 | self.apps.append(app) | 261 | self.apps.append(app) |
54 | 253 | 262 | ||
57 | 254 | # if we only have nonapps to be displayed, don't hide them | 263 | # if we only have nonapps to be displayed, and nonapps is set as |
58 | 255 | if (not self.nonapps_visible and | 264 | # NONAPPS_MAYBE_VISIBLE don't hide them |
59 | 265 | if (self.nonapps_visible == self.NONAPPS_MAYBE_VISIBLE and | ||
60 | 256 | self.nonapp_pkgs > 0 and | 266 | self.nonapp_pkgs > 0 and |
61 | 257 | len(self.apps) == 0): | 267 | len(self.apps) == 0): |
63 | 258 | self.nonapps_visible = True | 268 | self.nonapps_visible = self.NONAPPS_ALWAYS_VISIBLE |
64 | 259 | self._perform_search() | 269 | self._perform_search() |
65 | 260 | 270 | ||
66 | 261 | # in the case where the app list is sorted, we must rebuild | 271 | # in the case where the app list is sorted, we must rebuild |
67 | 262 | 272 | ||
68 | === modified file 'softwarecenter/view/availablepane.py' | |||
69 | --- softwarecenter/view/availablepane.py 2010-09-15 22:24:45 +0000 | |||
70 | +++ softwarecenter/view/availablepane.py 2010-10-02 21:16:44 +0000 | |||
71 | @@ -255,7 +255,7 @@ | |||
72 | 255 | # special case to disable hide nonapps for the "Featured Applications" category | 255 | # special case to disable hide nonapps for the "Featured Applications" category |
73 | 256 | if (self.apps_category and | 256 | if (self.apps_category and |
74 | 257 | self.apps_category.untranslated_name) == "Featured": | 257 | self.apps_category.untranslated_name) == "Featured": |
76 | 258 | self.nonapps_visible = True | 258 | self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE |
77 | 259 | # In custom list mode, search should yield the exact package name. | 259 | # In custom list mode, search should yield the exact package name. |
78 | 260 | new_model = AppStore(self.cache, | 260 | new_model = AppStore(self.cache, |
79 | 261 | self.db, | 261 | self.db, |
80 | 262 | 262 | ||
81 | === modified file 'softwarecenter/view/catview_gtk.py' | |||
82 | --- softwarecenter/view/catview_gtk.py 2010-09-15 09:09:58 +0000 | |||
83 | +++ softwarecenter/view/catview_gtk.py 2010-10-02 21:16:44 +0000 | |||
84 | @@ -346,7 +346,7 @@ | |||
85 | 346 | filter=self.apps_filter, | 346 | filter=self.apps_filter, |
86 | 347 | icon_size=best_stock_size, | 347 | icon_size=best_stock_size, |
87 | 348 | global_icon_cache=False, | 348 | global_icon_cache=False, |
89 | 349 | nonapps_visible=False) | 349 | nonapps_visible=AppStore.NONAPPS_MAYBE_VISIBLE) |
90 | 350 | 350 | ||
91 | 351 | self.featured_carousel = CarouselView(featured_apps, _('Featured'), self.icons) | 351 | self.featured_carousel = CarouselView(featured_apps, _('Featured'), self.icons) |
92 | 352 | self.featured_carousel.more_btn.connect('clicked', | 352 | self.featured_carousel.more_btn.connect('clicked', |
93 | @@ -368,7 +368,7 @@ | |||
94 | 368 | self.apps_filter, | 368 | self.apps_filter, |
95 | 369 | icon_size=best_stock_size, | 369 | icon_size=best_stock_size, |
96 | 370 | global_icon_cache=False, | 370 | global_icon_cache=False, |
98 | 371 | nonapps_visible=False) | 371 | nonapps_visible=AppStore.NONAPPS_MAYBE_VISIBLE) |
99 | 372 | self.newapps_carousel = CarouselView( | 372 | self.newapps_carousel = CarouselView( |
100 | 373 | new_apps, _(u"What\u2019s New"), self.icons, | 373 | new_apps, _(u"What\u2019s New"), self.icons, |
101 | 374 | start_random=False) | 374 | start_random=False) |
102 | 375 | 375 | ||
103 | === modified file 'softwarecenter/view/channelpane.py' | |||
104 | --- softwarecenter/view/channelpane.py 2010-09-23 01:34:43 +0000 | |||
105 | +++ softwarecenter/view/channelpane.py 2010-10-02 21:16:44 +0000 | |||
106 | @@ -190,10 +190,10 @@ | |||
107 | 190 | # always show all packages in the partner repository | 190 | # always show all packages in the partner repository |
108 | 191 | # FIXME: remove this special case code in favor of a more general solution | 191 | # FIXME: remove this special case code in favor of a more general solution |
109 | 192 | if channel.get_channel_component() == "partner": | 192 | if channel.get_channel_component() == "partner": |
111 | 193 | self.nonapps_visible = True | 193 | self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE |
112 | 194 | self.disable_show_hide_nonapps = True | 194 | self.disable_show_hide_nonapps = True |
113 | 195 | else: | 195 | else: |
115 | 196 | self.nonapps_visible = False | 196 | self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE |
116 | 197 | self.disable_show_hide_nonapps = False | 197 | self.disable_show_hide_nonapps = False |
117 | 198 | self.apps_filter = None | 198 | self.apps_filter = None |
118 | 199 | if self.channel.only_packages_without_applications: | 199 | if self.channel.only_packages_without_applications: |
119 | 200 | 200 | ||
120 | === modified file 'softwarecenter/view/softwarepane.py' | |||
121 | --- softwarecenter/view/softwarepane.py 2010-09-27 15:12:40 +0000 | |||
122 | +++ softwarecenter/view/softwarepane.py 2010-10-02 21:16:44 +0000 | |||
123 | @@ -151,7 +151,7 @@ | |||
124 | 151 | self.icons = icons | 151 | self.icons = icons |
125 | 152 | self.datadir = datadir | 152 | self.datadir = datadir |
126 | 153 | self.backend = get_install_backend() | 153 | self.backend = get_install_backend() |
128 | 154 | self.nonapps_visible = False | 154 | self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE |
129 | 155 | self.disable_show_hide_nonapps = False | 155 | self.disable_show_hide_nonapps = False |
130 | 156 | # refreshes can happen out-of-bound so we need to be sure | 156 | # refreshes can happen out-of-bound so we need to be sure |
131 | 157 | # that we only set the new model (when its available) if | 157 | # that we only set the new model (when its available) if |
132 | @@ -326,7 +326,7 @@ | |||
133 | 326 | pkgs = 0 | 326 | pkgs = 0 |
134 | 327 | apps = 0 | 327 | apps = 0 |
135 | 328 | if appstore.active: | 328 | if appstore.active: |
137 | 329 | if appstore.nonapps_visible: | 329 | if appstore.nonapps_visible == AppStore.NONAPPS_ALWAYS_VISIBLE: |
138 | 330 | pkgs = appstore.nonapp_pkgs | 330 | pkgs = appstore.nonapp_pkgs |
139 | 331 | apps = len(appstore) - pkgs | 331 | apps = len(appstore) - pkgs |
140 | 332 | else: | 332 | else: |
141 | @@ -353,7 +353,7 @@ | |||
142 | 353 | pkgs > 0 and | 353 | pkgs > 0 and |
143 | 354 | apps > 0 and | 354 | apps > 0 and |
144 | 355 | not self.disable_show_hide_nonapps): | 355 | not self.disable_show_hide_nonapps): |
146 | 356 | if appstore.nonapps_visible: | 356 | if appstore.nonapps_visible == AppStore.NONAPPS_ALWAYS_VISIBLE: |
147 | 357 | # TRANSLATORS: the text inbetween the underscores acts as a link | 357 | # TRANSLATORS: the text inbetween the underscores acts as a link |
148 | 358 | # In most/all languages you will want the whole string as a link | 358 | # In most/all languages you will want the whole string as a link |
149 | 359 | label = gettext.ngettext("_Hide %i technical item_", | 359 | label = gettext.ngettext("_Hide %i technical item_", |
150 | @@ -367,11 +367,11 @@ | |||
151 | 367 | self.action_bar.set_label(label, self._show_nonapp_pkgs) | 367 | self.action_bar.set_label(label, self._show_nonapp_pkgs) |
152 | 368 | 368 | ||
153 | 369 | def _show_nonapp_pkgs(self): | 369 | def _show_nonapp_pkgs(self): |
155 | 370 | self.nonapps_visible = True | 370 | self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE |
156 | 371 | self.refresh_apps() | 371 | self.refresh_apps() |
157 | 372 | 372 | ||
158 | 373 | def _hide_nonapp_pkgs(self): | 373 | def _hide_nonapp_pkgs(self): |
160 | 374 | self.nonapps_visible = False | 374 | self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE |
161 | 375 | self.refresh_apps() | 375 | self.refresh_apps() |
162 | 376 | 376 | ||
163 | 377 | def get_status_text(self): | 377 | def get_status_text(self): |
164 | 378 | 378 | ||
165 | === modified file 'test/test_appview.py' | |||
166 | --- test/test_appview.py 2010-09-08 03:13:07 +0000 | |||
167 | +++ test/test_appview.py 2010-10-02 21:16:44 +0000 | |||
168 | @@ -96,7 +96,7 @@ | |||
169 | 96 | store = AppStore(self.cache, self.db, self.mock_icons, | 96 | store = AppStore(self.cache, self.db, self.mock_icons, |
170 | 97 | sortmode=SORT_BY_CATALOGED_TIME, | 97 | sortmode=SORT_BY_CATALOGED_TIME, |
171 | 98 | limit=20, search_query=query, | 98 | limit=20, search_query=query, |
173 | 99 | nonapps_visible=True) | 99 | nonapps_visible=AppStore.NONAPPS_ALWAYS_VISIBLE) |
174 | 100 | for item in store: | 100 | for item in store: |
175 | 101 | sorted_by_appstore.append(item[AppStore.COL_PKGNAME]) | 101 | sorted_by_appstore.append(item[AppStore.COL_PKGNAME]) |
176 | 102 | self.assertEqual(sorted_by_axi, sorted_by_appstore) | 102 | self.assertEqual(sorted_by_axi, sorted_by_appstore) |
177 | @@ -157,12 +157,12 @@ | |||
178 | 157 | store = AppStore( | 157 | store = AppStore( |
179 | 158 | self.cache, self.db, self.mock_icons, | 158 | self.cache, self.db, self.mock_icons, |
180 | 159 | search_query = xapian.Query(""), | 159 | search_query = xapian.Query(""), |
182 | 160 | nonapps_visible = False) | 160 | nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE) |
183 | 161 | not_visible = store.nonapp_pkgs | 161 | not_visible = store.nonapp_pkgs |
184 | 162 | store = AppStore( | 162 | store = AppStore( |
185 | 163 | self.cache, self.db, self.mock_icons, | 163 | self.cache, self.db, self.mock_icons, |
186 | 164 | search_query = xapian.Query(""), | 164 | search_query = xapian.Query(""), |
188 | 165 | nonapps_visible = True) | 165 | nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE) |
189 | 166 | visible = store.nonapp_pkgs | 166 | visible = store.nonapp_pkgs |
190 | 167 | self.assertTrue(visible < not_visible) | 167 | self.assertTrue(visible < not_visible) |
191 | 168 | 168 |
I didn't notice any speed improvements in searching "linux 2.6.35". Or is this only foundations for more improvements?