Merge lp:~didrocks/software-center/smarter-app-filtering-level into lp:software-center

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
Reviewer Review Type Date Requested Status
Mohamed Amine Ilidrissi (community) Approve
software-store-developers Pending
Review via email: mp+37366@code.launchpad.net

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 :

I didn't notice any speed improvements in searching "linux 2.6.35". Or is this only foundations for more improvements?

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
=== modified file 'softwarecenter/view/appview.py'
--- softwarecenter/view/appview.py 2010-09-29 17:45:55 +0000
+++ softwarecenter/view/appview.py 2010-10-02 21:16:44 +0000
@@ -97,11 +97,15 @@
97 # the default result size for a search97 # the default result size for a search
98 DEFAULT_SEARCH_LIMIT = 20098 DEFAULT_SEARCH_LIMIT = 200
9999
100 (NONAPPS_ALWAYS_VISIBLE,
101 NONAPPS_MAYBE_VISIBLE,
102 NONAPPS_NEVER_VISIBLE) = range (3)
103
100 def __init__(self, cache, db, icons, search_query=None, 104 def __init__(self, cache, db, icons, search_query=None,
101 limit=DEFAULT_SEARCH_LIMIT,105 limit=DEFAULT_SEARCH_LIMIT,
102 sortmode=SORT_UNSORTED, filter=None, exact=False,106 sortmode=SORT_UNSORTED, filter=None, exact=False,
103 icon_size=ICON_SIZE, global_icon_cache=True, 107 icon_size=ICON_SIZE, global_icon_cache=True,
104 nonapps_visible=False):108 nonapps_visible=NONAPPS_MAYBE_VISIBLE):
105 """109 """
106 Initalize a AppStore.110 Initalize a AppStore.
107111
@@ -117,6 +121,11 @@
117 - `exact`: If true, indexes of queries without matches will be121 - `exact`: If true, indexes of queries without matches will be
118 maintained in the store (useful to show e.g. a row122 maintained in the store (useful to show e.g. a row
119 with "??? not found")123 with "??? not found")
124 - `nonapps_visible`: decide whether adding non apps in the model or not.
125 Can be NONAPPS_ALWAYS_VISIBLE/NONAPPS_MAYBE_VISIBLE
126 /NONAPPS_NEVER_VISIBLE
127 (NONAPPS_MAYBE_VISIBLE will return non apps result
128 if no matching apps is found)
120 """129 """
121 gtk.GenericTreeModel.__init__(self)130 gtk.GenericTreeModel.__init__(self)
122 self._logger = logging.getLogger("softwarecenter.view.appstore")131 self._logger = logging.getLogger("softwarecenter.view.appstore")
@@ -176,7 +185,7 @@
176 for q in self.search_query:185 for q in self.search_query:
177 self._logger.debug("using query: '%s'" % q)186 self._logger.debug("using query: '%s'" % q)
178 enquire = xapian.Enquire(self.db.xapiandb)187 enquire = xapian.Enquire(self.db.xapiandb)
179 if not self.nonapps_visible:188 if self.nonapps_visible != self.NONAPPS_ALWAYS_VISIBLE:
180 enquire.set_query(xapian.Query(xapian.Query.OP_AND_NOT, 189 enquire.set_query(xapian.Query(xapian.Query.OP_AND_NOT,
181 q, xapian.Query("ATapplication")))190 q, xapian.Query("ATapplication")))
182191
@@ -228,7 +237,7 @@
228 # FIXME: falsely assuming that apps come before nonapps237 # FIXME: falsely assuming that apps come before nonapps
229 if not appname:238 if not appname:
230 added = pkgname in already_added239 added = pkgname in already_added
231 if self.nonapps_visible and not added:240 if self.nonapps_visible == self.NONAPPS_ALWAYS_VISIBLE and not added:
232 self.nonapp_pkgs += 1241 self.nonapp_pkgs += 1
233 if appname or not added:242 if appname or not added:
234 if self.sortmode == SORT_BY_ALPHABET:243 if self.sortmode == SORT_BY_ALPHABET:
@@ -251,11 +260,12 @@
251 app = Application("", pkgname)260 app = Application("", pkgname)
252 self.apps.append(app)261 self.apps.append(app)
253 262
254 # if we only have nonapps to be displayed, don't hide them263 # if we only have nonapps to be displayed, and nonapps is set as
255 if (not self.nonapps_visible and264 # NONAPPS_MAYBE_VISIBLE don't hide them
265 if (self.nonapps_visible == self.NONAPPS_MAYBE_VISIBLE and
256 self.nonapp_pkgs > 0 and266 self.nonapp_pkgs > 0 and
257 len(self.apps) == 0):267 len(self.apps) == 0):
258 self.nonapps_visible = True268 self.nonapps_visible = self.NONAPPS_ALWAYS_VISIBLE
259 self._perform_search()269 self._perform_search()
260 270
261 # in the case where the app list is sorted, we must rebuild271 # in the case where the app list is sorted, we must rebuild
262272
=== modified file 'softwarecenter/view/availablepane.py'
--- softwarecenter/view/availablepane.py 2010-09-15 22:24:45 +0000
+++ softwarecenter/view/availablepane.py 2010-10-02 21:16:44 +0000
@@ -255,7 +255,7 @@
255 # special case to disable hide nonapps for the "Featured Applications" category255 # special case to disable hide nonapps for the "Featured Applications" category
256 if (self.apps_category and 256 if (self.apps_category and
257 self.apps_category.untranslated_name) == "Featured":257 self.apps_category.untranslated_name) == "Featured":
258 self.nonapps_visible = True258 self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE
259 # In custom list mode, search should yield the exact package name.259 # In custom list mode, search should yield the exact package name.
260 new_model = AppStore(self.cache,260 new_model = AppStore(self.cache,
261 self.db,261 self.db,
262262
=== modified file 'softwarecenter/view/catview_gtk.py'
--- softwarecenter/view/catview_gtk.py 2010-09-15 09:09:58 +0000
+++ softwarecenter/view/catview_gtk.py 2010-10-02 21:16:44 +0000
@@ -346,7 +346,7 @@
346 filter=self.apps_filter,346 filter=self.apps_filter,
347 icon_size=best_stock_size,347 icon_size=best_stock_size,
348 global_icon_cache=False,348 global_icon_cache=False,
349 nonapps_visible=False)349 nonapps_visible=AppStore.NONAPPS_MAYBE_VISIBLE)
350350
351 self.featured_carousel = CarouselView(featured_apps, _('Featured'), self.icons)351 self.featured_carousel = CarouselView(featured_apps, _('Featured'), self.icons)
352 self.featured_carousel.more_btn.connect('clicked',352 self.featured_carousel.more_btn.connect('clicked',
@@ -368,7 +368,7 @@
368 self.apps_filter,368 self.apps_filter,
369 icon_size=best_stock_size,369 icon_size=best_stock_size,
370 global_icon_cache=False,370 global_icon_cache=False,
371 nonapps_visible=False)371 nonapps_visible=AppStore.NONAPPS_MAYBE_VISIBLE)
372 self.newapps_carousel = CarouselView(372 self.newapps_carousel = CarouselView(
373 new_apps, _(u"What\u2019s New"), self.icons,373 new_apps, _(u"What\u2019s New"), self.icons,
374 start_random=False)374 start_random=False)
375375
=== modified file 'softwarecenter/view/channelpane.py'
--- softwarecenter/view/channelpane.py 2010-09-23 01:34:43 +0000
+++ softwarecenter/view/channelpane.py 2010-10-02 21:16:44 +0000
@@ -190,10 +190,10 @@
190 # always show all packages in the partner repository190 # always show all packages in the partner repository
191 # FIXME: remove this special case code in favor of a more general solution191 # FIXME: remove this special case code in favor of a more general solution
192 if channel.get_channel_component() == "partner":192 if channel.get_channel_component() == "partner":
193 self.nonapps_visible = True193 self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE
194 self.disable_show_hide_nonapps = True194 self.disable_show_hide_nonapps = True
195 else:195 else:
196 self.nonapps_visible = False196 self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE
197 self.disable_show_hide_nonapps = False197 self.disable_show_hide_nonapps = False
198 self.apps_filter = None198 self.apps_filter = None
199 if self.channel.only_packages_without_applications:199 if self.channel.only_packages_without_applications:
200200
=== modified file 'softwarecenter/view/softwarepane.py'
--- softwarecenter/view/softwarepane.py 2010-09-27 15:12:40 +0000
+++ softwarecenter/view/softwarepane.py 2010-10-02 21:16:44 +0000
@@ -151,7 +151,7 @@
151 self.icons = icons151 self.icons = icons
152 self.datadir = datadir152 self.datadir = datadir
153 self.backend = get_install_backend()153 self.backend = get_install_backend()
154 self.nonapps_visible = False154 self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE
155 self.disable_show_hide_nonapps = False155 self.disable_show_hide_nonapps = False
156 # refreshes can happen out-of-bound so we need to be sure156 # refreshes can happen out-of-bound so we need to be sure
157 # that we only set the new model (when its available) if157 # that we only set the new model (when its available) if
@@ -326,7 +326,7 @@
326 pkgs = 0326 pkgs = 0
327 apps = 0327 apps = 0
328 if appstore.active:328 if appstore.active:
329 if appstore.nonapps_visible:329 if appstore.nonapps_visible == AppStore.NONAPPS_ALWAYS_VISIBLE:
330 pkgs = appstore.nonapp_pkgs330 pkgs = appstore.nonapp_pkgs
331 apps = len(appstore) - pkgs331 apps = len(appstore) - pkgs
332 else:332 else:
@@ -353,7 +353,7 @@
353 pkgs > 0 and 353 pkgs > 0 and
354 apps > 0 and354 apps > 0 and
355 not self.disable_show_hide_nonapps):355 not self.disable_show_hide_nonapps):
356 if appstore.nonapps_visible:356 if appstore.nonapps_visible == AppStore.NONAPPS_ALWAYS_VISIBLE:
357 # TRANSLATORS: the text inbetween the underscores acts as a link357 # TRANSLATORS: the text inbetween the underscores acts as a link
358 # In most/all languages you will want the whole string as a link358 # In most/all languages you will want the whole string as a link
359 label = gettext.ngettext("_Hide %i technical item_",359 label = gettext.ngettext("_Hide %i technical item_",
@@ -367,11 +367,11 @@
367 self.action_bar.set_label(label, self._show_nonapp_pkgs)367 self.action_bar.set_label(label, self._show_nonapp_pkgs)
368 368
369 def _show_nonapp_pkgs(self):369 def _show_nonapp_pkgs(self):
370 self.nonapps_visible = True370 self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE
371 self.refresh_apps()371 self.refresh_apps()
372372
373 def _hide_nonapp_pkgs(self):373 def _hide_nonapp_pkgs(self):
374 self.nonapps_visible = False374 self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE
375 self.refresh_apps()375 self.refresh_apps()
376376
377 def get_status_text(self):377 def get_status_text(self):
378378
=== modified file 'test/test_appview.py'
--- test/test_appview.py 2010-09-08 03:13:07 +0000
+++ test/test_appview.py 2010-10-02 21:16:44 +0000
@@ -96,7 +96,7 @@
96 store = AppStore(self.cache, self.db, self.mock_icons, 96 store = AppStore(self.cache, self.db, self.mock_icons,
97 sortmode=SORT_BY_CATALOGED_TIME,97 sortmode=SORT_BY_CATALOGED_TIME,
98 limit=20, search_query=query,98 limit=20, search_query=query,
99 nonapps_visible=True)99 nonapps_visible=AppStore.NONAPPS_ALWAYS_VISIBLE)
100 for item in store:100 for item in store:
101 sorted_by_appstore.append(item[AppStore.COL_PKGNAME])101 sorted_by_appstore.append(item[AppStore.COL_PKGNAME])
102 self.assertEqual(sorted_by_axi, sorted_by_appstore)102 self.assertEqual(sorted_by_axi, sorted_by_appstore)
@@ -157,12 +157,12 @@
157 store = AppStore(157 store = AppStore(
158 self.cache, self.db, self.mock_icons,158 self.cache, self.db, self.mock_icons,
159 search_query = xapian.Query(""), 159 search_query = xapian.Query(""),
160 nonapps_visible = False)160 nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE)
161 not_visible = store.nonapp_pkgs161 not_visible = store.nonapp_pkgs
162 store = AppStore(162 store = AppStore(
163 self.cache, self.db, self.mock_icons,163 self.cache, self.db, self.mock_icons,
164 search_query = xapian.Query(""),164 search_query = xapian.Query(""),
165 nonapps_visible = True)165 nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE)
166 visible = store.nonapp_pkgs166 visible = store.nonapp_pkgs
167 self.assertTrue(visible < not_visible)167 self.assertTrue(visible < not_visible)
168168