Index: channels/jamendo.py ================================================================== --- channels/jamendo.py +++ channels/jamendo.py @@ -69,12 +69,12 @@ "description":"Streaming format. Use 'ogg' for Vorbis, 'mp32' for MP3 with 192kbps/VBR, or 'mp31' for 96kbps MP3, and even 'flac' for lossless audio." }, {"name": "jamendo_image_size", "value": "50", "type": "select", - "select": "25|35|50|55|60|65|70|75|85|100|130|150|200|300", - "description": "Preview images size (height and width in pixel) for albums or tracks." + "select": "25=25px|35=35px|50=50px|55=55px|60=60px|65=65px|70=70px|75=75px|85=85px|100=100px|130=130px|150=150px|200=200px|300=300px", + "description": "Preview images size (height and width) for albums or tracks." }, {"name": "jamendo_count", "value": "1", "type":"text", "description": "How many result sets (200 entries each) to retrieve." Index: mygtk.py ================================================================== --- mygtk.py +++ mygtk.py @@ -415,11 +415,11 @@ b.pack_start(w1, expand=False, fill=False) b.pack_start(w2, expand=True, fill=True) return b - # + # Attach textual menu entry and callback @staticmethod def add_menu(menuwidget, label, action): m = gtk.MenuItem(label) m.connect("activate", action) m.show() @@ -433,12 +433,21 @@ m.show() m.connect("response", lambda *w: m.destroy()) -# Implement text combobox, -# because debian packages lack the binding https://bugzilla.gnome.org/show_bug.cgi?id=660659 +# Text-only dropdown list. +# +# Necessary because gtk.ComboBoxText binding is absent in debian packages +# https://bugzilla.gnome.org/show_bug.cgi?id=660659 +# +# This one implements a convenience method `.set_default()` to define the active +# selection by value, rather than by index. +# +# Can use a list[] of entries or a key->value dict{}, where the value becomes +# display text, and the key the internal value. +# class ComboBoxText(gtk.ComboBox): ls = None def __init__(self, entries): @@ -451,12 +460,14 @@ self.add_attribute(cell, "text", 1) # collect entries self.ls = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.set_model(self.ls) - for value in entries: - self.ls.append([value, value]) + if type(entries[0]) is not tuple: + entries = zip(entries, entries) + for key,value in entries: + self.ls.append([key, value]) # activate dropdown of given value def set_default(self, value): for index,row in enumerate(self.ls): if value in row: @@ -469,7 +480,13 @@ def get_active_text(self): index = self.get_active() if index >= 0: return self.ls[index][0] - + # Expand A=a|B=b|C=c option list into (key,value) tuple list, or A|B|C just into a list. + @staticmethod + def parse_options(opts, sep="|", assoc="="): + if opts.find(assoc) >= 0: + return [ (k,v) for k,v in (x.split(assoc, 1) for x in opts.split(sep)) ] + else: + return opts.split(sep) #dict( (v,v) for v in opts.split(sep) ) Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -218,14 +218,10 @@ # actually display main window gui_startup(99/100.0) self.win_streamtuner2.show() - # WHY DON'T YOU WANT TO WORK?! - #self.shoutcast.gtk_list.set_enable_search(True) - #self.shoutcast.gtk_list.set_search_column(4) - #-- Shortcut for glade.get_widget() # Allows access to widgets as direct attributes instead of using .get_widget() @@ -247,17 +243,11 @@ # returns the currently selected directory/channel object def channel(self): - #try: - return self.channels[self.current_channel] - #except Exception,e: - # print(e) - # self.notebook_channels.set_current_page(0) - # self.current_channel = "bookmarks" - # return self.channels["bookmarks"] + return self.channels[self.current_channel] def current_channel_gtk(self): i = self.notebook_channels.get_current_page() try: return self.channel_names[i] @@ -863,11 +853,11 @@ if opt["type"] == "boolean": cb = gtk.CheckButton(opt["description"]) self.add_( "config_"+opt["name"], cb, color=color ) # drop down list elif opt["type"] == "select": - cb = ComboBoxText(opt["select"].split("|")) # custom mygtk widget + cb = ComboBoxText(ComboBoxText.parse_options(opt["select"])) # custom mygtk widget self.add_( "config_"+opt["name"], cb, opt["description"], color ) # text entry else: self.add_( "config_"+opt["name"], gtk.Entry(), opt["description"], color )