diff --git a/app/ui/main_helper.py b/app/ui/main_helper.py index efeedfcd..b13b2de2 100644 --- a/app/ui/main_helper.py +++ b/app/ui/main_helper.py @@ -37,7 +37,7 @@ from gi.repository import GdkPixbuf, GLib from app.eparser import Service from app.eparser.ecommons import Flag, BouquetService, Bouquet, BqType from app.eparser.enigma.bouquets import BqServiceType, to_bouquet_id -from app.settings import SettingsType, SEP +from app.settings import SettingsType, SEP, IS_WIN from .dialogs import show_dialog, DialogType, get_chooser_dialog from .uicommons import ViewTarget, BqGenType, Gtk, Gdk, HIDE_ICON, LOCKED_ICON, KeyboardKey, Column @@ -412,6 +412,10 @@ def assign_picons(target, srv_view, fav_view, transient, picons, settings, servi if src_path == Gtk.ResponseType.CANCEL: return picons_files + if IS_WIN: + src_path = src_path.lstrip("/") + dst_path = dst_path.lstrip("/") if dst_path else dst_path + if not str(src_path).endswith(".png") or not os.path.isfile(src_path): show_dialog(DialogType.ERROR, transient, text="No png file is selected!") return picons_files diff --git a/app/ui/picons.glade b/app/ui/picons.glade index 2dbe134b..e96ce7a2 100644 --- a/app/ui/picons.glade +++ b/app/ui/picons.glade @@ -249,62 +249,16 @@ Author: Dmitriy Yefremov True False - gtk-execute + edit-redo-symbolic False True - end 0 - - - True - False - False - Details - False - - - True - False - emblem-important-symbolic - - - - - False - True - end - 0 - - - - - True - True - True - Filter - - - - True - False - Filter - edit-find-replace-symbolic - - - - - False - True - end - 1 - - False @@ -330,25 +284,7 @@ Author: Dmitriy Yefremov True False - 2 - - - False - False - Source: - 0 - - Picon.cz - LyngSat - - - - - False - True - 0 - - + 5 False @@ -446,15 +382,111 @@ Author: Dmitriy Yefremov - + True False - stack + expand + + + Explorer + True + True + False + True + False + converter_button + + + + True + True + 0 + + + + + Downloader + True + True + False + True + False + manager_button + + + + True + True + 1 + + + + + Converter + True + True + False + True + False + manager_button + + + + True + True + 2 + + False True - 4 + 6 + + + + + True + False + False + Details + False + + + True + False + emblem-important-symbolic + + + + + False + True + end + 0 + + + + + True + True + True + Filter + + + + True + False + Filter + edit-find-replace-symbolic + + + + + False + True + end + 1 @@ -490,7 +522,6 @@ Author: Dmitriy Yefremov True False 5 - True @@ -911,6 +942,7 @@ Author: Dmitriy Yefremov True False vertical + 5 True @@ -919,102 +951,29 @@ Author: Dmitriy Yefremov 0.5 in - + True - True - 5 - 5 - 5 - 5 - True + False + vertical - - 180 + True False - 2 - vertical - 5 + 5 + 5 + 5 + 5 - - True + + False False - 5 - 2 - - - False - Satellite - - - False - True - 0 - - - - - True - False - Loading data... - end - - - False - True - 1 - - - - - True - False - 5 - True - - - False - True - 2 - - - - - True - False - 5 - 5 - - - True - False - Filter - - - 0 - 0 - - - - - True - True - True - - - - 1 - 0 - - - - - False - True - end - 3 - - + Source: + 0 + + Picon.cz + LyngSat + + False @@ -1023,94 +982,124 @@ Author: Dmitriy Yefremov - + + button True True - in - - - True - True - satellites_list_store - False - 0 - True - - - - - - - - Satellite - True - - - - 0 - - - - - - - False - Url - - - - 1 - - - - - - - False - Pos - - - - 2 - - - - - - + True + none + picon - True + False True + end 1 - True - False + False + True + 0 - - 300 + True - False - 2 - vertical - 5 + True + 5 + 5 + 5 + 5 + True - + + 180 True False - 10 + vertical + 5 - + True False - start 5 - end + 2 + + + False + Satellite + + + False + True + 0 + + + + + True + False + Loading data... + end + + + False + True + 1 + + + + + True + False + 5 + True + + + False + True + 2 + + + + + True + False + 5 + 5 + + + True + False + Filter + + + 0 + 0 + + + + + True + True + True + + + + 1 + 0 + + + + + False + True + end + 3 + + False @@ -1119,18 +1108,97 @@ Author: Dmitriy Yefremov - + + True + True + in + + + True + True + satellites_list_store + False + 0 + True + + + + + + + + Satellite + True + + + + 0 + + + + + + + False + Url + + + + 1 + + + + + + + False + Pos + + + + 2 + + + + + + + + + True + True + 1 + + + + + True + False + + + + + 300 + True + False + vertical + 5 + + True False - 5 + 5 + 5 True True - 1 - 0 + False + True + end + 0 @@ -1140,188 +1208,189 @@ Author: Dmitriy Yefremov Load only for selected bouquet - 0 - 0 + False + True + end + 1 False True - end - 1 + 0 - - - False - True - 0 - - - - - 150 - True - True - 2 - out - + + 150 True True - providers_list_store - 1 - 0 - - - - - - + 2 + out - - 15 - Name - True - 0.5 - 1 + + True + True + providers_list_store + 1 + 0 + + + + + + - - 5 + + 15 + Name + True + 0.5 + 1 + + + 5 + + + 0 + + + + + end + + + 1 + + - - 0 - - - end + + autosize + Position + + + 0.50999999046325684 + True + + + + 2 + + - - 1 - - - - - - autosize - Position - - 0.50999999046325684 - True - + + False + Url + + + + 3 + + - - 2 - - - - - - False - Url - - - 3 - - - - - - - False - ONID - - - - 4 - - - - - - - False - SSID - - - - 5 - - - - - - - False - Single - - - - 6 - - - - - - - Selected - 7 - - - + + False + ONID + + + + 4 + + + + + + + False + SSID + + + + 5 + + + + + + + False + Single + + + + 6 + + + + + + + Selected + 7 + + + + + + 7 + + - - 7 - + + True + True + 2 + + + + + True + False + Current picons path: + 0.019999999552965164 + + + False + True + 4 + + + + + True + True + folder-open + False + + + + False + True + 5 + - True - True - 2 - - - - - True - False - Current picons path: - 0.019999999552965164 - - - False - True - 4 - - - - - True - True - folder-open - False - - - - False - True - 5 + True + False - True - False + True + True + 1 @@ -1340,7 +1409,6 @@ Author: Dmitriy Yefremov True False - 2 2 True @@ -1590,6 +1658,7 @@ Author: Dmitriy Yefremov True False + 10 Enigma2 -> Neutrino-MP diff --git a/app/ui/picons.py b/app/ui/picons.py index 2cbc3702..9d28d171 100644 --- a/app/ui/picons.py +++ b/app/ui/picons.py @@ -76,7 +76,8 @@ class PiconManager(Gtk.Box): self._download_src = self.DownloadSource.PICON_CZ self._picon_cz_downloader = None - handlers = {"on_receive": self.on_receive, + handlers = {"on_tool_switched": self.on_tool_switched, + "on_receive": self.on_receive, "on_cancel": self.on_cancel, "on_send": self.on_send, "on_download": self.on_download, @@ -86,7 +87,6 @@ class PiconManager(Gtk.Box): "on_url_changed": self.on_url_changed, "on_picons_filter_changed": self.on_picons_filter_changed, "on_position_edited": self.on_position_edited, - "on_visible_page": self.on_visible_page, "on_convert": self.on_convert, "on_picons_view_drag_data_get": self.on_picons_view_drag_data_get, "on_picons_src_view_drag_drop": self.on_picons_src_view_drag_drop, @@ -117,6 +117,7 @@ class PiconManager(Gtk.Box): builder = get_builder(UI_RESOURCES_PATH + "picons.glade", handlers) self._app_window = app.get_active_window() + self._stack = builder.get_object("stack") 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") @@ -127,8 +128,6 @@ class PiconManager(Gtk.Box): self._picons_dst_filter_model.set_visible_func(self.picons_dst_filter_function) self._expander = builder.get_object("expander") self._text_view = builder.get_object("text_view") - self._filter_bar = builder.get_object("filter_bar") - self._filter_button = builder.get_object("filter_button") self._src_filter_button = builder.get_object("src_filter_button") self._dst_filter_button = builder.get_object("dst_filter_button") self._picons_filter_entry = builder.get_object("picons_filter_entry") @@ -151,10 +150,10 @@ class PiconManager(Gtk.Box): self._resize_220_132_radio_button = builder.get_object("resize_220_132_radio_button") self._resize_100_60_radio_button = builder.get_object("resize_100_60_radio_button") self._satellite_label = builder.get_object("satellite_label") - self._provider_header_label = builder.get_object("provider_header_label") + self._src_link_button = builder.get_object("src_link_button") self._satellite_filter_switch = builder.get_object("satellite_filter_switch") self._bouquet_filter_switch = builder.get_object("bouquet_filter_switch") - self._bouquet_filter_grid = builder.get_object("bouquet_filter_grid") + self._providers_header_box = builder.get_object("providers_header_box") self._header_download_box = builder.get_object("header_download_box") self._satellite_label.bind_property("visible", builder.get_object("loading_data_label"), "visible", 4) self._satellite_label.bind_property("visible", builder.get_object("loading_data_spinner"), "visible", 4) @@ -162,9 +161,10 @@ class PiconManager(Gtk.Box): self._satellite_label.bind_property("visible", self._satellites_view, "sensitive") self._cancel_button.bind_property("visible", self._header_download_box, "visible", 4) self._convert_button.bind_property("visible", self._header_download_box, "visible", 4) - self._convert_button.bind_property("visible", builder.get_object("converter_label"), "visible") self._download_source_button.bind_property("visible", self._receive_button, "visible") - self._download_source_button.bind_property("visible", builder.get_object("downloader_label"), "visible") + # Filter. + self._filter_bar = builder.get_object("filter_bar") + self._filter_button = builder.get_object("filter_button") self._filter_bar.bind_property("search-mode-enabled", self._filter_bar, "visible") self._filter_button.bind_property("active", builder.get_object("src_title_grid"), "visible") self._filter_button.bind_property("active", builder.get_object("dst_title_grid"), "visible") @@ -172,7 +172,6 @@ class PiconManager(Gtk.Box): self._filter_button.bind_property("visible", self._send_button, "visible") self._filter_button.bind_property("visible", self._download_button, "visible") self._filter_button.bind_property("visible", self._remove_button, "visible") - self._filter_button.bind_property("visible", builder.get_object("manager_label"), "visible") self._src_button = builder.get_object("src_button") self._src_button.bind_property("active", builder.get_object("explorer_dst_label"), "visible") self._src_button.bind_property("active", builder.get_object("src_picon_box_frame"), "visible") @@ -180,6 +179,13 @@ class PiconManager(Gtk.Box): explorer_info_bar = builder.get_object("explorer_info_bar") explorer_info_bar.bind_property("visible", builder.get_object("explorer_info_bar_frame"), "visible") self._info_check_button.bind_property("active", explorer_info_bar, "visible") + # Header buttons. -> Used instead stack switcher. + self._manager_button = builder.get_object("manager_button") + self._manager_button.bind_property("active", builder.get_object("manager_label"), "visible") + self._downloader_button = builder.get_object("downloader_button") + self._downloader_button.bind_property("active", builder.get_object("downloader_label"), "visible") + self._converter_button = builder.get_object("converter_button") + self._converter_button.bind_property("active", builder.get_object("converter_label"), "visible") # Init drag-and-drop self.init_drag_and_drop() # Settings @@ -196,6 +202,28 @@ class PiconManager(Gtk.Box): self.show_info_message(message, Gtk.MessageType.WARNING) self._satellite_label.show() + def on_tool_switched(self, button): + if not button.get_active(): + return True + + is_explorer = button is self._manager_button + is_downloader = button is self._downloader_button + is_converter = button is self._converter_button + + name = "explorer" + if is_downloader: + name = "downloader" + elif is_converter: + name = "converter" + + self._stack.set_visible_child_name(name) + + self._convert_button.set_visible(is_converter) + self._download_source_button.set_visible(is_downloader) + self._filter_button.set_visible(is_explorer) + if is_explorer: + self.update_picons_data(self._picons_dest_view) + def on_open(self): """ Opens picons from local path [in src view]. """ response = show_dialog(DialogType.CHOOSER, self._app.app_window, settings=self._settings, title="Open folder") @@ -476,7 +504,7 @@ class PiconManager(Gtk.Box): def on_download_source_changed(self, button): self._download_src = self.DownloadSource(button.get_active_id()) self.set_providers_header() - self._bouquet_filter_grid.set_sensitive(self._download_src is self.DownloadSource.PICON_CZ) + self._providers_header_box.set_sensitive(self._download_src is self.DownloadSource.PICON_CZ) GLib.idle_add(self._providers_view.get_model().clear) self.init_satellites(self._satellites_view) @@ -521,19 +549,19 @@ class PiconManager(Gtk.Box): @run_idle def set_providers_header(self): - msg = "{} [{}]" - tooltip = "" if self._download_src is self.DownloadSource.PICON_CZ: - tooltip = "https://picon.cz (by ChocholouĊĦek)" - msg = msg.format(get_message("Package"), tooltip) + link = "https://picon.cz" + tooltip = f"{link} (by ChocholouĊĦek)" elif self._download_src is self.DownloadSource.LYNG_SAT: - tooltip = "https://www.lyngsat.com" - msg = msg.format(get_message("Providers"), tooltip) + link = "https://www.lyngsat.com" + tooltip = f"{get_message('Providers')} [{link}]" else: - msg = "" + link = "" + tooltip = "" - self._provider_header_label.set_text(msg) - self._provider_header_label.set_tooltip_text(tooltip) + self._src_link_button.set_uri(link) + self._src_link_button.set_label(link) + self._src_link_button.set_tooltip_text(tooltip) @run_task def get_satellites(self, view): @@ -906,16 +934,6 @@ class PiconManager(Gtk.Box): model = self._providers_view.get_model() model.set_value(model.get_iter(path), 2, value) - @run_idle - 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") - is_explorer = name == "explorer" - self._filter_button.set_visible(is_explorer) - if is_explorer: - self.update_picons_data(self._picons_dest_view) - @run_idle def on_convert(self, item): if show_dialog(DialogType.QUESTION, self._app_window) == Gtk.ResponseType.CANCEL: