modified pref.py so that plugins can use the class to save their
preferences.. This fixes the issue with the torrent search plugin
This commit is contained in:
parent
07a73f6039
commit
034ea9e1a8
14
src/pref.py
14
src/pref.py
|
@ -75,15 +75,19 @@ DEFAULT_PREFS = {
|
||||||
"window_y_pos" : 0,
|
"window_y_pos" : 0,
|
||||||
}
|
}
|
||||||
class Preferences:
|
class Preferences:
|
||||||
def __init__(self, filename=None, defaults=None):
|
def __init__(self, filename=None, global_defaults=True, defaults=None):
|
||||||
self.mapping = DEFAULT_PREFS
|
self.mapping = {}
|
||||||
self.config_file = filename
|
|
||||||
if self.config_file is not None:
|
|
||||||
self.load(self.config_file)
|
|
||||||
if defaults is not None:
|
if defaults is not None:
|
||||||
for key in defaults.keys():
|
for key in defaults.keys():
|
||||||
self.mapping.setdefault(key, defaults[key])
|
self.mapping.setdefault(key, defaults[key])
|
||||||
|
|
||||||
|
if global_defaults is True:
|
||||||
|
self.mapping = DEFAULT_PREFS
|
||||||
|
|
||||||
|
self.config_file = filename
|
||||||
|
if self.config_file is not None:
|
||||||
|
self.load(self.config_file)
|
||||||
|
|
||||||
# Allows you to access an item in a Preferences objecy by calling
|
# Allows you to access an item in a Preferences objecy by calling
|
||||||
# instance[key] rather than instance.get(key). However, this will
|
# instance[key] rather than instance.get(key). However, this will
|
||||||
# return the value as the type it is currently in memory, so it is
|
# return the value as the type it is currently in memory, so it is
|
||||||
|
|
Loading…
Reference in New Issue