ADDED channels/ui_cht.py
Index: channels/ui_cht.py
==================================================================
--- channels/ui_cht.py
+++ channels/ui_cht.py
@@ -0,0 +1,31 @@
+# encoding: utf-8
+# title: Channel toolbar link
+# description: Shows current channel and a link to online service in toolbar.
+# version: 1.0
+# depends: streamtuner2 >= 2.1.9
+# type: feature
+# category: ui
+#
+# Reintroduces the channel/service link in the toolbar,
+# just like in streamtuner1.
+
+
+import re
+
+
+# Channel Homepage in Toolbar
+class ui_cht(object):
+ module = __name__
+
+ # Hook toolbar label
+ def __init__(self, parent):
+ self.label = parent.toolbar_link
+ parent.hooks["switch"].append(self.switchy)
+
+ # Update link label
+ def switchy(self, meta, *x, **y):
+ title = meta.get("title")
+ url = meta.get("url")
+ domain = re.sub("^.+?//|/.+$", "", url)
+ self.label.set_markup("{}\n{}".format(title, url, domain))
+
Index: st2.py
==================================================================
--- st2.py
+++ st2.py
@@ -74,10 +74,11 @@
features = {} # non-channel plugins
#working = [] # threads
hooks = {
"play": [], # observers queue here
"record": [],
+ "switch": [],
"init": [],
"quit": [action.cleanup_tmp_files],
"config_load": [],
"config_save": [],
}
@@ -253,13 +254,15 @@
# Invoked from the menu instead, uses module name instead of numeric tab id
def channel_switch_by_name(self, name):
self.notebook_channels.set_current_page(self.channel_names.index(name))
# Mirror selected channel tab into main window title
- def update_title(self):
+ def update_title(self, *x, **y):
+ meta = self.channel().meta
if conf.window_title:
- self.win_streamtuner2.set_title("Streamtuner2 - %s" % self.channel().meta.get("title"))
+ self.win_streamtuner2.set_title("Streamtuner2 - %s" % meta.get("title"))
+ [cb(meta) for cb in self.hooks["switch"]]
# Channel: row{} dict for current station
def row(self):
return self.channel().row()