Browse Source

show complete device description in wizard

283
ThomasV 9 years ago
parent
commit
4837d7a148
  1. 8
      lib/base_wizard.py
  2. 9
      lib/plugins.py

8
lib/base_wizard.py

@ -194,14 +194,18 @@ class BaseWizard(object):
# select device # select device
self.devices = devices self.devices = devices
choices = [] choices = []
for name, device_info in devices: for name, info in devices:
choices.append( ((name, device_info), device_info.description + ' [%s]'%name) ) state = _("initialized") if info.initialized else _("wiped")
label = info.label or _("An unnamed %s")%name
descr = "%s [%s, %s]" % (label, name, state)
choices.append(((name, info), descr))
msg = _('Select a device') + ':' msg = _('Select a device') + ':'
self.choice_dialog(title=title, message=msg, choices=choices, run_next=self.on_device) self.choice_dialog(title=title, message=msg, choices=choices, run_next=self.on_device)
def on_device(self, name, device_info): def on_device(self, name, device_info):
self.plugin = self.plugins.get_plugin(name) self.plugin = self.plugins.get_plugin(name)
self.plugin.setup_device(device_info, self) self.plugin.setup_device(device_info, self)
print device_info
f = lambda x: self.run('on_hardware_account_id', name, device_info, x) f = lambda x: self.run('on_hardware_account_id', name, device_info, x)
self.account_id_dialog(run_next=f) self.account_id_dialog(run_next=f)

9
lib/plugins.py

@ -261,7 +261,7 @@ class DeviceUnpairableError(Exception):
pass pass
Device = namedtuple("Device", "path interface_number id_ product_key") Device = namedtuple("Device", "path interface_number id_ product_key")
DeviceInfo = namedtuple("DeviceInfo", "device description initialized") DeviceInfo = namedtuple("DeviceInfo", "device label initialized")
class DeviceMgr(ThreadJob, PrintError): class DeviceMgr(ThreadJob, PrintError):
'''Manages hardware clients. A client communicates over a hardware '''Manages hardware clients. A client communicates over a hardware
@ -443,10 +443,7 @@ class DeviceMgr(ThreadJob, PrintError):
client = self.create_client(device, handler, plugin) client = self.create_client(device, handler, plugin)
if not client: if not client:
continue continue
state = _("initialized") if client.is_initialized() else _("wiped") infos.append(DeviceInfo(device, client.label(), client.is_initialized()))
label = client.label() or _("An unnamed %s") % plugin.device
descr = "%s (%s)" % (label, state)
infos.append(DeviceInfo(device, descr, client.is_initialized()))
return infos return infos
@ -467,7 +464,7 @@ class DeviceMgr(ThreadJob, PrintError):
if len(infos) == 1: if len(infos) == 1:
return infos[0] return infos[0]
msg = _("Please select which %s device to use:") % plugin.device msg = _("Please select which %s device to use:") % plugin.device
descriptions = [info.description for info in infos] descriptions = [info.label + ' (%s)'%(_("initialized") if info.initialized else _("wiped")) for info in infos]
return infos[handler.query_choice(msg, descriptions)] return infos[handler.query_choice(msg, descriptions)]
def scan_devices(self): def scan_devices(self):

Loading…
Cancel
Save