Index: channels/configwin.py ================================================================== --- channels/configwin.py +++ channels/configwin.py @@ -1,5 +1,6 @@ +# encoding: utf-8 # api: streamtuner2 # title: Config dialog # description: Allows to configure players, options, and plugins # version: 2.7 # type: feature @@ -50,10 +51,11 @@ # Load values from conf. store into gtk widgets def load_config(self, config, prefix="config_", widgets={}): for key,val in config.items(): w = self.main.get_widget(prefix + key) or widgets.get(prefix + key) + #log.CONF("load_config()", prefix+key, "=", val, "→", type(w)) if w: # number if isinstance(w, gtk.SpinButton): w.set_value(int(val)) # input field @@ -62,11 +64,11 @@ # checkmark elif isinstance(w, gtk.CheckButton): w.set_active(bool(val)) # dropdown elif isinstance(w, ComboBoxText): - w.set_default(val) + w.set_default(str(val)) # list elif isinstance(w, gtk.ListStore): w.clear() if isinstance(val, dict): for k,v in val.items(): @@ -76,11 +78,10 @@ for row in val: log.DATA(row) w.append([str(e) for e in row]) if len(val): w.append(["" for e in val[0]]) - #log.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, widgets={}): for key,val in config.items(): w = self.main.get_widget(prefix + key) or widgets.get(prefix + key) Index: contrib/recordflags.py ================================================================== --- contrib/recordflags.py +++ contrib/recordflags.py @@ -1,10 +1,10 @@ # encoding: utf-8 # api: streamtuner2 # title: Recording options # description: Allows to set streamripper/fIcy options before recording -# version: 0.9 +# version: 1.0 # depends: streamtuner2 > 2.2.0 # conflicts: continuous_record # priority: optional # config: # { name: recordflags_auto, type: bool, value: 1, description: Apply options automatically once saved. } @@ -18,20 +18,19 @@ # recording for example. # # Reuses the known option scheme from the config window. Which is perhaps # less pretty than a custom dialog, but allows to set options for different # download/recording tools: streamripper, fPls, youtube-dl, wget. +# +# The presented parameter dialog depends on which tool is configured in the +# Apps/Recording table to which audio type. (If you want fpls options, you +# have to have fpls/ficy configured beforehand.) # # Note that predefining -flags in the Apps/Recording config table might # conflict with per-stream options. In particular avoid a -d directory # default for streamripper; and use this plugins´ option instead. # -# ToDo: -# → override main.record() instead of action.record -# → eventually strip defaults such as `-d ../dir` from conf.record; -# using action append= param now, thus no rewriting of assoc dict -# import re import os import copy @@ -41,10 +40,16 @@ import action from compat2and3 import * # hook record button / menu / action +# +# ToDo: +# → override main.record() instead of action.record +# → eventually strip defaults such as `-d ../dir` from conf.record; +# using action append= param now, thus no rewriting of assoc dict +# class recordflags (FeaturePlugin): # settings cfg_widget_pfx = "recordoptions_config_" widgets = {} @@ -203,13 +208,10 @@ parent.recordoptions_go.connect("clicked", self.do_record) parent.recordoptions_save.connect("clicked", self.save_only) parent.recordoptions_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x44, 0x22, 0x11)) # shortcuts - self.add_plg = parent.configwin.add_plg # create _cfg widgets - self.load_config = parent.configwin.load_config # populate _cfg widgets - self.save_config = parent.configwin.save_config # save from _cfg widgets self.cfg_vbox = { "basic": self.parent.recordoptions_cfg, "meta": self.parent.recordoptions_cfg_extra, "net": self.parent.recordoptions_cfg_verbose, } @@ -294,13 +296,17 @@ # populate config widgets, seth defaults/current settings def load_config_widgets(self, row, group="streamripper", p=None): # clean up previous [vbox.remove(w) for vbox in self.cfg_vbox.values() for w in vbox.get_children()] # add plugins - self.add_plg(group, self.flag_meta[group], self.pack_option, self.cfg_widget_pfx) + self.parent.configwin.add_plg( + group, self.flag_meta[group], self.pack_option, self.cfg_widget_pfx + ) # set values - self.load_config(self.configdict_from_args(row), self.cfg_widget_pfx, widgets=self.widgets) + self.parent.configwin.load_config( + self.configdict_from_args(row), self.cfg_widget_pfx, widgets=self.widgets + ) # Put config widgets into recordoptions_cfg_*** vbox def pack_option(self, id=None, w=None, label=None, color=None, image=None, align=5, opt={}): category = opt.get("category") vbox = self.cfg_vbox.get(self.catalias.get(category) or category) or self.cfg_vbox["basic"] @@ -307,12 +313,16 @@ vbox.pack_start(uikit.wrap(self.widgets, id, w, label, color, image, align, label_markup=1, label_size=250), expand=False, fill=False) # return "--args str" for current config widget states def args_from_configwin(self): - cfg = { name: None for name in self.namemap.keys() } - self.save_config(cfg, self.cfg_widget_pfx, widgets=self.widgets) + cfg = { + name: None for name in self.namemap.keys() + } + self.parent.configwin.save_config( + cfg, self.cfg_widget_pfx, widgets=self.widgets + ) #log.DATA(cfg) return self.args_from_configdict(cfg) #-- extract saved row[record_flags] and conf.record[] defaults into name-config{} def configdict_from_args(self, row): @@ -346,5 +356,6 @@ arg = self.namemap[name] s = s + " " + arg if isinstance(val, (str, unicode)): # type == "bool" check here(...) s = s + " " + val return s +