streamtuner2: Check-in [41291d31ab]
Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ branch:  streamtuner2


Check-in [41291d31ab]

Overview
Comment:User standard pluginconf.dependency() for themes filtering.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:41291d31ab45580921d7672a79ea0ae08c1c5164
User & Date: mario on 2016-12-26 20:27:55
Other Links: manifest | tags
Context
2016-12-26
20:42
Exempt `%` from Win quoting. check-in: 837517237c user: Oliver tags: trunk
20:27
User standard pluginconf.dependency() for themes filtering. check-in: 41291d31ab user: mario tags: trunk
15:56
Introduce `depends:` field for themes as well (no version support, just basenames for linux/windows/gtk2/gtk3) check-in: 7027676c80 user: mario tags: trunk
Changes

Modified contrib/theme_installer.py from [ffc788c6a2] to [1a05b24e01].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
..
42
43
44
45
46
47
48

49
50
51
52
53
54
55
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
...
217
218
219
220
221
222
223
















# encoding: UTF-8
# api: streamtuner2
# title: Gtk2 theme installer
# description: Shows themes in the bookmarks pane for installation
# type: feature
# category: ui
# version: 0.4.2
# priority: experimental
#
# Downloads a list of Gtk themes and presents it in the bookmarks
# tab under... »themes«. Double clicking will download and install
# a theme right away.
#
# Note that this is primarily meant for Windows, as it unpacks
................................................................................
# *.dll engines if found. Should work on BSD/Linux still, but would
# require setting up .gtkrc, and writeable module_path for engines.
# It only handles Gtk2 themes currently.
#
# Reuses the `conf.theme` setting from the `gtk_theme` plugin, and
# should work in conjunction to it.
#
# The theme repository is a CSV file of:
#   themepkg.zip, theme.png, Title, Author, http://homepage/
# with the packages residing next to it.
#
# Using a repo.json works better however, and would allow to
# integrate it with the regular plugin manager somewhen.
# The bookmark/themes channel provides the nicer UI however.
#
# A theme.zip should contain a structure like:
#    ---------  ---------- -----   ----
#        62937  2016-12-12 16:39   librezlooks.dll
#            0  2016-12-12 16:40   Rezlooks-dark/
#            0  2016-12-03 20:58   Rezlooks-dark/gtk-2.0/
................................................................................
import os, shutil
import csv
import zipfile
import re
import json
import ahttp
from config import *

import uikit
from compat2and3 import *
import action
import channels.favicon as fi


# register a key
................................................................................
                    state = "gtk-zoom-fit",
                    format = self.mime,
                    listformat = "href"
                )
                # add
                r.append(d)

        # filter on properties
        d_platform = "win32" if conf.windows else "linux"
        d_gtk = "gtk2" if uikit.ver == 2 else "gtk3"
        for i,d in enumerate(r):
            if not d.get("depends"):
                continue
            for dep in re.split("\s*,\s*", d["depends"]):
                if dep in ("gtk", "streamtuner2", "theme_installer", "gtk2|gtk3", "win32|linux"):
                    continue
                if not dep in (d_platform, d_gtk):
                    del r[i]

        # convert relative references
        for d in r:
            for field in ("url", "img", '$file'):
                v = str(d.get(field))
                if v  and v.find("://") < 0:
                    d[field] = self.themes_url + v
................................................................................
        if dll:
            self.clear_dll(dll)

    # delete theme engine dll
    def clear_dll(self, dll):
        for fn in dll:
            os.remove(self.theme_dir + fn)






















|







 







|
|
<
<
<
<







 







>







 







|
|
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
15
16
17
18
19
20
21
22
23




24
25
26
27
28
29
30
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
120
121
122
123
124
125
126
127
128









129
130
131
132
133
134
135
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# encoding: UTF-8
# api: streamtuner2
# title: Gtk2 theme installer
# description: Shows themes in the bookmarks pane for installation
# type: feature
# category: ui
# version: 0.5
# priority: experimental
#
# Downloads a list of Gtk themes and presents it in the bookmarks
# tab under... »themes«. Double clicking will download and install
# a theme right away.
#
# Note that this is primarily meant for Windows, as it unpacks
................................................................................
# *.dll engines if found. Should work on BSD/Linux still, but would
# require setting up .gtkrc, and writeable module_path for engines.
# It only handles Gtk2 themes currently.
#
# Reuses the `conf.theme` setting from the `gtk_theme` plugin, and
# should work in conjunction to it.
#
# Using a repo.json-style format, which mirrors the station row{}
# layout however. Allows later integration with pluginmanager2...




