Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "Der Theme-Editor wurde beendet. Siehe theme_server.txt im PortMaster-Ordner.",
"{theme_name} (Selected)": "{theme_name} (Ausgewählt)",
"Download": "Herunterladen",
"Theme {theme_name} is not downloaded, would you like to download it?": "Das Theme {theme_name} ist nicht heruntergeladen. Möchten Sie es herunterladen?",
"{item_name} (Selected)": "{item_name} (Ausgewählt)",
"Please wait.": "Bitte warten.",
"Up to date already": "Neuste Version bereits installiert",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "El editor de temas se ha detenido. Consulta theme_server.txt en la carpeta de PortMaster.",
"{theme_name} (Selected)": "{theme_name} (seleccionado)",
"Download": "Descargar",
"Theme {theme_name} is not downloaded, would you like to download it?": "El tema {theme_name} no está descargado, ¿quieres descargarlo?",
"{item_name} (Selected)": "{item_name} (seleccionado)",
"Please wait.": "Espera, por favor.",
"Up to date already": "Ya está actualizado",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "L'éditeur de thèmes s'est arrêté. Voir theme_server.txt dans le dossier de PortMaster.",
"{theme_name} (Selected)": "{theme_name} (Sélectionné)",
"Download": "Télécharger",
"Theme {theme_name} is not downloaded, would you like to download it?": "Le thème {theme_name} n'est pas téléchargé, voulez-vous le télécharger ?",
"{item_name} (Selected)": "{item_name} (Sélectionné)",
"Please wait.": "Veuillez patienter.",
"Up to date already": "Déjà à jour",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "L'editor dei temi si è fermato. Vedi theme_server.txt nella cartella di PortMaster.",
"{theme_name} (Selected)": "{theme_name} (Attuale)",
"Download": "Download",
"Theme {theme_name} is not downloaded, would you like to download it?": "Il tema {theme_name} non è scaricato, vuoi scaricarlo?",
"{item_name} (Selected)": "{item_name} (Attuale)",
"Please wait.": "Attendi.",
"Up to date already": "Già aggiornata",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "テーマエディターが停止しました。PortMaster フォルダーの theme_server.txt を確認してください。",
"{theme_name} (Selected)": "{theme_name} (選択済み)",
"Download": "ダウンロード",
"Theme {theme_name} is not downloaded, would you like to download it?": "テーマ {theme_name} はダウンロードされていません。ダウンロードしますか?",
"{item_name} (Selected)": "{item_name} (選択済み)",
"Please wait.": "お待ちください。",
"Up to date already": "既に最新の状態です",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "테마 편집기가 중지되었습니다. PortMaster 폴더의 theme_server.txt를 확인하세요.",
"{theme_name} (Selected)": "{theme_name} (선택됨)",
"Download": "다운로드",
"Theme {theme_name} is not downloaded, would you like to download it?": "{theme_name} 테마가 다운로드되지 않았습니다. 다운로드하시겠습니까?",
"{item_name} (Selected)": "{item_name} (선택됨)",
"Please wait.": "잠시 기다려 주세요.",
"Up to date already": "이미 최신 상태입니다.",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/nl_NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "De thema-editor is gestopt. Zie theme_server.txt in de PortMaster-map.",
"{theme_name} (Selected)": "{theme_name} (Geselecteerd)",
"Download": "Download",
"Theme {theme_name} is not downloaded, would you like to download it?": "Thema {theme_name} is niet gedownload, wilt u het downloaden?",
"{item_name} (Selected)": "{item_name} (Geselecteerd)",
"Please wait.": "Even geduld.",
"Up to date already": "Al bijgewerkt",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "Edytor motywów się zatrzymał. Zobacz theme_server.txt w folderze PortMastera.",
"{theme_name} (Selected)": "{theme_name} (Wybrany)",
"Download": "Pobierz",
"Theme {theme_name} is not downloaded, would you like to download it?": "Motyw {theme_name} nie jest pobrany, czy chcesz go pobrać?",
"{item_name} (Selected)": "{item_name} (Wybrany)",
"Please wait.": "Proszę czekać.",
"Up to date already": "Już aktualne",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "O editor de temas parou. Veja theme_server.txt na pasta do PortMaster.",
"{theme_name} (Selected)": "{theme_name} (Selecionado)",
"Download": "Baixar",
"Theme {theme_name} is not downloaded, would you like to download it?": "O tema {theme_name} não foi baixado, deseja baixá-lo?",
"{item_name} (Selected)": "{item_name} (Selecionado)",
"Please wait.": "Aguarde.",
"Up to date already": "Já está atualizado",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/ro_RO.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "Editorul de teme s-a oprit. Vezi theme_server.txt în folderul PortMaster.",
"{theme_name} (Selected)": "{theme_name} (Selectat)",
"Download": "Descarcă",
"Theme {theme_name} is not downloaded, would you like to download it?": "Tema {theme_name} nu este descărcată, vrei să o descarci?",
"{item_name} (Selected)": "{item_name} (Selectat)",
"Please wait.": "Te rugăm să aștepți.",
"Up to date already": "Deja la zi",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "Редактор тем остановился. См. theme_server.txt в папке PortMaster.",
"{theme_name} (Selected)": "{theme_name} (Выбрана)",
"Download": "Скачать",
"Theme {theme_name} is not downloaded, would you like to download it?": "Тема {theme_name} не загружена. Загрузить её?",
"{item_name} (Selected)": "{item_name} (Выбранная)",
"Please wait.": "Пожалуйста, подождите.",
"Up to date already": "Актуальная версия уже существует",
Expand Down
23 changes: 13 additions & 10 deletions PortMaster/pylibs/locales/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,19 @@
],
"Updating": [
"pylibs/harbourmaster/source/portmaster.py:42",
"pylibs/pugwash/theme.py:581"
"pylibs/pugwash/theme.py:588"
],
"Fetching latest info": [
"pylibs/harbourmaster/source/portmaster.py:46",
"pylibs/pugwash/theme.py:591"
"pylibs/pugwash/theme.py:598"
],
"Done.": [
"pylibs/harbourmaster/source/portmaster.py:165",
"pylibs/pugwash/theme.py:614"
"pylibs/pugwash/theme.py:621"
],
"Fetching info": [
"pylibs/harbourmaster/source/portmaster.py:197",
"pylibs/pugwash/theme.py:620"
"pylibs/pugwash/theme.py:627"
],
"Unable to find {port_name}.": [
"pylibs/harbourmaster/source/portmaster.py:418"
Expand Down Expand Up @@ -433,7 +433,7 @@
"pylibs/pugwash/scenes/keyboard.py:41",
"pylibs/pugwash/scenes/language.py:30",
"pylibs/pugwash/scenes/themes.py:46",
"pylibs/pugwash/scenes/themes.py:127"
"pylibs/pugwash/scenes/themes.py:145"
],
"Back": [
"pylibs/pugwash/scenes/featured.py:30",
Expand All @@ -451,8 +451,8 @@
"pylibs/pugwash/scenes/runtimes.py:109",
"pylibs/pugwash/scenes/runtimes.py:112",
"pylibs/pugwash/scenes/themes.py:48",
"pylibs/pugwash/scenes/themes.py:126",
"pylibs/pugwash/scenes/themes.py:127"
"pylibs/pugwash/scenes/themes.py:144",
"pylibs/pugwash/scenes/themes.py:145"
],
"No featured ports found, internet connection is required.": [
"pylibs/pugwash/scenes/featured.py:47"
Expand Down Expand Up @@ -712,7 +712,7 @@
],
"Select Color Scheme": [
"pylibs/pugwash/scenes/options.py:43",
"pylibs/pugwash/scenes/themes.py:106"
"pylibs/pugwash/scenes/themes.py:124"
],
"Select a color scheme for PortMaster.": [
"pylibs/pugwash/scenes/options.py:44"
Expand Down Expand Up @@ -1057,14 +1057,17 @@
"Download": [
"pylibs/pugwash/scenes/themes.py:51"
],
"Theme {theme_name} is not downloaded, would you like to download it?": [
"pylibs/pugwash/scenes/themes.py:82"
],
"{item_name} (Selected)": [
"pylibs/pugwash/scenes/themes.py:120"
"pylibs/pugwash/scenes/themes.py:138"
],
"Please wait.": [
"pylibs/pugwash/theme.py:358"
],
"Up to date already": [
"pylibs/pugwash/theme.py:588"
"pylibs/pugwash/theme.py:595"
],
"You are switching from the {old_release_channel} to the {new_release_channel} version.\n\nDo you want to downgrade?": [
"pylibs/pugwash/update.py:79"
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "Temaredigeraren stoppades. Se theme_server.txt i PortMaster-mappen.",
"{theme_name} (Selected)": "{theme_name} (Vald)",
"Download": "Hämta",
"Theme {theme_name} is not downloaded, would you like to download it?": "Temat {theme_name} är inte nedladdat, vill du ladda ner det?",
"{item_name} (Selected)": "{item_name} (Vald)",
"Please wait.": "Vänta.",
"Up to date already": "Redan uppdaterad",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/uk_UA.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "Редактор тем зупинився. Див. theme_server.txt у теці PortMaster.",
"{theme_name} (Selected)": "{theme_name} (Обрано)",
"Download": "Завантажити",
"Theme {theme_name} is not downloaded, would you like to download it?": "Тему {theme_name} не завантажено. Завантажити її?",
"{item_name} (Selected)": "{item_name} (Обрано)",
"Please wait.": "Будь ласка, зачекайте.",
"Up to date already": "Вже оновлено",
Expand Down
1 change: 1 addition & 0 deletions PortMaster/pylibs/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"The theme editor stopped. See theme_server.txt in the PortMaster folder.": "主题编辑器已停止。请查看 PortMaster 文件夹中的 theme_server.txt。",
"{theme_name} (Selected)": "{theme_name} (已选)",
"Download": "下载",
"Theme {theme_name} is not downloaded, would you like to download it?": "主题 {theme_name} 尚未下载,是否要下载?",
"{item_name} (Selected)": "{item_name} (已选)",
"Please wait.": "请稍候。",
"Up to date already": "已经更新",
Expand Down
42 changes: 30 additions & 12 deletions PortMaster/pylibs/pugwash/scenes/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def update_selection(self):

self.set_buttons(keys)

def download_theme(self):
theme_info = self.themes[self.last_select]

with self.gui.enable_cancellable(True):
with self.gui.enable_messages():
self.gui.do_install(theme_info['name'], theme_info['url'] + ".md5")

self.themes = self.gui.themes.get_themes_list(
self.gui.theme_downloader.get_theme_list())

self.update_selection()

def do_update(self, events):
super().do_update(events)

Expand All @@ -63,9 +75,24 @@ def do_update(self, events):
theme_info = self.themes[self.last_select]

if theme_info['status'] not in ("Installed", "Update Available"):
return True
if theme_info['url'] is None:
return True

self.button_activate()
if not self.gui.message_box(
_("Theme {theme_name} is not downloaded, would you like to download it?").format(
theme_name=theme_info['name']),
want_cancel=True):
return True

self.button_activate()
self.download_theme()

## Downloaded: on to what A does for it, using it.
if self.themes.get(self.last_select, {}).get('status') not in ("Installed", "Update Available"):
return True

else:
self.button_activate()

## Applies straight away, back in this list.
from .options import OptionScene
Expand All @@ -82,16 +109,7 @@ def do_update(self, events):
return True

self.button_activate()

with self.gui.enable_cancellable(True):
with self.gui.enable_messages():
self.gui.do_install(theme_info['name'], theme_info['url'] + ".md5")

self.themes = self.gui.themes.get_themes_list(
self.gui.theme_downloader.get_theme_list())

self.update_selection()

self.download_theme()
return True

elif events.was_pressed('B'):
Expand Down
68 changes: 64 additions & 4 deletions tests/test_gui_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def test_themes_select(screen_gui, themes, monkeypatch):
assert screen_gui.events.running is True


def test_themes_not_installed_cant_be_selected(screen_gui, themes, monkeypatch):
def test_themes_x_downloads(screen_gui, themes, monkeypatch):
themes.themes['remote_theme'] = dict(themes.themes['default_theme'], name="Remote", status="Not Installed", url="https://example.com/remote.theme.zip")
## Still listed after the download reloads the list.
listed = dict(themes.themes)
Expand All @@ -509,13 +509,73 @@ def test_themes_not_installed_cant_be_selected(screen_gui, themes, monkeypatch):
screen_gui.do_loop(no_delay=True)
assert "Download" in bar(themes) and "Select" not in bar(themes)

press(screen_gui, monkeypatch, 'A')
assert screen_gui.boxes == []

press(screen_gui, monkeypatch, 'X')
assert installs == [("Remote", "https://example.com/remote.theme.zip.md5")]


@pytest.fixture
def remote_theme(screen_gui, themes, monkeypatch):
"""A theme that isn't downloaded, selected; `installs` gets what was downloaded, `reloads` what was applied."""
themes.themes['remote_theme'] = dict(themes.themes['default_theme'], name="Remote", status="Not Installed", url="https://example.com/remote.theme.zip")
listed = {name: dict(info) for name, info in themes.themes.items()}
monkeypatch.setattr(screen_gui.themes, "get_themes_list", lambda *args: {name: dict(info) for name, info in listed.items()})
themes.tags['themes_list'].add_option('remote_theme', "Remote")

remote_theme = type("Remote", (), {})()
remote_theme.installs = []
remote_theme.reloads = []
remote_theme.listed = listed

def do_install(name, url):
remote_theme.installs.append((name, url))
if remote_theme.works:
listed['remote_theme']['status'] = "Installed"

remote_theme.works = True
monkeypatch.setattr(screen_gui, "do_install", do_install)
monkeypatch.setattr(screen_gui, "reload_theme", lambda then=None: remote_theme.reloads.append([name for name, _ in then]))
monkeypatch.setitem(screen_gui.hm.cfg_data, 'theme', 'default_theme')

select(themes, 'remote_theme', tag='themes_list')
screen_gui.do_loop(no_delay=True)
return remote_theme


def test_themes_a_asks_to_download(screen_gui, themes, remote_theme, monkeypatch):
## A on a theme that isn't downloaded asks; yes downloads it, then uses it.
press(screen_gui, monkeypatch, 'A')

assert screen_gui.boxes == ["Theme Remote is not downloaded, would you like to download it?"]
assert remote_theme.installs == [("Remote", "https://example.com/remote.theme.zip.md5")]
assert screen_gui.hm.cfg_data['theme'] == 'remote_theme'
assert remote_theme.reloads == [['option', 'select-theme']]


def test_themes_a_download_declined(screen_gui, themes, remote_theme, monkeypatch):
screen_gui.answer = False
press(screen_gui, monkeypatch, 'A')

assert len(screen_gui.boxes) == 1
assert remote_theme.installs == [] and remote_theme.reloads == []
assert screen_gui.hm.cfg_data['theme'] == 'default_theme'


def test_themes_a_download_failed(screen_gui, themes, remote_theme, monkeypatch):
## Still not installed afterwards (failed, cancelled): the theme stays as it was.
remote_theme.works = False
press(screen_gui, monkeypatch, 'A')

assert len(remote_theme.installs) == 1
assert remote_theme.reloads == [] and screen_gui.hm.cfg_data['theme'] == 'default_theme'


def test_themes_a_without_a_url(screen_gui, themes, remote_theme, monkeypatch):
## Not installed and nowhere to download it from: nothing to ask.
themes.themes['remote_theme']['url'] = None
press(screen_gui, monkeypatch, 'A')
assert screen_gui.boxes == [] and remote_theme.installs == []


def test_themes_x_without_a_url(screen_gui, themes, monkeypatch):
installs = []
monkeypatch.setattr(screen_gui, "do_install", lambda name, url: installs.append(name))
Expand Down
Loading