mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-20 23:49:41 +01:00
Added services column data function prototypes
This commit is contained in:
@@ -34,29 +34,20 @@ class Application(Gtk.Application):
|
||||
_TV_TYPES = ("TV", "TV (HD)", "TV (UHD)", "TV (H264)")
|
||||
|
||||
_SERVICE_LIST_NAME = "services_list_store"
|
||||
|
||||
_FAV_LIST_NAME = "fav_list_store"
|
||||
|
||||
_BOUQUETS_LIST_NAME = "bouquets_tree_store"
|
||||
|
||||
# dynamically active elements depending on the selected view
|
||||
# Dynamically active elements depending on the selected view
|
||||
_SERVICE_ELEMENTS = ("services_popup_menu",)
|
||||
|
||||
_BOUQUET_ELEMENTS = ("edit_tool_button", "new_tool_button", "bouquets_new_popup_item", "bouquets_edit_popup_item",
|
||||
"bouquets_cut_popup_item", "bouquets_copy_popup_item", "bouquets_paste_popup_item")
|
||||
|
||||
_COMMONS_ELEMENTS = ("edit_tool_button", "bouquets_remove_popup_item", "fav_remove_popup_item")
|
||||
|
||||
_FAV_ELEMENTS = ("fav_cut_popup_item", "fav_paste_popup_item", "fav_locate_popup_item", "fav_iptv_popup_item",
|
||||
"fav_insert_marker_popup_item", "fav_edit_sub_menu_popup_item", "fav_edit_popup_item",
|
||||
"fav_picon_popup_item", "fav_copy_popup_item")
|
||||
|
||||
_BOUQUET_ELEMENTS = ("edit_tool_button", "new_tool_button", "bouquets_new_popup_item", "bouquets_edit_popup_item",
|
||||
"bouquets_cut_popup_item", "bouquets_copy_popup_item", "bouquets_paste_popup_item")
|
||||
_COMMONS_ELEMENTS = ("edit_tool_button", "bouquets_remove_popup_item", "fav_remove_popup_item")
|
||||
_FAV_ENIGMA_ELEMENTS = ("fav_insert_marker_popup_item",)
|
||||
|
||||
_FAV_IPTV_ELEMENTS = ("fav_iptv_popup_item",)
|
||||
|
||||
_LOCK_HIDE_ELEMENTS = ("locked_tool_button", "hide_tool_button")
|
||||
|
||||
_DYNAMIC_ELEMENTS = ("services_popup_menu", "new_tool_button", "edit_tool_button", "locked_tool_button",
|
||||
"fav_cut_popup_item", "fav_paste_popup_item", "bouquets_new_popup_item", "hide_tool_button",
|
||||
"bouquets_remove_popup_item", "fav_remove_popup_item", "bouquets_edit_popup_item",
|
||||
@@ -64,6 +55,10 @@ class Application(Gtk.Application):
|
||||
"fav_locate_popup_item", "fav_picon_popup_item", "fav_iptv_popup_item", "fav_copy_popup_item",
|
||||
"bouquets_cut_popup_item", "bouquets_copy_popup_item", "bouquets_paste_popup_item")
|
||||
|
||||
# Colors
|
||||
_NEW_COLOR = "#ff5733" # Color for new services in the main list
|
||||
_EXTRA_COLOR = "#33a8ff" # Color for services with a extra name for the bouquet
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@@ -220,6 +215,11 @@ class Application(Gtk.Application):
|
||||
# Force ctrl press event for view. Multiple selections in lists only with Space key(as in file managers)!!!
|
||||
self._services_view.connect("key-press-event", self.force_ctrl)
|
||||
self._fav_view.connect("key-press-event", self.force_ctrl)
|
||||
# Renders
|
||||
self._service_render = builder.get_object("service_cellrenderertext")
|
||||
self._fav_service_render = builder.get_object("fav_service_cellrenderertext")
|
||||
self._service_column = builder.get_object("service_column")
|
||||
self._fav_service_column = builder.get_object("fav_service_column")
|
||||
# Clipboard
|
||||
self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||
# Wait dialog
|
||||
@@ -242,6 +242,7 @@ class Application(Gtk.Application):
|
||||
|
||||
def do_startup(self):
|
||||
Gtk.Application.do_startup(self)
|
||||
self.init_service_renders()
|
||||
self.init_http_api()
|
||||
|
||||
def do_activate(self):
|
||||
@@ -281,6 +282,29 @@ class Application(Gtk.Application):
|
||||
""" Function for force ctrl press event for view """
|
||||
event.state |= Gdk.ModifierType.CONTROL_MASK
|
||||
|
||||
def init_service_renders(self):
|
||||
profile = Profile(self._profile)
|
||||
func = self.service_data_function if profile is Profile.ENIGMA_2 else None
|
||||
fav_func = self.fav_service_data_function if profile is Profile.ENIGMA_2 else None
|
||||
self._service_column.set_cell_data_func(self._service_render, func, None)
|
||||
self._fav_service_column.set_cell_data_func(self._fav_service_render, fav_func, None)
|
||||
|
||||
def service_data_function(self, column, render: Gtk.CellRendererText, model, itr, data):
|
||||
""" Data function for the service column of main list """
|
||||
render.set_property("foreground-set", None)
|
||||
cas_flags = model.get_value(itr, 0)
|
||||
if cas_flags:
|
||||
f_flags = list(filter(lambda x: x.startswith("f:"), cas_flags.split(",")))
|
||||
if f_flags and Flag.is_new(int(f_flags[0][2:])):
|
||||
render.set_property("foreground", self._NEW_COLOR)
|
||||
|
||||
def fav_service_data_function(self, column, render, model, itr, data):
|
||||
""" Data function for the service column of FAV list """
|
||||
fav_id = model.get_value(itr, 7)
|
||||
bq = self._extra_bouquets.get(self.get_selected_bouquet(), None)
|
||||
has_id = bq.get(fav_id, None) if bq else bq
|
||||
render.set_property("foreground", self._EXTRA_COLOR) if has_id else render.set_property("foreground-set", None)
|
||||
|
||||
@run_idle
|
||||
def on_close_app(self, *args):
|
||||
self.quit()
|
||||
@@ -992,6 +1016,7 @@ class Application(Gtk.Application):
|
||||
self.update_services_counts()
|
||||
|
||||
self.update_profile_label()
|
||||
self.init_service_renders()
|
||||
self.init_http_api()
|
||||
|
||||
def on_tree_view_key_press(self, view, event):
|
||||
|
||||
Reference in New Issue
Block a user