added prefs_put and prefs_del commands
This commit is contained in:
parent
2ec0cac1cc
commit
a1c0fbb4b0
|
@ -418,13 +418,17 @@ class Config:
|
|||
return 'you already have added %s before' % name
|
||||
opt[1][name] = copy.deepcopy(opt[0])
|
||||
|
||||
def del_per(self, typename, name): # per_group_of_option
|
||||
def del_per(self, typename, name, subname = None): # per_group_of_option
|
||||
if not self.__options_per_key.has_key(typename):
|
||||
# raise RuntimeError, 'option %s does not exist' % typename
|
||||
return
|
||||
|
||||
opt = self.__options_per_key[typename]
|
||||
del opt[1][name]
|
||||
if item is None:
|
||||
del opt[1][name]
|
||||
# if subname is specified, delete the item in the group.
|
||||
elif opt[1][name].has_key(subname):
|
||||
del opt[1][name][subname]
|
||||
|
||||
def set_per(self, optname, key, subname, value): # per_group_of_option
|
||||
if not self.__options_per_key.has_key(optname):
|
||||
|
|
|
@ -371,7 +371,7 @@ class SignalObject(DbusPrototype):
|
|||
key = ""
|
||||
if path is not None:
|
||||
for node in path:
|
||||
key += node + "->"
|
||||
key += node + "#"
|
||||
key += name
|
||||
prefs_dict[key] = unicode(value[1])
|
||||
gajim.config.foreach(get_prefs)
|
||||
|
@ -385,10 +385,30 @@ class SignalObject(DbusPrototype):
|
|||
return True
|
||||
|
||||
def prefs_del(self, *args):
|
||||
return ['Not implemented yet']
|
||||
[key] = self._get_real_arguments(args, 1)
|
||||
if not key:
|
||||
return False
|
||||
key_path = key.split('#', 2)
|
||||
if len(key_path) != 3:
|
||||
return False
|
||||
if key_path[2] == '*':
|
||||
gajim.config.del_per(key_path[0], key_path[1])
|
||||
else:
|
||||
gajim.config.del_per(key_path[0], key_path[1], key_path[2])
|
||||
return True
|
||||
|
||||
def prefs_put(self, *args):
|
||||
return ['Not implemented yet']
|
||||
[key] = self._get_real_arguments(args, 1)
|
||||
if not key:
|
||||
return False
|
||||
key_path = key.split('#', 2)
|
||||
if len(key_path) < 3:
|
||||
subname, value = key.split('=', 1)
|
||||
gajim.config.set(subname, value)
|
||||
return True
|
||||
subname, value = key_path[2].split('=', 1)
|
||||
gajim.config.set_per(key_path[0], key_path[1], subname, value)
|
||||
return True
|
||||
|
||||
def _is_first(self):
|
||||
if self.first_show:
|
||||
|
|
Loading…
Reference in New Issue