Merge lp:~gary-lasker/software-center/title-summary-fixes into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 1172
Proposed branch: lp:~gary-lasker/software-center/title-summary-fixes
Merge into: lp:software-center
Diff against target: 263 lines (+80/-45)
7 files modified
debian/changelog (+14/-3)
softwarecenter/db/application.py (+47/-24)
softwarecenter/db/database.py (+5/-8)
softwarecenter/view/appview.py (+2/-7)
softwarecenter/view/availablepane.py (+5/-1)
softwarecenter/view/installedpane.py (+5/-1)
softwarecenter/view/softwarepane.py (+2/-1)
To merge this branch: bzr merge lp:~gary-lasker/software-center/title-summary-fixes
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+35242@code.launchpad.net

Description of the change

This branch is to fix bug 636004.

Previously, there were two places that implemented the "special case" code that substituted summary for title and pkgname for summary (as required by the spec). The first was in applist.py for the applist view (where, as mpt noted, the substitution was working fine while the details view was broken). The second was in the db.AppDetails object, and this was used by the app details view.

Since we need to maintain a lightweight object for use with applist, I consolidated the code into a pair of calls (get_display_name and get_display_summary) in the lightweight db.Application object itself. By pulling these out of db.AppDetails we avoid having to generate an instance of db.AppDetails (a relatively heavyweight object) for every item in the applist. I kept the db.AppDetails API unchanged, however, and just reimplemented the display_name and display_summary properties to call out to the db.Application object's methods.

Finally, I wired the navigation button to use the display name rather than the simple pkgname as it was using up until now, so that bug is fixed as well. Now, the applist, the appdetails and the navigation bar all share the same code.

I'm sure there are further opportunities for optimization (for instance, once we have appdetails generated for the navigation bar, we could pass it for use in appdetails), but I stopped here as this seemed the minimum surgery to do the trick.

Thanks!

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

Bah, I'm seeing a freeze when trying to view the app details for the "A Better CD Encoder" package (see bug 636843). This doesn't seem related to my branch as I also see it happening in 2.1.18.1.

Anyway, since this is the test package for this bug, I wanted to report it here as well. You can work around the problem (if you see it) by first doing a search to narrow the length of the list before clicking "More Info" (just type "abcd" into the search bar).

1168. By Gary Lasker

merge lp:~kiwinote/software-center/title-summary-fixes, many thanks kiwinote

Revision history for this message
Gary Lasker (gary-lasker) wrote :

I just merged some additional fixes from kiwinote. Many thanks!

Here is a summary from kiwinote of his changes:
---
We need to replace the 'if self.appname' with 'if db.get_appname(doc)' as when we init s-c with a command line argument (eg software-center gdebi), we have self.appname = None. (Or we could look at actually setting self.appname in this case.)

