Check-in [bcbd6a4624]
Comment: | Add custom ComboBoxText for [select] list plugin config options. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
bcbd6a4624c33dad8657a6ebe7d63107 |
User & Date: | mario on 2014-05-25 00:41:18 |
Other Links: | manifest | tags |
2014-05-25
| ||
00:42 | Convert jamendo preview image sizes into [dropdown] options. check-in: 9c420b0231 user: mario tags: trunk | |
00:41 | Add custom ComboBoxText for [select] list plugin config options. check-in: bcbd6a4624 user: mario tags: trunk | |
2014-05-19
| ||
19:27 | Adds new [history] category in [bookmarks] tab; which lists last played stations. check-in: 6c60cc3c77 user: mario tags: trunk | |
Modified mygtk.py from [eafa93f0f3] to [f12cb00871].
409 410 411 412 413 414 415 416 417 | 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | # gtk.messagebox @staticmethod def msg(text, style=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE): m = gtk.MessageDialog(None, 0, style, buttons, message_format=text) 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 class ComboBoxText(gtk.ComboBox): ls = None def __init__(self, entries): # prepare widget gtk.ComboBox.__init__(self) cell = gtk.CellRendererText() self.pack_start(cell, True) 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]) # activate dropdown of given value def set_default(self, value): for index,row in enumerate(self.ls): if value in row: self.set_active(index) pass # fetch currently selected text entry def get_active_text(self): index = self.get_active() if index >= 0: return self.ls[index][0] |
Modified st2.py from [ed4fb66de3] to [0f49083876].
78 79 80 81 82 83 84 | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | - + | # add library path sys.path.insert(0, "/usr/share/streamtuner2") # pre-defined directory for modules sys.path.append( "/usr/share/streamtuner2/bundle") # external libraries sys.path.insert(0, ".") # development module path # gtk modules |
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 | + + + + + + | if w: # input field if type(w) is gtk.Entry: w.set_text(str(val)) # checkmark elif type(w) is gtk.CheckButton: w.set_active(bool(val)) # dropdown elif type(w) is ComboBoxText: w.set_default(val) # list elif type(w) is gtk.ListStore: w.clear() for k,v in val.items(): w.append([k, v, True]) w.append(["", "", True]) __print__(dbg.CONF, "config load", prefix+key, val, type(w)) # Store gtk widget valus back into conf. dict def save_config(self, config, prefix="config_", save=0): for key,val in config.items(): w = main.get_widget(prefix + key) if w: # text if type(w) is gtk.Entry: config[key] = w.get_text() # elif type(w) is ComboBoxText: config[key] = w.get_active_text() # boolean elif type(w) is gtk.CheckButton: config[key] = w.get_active() # dict elif type(w) is gtk.ListStore: config[key] = {} for row in w: |
859 860 861 862 863 864 865 | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | - + + + + + + + - + | # look up individual plugin options, if loaded if self.channels.get(name) or self.features.get(name): c = self.channels.get(name) or self.features.get(name) for opt in c.config: # default values are already in conf[] dict (now done in conf.add_plugin_defaults) |