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

Proposed by Didier Roche on 2010-10-02
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 on 2010-10-03
software-store-developers 2010-10-02 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 on 2010-10-02

fix an encoded 'always' to the constant in the test

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

Didier Roche (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.

> 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 # the default result size for a search
6 DEFAULT_SEARCH_LIMIT = 200
7
8+ (NONAPPS_ALWAYS_VISIBLE,
9+ NONAPPS_MAYBE_VISIBLE,
10+ NONAPPS_NEVER_VISIBLE) = range (3)
11+
12 def __init__(self, cache, db, icons, search_query=None,
13 limit=DEFAULT_SEARCH_LIMIT,
14 sortmode=SORT_UNSORTED, filter=None, exact=False,
15 icon_size=ICON_SIZE, global_icon_cache=True,
16- nonapps_visible=False):
17+ nonapps_visible=NONAPPS_MAYBE_VISIBLE):
18 """
19 Initalize a AppStore.
20
21@@ -117,6 +121,11 @@
22 - `exact`: If true, indexes of queries without matches will be
23 maintained in the store (useful to show e.g. a row
24 with "??? not found")
25+ - `nonapps_visible`: decide whether adding non apps in the model or not.
26+ Can be NONAPPS_ALWAYS_VISIBLE/NONAPPS_MAYBE_VISIBLE
27+ /NONAPPS_NEVER_VISIBLE
28+ (NONAPPS_MAYBE_VISIBLE will return non apps result
29+ if no matching apps is found)
30 """
31 gtk.GenericTreeModel.__init__(self)
32 self._logger = logging.getLogger("softwarecenter.view.appstore")
33@@ -176,7 +185,7 @@
34 for q in self.search_query:
35 self._logger.debug("using query: '%s'" % q)
36 enquire = xapian.Enquire(self.db.xapiandb)
37- if not self.nonapps_visible:
38+ if self.nonapps_visible != self.NONAPPS_ALWAYS_VISIBLE:
39 enquire.set_query(xapian.Query(xapian.Query.OP_AND_NOT,
40 q, xapian.Query("ATapplication")))
41
42@@ -228,7 +237,7 @@
43 # FIXME: falsely assuming that apps come before nonapps
44 if not appname:
45 added = pkgname in already_added
46- if self.nonapps_visible and not added:
47+ if self.nonapps_visible == self.NONAPPS_ALWAYS_VISIBLE and not added:
48 self.nonapp_pkgs += 1
49 if appname or not added:
50 if self.sortmode == SORT_BY_ALPHABET:
51@@ -251,11 +260,12 @@
52 app = Application("", pkgname)
53 self.apps.append(app)
54
55- # if we only have nonapps to be displayed, don't hide them
56- if (not self.nonapps_visible and
57+ # if we only have nonapps to be displayed, and nonapps is set as
58+ # NONAPPS_MAYBE_VISIBLE don't hide them
59+ if (self.nonapps_visible == self.NONAPPS_MAYBE_VISIBLE and
60 self.nonapp_pkgs > 0 and
61 len(self.apps) == 0):
62- self.nonapps_visible = True
63+ self.nonapps_visible = self.NONAPPS_ALWAYS_VISIBLE
64 self._perform_search()
65
66 # in the case where the app list is sorted, we must rebuild
67
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 # special case to disable hide nonapps for the "Featured Applications" category
73 if (self.apps_category and
74 self.apps_category.untranslated_name) == "Featured":
75- self.nonapps_visible = True
76+ self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE
77 # In custom list mode, search should yield the exact package name.
78 new_model = AppStore(self.cache,
79 self.db,
80
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 filter=self.apps_filter,
86 icon_size=best_stock_size,
87 global_icon_cache=False,
88- nonapps_visible=False)
89+ nonapps_visible=AppStore.NONAPPS_MAYBE_VISIBLE)
90
91 self.featured_carousel = CarouselView(featured_apps, _('Featured'), self.icons)
92 self.featured_carousel.more_btn.connect('clicked',
93@@ -368,7 +368,7 @@
94 self.apps_filter,
95 icon_size=best_stock_size,
96 global_icon_cache=False,
97- nonapps_visible=False)
98+ nonapps_visible=AppStore.NONAPPS_MAYBE_VISIBLE)
99 self.newapps_carousel = CarouselView(
100 new_apps, _(u"What\u2019s New"), self.icons,
101 start_random=False)
102
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 # always show all packages in the partner repository
108 # FIXME: remove this special case code in favor of a more general solution
109 if channel.get_channel_component() == "partner":
110- self.nonapps_visible = True
111+ self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE
112 self.disable_show_hide_nonapps = True
113 else:
114- self.nonapps_visible = False
115+ self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE
116 self.disable_show_hide_nonapps = False
117 self.apps_filter = None
118 if self.channel.only_packages_without_applications:
119
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 self.icons = icons
125 self.datadir = datadir
126 self.backend = get_install_backend()
127- self.nonapps_visible = False
128+ self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE
129 self.disable_show_hide_nonapps = False
130 # refreshes can happen out-of-bound so we need to be sure
131 # that we only set the new model (when its available) if
132@@ -326,7 +326,7 @@
133 pkgs = 0
134 apps = 0
135 if appstore.active:
136- if appstore.nonapps_visible:
137+ if appstore.nonapps_visible == AppStore.NONAPPS_ALWAYS_VISIBLE:
138 pkgs = appstore.nonapp_pkgs
139 apps = len(appstore) - pkgs
140 else:
141@@ -353,7 +353,7 @@
142 pkgs > 0 and
143 apps > 0 and
144 not self.disable_show_hide_nonapps):
145- if appstore.nonapps_visible:
146+ if appstore.nonapps_visible == AppStore.NONAPPS_ALWAYS_VISIBLE:
147 # TRANSLATORS: the text inbetween the underscores acts as a link
148 # In most/all languages you will want the whole string as a link
149 label = gettext.ngettext("_Hide %i technical item_",
150@@ -367,11 +367,11 @@
151 self.action_bar.set_label(label, self._show_nonapp_pkgs)
152
153 def _show_nonapp_pkgs(self):
154- self.nonapps_visible = True
155+ self.nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE
156 self.refresh_apps()
157
158 def _hide_nonapp_pkgs(self):
159- self.nonapps_visible = False
160+ self.nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE
161 self.refresh_apps()
162
163 def get_status_text(self):
164
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 store = AppStore(self.cache, self.db, self.mock_icons,
170 sortmode=SORT_BY_CATALOGED_TIME,
171 limit=20, search_query=query,
172- nonapps_visible=True)
173+ nonapps_visible=AppStore.NONAPPS_ALWAYS_VISIBLE)
174 for item in store:
175 sorted_by_appstore.append(item[AppStore.COL_PKGNAME])
176 self.assertEqual(sorted_by_axi, sorted_by_appstore)
177@@ -157,12 +157,12 @@
178 store = AppStore(
179 self.cache, self.db, self.mock_icons,
180 search_query = xapian.Query(""),
181- nonapps_visible = False)
182+ nonapps_visible = AppStore.NONAPPS_MAYBE_VISIBLE)
183 not_visible = store.nonapp_pkgs
184 store = AppStore(
185 self.cache, self.db, self.mock_icons,
186 search_query = xapian.Query(""),
187- nonapps_visible = True)
188+ nonapps_visible = AppStore.NONAPPS_ALWAYS_VISIBLE)
189 visible = store.nonapp_pkgs
190 self.assertTrue(visible < not_visible)
191