We add 'if doc' incase the doc=None (ie deb files. For deb file summaries this isn't crucial, as we override this anyway in a new function). We also need to add 'return self.name' as a fallback for the appdetailsview for deb files.

Display correct title in nav bar for apturls/deb files. (not really the most ideal of moves, as we open the deb files twice, but it seems acceptable (and encouragable) to do for maverick. (Given that a very little bit of extra time on a slowish startup doesn't make that much difference ;) ) )

(I also merged a revision from one of my other branches so that I could test the corner case deb files as well.)

1169. By Gary Lasker

merge with trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2010-09-13 16:27:49 +0000
+++ debian/changelog 2010-09-14 02:59:44 +0000
@@ -6,6 +6,16 @@
6 * softwarecenter/backend/channel.py:6 * softwarecenter/backend/channel.py:
7 - always display the partner channel, even if its7 - always display the partner channel, even if its
8 source is not enabled (LP: #635003) 8 source is not enabled (LP: #635003)
9 * softwarecenter/db/application.py,
10 softwarecenter/db/database.py,
11 softwarecenter/view/appview.py,
12 softwarecenter/view/softwarepane.py:
13 - make StoreDatabase.get_appname return None if the
14 name is not defined in the xapian doc
15 - consolidate code to generate application name and
16 summary for display in the UI to a single place
17 - wire applist, appdetails and the navigation bar
18 to use it (LP: #636004)
919
10 [ Kiwinote ]20 [ Kiwinote ]
11 * data/software-center.menu.in:21 * data/software-center.menu.in:
@@ -14,9 +24,12 @@
14 - allow 'for purchase' to have an icon in non-English locales (LP: #636242)24 - allow 'for purchase' to have an icon in non-English locales (LP: #636242)
15 * softwarecenter/db/application/py:25 * softwarecenter/db/application/py:
16 - try to open deb file, except on any sort of error (LP: #633379)26 - try to open deb file, except on any sort of error (LP: #633379)
27 - reload pkg cache object and xapian doc if it turns out that the pkgname
28 of a deb file is different than what we guessed on basis of the file name
17 * softwarecenter/view/appdetailsview_gtk.py:29 * softwarecenter/view/appdetailsview_gtk.py:
18 - use the display name for app entry in 'where is it' (LP: #635464)30 - use the display name for app entry in 'where is it' (LP: #635464)
19 - restore correct padding in addons status bar (LP: #625230)31 - restore correct padding in addons status bar (LP: #625230)
32 * minor tweaks to lp:~gary-lasker/software-center/title-summary-fixes
2033
21 [ Matthew Paul Thomas ]34 [ Matthew Paul Thomas ]
22 * data/software-center.menu.in:35 * data/software-center.menu.in:
@@ -26,7 +39,7 @@
26 [ Colin Watson ]39 [ Colin Watson ]
27 * Fix update-apt-xapian-index crashes when the Dir::Cache::pkgcache file40 * Fix update-apt-xapian-index crashes when the Dir::Cache::pkgcache file
28 doesn't exist (LP: #267330).41 doesn't exist (LP: #267330).
29 42
30 [ Michael Vogt ]43 [ Michael Vogt ]
31 * softwarecenter/backend/aptd.py:44 * softwarecenter/backend/aptd.py:
32 - fix "reload()" in enable_channel() and only update the particular45 - fix "reload()" in enable_channel() and only update the particular
@@ -36,8 +49,6 @@
36 * merged lp:~mmcg069/software-center/Bug63537549 * merged lp:~mmcg069/software-center/Bug635375
37 * merged lp:~mmcg069/software-center/tiny-pathbar-tweak50 * merged lp:~mmcg069/software-center/tiny-pathbar-tweak
3851
39 -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 13 Sep 2010 16:18:45 +0200
40
41software-center (2.1.18.1) maverick; urgency=low52software-center (2.1.18.1) maverick; urgency=low
4253
43 [ Colin Watson ]54 [ Colin Watson ]
4455
=== modified file 'softwarecenter/db/application.py'
--- softwarecenter/db/application.py 2010-09-11 14:49:38 +0000
+++ softwarecenter/db/application.py 2010-09-14 02:59:44 +0000
@@ -69,6 +69,28 @@
69 def get_details(self, db):69 def get_details(self, db):
70 """ return a new AppDetails object for this application """70 """ return a new AppDetails object for this application """
71 return AppDetails(db, application=self)71 return AppDetails(db, application=self)
72 def get_display_name(self, db, doc):
73 """ Return the application name as it should be displayed in the UI
74 If the appname is defined, just return it, else return
75 the summary (per the spec)
76 """
77 if doc:
78 appname = db.get_appname(doc)
79 if appname:
80 return appname
81 else:
82 return db.get_summary(doc)
83 def get_display_summary(self, db, doc):
84 """ Return the application summary as it should be displayed in the UI
85 If the appname is defined, return the application summary, else return
86 the application's pkgname (per the spec)
87 """
88 if doc:
89 if db.get_appname(doc):
90 return db.get_summary(doc)
91 else:
92 return db.get_pkgname(doc)
93
72 # special methods94 # special methods
73 def __hash__(self):95 def __hash__(self):
74 return ("%s:%s" % (self.appname, self.pkgname)).__hash__()96 return ("%s:%s" % (self.appname, self.pkgname)).__hash__()
@@ -96,7 +118,7 @@
96 if not debfile.endswith(".deb") and not debfile.count('/') >= 2:118 if not debfile.endswith(".deb") and not debfile.count('/') >= 2:
97 raise ValueError("Need a deb file, got '%s'" % debfile)119 raise ValueError("Need a deb file, got '%s'" % debfile)
98 debname = os.path.splitext(os.path.basename(debfile))[0]120 debname = os.path.splitext(os.path.basename(debfile))[0]
99 self.appname = debname.split('_')[0].capitalize()121 self.appname = ""
100 self.pkgname = debname.split('_')[0].lower()122 self.pkgname = debname.split('_')[0].lower()
101 self.request = debfile123 self.request = debfile
102 def get_details(self, db):124 def get_details(self, db):
@@ -295,38 +317,24 @@
295 317
296 @property318 @property
297 def display_name(self):319 def display_name(self):
298 """ Return the name as it should be displayed in the UI320 """ Return the application name as it should be displayed in the UI
299321 If the appname is defined, just return it, else return
300 Note that this may not corespond to the Appname as the322 the summary (per the spec)
301 spec says the name should be the summary for packages
302 and the summary the pkgname
303 """323 """
304 if self._error_not_found:324 if self._error_not_found:
305 return self._error325 return self._error
306 if self._doc:326 if self._doc:
307 name = self._db.get_appname(self._doc)327 return self._app.get_display_name(self._db, self._doc)
308 if name:
309 return name
310 else:
311 # by spec..
312 return self._db.get_summary(self._doc)
313 return self.name328 return self.name
314329
315 @property330 @property
316 def display_summary(self):331 def display_summary(self):
317 """ Return the summary as it should be displayed in the UI332 """ Return the application summary as it should be displayed in the UI
318333 If the appname is defined, return the application summary, else return
319 Note that this may not corespond to the summary value as the334 the application's pkgname (per the spec)
320 spec says the name should be the summary for packages
321 and the summary the pkgname
322 """335 """
323 if self._doc:336 if self._doc:
324 name = self._db.get_appname(self._doc)337 return self._app.get_display_summary(self._db, self._doc)
325 if name:
326 return self._db.get_summary(self._doc)
327 else:
328 # by spec..
329 return self._db.get_pkgname(self._doc)
330 return ""338 return ""
331339
332 @property340 @property
@@ -592,9 +600,24 @@
592 self._error_not_found = _("The file \"%s\" could not be opened.") % self._app.request600 self._error_not_found = _("The file \"%s\" could not be opened.") % self._app.request
593 return601 return
594602
595 if self.pkgname:603 if self.pkgname and self.pkgname != self._app.pkgname:
604 # this happens when the deb file has a quirky file name
596 self._app.pkgname = self.pkgname605 self._app.pkgname = self.pkgname
597606
607 # load pkg cache
608 self._pkg = None
609 if (self._app.pkgname in self._cache and
610 self._cache[self._app.pkgname].candidate):
611 self._pkg = self._cache[self._app.pkgname]
612
613 # load xapian document
614 self._doc = None
615 try:
616 self._doc = self._db.get_xapian_document(
617 self._app.appname, self._app.pkgname)
618 except:
619 pass
620
598 # check deb and set failure state on error621 # check deb and set failure state on error
599 if not self._deb.check():622 if not self._deb.check():
600 self._error = self._deb._failure_string623 self._error = self._deb._failure_string
601624
=== modified file 'softwarecenter/db/database.py'
--- softwarecenter/db/database.py 2010-09-10 09:17:07 +0000
+++ softwarecenter/db/database.py 2010-09-14 02:59:44 +0000
@@ -223,19 +223,16 @@
223 """ Return a packagename from a xapian document """223 """ Return a packagename from a xapian document """
224 pkgname = doc.get_value(XAPIAN_VALUE_PKGNAME)224 pkgname = doc.get_value(XAPIAN_VALUE_PKGNAME)
225 # if there is no value it means we use the apt-xapian-index 225 # if there is no value it means we use the apt-xapian-index
226 # that store the pkgname in the data field directly226 # that stores the pkgname in the data field directly
227 if not pkgname:227 if not pkgname:
228 pkgname = doc.get_data()228 pkgname = doc.get_data()
229 return pkgname229 return pkgname
230230
231 def get_appname(self, doc):231 def get_appname(self, doc):
232 """ Return a appname from a xapian document """232 """ Return a appname from a xapian document, or None if
233 appname = doc.get_value(XAPIAN_VALUE_APPNAME)233 a value for appname cannot be found in the document
234 # if there is no value it means we use the apt-xapian-index 234 """
235 # and that has no appname235 return doc.get_value(XAPIAN_VALUE_APPNAME)
236 if not appname:
237 appname = doc.get_data()
238 return appname
239236
240 def get_iconname(self, doc):237 def get_iconname(self, doc):
241 """ Return the iconname from the xapian document """238 """ Return the iconname from the xapian document """
242239
=== modified file 'softwarecenter/view/appview.py'
--- softwarecenter/view/appview.py 2010-09-10 09:17:07 +0000
+++ softwarecenter/view/appview.py 2010-09-14 02:59:44 +0000
@@ -540,13 +540,8 @@
540 summary = self.db.get_summary(doc)540 summary = self.db.get_summary(doc)
541 return "%s\n%s" % (appname, summary)541 return "%s\n%s" % (appname, summary)
542 elif column == self.COL_MARKUP:542 elif column == self.COL_MARKUP:
543 appname = app.appname543 appname = app.get_display_name(self.db, doc)
544 summary = self.db.get_summary(doc)544 summary = app.get_display_summary(self.db, doc)
545 # SPECIAL CASE: the spec says that when there is no appname,
546 # the summary should be displayed as appname
547 if not appname:
548 appname = summary
549 summary = app.pkgname
550 if self.db.is_appname_duplicated(appname):545 if self.db.is_appname_duplicated(appname):
551 appname = "%s (%s)" % (appname, app.pkgname)546 appname = "%s (%s)" % (appname, app.pkgname)
552 s = "%s\n<small>%s</small>" % (547 s = "%s\n<small>%s</small>" % (
553548
=== modified file 'softwarecenter/view/availablepane.py'
--- softwarecenter/view/availablepane.py 2010-09-13 09:14:31 +0000
+++ softwarecenter/view/availablepane.py 2010-09-14 02:59:44 +0000
@@ -486,7 +486,11 @@
486 else:486 else:
487 self.apps_category = Category("deb", "deb", None, None, False, True, None)487 self.apps_category = Category("deb", "deb", None, None, False, True, None)
488 self.current_app_by_category[self.apps_category] = app488 self.current_app_by_category[self.apps_category] = app
489 self.navigation_bar.add_with_id(app.name, self.on_navigation_details, "details", animate=True)489 details = app.get_details(self.db)
490 self.navigation_bar.add_with_id(details.display_name,
491 self.on_navigation_details,
492 "details",
493 animate=True)
490 self.app_details.show_app(app)494 self.app_details.show_app(app)
491 self.display_details()495 self.display_details()
492496
493497
=== modified file 'softwarecenter/view/installedpane.py'
--- softwarecenter/view/installedpane.py 2010-09-08 01:35:52 +0000
+++ softwarecenter/view/installedpane.py 2010-09-14 02:59:44 +0000
@@ -199,7 +199,11 @@
199 """ Display an application in the installed_pane """199 """ Display an application in the installed_pane """
200 self.navigation_bar.add_with_id(_("Installed Software"), self.on_navigation_list, "list", do_callback=False, animate=False)200 self.navigation_bar.add_with_id(_("Installed Software"), self.on_navigation_list, "list", do_callback=False, animate=False)
201 self.navigation_bar.remove_all(do_callback=False, animate=False) # do_callback and animate *must* both be false here201 self.navigation_bar.remove_all(do_callback=False, animate=False) # do_callback and animate *must* both be false here
202 self.navigation_bar.add_with_id(app.name, self.on_navigation_details, "details", animate=False)202 details = app.get_details(self.db)
203 self.navigation_bar.add_with_id(details.display_name,
204 self.on_navigation_details,
205 "details",
206 animate=False)
203 self.app_details.show_app(app)207 self.app_details.show_app(app)
204 self.app_view.emit("application-selected", app)208 self.app_view.emit("application-selected", app)
205209
206210
=== modified file 'softwarecenter/view/softwarepane.py'
--- softwarecenter/view/softwarepane.py 2010-09-13 09:14:31 +0000
+++ softwarecenter/view/softwarepane.py 2010-09-14 02:59:44 +0000
@@ -249,7 +249,8 @@
249 def on_application_activated(self, appview, app):249 def on_application_activated(self, appview, app):
250 """callback when an app is clicked"""250 """callback when an app is clicked"""
251 LOG.debug("on_application_activated: '%s'" % app)251 LOG.debug("on_application_activated: '%s'" % app)
252 self.navigation_bar.add_with_id(app.name,252 details = app.get_details(self.db)
253 self.navigation_bar.add_with_id(details.display_name,
253 self.on_navigation_details,254 self.on_navigation_details,
254 "details")255 "details")
255 self.notebook.set_current_page(self.PAGE_APP_DETAILS)256 self.notebook.set_current_page(self.PAGE_APP_DETAILS)

Subscribers

People subscribed via source and target branches