diff --git a/app/ui/main.glade b/app/ui/main.glade index b67a4337..0440efd1 100644 --- a/app/ui/main.glade +++ b/app/ui/main.glade @@ -148,6 +148,11 @@ Author: Dmitriy Yefremov False gtk-edit + + True + False + insert-link + True False @@ -350,12 +355,12 @@ Author: Dmitriy Yefremov True False - insert-link + insert-image True False - insert-link + insert-image True @@ -932,6 +937,11 @@ Author: Dmitriy Yefremov False gtk-select-all + + True + False + insert-link + True False @@ -1099,7 +1109,7 @@ Author: Dmitriy Yefremov - Clear marked + Clear True False clear_mark_not_in_bq_image @@ -1124,12 +1134,22 @@ Author: Dmitriy Yefremov True False + + + Assign file + True + False + insert_link_image + False + + + Assign True False - insert_link_image + services_assign_image False @@ -4055,12 +4075,22 @@ Author: Dmitriy Yefremov True False + + + Assign file + True + False + insert_link_image_2 + False + + + Assign True False - insert_link_image_2 + fav_assign_image False diff --git a/app/ui/main.py b/app/ui/main.py index 64b7f7f7..aa2cbaca 100644 --- a/app/ui/main.py +++ b/app/ui/main.py @@ -168,6 +168,7 @@ class Application(Gtk.Application): "on_services_filter_toggled": self.on_services_filter_toggled, "on_filter_satellite_toggled": self.on_filter_satellite_toggled, "on_filter_in_bq_toggled": self.on_filter_in_bq_toggled, + "on_assign_picon_file": self.on_assign_picon_file, "on_assign_picon": self.on_assign_picon, "on_remove_picon": self.on_remove_picon, "on_reference_picon": self.on_reference_picon, @@ -270,6 +271,8 @@ class Application(Gtk.Application): GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,)) GObject.signal_new("filter-toggled", self, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,)) + GObject.signal_new("picon-assign", self, GObject.SIGNAL_RUN_LAST, + GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,)) builder = get_builder(UI_RESOURCES_PATH + "main.glade", handlers) self._main_window = builder.get_object("main_window") @@ -314,6 +317,7 @@ class Application(Gtk.Application): self._signal_level_bar.bind_property("visible", builder.get_object("record_button"), "visible") self._receiver_info_box.bind_property("visible", self._http_status_image, "visible", 4) self._receiver_info_box.bind_property("visible", self._signal_box, "visible") + self._save_tool_button.bind_property("visible", builder.get_object("fav_assign_picon_popup_item"), "sensitive") # Alternatives self._alt_view = builder.get_object("alt_tree_view") self._alt_model = builder.get_object("alt_list_store") @@ -1442,14 +1446,14 @@ class Application(Gtk.Application): if uris: if len(uris) == 2: - self.picons_buffer = self.on_assign_picon(view, urlparse(unquote(uris[0])).path, - urlparse(unquote(uris[1])).path + os.sep) + self.picons_buffer = self.on_assign_picon_file(view, urlparse(unquote(uris[0])).path, + urlparse(unquote(uris[1])).path + os.sep) elif IS_DARWIN and len(uris) == 1: src, sep, dest = uris[0].partition(self.DRAG_SEP) src_path = urlparse(unquote(src)).path if dest: dest_path = urlparse(unquote(dest)).path + os.sep - self.picons_buffer = self.on_assign_picon(view, src_path, dest_path) + self.picons_buffer = self.on_assign_picon_file(view, src_path, dest_path) drag_context.finish(True, False, time) @@ -3406,6 +3410,10 @@ class Application(Gtk.Application): return get_picon_pixbuf(f"{self._settings.profile_picons_path}{p_id}", self._settings.list_picon_size) def on_assign_picon(self, view, src_path=None, dst_path=None): + self._stack.set_visible_child_name(Page.PICONS.value) + self.emit("picon-assign", self.get_target_view(view)) + + def on_assign_picon_file(self, view, src_path=None, dst_path=None): return assign_picons(self.get_target_view(view), self._services_view, self._fav_view, self._main_window, self._picons, self._settings, self._services, src_path, dst_path) diff --git a/app/ui/picons.glade b/app/ui/picons.glade index 0d6a40bb..0f932086 100644 --- a/app/ui/picons.glade +++ b/app/ui/picons.glade @@ -609,6 +609,7 @@ Author: Dmitriy Yefremov edit-find-replace-symbolic False False + Filter: N1|N2|N3, etc.. diff --git a/app/ui/picons.py b/app/ui/picons.py index 4938a90e..23aad7ff 100644 --- a/app/ui/picons.py +++ b/app/ui/picons.py @@ -44,7 +44,7 @@ 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) -from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TV_ICON, Column, KeyboardKey, Page +from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TV_ICON, Column, KeyboardKey, Page, ViewTarget class PiconManager(Gtk.Box): @@ -59,6 +59,7 @@ class PiconManager(Gtk.Box): self._app.connect("page-changed", self.update_picons_dest) self._app.connect("filter-toggled", self.on_app_filter_toggled) self._app.connect("profile-changed", self.on_profile_changed) + self._app.connect("picon-assign", self.on_picon_assign) self._app.fav_view.connect("row-activated", self.on_fav_changed) self._picon_ids = picon_ids self._sat_positions = sat_positions @@ -250,6 +251,19 @@ class PiconManager(Gtk.Box): self._current_path_label.set_text(self._settings.profile_picons_path) self.update_picons_dest(app, self._app.page) + def on_picon_assign(self, app, target): + if target is ViewTarget.SERVICES: + model, paths = app.services_view.get_selection().get_selected_rows() + ids = {model[p][Column.SRV_FAV_ID] for p in paths} + else: + model, paths = app.fav_view.get_selection().get_selected_rows() + ids = {model[p][Column.FAV_ID] for p in paths} + + self._filter_button.set_active(True) + self._dst_filter_button.set_active(True) + self._picons_filter_entry.set_text( + "|".join(s.service for f, s in self._app.current_services.items() if f in ids)) + def update_picons_data(self, view, path=None): if view is self._picons_dest_view: self.update_picon_info() @@ -378,7 +392,7 @@ class PiconManager(Gtk.Box): t_mod = target_view.get_model() dest_path = self._settings.profile_picons_path - self.update_picons_dest_view(self._app.on_assign_picon(target_view, model[path][-1], dest_path)) + self.update_picons_dest_view(self._app.on_assign_picon_file(target_view, model[path][-1], dest_path)) self.show_assign_info([t_mod.get_value(t_mod.get_iter_from_string(itr), c_id) for itr in itr_str.split(",")]) @run_idle @@ -957,10 +971,10 @@ class PiconManager(Gtk.Box): @run_with_delay(0.5) def on_picons_filter_changed(self, entry): - txt = entry.get_text().upper() self._filter_cache.clear() + txt = entry.get_text().upper().split("|") for s in self._app.current_services.values(): - self._filter_cache[s.picon_id] = txt in s.service.upper() + self._filter_cache[s.picon_id] = any(t in s.service.upper() or t in str(s.picon_id) for t in txt) GLib.idle_add(self._picons_src_filter_model.refilter, priority=GLib.PRIORITY_LOW) GLib.idle_add(self._picons_dst_filter_model.refilter, priority=GLib.PRIORITY_LOW)