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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [cdafbe23ce]

Overview
Comment:Typecast plugin options on initialization. Use SpinButton for `int` options instead of text label.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cdafbe23ce0b3ea9906e167a4be6f8929d168ee7
User & Date: mario on 2015-05-17 19:12:35
Other Links: manifest | tags
Context
2015-05-17
19:13
Remove stray `print` statement check-in: d10f61093f user: mario tags: trunk
19:12
Typecast plugin options on initialization. Use SpinButton for `int` options instead of text label. check-in: cdafbe23ce user: mario tags: trunk
19:11
Introduce new hooks["switch"] for update_title(). Used by new `Channel homepage link` plugin, which brings back streamtuner1-style service homepage. check-in: f992b0792a user: mario tags: trunk
Changes

Modified channels/configwin.py from [3a18900ebe] to [e39ea3ed2b].

50
51
52
53
54
55
56
57

58
59
60

61
62
63

64



65
66

67
68
69
70
71
72
73
74
75
76
77
78
79

80
81
82

83
84
85

86



87
88

89
90
91
92
93
94
95
50
51
52
53
54
55
56

57
58
59

60
61
62

63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79
80
81

82
83
84

85
86
87

88
89
90
91
92
93

94
95
96
97
98
99
100
101







-
+


-
+


-
+

+
+
+

-
+












-
+


-
+


-
+

+
+
+

-
+







    
    # Load values from conf. store into gtk widgets
    def load_config(self, config, prefix="config_"):
        for key,val in config.items():
            w = self.main.get_widget(prefix + key)
            if w:
                # input field
                if type(w) is gtk.Entry:
                if isinstance(w, gtk.Entry):
                    w.set_text(str(val))
                # checkmark
                elif type(w) is gtk.CheckButton:
                elif isinstance(w, gtk.CheckButton):
                    w.set_active(bool(val))
                # dropdown
                elif type(w) is ComboBoxText:
                elif isinstance(w, ComboBoxText):
                    w.set_default(val)
                # number
                elif isinstance(w, gtk.SpinButton):
                    w.set_value(int(val))
                # list
                elif type(w) is gtk.ListStore:
                elif isinstance(w, gtk.ListStore):
                    w.clear()
                    for k,v in val.items():
                        w.append([k, v, True, self.app_bin_check(v)])
                    w.append(["", "", True, gtk.STOCK_NEW])
            #log.CONF("config load", prefix+key, val, type(w))

    # Store gtk widget valus back into conf. dict
    def save_config(self, config, prefix="config_", save=0):
        for key,val in config.items():
            w = self.main.get_widget(prefix + key)
            if w:
                # text
                if type(w) is gtk.Entry:
                if isinstance(w, gtk.Entry):
                    config[key] = w.get_text()
                # pre-defined text
                elif type(w) is ComboBoxText:
                elif isinstance(w, ComboBoxText):
                    config[key] = w.get_active_text()
                # boolean
                elif type(w) is gtk.CheckButton:
                elif isinstance(w, gtk.CheckButton):
                    config[key] = w.get_active()
                # int
                elif isinstance(w, gtk.SpinButton):
                    config[key] = int(w.get_value(val))
                # dict
                elif type(w) is gtk.ListStore:
                elif isinstance(w, gtk.ListStore):
                    config[key] = {}
                    for row in w:
                        if row[0] and row[1]:
                            config[key][row[0]] = row[1]
            log.CONF("config save", prefix+key, val)
    
    
140
141
142
143
144
145
146


147
148
149
150
151
152
153
154
155

156
157
158
159
160





161
162

163


164

165
166
167
168
169
170
171
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167

168
169
170
171
172
173

174
175
176
177

178
179
180
181
182
183
184
185







+
+








-
+




-
+
+
+
+
+

-
+

+
+
-
+







        cb.set_tooltip_text(self._tooltip(meta))
        add_( "config_plugins_"+name, cb, color=meta.get("color"), image=meta.get("png"), align=0)

        # Default values are already in conf[] dict
        # (now done in conf.add_plugin_defaults)
        for opt in meta["config"]:
            color = opt.get("color", None)
            type = opt.get("type", "str")
            description = opt.get("description", "./.")
            
            # hidden
            if opt.get("hidden"):
                continue 

            # display checkbox
            elif opt["type"] in ("bool", "boolean"):
                cb = gtk.CheckButton(opt["description"])
                add_( "config_"+opt["name"], cb, color=color )
                description = None

            # drop down list
            elif opt["type"] in ("select", "choose", "options"):
                cb = ComboBoxText(ComboBoxText.parse_options(opt["select"])) # custom uikit widget
                add_( "config_"+opt["name"], cb, opt["description"], color )

            # numeric
            elif opt["type"] in ("int", "integer", "numeric"):
                adj = gtk.Adjustment(0, 0, 5000, 1, 10, 0)
                cb = gtk.SpinButton(adj, 1.0, 0)

            # text entry
            # text field
            else:
                cb = gtk.Entry()
           
                add_( "config_"+opt["name"], gtk.Entry(), opt["description"], color )
            add_( "config_"+opt["name"], cb, description, color )

        # Spacer between plugins
        add_( None, gtk.HSeparator() )

    # Reformat `doc` linebreaks for gtk.tooltip
    def _tooltip(self, meta):
        doc = meta.get("doc", "").strip()

Modified pluginconf.py from [33b1fa968d] to [d5e7efa673].

466
467
468
469
470
471
472







473

474
475
476
477
478
479
466
467
468
469
470
471
472
473
474
475
476
477
478
479

480
481
482
483
484
485
486







+
+
+
+
+
+
+
-
+






#
def add_plugin_defaults(conf_options, conf_plugins, meta={}, module=""):

    # Option defaults, if not yet defined
    for opt in meta.get("config", []):
        if "name" in opt and "value" in opt:
            if opt["name"] not in conf_options:
                 # typemap "bool" and "int" here
                 if opt["type"] in ("bool", "boolean"):
                     val = bool(opt["value"])
                 elif opt["type"] in ("int", "integer", "numeric"):
                     val = int(opt["value"])
                 else:
                     val = str(opt["value"])
                 conf_options[opt["name"]] = opt["value"]  # should typemap "bool" and "int" here
                 conf_options[opt["name"]] = val

    # Initial plugin activation status
    if module and module not in conf_plugins:
         conf_plugins[module] = meta.get("priority") in ("core", "builtin", "always", "default", "standard")