# The bookmark/themes channel provides the nicer UI however.
#
# A theme.zip should contain a structure like:
#    ---------  ---------- -----   ----
#        62937  2016-12-12 16:39   librezlooks.dll
#            0  2016-12-12 16:40   Rezlooks-dark/
#            0  2016-12-03 20:58   Rezlooks-dark/gtk-2.0/
................................................................................
import os, shutil
import csv
import zipfile
import re
import json
import ahttp
from config import *
from config import pluginconf
import uikit
from compat2and3 import *
import action
import channels.favicon as fi


# register a key
................................................................................
                    state = "gtk-zoom-fit",
                    format = self.mime,
                    listformat = "href"
                )
                # add
                r.append(d)

        # filter on depends: (such as "gtk => 2.0, win32")
        r = [d for d in r if self.deps(d)]










        # convert relative references
        for d in r:
            for field in ("url", "img", '$file'):
                v = str(d.get(field))
                if v  and v.find("://") < 0:
                    d[field] = self.themes_url + v
................................................................................
        if dll:
            self.clear_dll(dll)

    # delete theme engine dll
    def clear_dll(self, dll):
        for fn in dll:
            os.remove(self.theme_dir + fn)

    # instantiate pluginconf.dependency()
    def deps(self, theme):
        d = pluginconf.dependency()
        d.have.update(dict([name, {"version": str(ver)}] for name,ver in [
            ("gtk", ".".join(str(i) for i in uikit.gtk.gtk_version)),
            ("gtk2", "2" if uikit.ver == 2 else "-1"),
            ("gtk3", "3" if uikit.ver == 3 else "-1"),
            ("linux", "-1" if conf.windows else "4.0.0"),
            ("win32", "6.1" if conf.windows else "-1")
        ]))
        #log.HAVE(dict((k,d.have[k].get("version")) for k in d.have))
        self.deps = d.depends
        return self.deps(theme)

    

Modified pluginconf.py from [1a7e07fce3] to [69c2b6a573].

395
396
397
398
399
400
401
402

403
404
405
406
407
408
409
...
457
458
459
460
461
462
463

464
465
466
467
468
469
470
#
# In practice there's little need for full-blown dependency resolving
# for application-level modules.
#
class dependency(object):

    # prepare list of known plugins and versions
    def __init__(self):

        self.have = all_plugin_meta()
        # dependencies on core modules are somewhat more interesting:
        for name in ("st2", "uikit", "config", "action"):
            self.have[name] = plugin_meta(module=name, extra_base=["config"])
        self.have["streamtuner2"] = self.have["st2"]
    have = {}

................................................................................
                ">=": curr >= ver,
                "<=": curr <= ver,
                "==": curr == ver,
                ">":  curr > ver,
                "<":  curr < ver,
                "!=": curr != ver,
            }

            r &= tbl.get(op, True)
        return r


# Add plugin defaults to conf.* store
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Utility function which applies plugin meta data to a config







|
>







 







>







395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
...
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
#
# In practice there's little need for full-blown dependency resolving
# for application-level modules.
#
class dependency(object):

    # prepare list of known plugins and versions
    def __init__(self, core={}):
        self.have = {}.update(core)
        self.have = all_plugin_meta()
        # dependencies on core modules are somewhat more interesting:
        for name in ("st2", "uikit", "config", "action"):
            self.have[name] = plugin_meta(module=name, extra_base=["config"])
        self.have["streamtuner2"] = self.have["st2"]
    have = {}

................................................................................
                ">=": curr >= ver,
                "<=": curr <= ver,
                "==": curr == ver,
                ">":  curr > ver,
                "<":  curr < ver,
                "!=": curr != ver,
            }
            #log.VERSION_COMPARE(name, " → (", curr, op, ver, ") == ", r)
            r &= tbl.get(op, True)
        return r


# Add plugin defaults to conf.* store
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Utility function which applies plugin meta data to a config