From 3c72f0cc3c653971f3cdbb86104aae10313dea8d Mon Sep 17 00:00:00 2001 From: DYefremov Date: Sun, 15 Aug 2021 15:42:27 +0300 Subject: [PATCH] added picons page --- app/ui/main.glade | 68 ++-- app/ui/main.py | 72 ++-- app/ui/{picons_manager.glade => picons.glade} | 384 ++++++++++-------- app/ui/{picons_manager.py => picons.py} | 50 +-- 4 files changed, 281 insertions(+), 293 deletions(-) rename app/ui/{picons_manager.glade => picons.glade} (91%) rename app/ui/{picons_manager.py => picons.py} (96%) diff --git a/app/ui/main.glade b/app/ui/main.glade index 64bcf886..f9f37c07 100644 --- a/app/ui/main.glade +++ b/app/ui/main.glade @@ -1445,29 +1445,6 @@ Author: Dmitriy Yefremov 1 - - - True - False - False - True - Search - center - win.search - - - True - False - gtk-find - - - - - False - True - 2 - - False @@ -1540,6 +1517,29 @@ Author: Dmitriy Yefremov 2 + + + True + False + False + True + Search + center + win.search + + + True + False + gtk-find + + + + + False + True + 2 + + True @@ -1655,28 +1655,6 @@ Author: Dmitriy Yefremov 8 - - - True - True - True - Picons manager - - - - True - False - insert-image - - - - - False - True - end - 9 - - False diff --git a/app/ui/main.py b/app/ui/main.py index 664fccaa..9476b514 100644 --- a/app/ui/main.py +++ b/app/ui/main.py @@ -61,7 +61,7 @@ from .main_helper import (insert_marker, move_items, rename, ViewTarget, set_fla scroll_to, get_base_model, update_picons_data, copy_picon_reference, assign_picons, remove_picon, is_only_one_item_selected, gen_bouquets, BqGenType, get_iptv_url, append_picons, get_selection, get_model_data, remove_all_unused_picons, get_picon_pixbuf, get_base_itrs) -from .picons_manager import PiconsDialog +from .picons import PiconManager from .satellites import SatellitesTool, ServicesUpdateDialog from .search import SearchProvider from .service_details_dialog import ServiceDetailsDialog, Action @@ -166,7 +166,6 @@ class Application(Gtk.Application): "on_fav_press": self.on_fav_press, "on_locate_in_services": self.on_locate_in_services, "on_mark_duplicates": self.on_mark_duplicates, - "on_picons_manager_show": self.on_picons_manager_show, "on_filter_changed": self.on_filter_changed, "on_filter_type_toggled": self.on_filter_type_toggled, "on_filter_satellite_toggled": self.on_filter_satellite_toggled, @@ -204,7 +203,7 @@ class Application(Gtk.Application): "on_create_bouquet_for_each_type": self.on_create_bouquet_for_each_type, "on_add_alternatives": self.on_add_alternatives, "on_satellites_realize": self.on_satellites_realize, - "on_picons_realize": self. on_picons_realize, + "on_picons_realize": self.on_picons_realize, "on_control_realize": self.on_control_realize, "on_ftp_realize": self.on_ftp_realize, "on_visible_page": self.on_visible_page} @@ -237,7 +236,7 @@ class Application(Gtk.Application): # Tools self._links_transmitter = None self._satellite_tool = None - self._picons_manager = None + self._picon_manager = None self._control_box = None self._ftp_client = None # Player @@ -266,7 +265,6 @@ class Application(Gtk.Application): self._fav_paned = builder.get_object("fav_paned") self._tool_box = builder.get_object("tool_box") - self._fav_paned.bind_property("visible", self._tool_box, "visible") self._services_view = builder.get_object("services_tree_view") self._fav_view = builder.get_object("fav_tree_view") self._bouquets_view = builder.get_object("bouquets_tree_view") @@ -393,28 +391,6 @@ class Application(Gtk.Application): gen = self.init_http_api() GLib.idle_add(lambda: next(gen, False), priority=GLib.PRIORITY_LOW) - # ************** Pages initialization *************** # - - def on_satellites_realize(self, box): - self._satellite_tool = SatellitesTool(self, self._settings) - box.pack_start(self._satellite_tool, True, True, 0) - - def on_picons_realize(self, box): - self._picons_manager = None - - def on_ftp_realize(self, box): - self._ftp_client = FtpClientBox(self, self._settings) - box.pack_start(self._ftp_client, True, True, 0) - - def on_control_realize(self, box: Gtk.HBox): - self._control_box = ControlBox(self, self._http_api, self._settings) - box.pack_start(self._control_box, True, True, 0) - - def on_visible_page(self, stack, param): - page = Page(stack.get_visible_child_name()) - self._fav_paned.set_visible(page in (Page.SERVICES, Page.PLAYBACK)) - self._save_header_button.set_visible(page in (Page.SERVICES, Page.SATELLITE)) - def init_keys(self): self.set_action("on_close_app", self.on_close_app) self.set_action("on_data_save", self.on_data_save) @@ -653,7 +629,37 @@ class Application(Gtk.Application): return move_items(key, self._fav_view if self._fav_view.is_focus() else self._bouquets_view) - # ***************** Copy - Cut - Paste *********************# + # ************** Pages initialization *************** # + + def on_satellites_realize(self, box): + self._satellite_tool = SatellitesTool(self, self._settings) + box.pack_start(self._satellite_tool, True, True, 0) + + def on_picons_realize(self, box): + ids = {} + if self._s_type is SettingsType.ENIGMA_2: + for r in self._services_model: + data = r[Column.SRV_PICON_ID].split("_") + ids["{}:{}:{}".format(data[3], data[5], data[6])] = r[Column.SRV_PICON_ID] + + self._picon_manager = PiconManager(self, self._settings, ids, self._sat_positions) + box.pack_start(self._picon_manager, True, True, 0) + + def on_ftp_realize(self, box): + self._ftp_client = FtpClientBox(self, self._settings) + box.pack_start(self._ftp_client, True, True, 0) + + def on_control_realize(self, box: Gtk.HBox): + self._control_box = ControlBox(self, self._http_api, self._settings) + box.pack_start(self._control_box, True, True, 0) + + def on_visible_page(self, stack, param): + page = Page(stack.get_visible_child_name()) + self._fav_paned.set_visible(page in (Page.SERVICES, Page.PICONS, Page.PLAYBACK)) + self._save_header_button.set_visible(page in (Page.SERVICES, Page.SATELLITE)) + self._tool_box.set_visible(page is Page.SERVICES) + + # ***************** Copy - Cut - Paste ********************* # def on_services_copy(self, view): self.on_copy(view, target=ViewTarget.FAV) @@ -1372,7 +1378,6 @@ class Application(Gtk.Application): menu.popup(None, None, None, None, event.button, event.time) return True - def on_download(self, action=None, value=None): dialog = DownloadDialog(self._main_window, self._settings, self.open_data, self.update_settings) @@ -3212,15 +3217,6 @@ class Application(Gtk.Application): # ***************** Picons *********************# - def on_picons_manager_show(self, action, value=None): - ids = {} - if self._s_type is SettingsType.ENIGMA_2: - for r in self._services_model: - data = r[Column.SRV_PICON_ID].split("_") - ids["{}:{}:{}".format(data[3], data[5], data[6])] = r[Column.SRV_PICON_ID] - - PiconsDialog(self._main_window, self._settings, ids, self._sat_positions, self).show() - @run_task def update_picons(self): update_picons_data(self._settings.picons_local_path, self._picons, self._picons_size) diff --git a/app/ui/picons_manager.glade b/app/ui/picons.glade similarity index 91% rename from app/ui/picons_manager.glade rename to app/ui/picons.glade index 21194022..9a0176a3 100644 --- a/app/ui/picons_manager.glade +++ b/app/ui/picons.glade @@ -27,7 +27,7 @@ Author: Dmitriy Yefremov --> - + @@ -83,7 +83,6 @@ Author: Dmitriy Yefremov Remove True - @@ -145,7 +144,6 @@ Author: Dmitriy Yefremov Remove True - @@ -217,55 +215,44 @@ Author: Dmitriy Yefremov - + + True False - center-on-parent - True - True - True - center - - - + 0 + in + + True False - True + 5 + 5 + 5 + 5 + vertical + 5 - - False - True - Cancel - True - - - - True - False - gtk-cancel - - - - - - 1 - - - - + True False - 2 + 15 + 15 + 10 + 5 + 5 - - False + False - Source: - 0 - - Picon.cz - LyngSat - - + True + Cancel + True + + + + True + False + gtk-cancel + + False @@ -274,20 +261,117 @@ Author: Dmitriy Yefremov - - False + + True False - False - Receive picons - center - True - + 2 - + + False + False + Source: + 0 + + Picon.cz + LyngSat + + + + + False + True + 0 + + + + + False + False + False + Receive picons + center + True + + + + True + False + gtk-goto-bottom + + + + + False + True + 1 + + + + True False - gtk-goto-bottom + True + Transfer to receiver + True + + + + + True + False + gtk-go-up + + + + False + True + 4 + + + + + True + False + True + Download from the receiver + + + + + True + False + gtk-go-down + + + + + False + True + 5 + + + + + True + False + True + Remove all picons from the receiver + + + + + True + False + gtk-delete + + + + + False + True + 6 + @@ -296,44 +380,11 @@ Author: Dmitriy Yefremov 1 - - + + True False - True - Transfer to receiver - True - - - - - True - False - gtk-go-up - - - - - False - True - 4 - - - - - True - False - True - Download from the receiver - - - - - True - False - gtk-go-down - - + stack False @@ -342,110 +393,80 @@ Author: Dmitriy Yefremov - - True + False - True - Remove all picons from the receiver - - + False + Convert + center + True + - + True False - gtk-delete + gtk-execute False True - 6 + end + 2 + + + + + True + False + True + Filter + + + + True + False + Filter + gtk-select-all + + + + + False + True + end + 3 + + + + + True + False + False + Details + False + + + True + False + gtk-dialog-info + + + + + False + True + end + 4 - 6 + False + True + 0 - - - True - False - stack - - - - - False - False - Convert - center - True - - - - True - False - gtk-execute - - - - - end - 4 - - - - - True - False - True - Filter - - - - True - False - Filter - gtk-select-all - - - - - - end - 4 - - - - - True - False - False - Details - False - - - True - False - gtk-dialog-info - - - - - - end - 5 - - - - - - - True - False - vertical True @@ -1702,7 +1723,7 @@ Author: Dmitriy Yefremov True True - 0 + 1 @@ -1741,7 +1762,7 @@ Author: Dmitriy Yefremov False True - 1 + 2 @@ -1798,10 +1819,13 @@ Author: Dmitriy Yefremov False True - 2 + 3 + + + diff --git a/app/ui/picons_manager.py b/app/ui/picons.py similarity index 96% rename from app/ui/picons_manager.py rename to app/ui/picons.py index 1de92a32..be669a5a 100644 --- a/app/ui/picons_manager.py +++ b/app/ui/picons.py @@ -47,15 +47,17 @@ from .main_helper import (update_entry_data, append_text_to_tview, scroll_to, on from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TV_ICON, Column, KeyboardKey -class PiconsDialog: +class PiconManager(Gtk.Box): class DownloadSource(Enum): LYNG_SAT = "lyngsat" PICON_CZ = "piconcz" - def __init__(self, transient, settings, picon_ids, sat_positions, app): + def __init__(self, app, settings, picon_ids, sat_positions, *args, **kwargs): + super().__init__(*args, **kwargs) + + self._app = app self._picon_ids = picon_ids self._sat_positions = sat_positions - self._app = app self._BASE_URL = "www.lyngsat.com/packages/" self._PATTERN = re.compile(r"^https://www\.lyngsat\.com/[\w-]+\.html$") self._POS_PATTERN = re.compile(r"^\d+\.\d+[EW]?$") @@ -74,7 +76,6 @@ class PiconsDialog: handlers = {"on_receive": self.on_receive, "on_cancel": self.on_cancel, - "on_close": self.on_close, "on_send": self.on_send, "on_download": self.on_download, "on_remove": self.on_remove, @@ -116,10 +117,9 @@ class PiconsDialog: "on_tree_view_key_press": self.on_tree_view_key_press, "on_popup_menu": on_popup_menu} - builder = get_builder(UI_RESOURCES_PATH + "picons_manager.glade", handlers) + builder = get_builder(UI_RESOURCES_PATH + "picons.glade", handlers) - self._dialog = builder.get_object("picons_dialog") - self._dialog.set_transient_for(transient) + self._app_window = app.get_active_window() self._picons_src_view = builder.get_object("picons_src_view") self._picons_dest_view = builder.get_object("picons_dest_view") self._providers_view = builder.get_object("providers_view") @@ -191,9 +191,8 @@ class PiconsDialog: self._s_type = settings.setting_type self._picons_dir_entry.set_text(self._settings.picons_local_path) - window_size = self._settings.get("picons_downloader_window_size") - if window_size: - self._dialog.resize(*window_size) + self.pack_start(builder.get_object("picon_manager_frame"), True, True, 0) + self.show() if not len(self._picon_ids) and self._s_type is SettingsType.ENIGMA_2: message = get_message("To automatically set the identifiers for picons,\n" @@ -201,9 +200,6 @@ class PiconsDialog: self.show_info_message(message, Gtk.MessageType.WARNING) self._satellite_label.show() - def show(self): - self._dialog.show() - def on_picons_dest_view_realize(self, view): self._services = {s.picon_id: s for s in self._app.current_services.values() if s.picon_id} self._explorer_dest_path_button.select_filename(self._settings.picons_local_path) @@ -436,7 +432,7 @@ class PiconsDialog: def on_local_remove(self, view): model, paths = view.get_selection().get_selected_rows() - if paths and show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.OK: + if paths and show_dialog(DialogType.QUESTION, self._app_window) == Gtk.ResponseType.OK: itr = model.get_iter(paths.pop()) p_path = Path(model.get_value(itr, 2)).resolve() if p_path.is_file(): @@ -474,7 +470,7 @@ class PiconsDialog: files_filter=files_filter), True) def on_remove(self, item=None, files_filter=None): - if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.CANCEL: + if show_dialog(DialogType.QUESTION, self._app_window) == Gtk.ResponseType.CANCEL: return self.run_func(lambda: remove_picons(settings=self._settings, @@ -490,12 +486,12 @@ class PiconsDialog: def check_dest_path(self): """ Checks the destination path and returns if present. """ - if show_dialog(DialogType.QUESTION, self._dialog) != Gtk.ResponseType.OK: + if show_dialog(DialogType.QUESTION, self._app_window) != Gtk.ResponseType.OK: return path = self._explorer_dest_path_button.get_filename() if not path: - show_dialog(DialogType.ERROR, transient=self._dialog, text="Select paths!") + show_dialog(DialogType.ERROR, transient=self._app_window, text="Select paths!") return return path @@ -774,7 +770,7 @@ class PiconsDialog: self.show_info_message(get_message("Done!"), Gtk.MessageType.INFO) def on_cancel(self, item=None): - if self._is_downloading and show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.CANCEL: + if self._is_downloading and show_dialog(DialogType.QUESTION, self._app_window) == Gtk.ResponseType.CANCEL: return True self.terminate_task() @@ -791,14 +787,8 @@ class PiconsDialog: self._terminate = True self._is_downloading = False - self.save_window_size(window) self._app.update_picons() - GLib.idle_add(self._dialog.destroy) - - def save_window_size(self, window): - size = window.get_size() - height = size.height - self._text_view.get_allocated_height() - self._info_bar.get_allocated_height() - self._settings.add("picons_downloader_window_size", (size.width, height)) + GLib.idle_add(self._app_window.destroy) @run_task def run_func(self, func, update=False): @@ -824,7 +814,7 @@ class PiconsDialog: self._info_bar.set_visible(True) def on_picons_dir_open(self, entry, icon, event_button): - update_entry_data(entry, self._dialog, settings=self._settings) + update_entry_data(entry, self._app_window, settings=self._settings) @run_idle def on_selected_toggled(self, toggle, path): @@ -954,7 +944,7 @@ class PiconsDialog: model.set_value(model.get_iter(path), 2, value) @run_idle - def on_visible_page(self, stack: Gtk.Stack, param): + def on_visible_page(self, stack, param): name = stack.get_visible_child_name() self._convert_button.set_visible(name == "converter") self._download_source_button.set_visible(name == "downloader") @@ -965,13 +955,13 @@ class PiconsDialog: @run_idle def on_convert(self, item): - if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.CANCEL: + if show_dialog(DialogType.QUESTION, self._app_window) == Gtk.ResponseType.CANCEL: return picons_path = self._enigma2_path_button.get_filename() save_path = self._save_to_button.get_filename() if not picons_path or not save_path: - show_dialog(DialogType.ERROR, transient=self._dialog, text="Select paths!") + show_dialog(DialogType.ERROR, transient=self._app_window, text="Select paths!") return self._expander.set_expanded(True) @@ -994,7 +984,7 @@ class PiconsDialog: @run_idle def show_dialog(self, message, dialog_type): - show_dialog(dialog_type, self._dialog, message) + show_dialog(dialog_type, self._app_window, message) def get_picons_format(self): picon_format = SettingsType.ENIGMA_2