Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -5,11 +5,11 @@ # type: application # title: streamtuner2 # description: Directory browser for internet radio / audio streams # depends: pygtk | gi, threading, requests, pyquery, lxml, deb:python-pyquery, deb:python-requests, deb:python-gtk2 # version: 2.1.4 -# author: Mario Salzer +# author: Mario Salzer # license: public domain # url: http://freshcode.club/projects/streamtuner2 # config: # { type: env, name: http_proxy, description: proxy for HTTP access } # { type: env, name: XDG_CONFIG_HOME, description: relocates user .config subdirectory } @@ -59,11 +59,11 @@ # gtk modules from mygtk import pygtk, gtk, gobject, ui_file, mygtk, ver as GTK_VER, ComboBoxText, gui_startup # custom modules from config import conf # initializes itself, so all conf.vars are available right away -from config import __print__, dbg +from config import __print__, dbg, plugin_meta import ahttp import action # needs workaround... (action.main=main) import channels from channels import * import favicon @@ -403,14 +403,12 @@ # load plugins from /usr/share/streamtuner2/channels/ def load_plugin_channels(self): - # find and order plugin files + # initialize plugin modules (pre-ordered) ls = channels.module_list() - - # step through for module in ls: gui_startup(2/10.0 + 7/10.0 * float(ls.index(module))/len(ls), "loading module "+module) # skip module if disabled if conf.plugins.get(module, 1) == False: @@ -546,11 +544,11 @@ # show search dialog def menu_search(self, w): self.search_dialog.show(); if not self.current or main.current_channel != "bookmarks": self.current = main.current_channel - self.search_dialog_current.set_label("just %s" % main.channels[self.current].title) + self.search_dialog_current.set_label("just %s" % main.channels[self.current].meta["title"]) # hide dialog box again def cancel(self, *args): self.search_dialog.hide() @@ -606,11 +604,11 @@ if cn.has_search: # "search" in cn.update_streams.func_code.co_varnames: __print__(dbg.PROC, "has_search:", cn.module) try: add = cn.update_streams(cat=None, search=self.q) for row in add: - row["genre"] = cn.title + " " + row.get("genre", "") + row["genre"] = cn.meta["title"] + " " + row.get("genre", "") entries += add except: continue #main.status(main, 1.0 * i / 15) self.show_results(entries) @@ -797,21 +795,28 @@ main.load_theme() # iterate over channel and feature plugins def add_plugins(self): - for name,plugin in main.channels.iteritems(): - self.add_plg(name, plugin, plugin.meta) - self.plugin_options.pack_start(mygtk.label("\nFeature plugins add categories, submenu entries, or other extensions.\n", 500, 1)) - for name,plugin in main.features.iteritems(): - self.add_plg(name, plugin, plugin.meta) + ls = {} + for name in channels.module_list(): + if name in main.channels: + ls[name] = main.channels[name].meta + elif name in main.features: + ls[name] = main.features[name].meta + else: + ls[name] = plugin_meta(conf.share+"/channels/"+name+".py") + for name,meta in sorted(ls.items(), key=lambda e: e[1]["type"]+e[1]["title"].lower(), reverse=False): + self.add_plg(name, meta) + #self.plugin_options.pack_start(mygtk.label("\nFeature plugins add categories, submenu entries, or other extensions.\n", 500, 1)) # add configuration setting definitions from plugins - def add_plg(self, name, c, meta): + def add_plg(self, name, meta): # add plugin load entry cb = gtk.CheckButton(name) - cb.get_children()[0].set_markup("%s (%s) %s\n%s" % (meta["title"], meta["type"], meta.get("version", ""), meta["description"])) + cb.get_children()[0].set_markup("%s (%s) %s\n%s" % (meta.get("title", name), meta.get("type", "unknown"), meta.get("version", "./."), meta.get("description", "no description"))) + cb.set_tooltip_text(meta.get("doc", "").strip()) self.add_( "config_plugins_"+name, cb ) # default values are already in conf[] dict (now done in conf.add_plugin_defaults) for opt in meta["config"]: color = opt.get("color", None)