Merge lp:~andrewmccarthy/unity-lens-photos/less-tags-in-preview-raring into lp:unity-lens-photos/raring

Proposed by Andrew McCarthy
Status: Needs review
Proposed branch: lp:~andrewmccarthy/unity-lens-photos/less-tags-in-preview-raring
Merge into: lp:unity-lens-photos/raring
Diff against target: 38 lines (+19/-2)
1 file modified
src/shotwell_scope.py (+19/-2)
To merge this branch: bzr merge lp:~andrewmccarthy/unity-lens-photos/less-tags-in-preview-raring
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+168878@code.launchpad.net

Description of the change

Tidies up the display of tags in shotwell photo previews by changing to a newline-separated list, and also removing duplicate prefixes in hierarchical tags. Cosmetic change only.

To post a comment you must log in.
Revision history for this message
David Callé (davidc3) wrote :

Looks good.

Revision history for this message
Michael Terry (mterry) wrote :

Did you mean to approve, David? Do we want design feedback on this?

138. By Andrew McCarthy

Remove leading slash in Shotwell's hierarchical tags.

Unmerged revisions

138. By Andrew McCarthy

Remove leading slash in Shotwell's hierarchical tags.

137. By Andrew McCarthy

Tidy up tagging in preview by using newline-separated list and removing tags with common prefixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/shotwell_scope.py'
--- src/shotwell_scope.py 2012-11-06 16:36:53 +0000
+++ src/shotwell_scope.py 2013-06-14 20:32:26 +0000
@@ -180,8 +180,8 @@
180 height = str(photo[3])180 height = str(photo[3])
181 filesize = self.humanize_bytes(photo[4])181 filesize = self.humanize_bytes(photo[4])
182 dimensions = _("%s x %s pixels") % (width, height)182 dimensions = _("%s x %s pixels") % (width, height)
183 tags_raw = self.getTagsForPhotoId(db, photo[0])183 tags_raw = self.getMinTagsForPhotoId(db, photo[0])
184 tags = ', '.join(tags_raw.split("__"))[2:]184 tags = '\n'.join(tags_raw)
185 if dimensions:185 if dimensions:
186 preview.add_info(Unity.InfoHint.new("dimensions", _("Dimensions"), None, dimensions))186 preview.add_info(Unity.InfoHint.new("dimensions", _("Dimensions"), None, dimensions))
187 if filesize:187 if filesize:
@@ -497,6 +497,23 @@
497 return string_of_tags497 return string_of_tags
498498
499499
500 def getMinTagsForPhotoId (self, db, photo):
501 """Get minimal tags related to a photo, removing repeated tags in a hierarchy"""
502 thumb_id = "thumb%016x" % photo
503 sql='SELECT LTRIM(name,\'/\') FROM TagTable WHERE photo_id_list LIKE ? ORDER BY name'
504 args=['%'+thumb_id+'%']
505 cursor = db.cursor ()
506 tags = cursor.execute(sql, args).fetchall()
507 cursor.close ()
508 results = [t[0] for t in tags]
509 i = 1
510 while i < len(results):
511 if results[i].startswith(results[i-1]):
512 del results[i-1]
513 else:
514 i += 1
515 return results
516
500 def humanize_bytes(self, bytes, precision=1):517 def humanize_bytes(self, bytes, precision=1):
501 """Get a humanized string representation of a number of bytes."""518 """Get a humanized string representation of a number of bytes."""
502 abbrevs = ((10**15, 'PB'),(10**12, 'TB'),(10**9, 'GB'),(10**6, 'MB'),(10**3, 'kB'),(1, 'b'))519 abbrevs = ((10**15, 'PB'),(10**12, 'TB'),(10**9, 'GB'),(10**6, 'MB'),(10**3, 'kB'),(1, 'b'))

Subscribers

People subscribed via source and target branches

to all changes: