def _action_menu_for_device(self, device):
     device_actions = []
     for action in device.supported_actions:
         label = _(action.value)
         if action == DeviceAction.REMOVE and device.constructed_device():
             cd = device.constructed_device()
             label = _("Remove from {}").format(cd.desc())
         enabled, whynot = device.action_possible(action)
         if whynot:
             assert not enabled
             enabled = True
             label += " *"
             meth = _whynot_shower(self.parent, action, whynot)
         else:
             meth_name = '_{}_{}'.format(device.type, action.name)
             meth = getattr(self, meth_name)
         if not whynot and action == DeviceAction.DELETE:
             label = Color.danger_button(ActionMenuOpenButton(label))
         device_actions.append(Action(
             label=label,
             enabled=enabled,
             value=(action, meth),
             opens_dialog=getattr(meth, 'opens_dialog', False)))
     menu = ActionMenu(device_actions)
     connect_signal(menu, 'action', self._action, device)
     return menu
Beispiel #2
0
 def _action_menu_for_device(self, device):
     device_actions = []
     for action in DeviceAction.supported(device):
         label_meth = getattr(self, '_label_{}'.format(action.name),
                              lambda a, d: a.str())
         label = label_meth(action, device)
         enabled, whynot = action.can(device)
         if whynot:
             assert not enabled
             enabled = True
             label += " *"
             meth = _whynot_shower(self.parent, action, whynot)
         else:
             meth_name = '_{}_{}'.format(device.type, action.name)
             meth = getattr(self, meth_name)
         if not whynot and action in [
                 DeviceAction.DELETE, DeviceAction.REFORMAT
         ]:
             label = Color.danger_button(ActionMenuOpenButton(label))
         device_actions.append(
             Action(label=label,
                    enabled=enabled,
                    value=(action, meth),
                    opens_dialog=getattr(meth, 'opens_dialog', False)))
     menu = ActionMenu(device_actions)
     connect_signal(menu, 'action', self._action, device)
     return menu
Beispiel #3
0
 def _action_menu_for_device(self, device):
     delete_btn = Color.danger_button(ActionMenuButton(_("Delete")))
     device_actions = [
         (_("Information"), DeviceAction.INFO),
         (_("Edit"), DeviceAction.EDIT),
         (_("Add Partition"), DeviceAction.PARTITION),
         (_("Format / Mount"), DeviceAction.FORMAT),
         (delete_btn, DeviceAction.DELETE),
         (_("Make boot device"), DeviceAction.MAKE_BOOT),
     ]
     menu = ActionMenu([(label, device.supports_action(action), action)
                        for label, action in device_actions])
     connect_signal(menu, 'action', self._action, device)
     return menu
Beispiel #4
0
 def _action_menu_for_device(self, device):
     if can_delete(device)[0]:
         delete_btn = Color.danger_button(ActionMenuButton(_("Delete")))
     else:
         delete_btn = _("Delete *")
     device_actions = [
         (_("Information"), DeviceAction.INFO),
         (_("Edit"), DeviceAction.EDIT),
         (_("Add Partition"), DeviceAction.PARTITION),
         (_("Format / Mount"), DeviceAction.FORMAT),
         (delete_btn, DeviceAction.DELETE),
         (_("Make boot device"), DeviceAction.MAKE_BOOT),
     ]
     actions = []
     for label, action in device_actions:
         actions.append(
             Action(label=label,
                    enabled=device.supports_action(action),
                    value=action,
                    opens_dialog=action != DeviceAction.MAKE_BOOT))
     menu = ActionMenu(actions, "\N{BLACK RIGHT-POINTING SMALL TRIANGLE}")
     connect_signal(menu, 'action', self._action, device)
     return menu