Skip to content

Commit 221c3e1

Browse files
committed
Show partition label in unlocking dialog
Resolves #305
1 parent 1199864 commit 221c3e1

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

udiskie/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class DeviceFilter:
8787
'in_use',
8888
'should_automount',
8989
'ui_label',
90+
'ui_label_dialog',
9091
'loop_file',
9192
'setup_by_uid',
9293
'autoclear',

udiskie/prompt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async def password_dialog(key, title, message, options):
154154

155155
def get_password_gui(device, options):
156156
"""Get the password to unlock a device from GUI."""
157-
text = _('Enter password for {0.device_presentation}: ', device)
157+
text = _('Enter password for {0.ui_label_dialog}: ', device)
158158
try:
159159
return password_dialog(device.id_uuid, 'udiskie', text, options)
160160
except RuntimeError:
@@ -164,7 +164,7 @@ def get_password_gui(device, options):
164164
async def get_password_tty(device, options):
165165
"""Get the password to unlock a device from terminal."""
166166
# TODO: make this a TRUE async
167-
text = _('Enter password for {0.device_presentation}: ', device)
167+
text = _('Enter password for {0.ui_label_dialog}: ', device)
168168
try:
169169
return PasswordResult(getpass.getpass(text),
170170
options.get('cache_hint', False))

udiskie/udisks2.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,18 @@ def ui_label(self):
598598
self.ui_id_label or self.ui_id_uuid or self.drive_label
599599
]))
600600

601+
@property
602+
def ui_label_dialog(self):
603+
"""UI string identifying the partition if possible."""
604+
dev_path = self.ui_device_presentation
605+
fs_label = self.ui_id_label or self.ui_id_uuid or self.drive_label
606+
if dev_path and fs_label:
607+
return '{0} [{1}]'.format(dev_path, fs_label)
608+
elif fs_label:
609+
return fs_label
610+
else:
611+
return dev_path
612+
601613
@property
602614
def ui_device_label(self):
603615
"""UI string identifying the device (drive) if toplevel."""

0 commit comments

Comments
 (0)