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

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [2254b1cf48]:

To Artifact [6af40f336b]:


1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
-






#
# encoding: UTF-8
# api: streamtuner2
# type: base
# category: ui
# title: Channel plugins
# description: Base implementation for channels and feature plugins
# version: 1.1
500
501
502
503
504
505
506

507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534






























535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555




















556
557
558
559
560
561
562
563
564
565
566
567
568










569
570
571
572


573
574
575
576
577



578
579
580

581
582
583
584
585



586
587
588
589
590
591
499
500
501
502
503
504
505
506




























507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537




















538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558












559
560
561
562
563
564
565
566
567
568
569
570


571
572
573




574
575
576



577
578




579
580
581
582




583







+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+


-
-
+
+

-
-
-
-
+
+
+
-
-
-
+

-
-
-
-
+
+
+

-
-
-
-
# channel plugin without glade-pre-defined notebook tab
#
class ChannelPlugin(GenericChannel):

    module = "abstract"

    def gui(self, parent):

        if parent:
            module = self.__class__.__name__
            # two panes
            vbox = gtk.HPaned()
            vbox.show()
            # category treeview
            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)
            sw2.show()
            tv2 = gtk.TreeView()
            tv2.set_property("width_request", 200)
            tv2.set_property("enable_tree_lines", True)
            tv2.connect("row_activated", parent.on_play_clicked)
            tv2.show()
            sw2.add(tv2)
            vbox.pack2(sw2, resize=True, shrink=True)
        if not parent:
            return

        module = self.__class__.__name__
        # two panes
        vbox = gtk.HPaned()
        vbox.show()
        # category treeview
        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)
        sw2.show()
        tv2 = gtk.TreeView()
        tv2.set_property("width_request", 200)
        tv2.set_property("enable_tree_lines", True)
        tv2.connect("row_activated", parent.on_play_clicked)
        tv2.show()
        sw2.add(tv2)
        vbox.pack2(sw2, resize=True, shrink=True)

            # prepare label
            pixbuf = None
            if "png" in self.meta:
                pixbuf = uikit.pixbuf(self.meta["png"])
            else:
                png = get_data("channels/" + self.module + ".png")
                pixbuf = uikit.pixbuf(png)
            if pixbuf:
                icon = gtk.image_new_from_pixbuf(pixbuf)
            else:
                icon = gtk.image_new_from_stock(gtk.STOCK_DIRECTORY, size=1)
            label = gtk.HBox()
            label.pack_start(icon, expand=False, fill=True)
            label.pack_start(gtk.Label(self.meta.get("title", self.module)), expand=True, fill=True)
                
            # pack it into an event container to catch double-clicks
            ev_label = gtk.EventBox()
            ev_label.add(label)
            ev_label.connect('event', parent.on_homepage_channel_clicked)
            plain_label = gtk.Label(self.module)
        # prepare label
        pixbuf = None
        if "png" in self.meta:
            pixbuf = uikit.pixbuf(self.meta["png"])
        else:
            png = get_data("channels/" + self.module + ".png")
            pixbuf = uikit.pixbuf(png)
        if pixbuf:
            icon = gtk.image_new_from_pixbuf(pixbuf)
        else:
            icon = gtk.image_new_from_stock(gtk.STOCK_DIRECTORY, size=1)
        label = gtk.HBox()
        label.pack_start(icon, expand=False, fill=True)
        label.pack_start(gtk.Label(self.meta.get("title", self.module)), expand=True, fill=True)
            
        # pack it into an event container to catch double-clicks
        ev_label = gtk.EventBox()
        ev_label.add(label)
        ev_label.connect('event', parent.on_homepage_channel_clicked)
        plain_label = gtk.Label(self.module)



            # to widgets
            self.gtk_cat = tv1
            parent.widgets[module + "_cat"] = tv1
            self.gtk_list = tv2
            parent.widgets[module + "_list"] = tv2
            ev_label.show_all()
            vbox.show_all()
            parent.widgets["v_" + module] = vbox
            parent.widgets["c_" + module] = ev_label
            tv2.connect('button-press-event', parent.station_context_menu)
        # to widgets
        self.gtk_cat = tv1
        parent.widgets[module + "_cat"] = tv1
        self.gtk_list = tv2
        parent.widgets[module + "_list"] = tv2
        ev_label.show_all()
        vbox.show_all()
        parent.widgets["v_" + module] = vbox
        parent.widgets["c_" + module] = ev_label
        tv2.connect('button-press-event', parent.station_context_menu)


            # try to initialize superclass now, before adding to channel tabs
            GenericChannel.gui(self, parent)
        # try to initialize superclass now, before adding to channel tabs
        GenericChannel.gui(self, parent)


            # add notebook tab
            tab = parent.notebook_channels.insert_page_menu(vbox, ev_label, plain_label, -1)
            
        # add notebook tab
        tab = parent.notebook_channels.insert_page_menu(vbox, ev_label, plain_label, -1)

            
            
            # double-click catch
        # double-click catch


            # add module to list            
            #parent.channels[module] = None
            #parent.channel_names.append(module)
        # add module to list            
        #parent.channels[module] = None
        #parent.channel_names.append(module)
            """ -> already taken care of in main.load_plugins() """