Index: channels/specbuttons.py ================================================================== --- channels/specbuttons.py +++ channels/specbuttons.py @@ -1,9 +1,9 @@ # encoding: utf-8 # title: Spec buttons for apps # description: Adds configurable mini toolbar buttons -# version: 0.8.3 +# version: 0.8.4 # depends: streamtuner2 >= 2.2.0 # type: feature # category: ui # config: # { name: specbutton_rows, value: 2, max: 4, type: int, description: "Number of rows to arrange buttons in." } @@ -22,10 +22,17 @@ # # kill pkill vlc # # Icons can be gtk-xyz icon names or /usr/share/icon/* PNG files. # Each command may use streamtuner2 placeholders like %g or %url and $title. +# +# Internal functions can be bound now as well, for example: +# +# find search.menu_search(1) +# +# disk exportcat.savewindow(1) +# import os.path import subprocess import math @@ -126,11 +133,20 @@ conf.specbuttons = r self.update_buttons(self.parent) # Button callback, allow for %url/%title placeholders def action(self, cmd): + # code hooks (`search.menu_search(0)`) + internal = re.match("^(\w+)\.(\w+)\((.*)\)$", cmd) + if internal: + feature, func, args = internal.groups() + if self.parent.__getattr__(feature): + func = getattr(self.parent.__getattr__(feature), func) + if func: + return func(*(args.split())) + # external commands if re.search("[%$]", cmd): row = self.parent.channel().row() action.run_fmt_url(row=row, add_default=False, cmd=cmd) else: action.run(cmd)