From 671c2204bfe44add6a0b40da8277bda82e35b17b Mon Sep 17 00:00:00 2001 From: DYefremov Date: Thu, 20 Oct 2022 09:03:58 +0300 Subject: [PATCH] paths setting refactoring (#123) --- app/settings.py | 14 +-- app/tools/media.py | 2 +- app/ui/picons.py | 7 +- app/ui/settings_dialog.glade | 218 +++++++++++++++++++++++++++-------- app/ui/settings_dialog.py | 14 +-- 5 files changed, 188 insertions(+), 67 deletions(-) diff --git a/app/settings.py b/app/settings.py index a6b53391..143910a2 100644 --- a/app/settings.py +++ b/app/settings.py @@ -95,7 +95,7 @@ class Defaults(Enum): STREAM_LIB = "mpv" if IS_WIN else "vlc" MAIN_LIST_PLAYBACK = False PROFILE_FOLDER_DEFAULT = False - RECORDS_PATH = f"{DATA_PATH}records{SEP}" + RECORDINGS_PATH = f"{DATA_PATH}recordings{SEP}" ACTIVATE_TRANSCODING = False ACTIVE_TRANSCODING_PRESET = f"720p TV{SEP}device" @@ -462,12 +462,12 @@ class Settings: self._cp_settings["profile_backup_path"] = value @property - def records_path(self): - return self._settings.get("records_path", Defaults.RECORDS_PATH.value) + def recordings_path(self): + return self._settings.get("recordings_path", Defaults.RECORDINGS_PATH.value) - @records_path.setter - def records_path(self, value): - self._settings["records_path"] = value + @recordings_path.setter + def recordings_path(self, value): + self._settings["recordings_path"] = value # ******** Streaming ********* # @@ -884,7 +884,7 @@ class Settings: "extra_color": Defaults.EXTRA_COLOR.value, "fav_click_mode": Defaults.FAV_CLICK_MODE.value, "profile_folder_is_default": Defaults.PROFILE_FOLDER_DEFAULT.value, - "records_path": Defaults.RECORDS_PATH.value + "records_path": Defaults.RECORDINGS_PATH.value } @staticmethod diff --git a/app/tools/media.py b/app/tools/media.py index e1134e28..eafaea5c 100644 --- a/app/tools/media.py +++ b/app/tools/media.py @@ -526,7 +526,7 @@ class Recorder: if self._recorder: self._recorder.stop() - path = self._settings.records_path + path = self._settings.recordings_path os.makedirs(os.path.dirname(path), exist_ok=True) d_now = datetime.now().strftime(LOG_DATE_FORMAT) d_now = d_now.replace(" ", "_").replace(":", "-") if IS_WIN else d_now.replace(" ", "_") diff --git a/app/ui/picons.py b/app/ui/picons.py index 7fe25864..c1b43d2c 100644 --- a/app/ui/picons.py +++ b/app/ui/picons.py @@ -42,8 +42,7 @@ from app.tools.picons import (PiconsParser, parse_providers, Provider, convert_t PiconsError) from app.tools.satellites import SatellitesParser, SatelliteSource from .dialogs import show_dialog, DialogType, get_message, get_builder, get_chooser_dialog -from .main_helper import (update_entry_data, append_text_to_tview, scroll_to, on_popup_menu, get_base_model, set_picon, - get_picon_pixbuf, get_picon_dialog) +from .main_helper import scroll_to, on_popup_menu, get_base_model, set_picon, get_picon_pixbuf, get_picon_dialog from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TV_ICON, Column, KeyboardKey, Page, ViewTarget @@ -87,7 +86,6 @@ class PiconManager(Gtk.Box): "on_receive": self.on_receive, "on_cancel": self.on_cancel, "on_remove": self.on_remove, - "on_picons_dir_open": self.on_picons_dir_open, "on_selected_toggled": self.on_selected_toggled, "on_url_changed": self.on_url_changed, "on_picons_filter_changed": self.on_picons_filter_changed, @@ -869,9 +867,6 @@ class PiconManager(Gtk.Box): def show_info_message(self, text, message_type): self._app.show_info_message(text, message_type) - def on_picons_dir_open(self, entry, icon, event_button): - update_entry_data(entry, self._app_window, settings=self._settings) - @run_idle def on_selected_toggled(self, toggle, path): model = self._providers_view.get_model() diff --git a/app/ui/settings_dialog.glade b/app/ui/settings_dialog.glade index 434a5c9d..16a3592b 100644 --- a/app/ui/settings_dialog.glade +++ b/app/ui/settings_dialog.glade @@ -599,8 +599,8 @@ Author: Dmitriy Yefremov True False - 5 - 5 + 5 + 5 5 vertical 5 @@ -649,6 +649,7 @@ Author: Dmitriy Yefremov + True False @@ -693,16 +694,47 @@ Author: Dmitriy Yefremov - + True - True - True - document-edit-symbolic - folder-open-symbolic - False - Select - Select - + False + + + True + True + True + document-edit-symbolic + False + + + False + True + 0 + + + + + True + True + True + Select + + + + True + False + folder-open-symbolic + + + + + False + True + 1 + + + 1 @@ -710,16 +742,47 @@ Author: Dmitriy Yefremov - + True - True - True - document-edit-symbolic - folder-open-symbolic - False - Select - Select - + False + + + True + True + True + document-edit-symbolic + False + + + False + True + 0 + + + + + True + True + True + Select + + + + True + False + folder-open-symbolic + + + + + False + True + 1 + + + 1 @@ -727,16 +790,47 @@ Author: Dmitriy Yefremov - + True - True - True - document-edit-symbolic - folder-open-symbolic - False - Select - Select - + False + + + True + True + True + document-edit-symbolic + False + + + False + True + 0 + + + + + True + True + True + Select + + + + True + False + folder-open-symbolic + + + + + False + True + 1 + + + 1 @@ -767,23 +861,24 @@ Author: Dmitriy Yefremov - + True False 0.019999999552965164 in - + + True False - 5 - 5 + 5 + 5 5 5 10 True - + True False Streams record path: @@ -795,26 +890,57 @@ Author: Dmitriy Yefremov - + True - True - True - document-edit-symbolic - folder-open-symbolic - False - Select - Select - + False + + + True + True + True + document-edit-symbolic + False + + + False + True + 0 + + + + + True + True + True + Select + + + + True + False + folder-open-symbolic + + + + + False + True + 1 + + + - 1 - 0 + 1 + 0 - + True False Recordings: diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index d6d5b300..ffd86946 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -42,7 +42,7 @@ class SettingsDialog: _DIGIT_PATTERN = re.compile("(?:^[\\s]*$|\\D)") def __init__(self, transient, settings: Settings): - handlers = {"on_field_icon_press": self.on_field_icon_press, + handlers = {"on_field_button_press": self.on_field_button_press, "on_settings_type_changed": self.on_settings_type_changed, "on_reset": self.on_reset, "on_response": self.on_response, @@ -119,10 +119,10 @@ class SettingsDialog: self._picons_path_field = builder.get_object("picons_path_field") self._data_path_field = builder.get_object("data_path_field") self._backup_path_field = builder.get_object("backup_path_field") - self._record_data_path_field = builder.get_object("record_data_path_field") + self._recordings_path_field = builder.get_object("recordings_path_field") self._default_data_paths_switch = builder.get_object("default_data_paths_switch") - self._default_data_paths_switch.bind_property("active", self._backup_path_field, "sensitive", 4) - self._default_data_paths_switch.bind_property("active", self._picons_path_field, "sensitive", 4) + self._default_data_paths_switch.bind_property("active", builder.get_object("picons_path_box"), "sensitive", 4) + self._default_data_paths_switch.bind_property("active", builder.get_object("backup_path_box"), "sensitive", 4) # Info bar. self._info_bar = builder.get_object("info_bar") self._message_label = builder.get_object("info_bar_message_label") @@ -278,7 +278,7 @@ class SettingsDialog: self._updated = self.on_save_settings() dialog.destroy() - def on_field_icon_press(self, entry, icon, event_button): + def on_field_button_press(self, entry): update_entry_data(entry, self._dialog, self._settings) def on_settings_type_changed(self, item): @@ -311,7 +311,7 @@ class SettingsDialog: self._data_path_field.set_text(self._settings.default_data_path) self._picons_path_field.set_text(self._settings.default_picon_path) self._backup_path_field.set_text(self._settings.default_backup_path) - self._record_data_path_field.set_text(self._settings.records_path) + self._recordings_path_field.set_text(self._settings.recordings_path) self._before_save_switch.set_active(self._settings.backup_before_save) self._before_downloading_switch.set_active(self._settings.backup_before_downloading) self._play_streams_combo_box.set_active_id(str(self._settings.play_streams_mode.value)) @@ -393,7 +393,7 @@ class SettingsDialog: self._ext_settings.default_data_path = self._data_path_field.get_text() self._ext_settings.default_backup_path = self._backup_path_field.get_text() self._ext_settings.default_picon_path = self._picons_path_field.get_text() - self._ext_settings.records_path = self._record_data_path_field.get_text() + self._ext_settings.recordings_path = self._recordings_path_field.get_text() self._ext_settings.activate_transcoding = self._transcoding_switch.get_active() self._ext_settings.active_preset = self._presets_combo_box.get_active_id() self._ext_settings.list_picon_size = int(self._picons_size_button.get_active_id())