snaplist: add visual indication for starred publishers
In addition to verified publishers being indicated by a check-mark, we now have starred publishers indicated with a circled star. If unicode support is not available, for instance with serial connections, we use a different number of stars to represent: * verified publishers: 2 stars * starred publishers: 1 star * others: no star Because our mechanism to substitute unicode characters with ascii equivalents expect a 1:1 mapping, we cannot simply replace the circled start by two stars. To workaround the issue, we added a narrow non-breakable space. When support of unicode is available, this character shows up as a normal space. When support of unicode is not available, it gets replaced by a star. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
3aa9263e73
commit
e5017256a2
|
@ -15,7 +15,7 @@
|
||||||
"id": "l5m6dy7O2H7mosoJSwmhRa2ZA0H6yGt1",
|
"id": "l5m6dy7O2H7mosoJSwmhRa2ZA0H6yGt1",
|
||||||
"username": "ralight",
|
"username": "ralight",
|
||||||
"display-name": "Roger Light",
|
"display-name": "Roger Light",
|
||||||
"validation": "unproven"
|
"validation": "starred"
|
||||||
},
|
},
|
||||||
"developer": "ralight",
|
"developer": "ralight",
|
||||||
"status": "available",
|
"status": "available",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"id": "IJ1Iesv3hhEPHuegj7b3zvPLOh8wZs34",
|
"id": "IJ1Iesv3hhEPHuegj7b3zvPLOh8wZs34",
|
||||||
"username": "jacek",
|
"username": "jacek",
|
||||||
"display-name": "Jacek Nykis",
|
"display-name": "Jacek Nykis",
|
||||||
"validation": "unproven"
|
"validation": "starred"
|
||||||
},
|
},
|
||||||
"developer": "jacek",
|
"developer": "jacek",
|
||||||
"status": "available",
|
"status": "available",
|
||||||
|
|
|
@ -1527,7 +1527,7 @@
|
||||||
"id": "l5m6dy7O2H7mosoJSwmhRa2ZA0H6yGt1",
|
"id": "l5m6dy7O2H7mosoJSwmhRa2ZA0H6yGt1",
|
||||||
"username": "ralight",
|
"username": "ralight",
|
||||||
"display-name": "Roger Light",
|
"display-name": "Roger Light",
|
||||||
"validation": "unproven"
|
"validation": "starred"
|
||||||
},
|
},
|
||||||
"developer": "ralight",
|
"developer": "ralight",
|
||||||
"status": "available",
|
"status": "available",
|
||||||
|
@ -2213,7 +2213,7 @@
|
||||||
"id": "IJ1Iesv3hhEPHuegj7b3zvPLOh8wZs34",
|
"id": "IJ1Iesv3hhEPHuegj7b3zvPLOh8wZs34",
|
||||||
"username": "jacek",
|
"username": "jacek",
|
||||||
"display-name": "Jacek Nykis",
|
"display-name": "Jacek Nykis",
|
||||||
"validation": "unproven"
|
"validation": "starred"
|
||||||
},
|
},
|
||||||
"developer": "jacek",
|
"developer": "jacek",
|
||||||
"status": "available",
|
"status": "available",
|
||||||
|
|
|
@ -385,6 +385,7 @@ class SnapInfo:
|
||||||
summary: str = ''
|
summary: str = ''
|
||||||
publisher: str = ''
|
publisher: str = ''
|
||||||
verified: bool = False
|
verified: bool = False
|
||||||
|
starred: bool = False
|
||||||
description: str = ''
|
description: str = ''
|
||||||
confinement: str = ''
|
confinement: str = ''
|
||||||
license: str = ''
|
license: str = ''
|
||||||
|
|
|
@ -54,6 +54,7 @@ class SnapListModel:
|
||||||
snap.summary = data['summary']
|
snap.summary = data['summary']
|
||||||
snap.publisher = data['developer']
|
snap.publisher = data['developer']
|
||||||
snap.verified = data['publisher']['validation'] == "verified"
|
snap.verified = data['publisher']['validation'] == "verified"
|
||||||
|
snap.starred = data['publisher']['validation'] == "starred"
|
||||||
snap.description = data['description']
|
snap.description = data['description']
|
||||||
snap.confinement = data['confinement']
|
snap.confinement = data['confinement']
|
||||||
snap.license = data['license']
|
snap.license = data['license']
|
||||||
|
|
|
@ -182,7 +182,11 @@ class SnapInfoView(WidgetWrap):
|
||||||
|
|
||||||
publisher = [('info_minor', _("by: ")), snap.publisher]
|
publisher = [('info_minor', _("by: ")), snap.publisher]
|
||||||
if snap.verified:
|
if snap.verified:
|
||||||
publisher.append(('verified', ' \N{check mark}'))
|
# Check extend_dec_special_charmap for the meaning of the
|
||||||
|
# narrow non-breakable space here.
|
||||||
|
publisher.append(('verified', ' \N{check mark}\N{NNBSP}'))
|
||||||
|
elif snap.starred:
|
||||||
|
publisher.append(' \N{circled white star}')
|
||||||
|
|
||||||
title = Columns([
|
title = Columns([
|
||||||
Text(snap.name),
|
Text(snap.name),
|
||||||
|
@ -433,9 +437,13 @@ class SnapListView(BaseView):
|
||||||
continue
|
continue
|
||||||
box = self.snap_boxes[snap.name] = SnapCheckBox(
|
box = self.snap_boxes[snap.name] = SnapCheckBox(
|
||||||
self, snap, snap.name in self.selections_by_name)
|
self, snap, snap.name in self.selections_by_name)
|
||||||
publisher = snap.publisher
|
publisher = [snap.publisher]
|
||||||
if snap.verified:
|
if snap.verified:
|
||||||
publisher = [publisher, ('verified', '\N{check mark}')]
|
# Check extend_dec_special_charmap for the meaning of the
|
||||||
|
# narrow non-breakable space here.
|
||||||
|
publisher.append(('verified', '\N{check mark}\N{NNBSP}'))
|
||||||
|
elif snap.starred:
|
||||||
|
publisher.append('\N{circled white star}')
|
||||||
row = [
|
row = [
|
||||||
box,
|
box,
|
||||||
Text(publisher),
|
Text(publisher),
|
||||||
|
|
|
@ -46,12 +46,18 @@ def extend_dec_special_charmap():
|
||||||
ord('\N{BLACK LEFT-POINTING SMALL TRIANGLE}'): '<',
|
ord('\N{BLACK LEFT-POINTING SMALL TRIANGLE}'): '<',
|
||||||
ord('\N{BLACK DOWN-POINTING SMALL TRIANGLE}'): 'v',
|
ord('\N{BLACK DOWN-POINTING SMALL TRIANGLE}'): 'v',
|
||||||
ord('\N{BLACK UP-POINTING SMALL TRIANGLE}'): '^',
|
ord('\N{BLACK UP-POINTING SMALL TRIANGLE}'): '^',
|
||||||
ord('\N{check mark}'): '+',
|
ord('\N{check mark}'): '*',
|
||||||
|
ord('\N{circled white star}'): '*',
|
||||||
ord('\N{bullet}'): '*',
|
ord('\N{bullet}'): '*',
|
||||||
ord('\N{lower half block}'): '=',
|
ord('\N{lower half block}'): '=',
|
||||||
ord('\N{upper half block}'): '=',
|
ord('\N{upper half block}'): '=',
|
||||||
ord('\N{FULL BLOCK}'): urwid.escape.DEC_SPECIAL_CHARMAP[
|
ord('\N{FULL BLOCK}'): urwid.escape.DEC_SPECIAL_CHARMAP[
|
||||||
ord('\N{BOX DRAWINGS LIGHT VERTICAL}')],
|
ord('\N{BOX DRAWINGS LIGHT VERTICAL}')],
|
||||||
|
# XXX: Hack to show the verified snap publishers with two stars when
|
||||||
|
# unicode is not supported. In rich mode, we display ✪ followed by a
|
||||||
|
# mostly invisible character (i.e., NNBSP). In basic mode,
|
||||||
|
# both characters get translated to a star, resulting in two stars.
|
||||||
|
ord('\N{NNBSP}'): '*',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue