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

⌈⌋ branch:  streamtuner2


Check-in [71b6a7785e]

Overview
Comment:New plugin: Vorbis and Opus icons for OGG streams
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:71b6a7785ea8d05825b9acdd5bacb1e099b05e1d
User & Date: mario on 2017-02-13 21:55:08
Other Links: manifest | tags
Context
2017-02-14
16:33
Shorten format comparison in postprocess_filter, remove original *gtkrc* stock item binding. check-in: 9933677f41 user: mario tags: trunk
2017-02-13
21:55
New plugin: Vorbis and Opus icons for OGG streams check-in: 71b6a7785e user: mario tags: trunk
16:51
Move -verbose flag into category:verbose. check-in: bdae219b88 user: mario tags: trunk
Changes

Added c/plugins/oggicon.py version [7236873b7f].





































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# encoding: UTF-8
# api: streamtuner2
# title: OGG icon
# description: highlights OGG Vorbis and Opus stations with icons
# version: 0.1
# depends: uikit
# type: feature
# category: ui
# priority: extra
#
# Adds a Gtk icon for OGG Vorbis and Opus streams, which get displayed
# leftmost (to the genre) as state icon.
#
# Instantiates the icons right away as pixbufs in an IconFactory, assigns
# each to a short stock_id: `ogg` and `opus`.


import uikit
from config import *
from channels import *


# oggicon
class oggicon (FeaturePlugin):

    # icons
    png = {
        "ogg": """
            iVBORw0KGgoAAAANSUhEUgAAABgAAAAYBAMAAAASWSDLAAAAJFBMVEUAAAAVJCtCRRsdUnc5Vls2
            b5qLhjZTjrBqkpOqmhmWz9fu1CObwCzQAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZ
            cwAACxMAAAsTAQCanBgAAAAHdElNRQfhAg0VAAsUWVEpAAAA10lEQVQY02NgAAGuAgYEWB6OYHNV
            hSKklleFwqW4yqtC4VLLy11cnM0hbHaXwq5Vq4QhUktWCal0rVoCluKqaOnenbJqlaMISIfGKu+d
            27yWSHQ4MDA67WyavXPmRI9VqxwYOpbM3g0E2VmrVpgzFHp57k7SnLZt1xJHUwb2wGW7V2jvzpy1
            aoUDA4NI57YmoLpVq1YATRMR2r17m5Kix6olIItKBQVFVgkbCgqCnRMaGixobBwAcVxpaKixsSnU
            1ewgTgDMQ6WhcAmQFEICKGWKFDrsEAkAzOpE42DS7YsAAAAASUVORK5CYII=""",
        "opus": """
            iVBORw0KGgoAAAANSUhEUgAAABgAAAAYBAMAAAASWSDLAAAAGFBMVEVhcACTlZKYmpeeoJ2ipKGp
            q6isrquytLF6/PABAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCa
            nBgAAAAHdElNRQfhAg0UOTZDd/q1AAAAYUlEQVQY02NgoAYoBwJ2CJMdxC4AIiCbLQ0EEkCYgSEN
            DhIYWENBgBVMQTgMUMoFCBwYGFhANIwDoYyBwICBGUIZIwADgxICMDAwIbEZGAWhAOw0ICUAdzKj
            ILIHBEn1MQBjViBd1YYkTgAAAABJRU5ErkJggg=="""
    }

    # hook filter, set gtk icons
    def init2(self, parent):
        GenericChannel.postprocess_filters.append(self.row_icon)
        #uikit.gtk.rc_parse_string(gtkrc)
        #uikit.gtk.rc_reset_styles(uikit.gtk.settings_get_for_screen(uikit.gtk.gdk.screen_get_default()))
        self.add_icons()
 
    # adds gtk.IconFactory and one IconSet/Pixbuf each
    def add_icons(self):
        fact = uikit.gtk.IconFactory()
        for stock_id, b64_png in self.png.items():
            img = uikit.gtk.IconSet(uikit.uikit.pixbuf(b64_png))
            fact.add(stock_id, img)
        fact.add_default()

    # filter: add `state` icon name depending on audio format
    def row_icon(self, row, channel):
        if row.get("format") == "audio/ogg":
            row["state"] = "ogg"
        if row.get("format") == "audio/opus":
            row["state"] = "opus"
        return True