From bd047e5f72af8c54be38fee018091b700cd5e01a Mon Sep 17 00:00:00 2001 From: DYefremov Date: Mon, 25 May 2020 18:25:36 +0300 Subject: [PATCH] added services filtering from picons manager --- app/ui/main_app_window.py | 4 ++++ app/ui/picons_manager.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index 6e9438d4..61183829 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -2703,6 +2703,10 @@ class Application(Gtk.Application): def bouquets_view(self): return self._bouquets_view + @property + def filter_entry(self): + return self._filter_entry + @property def current_services(self): return self._services diff --git a/app/ui/picons_manager.py b/app/ui/picons_manager.py index d01ce699..934ebe6d 100644 --- a/app/ui/picons_manager.py +++ b/app/ui/picons_manager.py @@ -5,7 +5,7 @@ import subprocess import tempfile from pathlib import Path -from gi.repository import GLib, GdkPixbuf +from gi.repository import GLib, GdkPixbuf, GObject from app.commons import run_idle, run_task, run_with_delay from app.connections import upload_data, DownloadType, download_data, remove_picons @@ -28,6 +28,7 @@ class PiconsDialog: self._POS_PATTERN = re.compile(r"^\d+\.\d+[EW]?$") self._current_process = None self._terminate = False + self._filter_binding = None handlers = {"on_receive": self.on_receive, "on_load_providers": self.on_load_providers, @@ -54,6 +55,7 @@ class PiconsDialog: "on_select_all": self.on_select_all, "on_unselect_all": self.on_unselect_all, "on_filter_toggled": self.on_filter_toggled, + "on_filter_services_switch": self.on_filter_services_switch, "on_popup_menu": on_popup_menu} builder = Gtk.Builder() @@ -105,6 +107,7 @@ class PiconsDialog: self._convert_button.bind_property("visible", downloader_action_box, "visible", 4) self._filter_bar.bind_property("search-mode-enabled", self._filter_bar, "visible") self._explorer_path_button.bind_property("sensitive", builder.get_object("picons_view_sw"), "sensitive") + self._filter_button.bind_property("active", builder.get_object("filter_service_box"), "visible") # Init drag-and-drop self.init_drag_and_drop() # Style @@ -514,6 +517,15 @@ class PiconsDialog: if not active: self._picons_filter_entry.set_text("") + def on_filter_services_switch(self, button, state): + if state: + self._filter_binding = self._picons_filter_entry.bind_property("text", self._app.filter_entry, "text") + self._app.filter_entry.set_text(self._picons_filter_entry.get_text()) + else: + if self._filter_binding: + self._filter_binding.unbind() + self._app.filter_entry.set_text("") + def on_url_changed(self, entry): suit = self._PATTERN.search(entry.get_text()) entry.set_name("GtkEntry" if suit else "digit-entry")