mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-03-11 23:21:03 +01:00
picons display by service name (#128)
This commit is contained in:
@@ -1093,10 +1093,16 @@ class Application(Gtk.Application):
|
||||
renderer.set_property("text", f"{StreamType(f_data[0].strip() if f_data else '0').name}")
|
||||
|
||||
def iptv_picon_data_func(self, column, renderer, model, itr, data):
|
||||
renderer.set_property("pixbuf", self._picons.get(model.get_value(itr, Column.IPTV_PICON_ID)))
|
||||
picon = self._picons.get(model.get_value(itr, Column.IPTV_PICON_ID))
|
||||
if not picon:
|
||||
picon = self._picons.get(get_picon_file_name(model.get_value(itr, Column.IPTV_SERVICE)))
|
||||
renderer.set_property("pixbuf", picon)
|
||||
|
||||
def picon_data_func(self, column, renderer, model, itr, data):
|
||||
renderer.set_property("pixbuf", self._picons.get(model.get_value(itr, Column.SRV_PICON_ID)))
|
||||
picon = self._picons.get(model.get_value(itr, Column.SRV_PICON_ID))
|
||||
if not picon:
|
||||
picon = self._picons.get(get_picon_file_name(model.get_value(itr, Column.SRV_SERVICE)))
|
||||
renderer.set_property("pixbuf", picon)
|
||||
|
||||
def fav_picon_data_func(self, column, renderer, model, itr, data):
|
||||
srv = self._services.get(model.get_value(itr, Column.FAV_ID), None)
|
||||
@@ -1112,6 +1118,9 @@ class Application(Gtk.Application):
|
||||
if alt_srv:
|
||||
picon = self._picons.get(alt_srv.picon_id, None) if srv else None
|
||||
|
||||
if not picon:
|
||||
picon = self._picons.get(get_picon_file_name(model.get_value(itr, Column.FAV_SERVICE)))
|
||||
|
||||
renderer.set_property("pixbuf", picon)
|
||||
|
||||
def fav_service_data_func(self, column, renderer, model, itr, data):
|
||||
@@ -1628,8 +1637,7 @@ class Application(Gtk.Application):
|
||||
path, pos = result
|
||||
srv = self._services.get(view.get_model()[path][Column.IPTV_FAV_ID], None)
|
||||
if srv and srv.picon_id:
|
||||
tooltip.set_icon(get_picon_pixbuf(self._settings.profile_picons_path + srv.picon_id,
|
||||
size=self._settings.tooltip_logo_size))
|
||||
tooltip.set_icon(self.get_tooltip_picon(srv))
|
||||
fav_id = srv.fav_id
|
||||
names = (b[:b.rindex(":")] for b, ids in self._bouquets.items() if fav_id in ids)
|
||||
text = f"{get_message('Name')}: {srv.service}\n{get_message('Bouquets')}: {', '.join(names)}"
|
||||
@@ -1645,8 +1653,7 @@ class Application(Gtk.Application):
|
||||
target_column = Column.FAV_ID if target is ViewTarget.FAV else Column.SRV_FAV_ID
|
||||
srv = self._services.get(model[path][target_column], None)
|
||||
if srv and srv.picon_id:
|
||||
tooltip.set_icon(get_picon_pixbuf(self._settings.profile_picons_path + srv.picon_id,
|
||||
size=self._settings.tooltip_logo_size))
|
||||
tooltip.set_icon(self.get_tooltip_picon(srv))
|
||||
txt = self.get_hint_for_fav_list(srv) if target is ViewTarget.FAV else self.get_hint_for_srv_list(srv)
|
||||
tooltip.set_text(txt)
|
||||
view.set_tooltip_row(tooltip, path)
|
||||
@@ -4008,6 +4015,13 @@ class Application(Gtk.Application):
|
||||
def get_picon(self, p_id):
|
||||
return get_picon_pixbuf(f"{self._settings.profile_picons_path}{p_id}", self._picons_size)
|
||||
|
||||
def get_tooltip_picon(self, srv):
|
||||
size, path = self._settings.tooltip_logo_size, self._settings.profile_picons_path
|
||||
pix = get_picon_pixbuf(f"{path}{srv.picon_id}", size=size)
|
||||
if not pix:
|
||||
pix = get_picon_pixbuf(f"{path}{get_picon_file_name(srv.service)}", size=size)
|
||||
return pix
|
||||
|
||||
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))
|
||||
|
||||
@@ -32,11 +32,14 @@ __all__ = ("insert_marker", "move_items", "rename", "ViewTarget", "set_flags", "
|
||||
"scroll_to", "get_base_model", "copy_reference", "assign_picons", "remove_picon",
|
||||
"is_only_one_item_selected", "gen_bouquets", "BqGenType", "get_selection",
|
||||
"get_model_data", "remove_all_unused_picons", "get_picon_pixbuf", "get_base_itrs", "get_iptv_url",
|
||||
"get_iptv_data", "update_entry_data", "append_text_to_tview", "on_popup_menu")
|
||||
"get_iptv_data", "update_entry_data", "append_text_to_tview", "on_popup_menu", "get_picon_file_name")
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import unicodedata
|
||||
from collections import defaultdict
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from urllib.parse import unquote
|
||||
|
||||
@@ -557,8 +560,15 @@ def is_only_one_item_selected(paths, transient):
|
||||
def get_picon_pixbuf(path, size=32):
|
||||
try:
|
||||
return GdkPixbuf.Pixbuf.new_from_file_at_scale(path, width=size, height=size, preserve_aspect_ratio=True)
|
||||
except GLib.GError as e:
|
||||
pass
|
||||
except GLib.GError:
|
||||
pass # NOP
|
||||
|
||||
|
||||
@lru_cache(50)
|
||||
def get_picon_file_name(service_name):
|
||||
""" Returns picon file name by service name. """
|
||||
name = unicodedata.normalize("NFKD", service_name).encode("ASCII", errors="ignore").decode(errors="ignore")
|
||||
return f"{re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())}.png"
|
||||
|
||||
|
||||
# ***************** Bouquets ********************* #
|
||||
|
||||
Reference in New Issue
Block a user