added prefs_put and prefs_del commands

This commit is contained in:
Dimitur Kirov 2005-09-09 20:51:22 +00:00
parent 2ec0cac1cc
commit a1c0fbb4b0
2 changed files with 29 additions and 5 deletions

View File

@ -418,13 +418,17 @@ class Config:
return 'you already have added %s before' % name return 'you already have added %s before' % name
opt[1][name] = copy.deepcopy(opt[0]) 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): if not self.__options_per_key.has_key(typename):
# raise RuntimeError, 'option %s does not exist' % typename # raise RuntimeError, 'option %s does not exist' % typename
return return
opt = self.__options_per_key[typename] 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 def set_per(self, optname, key, subname, value): # per_group_of_option
if not self.__options_per_key.has_key(optname): if not self.__options_per_key.has_key(optname):

View File

@ -371,7 +371,7 @@ class SignalObject(DbusPrototype):
key = "" key = ""
if path is not None: if path is not None:
for node in path: for node in path:
key += node + "->" key += node + "#"
key += name key += name
prefs_dict[key] = unicode(value[1]) prefs_dict[key] = unicode(value[1])
gajim.config.foreach(get_prefs) gajim.config.foreach(get_prefs)
@ -385,10 +385,30 @@ class SignalObject(DbusPrototype):
return True return True
def prefs_del(self, *args): 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): 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): def _is_first(self):
if self.first_show: if self.first_show: