[ui] feature: themes

This commit is contained in:
Vinicius Moreira
2020-11-27 15:52:57 -03:00
parent 813c812030
commit 60228eec97
176 changed files with 11941 additions and 2985 deletions

View File

@@ -5,6 +5,7 @@ from bauh.api.abstract.cache import MemoryCacheFactory
from bauh.api.abstract.disk import DiskCacheLoaderFactory
from bauh.api.abstract.download import FileDownloader
from bauh.api.http import HttpClient
from bauh.commons.internet import InternetChecker
from bauh.view.util.translation import I18n
@@ -12,7 +13,8 @@ class ApplicationContext:
def __init__(self, download_icons: bool, http_client: HttpClient, app_root_dir: str, i18n: I18n,
cache_factory: MemoryCacheFactory, disk_loader_factory: DiskCacheLoaderFactory,
logger: logging.Logger, file_downloader: FileDownloader, distro: str, app_name: str):
logger: logging.Logger, file_downloader: FileDownloader, distro: str, app_name: str,
internet_checker: InternetChecker):
"""
:param download_icons: if packages icons should be downloaded
:param http_client: a shared instance of http client
@@ -24,7 +26,7 @@ class ApplicationContext:
:param file_downloader
:param distro
:param app_name
:param root_password
:param internet_checker
"""
self.download_icons = download_icons
self.http_client = http_client
@@ -40,9 +42,13 @@ class ApplicationContext:
'Graphics', 'Network', 'Office', 'Science', 'Settings', 'System', 'Utility')
self.app_name = app_name
self.root_password = None
self.internet_checker = internet_checker
def is_system_x86_64(self):
return self.arch_x86_64
def get_view_path(self):
return self.app_root_dir + '/view'
def is_internet_available(self) -> bool:
return self.internet_checker.is_available()

View File

@@ -52,7 +52,7 @@ class UpgradeRequirement:
class UpgradeRequirements:
def __init__(self, to_install: List[UpgradeRequirement], to_remove: List[UpgradeRequirement],
def __init__(self, to_install: Optional[List[UpgradeRequirement]], to_remove: Optional[List[UpgradeRequirement]],
to_upgrade: List[UpgradeRequirement], cannot_upgrade: List[UpgradeRequirement]):
"""
:param to_install: additional packages that must be installed with the upgrade
@@ -264,7 +264,7 @@ class SoftwareManager(ABC):
f.write(icon_bytes)
@abstractmethod
def requires_root(self, action: str, pkg: SoftwarePackage):
def requires_root(self, action: str, pkg: Optional[SoftwarePackage]):
"""
if a given action requires root privileges to be executed. Current actions are: 'install', 'uninstall', 'downgrade', 'search', 'refresh', 'prepare'
:param action:
@@ -274,11 +274,12 @@ class SoftwareManager(ABC):
pass
@abstractmethod
def prepare(self, task_manager: TaskManager, root_password: str, internet_available: bool):
def prepare(self, task_manager: Optional[TaskManager], root_password: Optional[str], internet_available: Optional[bool]):
"""
It prepares the manager to start working. It will be called by GUI. Do not call it within.
:param task_manager: a task manager instance used to register ongoing tasks during prepare
:param root_password
:param internet_available: if there is internet connection available
:return:
"""
pass

View File

@@ -77,10 +77,10 @@ class ProcessWatcher:
:return: if the use requested to stop the process.
"""
def request_root_password(self) -> Tuple[str, bool]:
def request_root_password(self) -> Tuple[bool, str]:
"""
asks the root password for the user
:return: a tuple with the typed password and if it is valid
:return: a tuple informing if the password is valid and its text
"""

View File

@@ -3,7 +3,7 @@ from enum import Enum
from typing import List, Set, Optional
class MessageType:
class MessageType(Enum):
INFO = 0
WARNING = 1
ERROR = 2
@@ -19,7 +19,7 @@ class ViewComponent(ABC):
"""
Represents a GUI component
"""
def __init__(self, id_: str, observers: List[ViewObserver] = None):
def __init__(self, id_: Optional[str], observers: Optional[List[ViewObserver]] = None):
self.id = id_
self.observers = observers if observers else []
@@ -56,12 +56,15 @@ class InputOption:
Represents a select component option.
"""
def __init__(self, label: str, value: object, tooltip: str = None, icon_path: str = None, read_only: bool = False, id_: str = None):
def __init__(self, label: str, value: object, tooltip: Optional[str] = None,
icon_path: Optional[str] = None, read_only: bool = False, id_: Optional[str] = None,
invalid: bool = False):
"""
:param label: the string that will be shown to the user
:param value: the option value (not shown)
:param tooltip: an optional tooltip
:param icon_path: an optional icon path
:param invalid: if this option is considered invalid
"""
if not label:
raise Exception("'label' must be a not blank string")
@@ -72,6 +75,7 @@ class InputOption:
self.tooltip = tooltip
self.icon_path = icon_path
self.read_only = read_only
self.invalid = invalid
def __hash__(self):
return hash(self.label) + hash(self.value)
@@ -155,9 +159,10 @@ class TextInputType(Enum):
class TextInputComponent(ViewComponent):
def __init__(self, label: str, value: str = '', placeholder: str = None, tooltip: str = None, read_only: bool =False,
id_: str = None, only_int: bool = False, max_width: int = -1, type_: TextInputType = TextInputType.SINGLE_LINE,
capitalize_label: bool = True, min_width: int = -1, min_height: int = -1):
def __init__(self, label: str, value: str = '', placeholder: Optional[str] = None, tooltip: Optional[str] = None,
read_only: bool = False, id_: Optional[str] = None, only_int: bool = False, max_width: int = -1,
type_: TextInputType = TextInputType.SINGLE_LINE, capitalize_label: bool = True, min_width: int = -1,
min_height: int = -1):
super(TextInputComponent, self).__init__(id_=id_)
self.label = label
self.value = value
@@ -216,9 +221,9 @@ class FormComponent(ViewComponent):
class FileChooserComponent(ViewComponent):
def __init__(self, allowed_extensions: Set[str] = None, label: str = None, tooltip: str = None,
file_path: str = None, max_width: int = -1, id_: str = None, search_path: str = None, capitalize_label: bool = True,
directory: bool = False):
def __init__(self, allowed_extensions: Optional[Set[str]] = None, label: Optional[str] = None, tooltip: Optional[str] = None,
file_path: Optional[str] = None, max_width: int = -1, id_: Optional[str] = None,
search_path: Optional[str] = None, capitalize_label: bool = True, directory: bool = False):
super(FileChooserComponent, self).__init__(id_=id_)
self.label = label
self.allowed_extensions = allowed_extensions
@@ -229,7 +234,7 @@ class FileChooserComponent(ViewComponent):
self.capitalize_label = capitalize_label
self.directory = directory
def set_file_path(self, fpath: str):
def set_file_path(self, fpath: Optional[str]):
self.file_path = fpath
if self.observers:

View File

@@ -3,5 +3,6 @@ from pathlib import Path
CACHE_PATH = '{}/.cache/bauh'.format(str(Path.home()))
CONFIG_PATH = '{}/.config/bauh'.format(str(Path.home()))
USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home()))
DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home()))
TEMP_DIR = '/tmp/bauh{}'.format('_root' if os.getuid() == 0 else '')