summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-09-11 19:48:28 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-09-11 19:48:28 +0000
commitc2ca29574766568eb4a865578e4e99ab4a13c903 (patch)
tree4a05d9232d6cf234b0d40ee0523691b2e72b6d4e
parent508bf5d5614936a270d73a4e2f8fd5f468c5e0cb (diff)
downloadpoezio-c2ca29574766568eb4a865578e4e99ab4a13c903.tar.gz
poezio-c2ca29574766568eb4a865578e4e99ab4a13c903.tar.bz2
poezio-c2ca29574766568eb4a865578e4e99ab4a13c903.tar.xz
poezio-c2ca29574766568eb4a865578e4e99ab4a13c903.zip
recolor command. fixed #1830
-rw-r--r--src/gui.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui.py b/src/gui.py
index dd7ae1cc..9c33d2e7 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -106,6 +106,7 @@ class Gui(object):
'say': (self.command_say, _('Usage: /say <message>\nSay: Just send the message. Useful if you want your message to begin with a "/"')),
'whois': (self.command_whois, _('Usage: /whois <nickname>\nWhois: Request many informations about the user.')),
'theme': (self.command_theme, _('Usage: /theme\nTheme: Reload the theme defined in the config file.')),
+ 'recolor': (self.command_recolor, _('Usage: /recolor\nRecolor: Re-assign a color to all participants of the current room, based on the last time they talked. Use this if the participant currently talking have too many identical colors.')),
}
self.key_func = {
@@ -784,6 +785,26 @@ class Gui(object):
theme.reload_theme()
self.resize_window()
+ def command_recolor(self, arg):
+ """
+ Re-assign color to the participants of the room
+ """
+ room = self.current_room()
+ if room.name == 'Info' or room.jid:
+ return
+ i = 0
+ compare_users = lambda x: x.last_talked
+ users = list(room.users)
+ # search our own user, to remove it from the room
+ for user in users:
+ if user.nick == room.own_nick:
+ users.remove(user)
+ nb_color = len(theme.LIST_COLOR_NICKNAMES)
+ for user in sorted(users, key=compare_users, reverse=True):
+ user.color = theme.LIST_COLOR_NICKNAMES[i % nb_color]
+ i+= 1
+ self.refresh_window()
+
def command_win(self, arg):
"""
/win <number>