From 1bbdab7f12df2f1cd71db86ba6caf6c888e2a3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lestin=20Matte?= Date: Tue, 23 Dec 2014 16:43:40 +0100 Subject: Unset color with /color unset --- src/tabs/muctab.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py index b9dba7ab..89cecca8 100644 --- a/src/tabs/muctab.py +++ b/src/tabs/muctab.py @@ -160,7 +160,8 @@ class MucTab(ChatTab): completion=self.completion_recolor) self.register_command('color', self.command_color, usage=_(' '), - desc=_('Fix a color for a nick.'), + desc=_('Fix a color for a nick. Use "unset" instead of a color' + ' to remove the attribution'), shortdesc=_('Fix a color for a nick.'), completion=self.completion_color) self.register_command('cycle', self.command_cycle, @@ -277,6 +278,7 @@ class MucTab(ChatTab): elif n == 2: colors = [i for i in xhtml.colors if i] colors.sort() + colors.append('unset') return the_input.new_completion(colors, 2, '', quotify=False) def completion_ignore(self, the_input): @@ -464,6 +466,7 @@ class MucTab(ChatTab): """ /color Fix a color for a nick. + Use "unset" instead of a color to remove the attribution """ if args is None: return self.core.command_help('color') @@ -472,17 +475,21 @@ class MucTab(ChatTab): user = self.get_user_by_name(nick) if not user: return self.core.information(_("Unknown user: %s") % nick) - if not color in xhtml.colors: + if not color in xhtml.colors and color != 'unset': return self.core.information(_("Unknown color: %s") % color, 'Error') if user.nick == self.own_nick: return self.core.information(_("You cannot change the color of your" " own nick.", 'Error')) - user.change_color(color) - config.write_in_file('muc_colors', nick, color) - self.text_win.rebuild_everything(self._text_buffer) - self.user_win.refresh(self.users) - self.text_win.refresh() - self.input.refresh() + if color == 'unset': + if config.remove_and_save(nick, 'muc_colors'): + self.core.information(_('Color for nick %s unset') % (nick)) + else: + user.change_color(color) + config.set_and_save(nick, color, 'muc_colors') + self.text_win.rebuild_everything(self._text_buffer) + self.user_win.refresh(self.users) + self.text_win.refresh() + self.input.refresh() @command_args_parser.quoted(1) def command_version(self, args): -- cgit v1.2.3