From 6863318d5b92df36d2190334ba62214d54510d2f Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Tue, 1 Feb 2011 22:45:09 -0500 Subject: [PATCH] plugins: Web radio drop down selector The drop down selector provides a way of changing stations while on another station. It's much more convenient. --- plugins/web_radio.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/plugins/web_radio.py b/plugins/web_radio.py index 0d7f2247..611987ee 100644 --- a/plugins/web_radio.py +++ b/plugins/web_radio.py @@ -11,25 +11,39 @@ path = libsaria.path audio = libsaria.audio gtk = ocarina.gtk -page = gtk.ScrolledWindow() box = gtk.VBox() -sel = gtk.ComboBoxEntry() +sel = gtk.combo_box_new_text() +page = gtk.ScrolledWindow() web = webkit.WebView() -#box.pack_start(sel) -#box.pack_start(web) +sel.append_text("Select a station:") +sel.append_text("Groove Shark") +sel.append_text("Pandora") +sel.set_active(0) + page.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) -#page.add_with_viewport(box) page.add(web) html = path.join(path.cwd(), "html") radio = path.join(html, "web_radio.html") web.open(radio) -page.show_all() +box.pack_start(sel, False, False) +box.pack_start(page) +box.show_all() + +urls = [radio, "http://www.grooveshark.com", "http://www.pandora.com"] + +def combo_box_changed(box): + model = box.get_model() + index = box.get_active() + if index != None: + web.open(urls[index]) + +sel.connect("changed", combo_box_changed) def start(): - body.add_page("Web Radio", page, False, False) + body.add_page("Web Radio", box, False, False) def stop(): body.remove_page("Web Radio")