Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [bbb93d412c]

Overview
Comment:Added crude support for binding internal calls `object.func()` to buttons.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bbb93d412ca34ef650270edff7b194d146991d37
User & Date: mario on 2018-12-17 22:19:42
Other Links: manifest | tags
Context
2018-12-18
22:40
Allow for subcategories in bookmarks. check-in: 1a034aeac0 user: mario tags: trunk
2018-12-17
22:19
Added crude support for binding internal calls `object.func()` to buttons. check-in: bbb93d412c user: mario tags: trunk
20:32
Add .reload_bookmarks for RT-NG check-in: 6bbc8bba7f user: mario tags: trunk
Changes

Modified channels/specbuttons.py from [9ee8fca8b8] to [f76050e966].

1
2
3
4
5
6
7
8
9
10
11
# encoding: utf-8
# title: Spec buttons for apps
# description: Adds configurable mini toolbar buttons
# version: 0.8.3
# 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." }
#    { name: specbuttons, type: dict, columns: "Icon,Command", description: "Icons can be `<a href='http://www.pygtk.org/pygtk2reference/gtk-stock-items.html'>gtk-xyz</a>` internal names. Else use `/usr/share/icon/*.png` file names. Icon file basenames will be expanded into full paths." }
# documentation:



|







1
2
3
4
5
6
7
8
9
10
11
# encoding: utf-8
# title: Spec buttons for apps
# description: Adds configurable mini toolbar buttons
# 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." }
#    { name: specbuttons, type: dict, columns: "Icon,Command", description: "Icons can be `<a href='http://www.pygtk.org/pygtk2reference/gtk-stock-items.html'>gtk-xyz</a>` internal names. Else use `/usr/share/icon/*.png` file names. Icon file basenames will be expanded into full paths." }
# documentation:
20
21
22
23
24
25
26







27
28
29
30
31
32
33
#
#  up      amixer sset Master 5%+
#
#  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.









import os.path
import subprocess
import math
import re
from config import conf, log, plugin_meta







>
>
>
>
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
#  up      amixer sset Master 5%+
#
#  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
import re
from config import conf, log, plugin_meta
124
125
126
127
128
129
130









131
132
133
134
135
136
                    log.WARN("Extra button icon '%s' could not be found" % btn)
            r[btn] = cmd
        conf.specbuttons = r
        self.update_buttons(self.parent)

    # Button callback, allow for %url/%title placeholders
    def action(self, cmd):









        if re.search("[%$]", cmd):
            row = self.parent.channel().row()
            action.run_fmt_url(row=row, add_default=False, cmd=cmd)
        else:
            action.run(cmd)








>
>
>
>
>
>
>
>
>






131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
                    log.WARN("Extra button icon '%s' could not be found" % btn)
            r[btn] = cmd
        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)