mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[core] improvement: instantiating custom actions on demand
This commit is contained in:
@@ -54,23 +54,38 @@ class GenericSoftwareManager(SoftwareManager):
|
|||||||
self.settings_manager = settings_manager
|
self.settings_manager = settings_manager
|
||||||
self.http_client = context.http_client
|
self.http_client = context.http_client
|
||||||
self.configman = CoreConfigManager()
|
self.configman = CoreConfigManager()
|
||||||
self.extra_actions = (CustomSoftwareAction(i18n_label_key='action.reset',
|
self._action_reset: Optional[CustomSoftwareAction] = None
|
||||||
i18n_status_key='action.reset.status',
|
self._dynamic_extra_actions: Optional[Dict[CustomSoftwareAction, Callable[[dict], bool]]] = None
|
||||||
i18n_description_key='action.reset.desc',
|
|
||||||
manager_method='reset',
|
@property
|
||||||
manager=self,
|
def dynamic_extra_actions(self) -> Dict[CustomSoftwareAction, Callable[[dict], bool]]:
|
||||||
icon_path=resource.get_path('img/logo.svg'),
|
if self._dynamic_extra_actions is None:
|
||||||
requires_root=False,
|
self._dynamic_extra_actions = {
|
||||||
refresh=False),)
|
CustomSoftwareAction(i18n_label_key='action.backups',
|
||||||
self.dynamic_extra_actions: Dict[CustomSoftwareAction, Callable[[dict], bool]] = {
|
i18n_status_key='action.backups.status',
|
||||||
CustomSoftwareAction(i18n_label_key='action.backups',
|
i18n_description_key='action.backups.desc',
|
||||||
i18n_status_key='action.backups.status',
|
manager_method='launch_timeshift',
|
||||||
i18n_description_key='action.backups.desc',
|
manager=self,
|
||||||
manager_method='launch_timeshift',
|
icon_path='timeshift',
|
||||||
manager=self,
|
requires_root=False,
|
||||||
icon_path='timeshift',
|
refresh=False): self.is_backups_action_available
|
||||||
requires_root=False,
|
}
|
||||||
refresh=False): self.is_backups_action_available}
|
|
||||||
|
return self._dynamic_extra_actions
|
||||||
|
|
||||||
|
@property
|
||||||
|
def action_reset(self) -> CustomSoftwareAction:
|
||||||
|
if self._action_reset is None:
|
||||||
|
self._action_reset = CustomSoftwareAction(i18n_label_key='action.reset',
|
||||||
|
i18n_status_key='action.reset.status',
|
||||||
|
i18n_description_key='action.reset.desc',
|
||||||
|
manager_method='reset',
|
||||||
|
icon_path=resource.get_path('img/logo.svg'),
|
||||||
|
requires_root=False,
|
||||||
|
manager=self,
|
||||||
|
refresh=False)
|
||||||
|
|
||||||
|
return self._action_reset
|
||||||
|
|
||||||
def _is_timeshift_launcher_available(self) -> bool:
|
def _is_timeshift_launcher_available(self) -> bool:
|
||||||
return bool(shutil.which('timeshift-launcher'))
|
return bool(shutil.which('timeshift-launcher'))
|
||||||
@@ -635,8 +650,7 @@ class GenericSoftwareManager(SoftwareManager):
|
|||||||
if available(app_config):
|
if available(app_config):
|
||||||
yield action
|
yield action
|
||||||
|
|
||||||
for action in self.extra_actions:
|
yield self.action_reset
|
||||||
yield action
|
|
||||||
|
|
||||||
def _fill_sizes(self, man: SoftwareManager, pkgs: List[SoftwarePackage]):
|
def _fill_sizes(self, man: SoftwareManager, pkgs: List[SoftwarePackage]):
|
||||||
ti = time.time()
|
ti = time.time()
|
||||||
|
|||||||
Reference in New Issue
Block a user