Index: channels/configwin.py ================================================================== --- channels/configwin.py +++ channels/configwin.py @@ -52,20 +52,23 @@ def load_config(self, config, prefix="config_"): for key,val in config.items(): w = self.main.get_widget(prefix + key) if w: # input field - if type(w) is gtk.Entry: + if isinstance(w, gtk.Entry): w.set_text(str(val)) # checkmark - elif type(w) is gtk.CheckButton: + elif isinstance(w, gtk.CheckButton): w.set_active(bool(val)) # dropdown - elif type(w) is ComboBoxText: + elif isinstance(w, ComboBoxText): w.set_default(val) + # number + elif isinstance(w, gtk.SpinButton): + w.set_value(int(val)) # list - elif type(w) is gtk.ListStore: + elif isinstance(w, gtk.ListStore): w.clear() for k,v in val.items(): w.append([k, v, True, self.app_bin_check(v)]) w.append(["", "", True, gtk.STOCK_NEW]) #log.CONF("config load", prefix+key, val, type(w)) @@ -74,20 +77,23 @@ def save_config(self, config, prefix="config_", save=0): for key,val in config.items(): w = self.main.get_widget(prefix + key) if w: # text - if type(w) is gtk.Entry: + if isinstance(w, gtk.Entry): config[key] = w.get_text() # pre-defined text - elif type(w) is ComboBoxText: + elif isinstance(w, ComboBoxText): config[key] = w.get_active_text() # boolean - elif type(w) is gtk.CheckButton: + elif isinstance(w, gtk.CheckButton): config[key] = w.get_active() + # int + elif isinstance(w, gtk.SpinButton): + config[key] = int(w.get_value(val)) # dict - elif type(w) is gtk.ListStore: + elif isinstance(w, gtk.ListStore): config[key] = {} for row in w: if row[0] and row[1]: config[key][row[0]] = row[1] log.CONF("config save", prefix+key, val) @@ -142,28 +148,36 @@ # Default values are already in conf[] dict # (now done in conf.add_plugin_defaults) for opt in meta["config"]: color = opt.get("color", None) + type = opt.get("type", "str") + description = opt.get("description", "./.") # hidden if opt.get("hidden"): continue # display checkbox elif opt["type"] in ("bool", "boolean"): cb = gtk.CheckButton(opt["description"]) - add_( "config_"+opt["name"], cb, color=color ) + description = None # drop down list elif opt["type"] in ("select", "choose", "options"): cb = ComboBoxText(ComboBoxText.parse_options(opt["select"])) # custom uikit widget - add_( "config_"+opt["name"], cb, opt["description"], color ) + + # numeric + elif opt["type"] in ("int", "integer", "numeric"): + adj = gtk.Adjustment(0, 0, 5000, 1, 10, 0) + cb = gtk.SpinButton(adj, 1.0, 0) - # text entry + # text field else: - add_( "config_"+opt["name"], gtk.Entry(), opt["description"], color ) + cb = gtk.Entry() + + add_( "config_"+opt["name"], cb, description, color ) # Spacer between plugins add_( None, gtk.HSeparator() ) # Reformat `doc` linebreaks for gtk.tooltip Index: pluginconf.py ================================================================== --- pluginconf.py +++ pluginconf.py @@ -468,12 +468,19 @@ # Option defaults, if not yet defined for opt in meta.get("config", []): if "name" in opt and "value" in opt: if opt["name"] not in conf_options: - conf_options[opt["name"]] = opt["value"] # should typemap "bool" and "int" here + # typemap "bool" and "int" here + if opt["type"] in ("bool", "boolean"): + val = bool(opt["value"]) + elif opt["type"] in ("int", "integer", "numeric"): + val = int(opt["value"]) + else: + val = str(opt["value"]) + conf_options[opt["name"]] = val # Initial plugin activation status if module and module not in conf_plugins: conf_plugins[module] = meta.get("priority") in ("core", "builtin", "always", "default", "standard")