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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [5d8d7fd191]

Overview
Comment:Use custom GenericChannel.columns() wrapper to simplify passing TreeView widget and keeping returned liststore/rowmap/pix_entry.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5d8d7fd191eb5bda0342183cc7fd146be2c9c78c
User & Date: mario on 2015-05-09 21:37:44
Other Links: manifest | tags
Context
2015-05-09
21:38
Prepare for more complex hooks["play"] invocation (ignore args, kwargs). check-in: 5fbe0ccd0c user: mario tags: trunk
21:37
Use custom GenericChannel.columns() wrapper to simplify passing TreeView widget and keeping returned liststore/rowmap/pix_entry. check-in: 5d8d7fd191 user: mario tags: trunk
21:36
Minor typo fixes. check-in: d1befc2a99 user: mario tags: trunk
Changes

Modified channels/__init__.py from [824048913b] to [33bbfd495e].

66
67
68
69
70
71
72



73
74
75
76
77
78
79
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82







+
+
+







    catmap = {}
    shown = None      # last selected entry in stream list, also indicator if notebook tab has been selected once / stream list of current category been displayed yet

    # gui + data
    streams = {}      # Station list dict, associates each genre to a list of stream rows
    gtk_list = None   # Gtk widget for station treeview
    gtk_cat = None    # Gtk widget for category columns
    _ls = None        # ListStore for station treeview
    _rowmap = None    # Preserve streams-datamap
    _pix_entry = None # ListStore entry that contains favicon

    # mapping of stream{} data into gtk treeview/treestore representation
    datamap = [
       # coltitle   width	[ datasrc key, type, renderer, attrs ]	[cellrenderer2], ...
       ["",		20,	["state",	str,  "pixbuf",	{}],	],
       ["Genre",	65,	['genre',	str,	"t",	{}],	],
       ["Station Title",275,	["title",	str,    "text",	{"strikethrough":11, "cell-background":12, "cell-background-set":13}],  ["favicon", gtk.gdk.Pixbuf, "pixbuf", {}], ],
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
155
156
157
158
159
160
161






162

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177







-
-
-
-
-
-

-
+




+
+
+







        self.current = conf.state(self.module).get("current")
        self.display_categories()

        # update column names
        for field,title in list(self.titles.items()):
            self.update_datamap(field, title=title)
        
        # prepare stream list
        if (not self.rowmap):
            for row in self.datamap:
                for x in range(2, len(row)):
                    self.rowmap.append(row[x][0])

        # Initialize stations TreeView
        uikit.columns(self.gtk_list, self.datamap, [])
        self.columns([])
        
        # add to main menu
        uikit.add_menu([parent.channelmenuitems], self.meta["title"], lambda w: parent.channel_switch_by_name(self.module) or 1)

    # Just wraps uikit.columns() to retain liststore, rowmap and pix_entry
    def columns(self, entries=None, pix_entry=False, typecast=0):
        self._ls, self._rowmap, self._pix_entry = uikit.columns(self.gtk_list, self.datamap, entries)

    # Statusbar stub (defers to parent/main window, if in GUI mode)
    def status(self, *args, **kw):
        if self.parent: self.parent.status(*args, **kw)
        else: log.INFO("status():", *v)


320
321
322
323
324
325
326
327

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346

347
348
349
350
351
352
353
320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345

346
347
348
349
350
351
352
353







-
+


















-
+







                self.status("Category parsed empty.")
                self.streams[category] = self.nothing_found
                log.INFO("Oooops, parser returned nothing for category " + category)
                
        # Update treeview/model (if category is still selected)
        if self.current == category:
            log.UI("load() → uikit.columns({}.streams[{}])".format(self.module, category), [inspect.stack()[x][3] for x in range(1,5)])
            uikit.do(uikit.columns, self.gtk_list, self.datamap, self.prepare(self.streams[category]))
            uikit.do(self.columns, self.prepare(self.streams[category]))
            if y:
                uikit.do(self.gtk_list.scroll_to_point, 0, y + 1)   # scroll to previous position, +1 px, because
                # somehow Gtk.TreeView else stumbles over itself when scrolling to the same position the 2nd time

        # unset statusbar
        self.status()

        
    # store current streams data
    def save(self):
        conf.save("cache/" + self.module, self.streams, gz=1)


    # called occasionally while retrieving and parsing
    def update_streams_partially_done(self, entries):
        if gtk_ver == 3 and not conf.nothreads:
            pass
        else:  # kills Gtk3 too easily
            uikit.do(uikit.columns, self.gtk_list, self.datamap, entries)
            uikit.do(self.columns, entries)

        
    # finds differences in new/old streamlist, marks deleted with flag
    def deleted_streams(self, new, old):
        diff = []
        new = [row.get("url","http://example.com/") for row in new]
        for row in old: