Display chatstates in the user list in MucTabs
This commit is contained in:
parent
cccbad13d5
commit
001a20c91a
4 changed files with 23 additions and 2 deletions
11
src/core.py
11
src/core.py
|
@ -240,6 +240,8 @@ class Core(object):
|
||||||
if not room:
|
if not room:
|
||||||
return
|
return
|
||||||
self.on_chatstate_private_conversation(message, state)
|
self.on_chatstate_private_conversation(message, state)
|
||||||
|
elif message['type'] == 'groupchat':
|
||||||
|
self.on_chatstate_groupchat_conversation(message, state)
|
||||||
|
|
||||||
def on_chatstate_normal_conversation(self, message,state):
|
def on_chatstate_normal_conversation(self, message,state):
|
||||||
tab = self.get_tab_of_conversation_with_jid(message['from'], False)
|
tab = self.get_tab_of_conversation_with_jid(message['from'], False)
|
||||||
|
@ -259,6 +261,15 @@ class Core(object):
|
||||||
self.refresh_window()
|
self.refresh_window()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def on_chatstate_groupchat_conversation(self, message, state):
|
||||||
|
nick = message['mucnick']
|
||||||
|
room_from = message.getMucroom()
|
||||||
|
tab = self.get_tab_by_name(room_from, tabs.MucTab)
|
||||||
|
if tab and tab.get_room() and tab.get_room().get_user_by_name(nick):
|
||||||
|
tab.get_room().get_user_by_name(nick).chatstate = state
|
||||||
|
if tab == self.current_tab():
|
||||||
|
self.refresh_window()
|
||||||
|
|
||||||
def open_new_form(self, form, on_cancel, on_send, **kwargs):
|
def open_new_form(self, form, on_cancel, on_send, **kwargs):
|
||||||
"""
|
"""
|
||||||
Open a new tab containing the form
|
Open a new tab containing the form
|
||||||
|
|
|
@ -555,7 +555,12 @@ class MucTab(ChatTab, TabWithInfoWin):
|
||||||
self.core.room_error(res, self.get_name())
|
self.core.room_error(res, self.get_name())
|
||||||
|
|
||||||
def command_say(self, line):
|
def command_say(self, line):
|
||||||
muc.send_groupchat_message(self.core.xmpp, self.get_name(), line)
|
msg = self.core.xmpp.make_message(self.get_name())
|
||||||
|
msg['type'] = 'groupchat'
|
||||||
|
msg['body'] = line
|
||||||
|
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
||||||
|
msg['chat_state'] = 'active'
|
||||||
|
msg.send()
|
||||||
|
|
||||||
def command_ignore(self, arg):
|
def command_ignore(self, arg):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -43,6 +43,7 @@ class User(object):
|
||||||
self.change_nick(nick)
|
self.change_nick(nick)
|
||||||
self.color = choice(theme.LIST_COLOR_NICKNAMES)
|
self.color = choice(theme.LIST_COLOR_NICKNAMES)
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
|
self.chatstate = None
|
||||||
|
|
||||||
def update(self, affiliation, show, status, role):
|
def update(self, affiliation, show, status, role):
|
||||||
self.affiliation = affiliation
|
self.affiliation = affiliation
|
||||||
|
|
|
@ -138,7 +138,11 @@ class UserList(Win):
|
||||||
show_col = theme.COLOR_STATUS_NONE
|
show_col = theme.COLOR_STATUS_NONE
|
||||||
else:
|
else:
|
||||||
show_col = self.color_show[user.show]
|
show_col = self.color_show[user.show]
|
||||||
self.addstr(y, 0, theme.CHAR_STATUS, common.curses_color_pair(show_col))
|
if user.chatstate == 'composing':
|
||||||
|
char = 'X'
|
||||||
|
else:
|
||||||
|
char = theme.CHAR_STATUS
|
||||||
|
self.addstr(y, 0, char, common.curses_color_pair(show_col))
|
||||||
self.addstr(y, 1, user.nick[:self.width-2], common.curses_color_pair(role_col))
|
self.addstr(y, 1, user.nick[:self.width-2], common.curses_color_pair(role_col))
|
||||||
y += 1
|
y += 1
|
||||||
if y == self.height:
|
if y == self.height:
|
||||||
|
|
Loading…
Reference in a new issue