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

βŒˆβŒ‹ βŽ‡ branch:  streamtuner2


Check-in [f1a357a60d]

Overview
Comment:Draw gtk_cat columns on initialiation in .gui() call. Use more literal uikit.do() invocations without lambda: wrapping. Let display_categories only run in uikit.do/idle, whereas .load() is run directly from there now.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f1a357a60d13ca906bffd42f51fa5c7a1df40559
User & Date: mario on 2015-04-23 19:03:20
Other Links: manifest | tags
Context
2015-04-23
19:04
Add uikit.tree() instantiation for bookmarks tab. check-in: dbfe218f76 user: mario tags: trunk
19:03
Draw gtk_cat columns on initialiation in .gui() call. Use more literal uikit.do() invocations without lambda: wrapping. Let display_categories only run in uikit.do/idle, whereas .load() is run directly from there now. check-in: f1a357a60d user: mario tags: trunk
18:58
Statusbar updates via uikit.do, immediate=True. check-in: 7aa0ce2a25 user: mario tags: trunk
Changes

Modified channels/__init__.py from [6ef5fada5c] to [bddc9139b6].

280
281
282
283
284
285
286

287
288
289

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
            else:
                # parse error
                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:
            uikit.do(lambda:[
                uikit.columns(self.gtk_list, self.datamap, self.prepare(self.streams[category])),

                y and self.gtk_list.scroll_to_point(0, y)  # scroll to previous position
            ])

        # set pointer
        self.status("")
        self.status(1.0)

        
    # 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):
        uikit.do(lambda: uikit.columns(self.gtk_list, self.datamap, 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:







>

<
|
>
|
<













|







280
281
282
283
284
285
286
287
288

289
290
291

292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
            else:
                # parse error
                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)
        log.UI("load columns datamap streams")
        if self.current == category:

            uikit.do(uikit.columns, self.gtk_list, self.datamap, self.prepare(self.streams[category]))
            if y:
                uikit.do(self.gtk_list.scroll_to_point, 0, y)  # scroll to previous position


        # set pointer
        self.status("")
        self.status(1.0)

        
    # 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):
        uikit.do(uikit.columns, self.gtk_list, self.datamap, 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:
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
        if not self.current:
            self.current = self.str_from_struct(self.categories) or None
            log.STAT(self.module, "β†’ first_show(); use first category as current =", self.current)
            self.shown = 0,

        # Show current category in any case
        log.UI(self.module, "β†’ first_show(); station list β†’ load(", self.current, ")")
        uikit.do(self.load, self.current)
    
        # put selection/cursor on last position
        if True:#self.shown != None:
            log.STAT(self.module+".first_show()", "select last known category treelist position =", self.shown)
            try:
                uikit.do(lambda:self.gtk_list.get_selection().select_path(self.shown))
            except:







|







402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
        if not self.current:
            self.current = self.str_from_struct(self.categories) or None
            log.STAT(self.module, "β†’ first_show(); use first category as current =", self.current)
            self.shown = 0,

        # Show current category in any case
        log.UI(self.module, "β†’ first_show(); station list β†’ load(", self.current, ")")
        self.load(self.current)
    
        # put selection/cursor on last position
        if True:#self.shown != None:
            log.STAT(self.module+".first_show()", "select last known category treelist position =", self.shown)
            try:
                uikit.do(lambda:self.gtk_list.get_selection().select_path(self.shown))
            except:
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453

454
455
456

457
458
459
460
461
462
463
        # get data and save
        self.update_categories()
        if self.categories:
            conf.save("cache/categories_"+self.module, self.categories)
        if self.catmap:
            conf.save("cache/catmap_" + self.module, self.catmap);

        # display outside of this non-main thread            
        uikit.do(self.display_categories)


    # insert content into gtk category list
    def display_categories(self):
    
        # remove any existing columns
        if self.gtk_cat:
            [self.gtk_cat.remove_column(c) for c in self.gtk_cat.get_columns()]
        # rebuild gtk.TreeView

        uikit.tree(self.gtk_cat, self.categories, title="Category", icon=gtk.STOCK_OPEN);

        # if it's a short list of categories, there's probably subfolders

        if len(self.categories) < 20:
            self.gtk_cat.expand_all()
            
        # select any first element
        self.gtk_cat.get_selection().select_path("0") #set_cursor
        self.currentcat()








|






<
<
<

>
|


>







436
437
438
439
440
441
442
443
444
445
446
447
448
449



450
451
452
453
454
455
456
457
458
459
460
461
462
        # get data and save
        self.update_categories()
        if self.categories:
            conf.save("cache/categories_"+self.module, self.categories)
        if self.catmap:
            conf.save("cache/catmap_" + self.module, self.catmap);

        # display outside of this non-main thread
        uikit.do(self.display_categories)


    # insert content into gtk category list
    def display_categories(self):
    



        # rebuild gtk.TreeView
        log.UI("display_categoris: tree→gtk_cat")
        uikit.tree(self.gtk_cat, self.categories, title="Category", icon=gtk.STOCK_OPEN)

        # if it's a short list of categories, there's probably subfolders
        log.UI("display_categoris: expand_all")
        if len(self.categories) < 20:
            self.gtk_cat.expand_all()
            
        # select any first element
        self.gtk_cat.get_selection().select_path("0") #set_cursor
        self.currentcat()

482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
                streams.insert(i_pos - 1, row)
                i_pos = i_pos + 1
        else:
            streams += rows

        # Now appending to the liststore directly would be even nicer
        y = int(tv.get_vadjustment().get_value())
        uikit.do(self.load, self.current, y=y)





    #--------------------------- actions ---------------------------------








|







481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
                streams.insert(i_pos - 1, row)
                i_pos = i_pos + 1
        else:
            streams += rows

        # Now appending to the liststore directly would be even nicer
        y = int(tv.get_vadjustment().get_value())
        self.load(self.current, y=y)





    #--------------------------- actions ---------------------------------

590
591
592
593
594
595
596

597
598
599
600
601
602
603
        sw1 = gtk.ScrolledWindow()
        sw1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw1.set_property("width_request", 150)
        sw1.show()
        tv1 = gtk.TreeView()
        tv1.set_property("width_request", 75)
        tv1.set_property("enable_tree_lines", True)

        tv1.connect("button_release_event", parent.on_category_clicked)
        tv1.show()
        sw1.add(tv1)
        vbox.pack1(sw1, resize=False, shrink=True)
        # stream list
        sw2 = gtk.ScrolledWindow()
        sw2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)







>







589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
        sw1 = gtk.ScrolledWindow()
        sw1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw1.set_property("width_request", 150)
        sw1.show()
        tv1 = gtk.TreeView()
        tv1.set_property("width_request", 75)
        tv1.set_property("enable_tree_lines", True)
        uikit.tree_column(tv1, "Category")
        tv1.connect("button_release_event", parent.on_category_clicked)
        tv1.show()
        sw1.add(tv1)
        vbox.pack1(sw1, resize=False, shrink=True)
        # stream list
        sw2 = gtk.ScrolledWindow()
        sw2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)