added hints support for the main list

This commit is contained in:
DYefremov
2020-04-19 17:20:51 +03:00
parent 9fe328b54e
commit 6957a960ca
5 changed files with 77 additions and 20 deletions

View File

@@ -578,6 +578,15 @@ class Settings:
def load_last_config(self, value):
self._settings["load_last_config"] = value
@property
def show_srv_hints(self):
""" Show short info as hints in the main services list. """
return self._settings.get("show_srv_hints", True)
@show_srv_hints.setter
def show_srv_hints(self, value):
self._settings["show_srv_hints"] = value
@property
def show_bq_hints(self):
""" Show detailed info as hints in the bouquet list. """

View File

@@ -64,7 +64,6 @@ class Application(Gtk.Application):
_FAV_IPTV_ELEMENTS = ("fav_iptv_popup_item",)
# _LOCK_HIDE_ELEMENTS = ("locked_tool_button", "hide_tool_button")
_LOCK_HIDE_ELEMENTS = ()
def __init__(self, **kwargs):
@@ -102,6 +101,7 @@ class Application(Gtk.Application):
"on_to_fav_copy": self.on_to_fav_copy,
"on_to_fav_end_copy": self.on_to_fav_end_copy,
"on_fav_view_query_tooltip": self.on_fav_view_query_tooltip,
"on_services_view_query_tooltip": self.on_services_view_query_tooltip,
"on_view_drag_begin": self.on_view_drag_begin,
"on_view_drag_data_get": self.on_view_drag_data_get,
"on_services_view_drag_drop": self.on_services_view_drag_drop,
@@ -814,27 +814,39 @@ class Application(Gtk.Application):
# ********************* Hints *************************#
def on_fav_view_query_tooltip(self, view, x, y, keyboard_mode, tooltip: Gtk.Tooltip):
""" Sets detailed info about service in the tooltip. """
def on_fav_view_query_tooltip(self, view, x, y, keyboard_mode, tooltip):
""" Sets detailed info about service in the tooltip [fav view]. """
result = view.get_dest_row_at_pos(x, y)
if not result or not self._settings.show_bq_hints:
return False
path, pos = result
return self.get_tooltip(view, result, tooltip)
def on_services_view_query_tooltip(self, view, x, y, keyboard_mode, tooltip):
""" Sets short info about service in the tooltip [main services view]. """
result = view.get_dest_row_at_pos(x, y)
if not result or not self._settings.show_srv_hints:
return False
return self.get_tooltip(view, result, tooltip, target=ViewTarget.SERVICES)
def get_tooltip(self, view, dest_row, tooltip, target=ViewTarget.FAV):
path, pos = dest_row
model = view.get_model()
srv = self._services.get(model[path][Column.FAV_ID], None)
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.picons_local_path + srv.picon_id, size=96))
tooltip.set_text(self.get_hint_for_bq_list(srv))
tooltip.set_text(
self.get_hint_for_bq_list(srv) if target is ViewTarget.FAV else self.get_hint_for_srv_list(srv))
view.set_tooltip_row(tooltip, path)
return True
return False
def get_hint_for_bq_list(self, srv: Service):
def get_hint_for_bq_list(self, srv):
""" Returns detailed info about service as formatted string for using as hint. """
header = "{}: {}\n{}: {}\n".format(get_message("Name"), srv.service, get_message("Type"), srv.service_type)
ref = "{}: {}".format(get_message("Service reference"), srv.picon_id.rstrip(".png"))
header, ref = self.get_hint_header_info(srv)
if srv.service_type == "IPTV":
return "{}{}".format(header, ref)
@@ -849,6 +861,15 @@ class Application(Gtk.Application):
get_message("Rate"), srv.rate, pol, fec, "SID", srv.ssid,
ref)
def get_hint_for_srv_list(self, srv):
""" Returns short info about service as formatted string for using as hint. """
return "{}{}".format(*self.get_hint_header_info(srv))
def get_hint_header_info(self, srv):
header = "{}: {}\n{}: {}\n".format(get_message("Name"), srv.service, get_message("Type"), srv.service_type)
ref = "{}: {}".format(get_message("Service reference"), srv.picon_id.rstrip(".png"))
return header, ref
# ***************** Drag-and-drop *********************#
def on_view_drag_begin(self, view, context):
@@ -2452,7 +2473,7 @@ class Application(Gtk.Application):
data = r[Column.SRV_PICON_ID].split("_")
ids["{}:{}:{}".format(data[3], data[5], data[6])] = r[Column.SRV_PICON_ID]
PiconsDialog(self._main_window, self._settings, ids, self._sat_positions, self.update_picons).show()
PiconsDialog(self._main_window, self._settings, ids, self._sat_positions, self).show()
@run_task
def update_picons(self):

View File

@@ -1424,6 +1424,7 @@ Author: Dmitriy Yefremov
<signal name="focus-in-event" handler="on_view_focus" swapped="no"/>
<signal name="key-press-event" handler="on_tree_view_key_press" swapped="no"/>
<signal name="key-release-event" handler="on_tree_view_key_release" swapped="no"/>
<signal name="query-tooltip" handler="on_services_view_query_tooltip" swapped="no"/>
<signal name="row-activated" handler="on_services_selection" object="services_list_store" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="services_selection">

View File

@@ -2157,38 +2157,61 @@ Author: Dmitriy Yefremov
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkBox" id="hints_box">
<object class="GtkGrid" id="hints_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="row_spacing">5</property>
<property name="column_spacing">5</property>
<child>
<object class="GtkLabel" id="fav_hints_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Show detailed info as hints in the bouquet list</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="bouquet_hints_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="services_hints_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Show short info as hints in the main services list</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="services_hints_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>

View File

@@ -143,6 +143,7 @@ class SettingsDialog:
self._extra_color_button = builder.get_object("extra_color_button")
self._load_on_startup_switch = builder.get_object("load_on_startup_switch")
self._bouquet_hints_switch = builder.get_object("bouquet_hints_switch")
self._services_hints_switch = builder.get_object("services_hints_switch")
self._lang_combo_box = builder.get_object("lang_combo_box")
# HTTP API
self._support_http_api_switch = builder.get_object("support_http_api_switch")
@@ -274,6 +275,7 @@ class SettingsDialog:
self.set_play_stream_mode(self._settings.play_streams_mode)
self._load_on_startup_switch.set_active(self._settings.load_last_config)
self._bouquet_hints_switch.set_active(self._settings.show_bq_hints)
self._services_hints_switch.set_active(self._settings.show_srv_hints)
self._default_data_paths_switch.set_active(self._settings.profile_folder_is_default)
self._transcoding_switch.set_active(self._settings.activate_transcoding)
self._presets_combo_box.set_active_id(self._settings.active_preset)
@@ -337,6 +339,7 @@ class SettingsDialog:
self._ext_settings.language = self._lang_combo_box.get_active_id()
self._ext_settings.load_last_config = self._load_on_startup_switch.get_active()
self._ext_settings.show_bq_hints = self._bouquet_hints_switch.get_active()
self._ext_settings.show_srv_hints = self._services_hints_switch.get_active()
self._ext_settings.profile_folder_is_default = self._default_data_paths_switch.get_active()
self._ext_settings.default_data_path = self._default_data_dir_field.get_text()
self._ext_settings.records_path = self._record_data_dir_field.get_text()