mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 02:54:16 +02:00
[wgem] custom icon selector
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
@@ -11,13 +10,14 @@ class WebApplication(SoftwarePackage):
|
||||
|
||||
def __init__(self, id: str = None, url: str = None, name: str = None, description: str = None, icon_url: str = None,
|
||||
installation_dir: str = None, desktop_entry: str = None, installed: bool = False, version: str = None,
|
||||
categories: List[str] = None):
|
||||
categories: List[str] = None, custom_icon: str = None):
|
||||
super(WebApplication, self).__init__(id=id if id else url, name=name, description=description,
|
||||
icon_url=icon_url, installed=installed, version=version,
|
||||
categories=categories)
|
||||
self.url = url
|
||||
self.installation_dir = installation_dir
|
||||
self.desktop_entry = desktop_entry
|
||||
self.set_custom_icon(custom_icon)
|
||||
|
||||
def has_history(self):
|
||||
return False
|
||||
@@ -27,7 +27,7 @@ class WebApplication(SoftwarePackage):
|
||||
|
||||
@staticmethod
|
||||
def _get_cached_attrs() -> tuple:
|
||||
return 'id', 'name', 'version', 'url', 'description', 'icon_url', 'installation_dir', 'desktop_entry', 'categories'
|
||||
return 'id', 'name', 'version', 'url', 'description', 'icon_url', 'installation_dir', 'desktop_entry', 'categories', 'custom_icon'
|
||||
|
||||
def can_be_downgraded(self):
|
||||
return False
|
||||
@@ -45,9 +45,15 @@ class WebApplication(SoftwarePackage):
|
||||
def get_default_icon_path(self) -> str:
|
||||
return resource.get_path('img/web.png', ROOT_DIR)
|
||||
|
||||
def get_disk_data_path(self):
|
||||
def get_disk_data_path(self) -> str:
|
||||
return '{}/data.yml'.format(self.get_disk_cache_path())
|
||||
|
||||
def get_disk_icon_path(self) -> str:
|
||||
if self.custom_icon:
|
||||
return self.custom_icon
|
||||
else:
|
||||
super(WebApplication, self).get_disk_icon_path()
|
||||
|
||||
def is_application(self):
|
||||
return True
|
||||
|
||||
@@ -76,6 +82,8 @@ class WebApplication(SoftwarePackage):
|
||||
if val and hasattr(self, attr):
|
||||
setattr(self, attr, val)
|
||||
|
||||
self.set_custom_icon(self.custom_icon)
|
||||
|
||||
def can_be_run(self) -> bool:
|
||||
return self.installed and self.installation_dir
|
||||
|
||||
@@ -91,3 +99,10 @@ class WebApplication(SoftwarePackage):
|
||||
def get_autostart_path(self) -> str:
|
||||
if self.desktop_entry:
|
||||
return '{}/.config/autostart/{}'.format(Path.home(), self.desktop_entry.split('/')[-1])
|
||||
|
||||
def set_custom_icon(self, custom_icon: str):
|
||||
self.custom_icon = custom_icon
|
||||
|
||||
if custom_icon:
|
||||
self.icon_url = custom_icon
|
||||
|
||||
|
||||
Reference in New Issue
Block a user