From 1d94e80da7144922e96ffc6ed6c91722f82ddf52 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 24 Feb 2011 20:50:21 +0100 Subject: Send active/inactive if we are focused on the tab or not. And send "gone" when we close the tab --- src/tabs.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/tabs.py b/src/tabs.py index 284696ab..39794f78 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -260,6 +260,15 @@ class ChatTab(Tab): txt = txt[1:] self.command_say(txt) + def send_chat_state(self, state): + """ + Send an empty chatstate message + """ + msg = self.core.xmpp.make_message(self.get_name()) + msg['type'] = 'chat' + msg['chat_state'] = state + msg.send() + def send_composing_chat_state(self, empty_before, empty_after): """ Send the "active" or "composing" chatstate, depending @@ -267,16 +276,9 @@ class ChatTab(Tab): """ if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates: if not empty_before and empty_after: - msg = self.core.xmpp.make_message(self.get_name()) - msg['type'] = 'chat' - msg['chat_state'] = 'active' - msg.send() + self.send_chat_state("active") elif empty_before and not empty_after: - msg = self.core.xmpp.make_message(self.get_name()) - msg['type'] = 'chat' - msg['chat_state'] = 'composing' - log.debug('MSG:%s\n' % msg) - msg.send() + self.send_chat_state("composing") def command_say(self, line): raise NotImplementedError @@ -1193,10 +1195,14 @@ class ConversationTab(ChatTab, TabWithInfoWin): self.set_color_state(theme.COLOR_TAB_NORMAL) self.text_win.remove_line_separator() self.text_win.add_line_separator() + if config.get('send_chat_states', 'true') == 'true': + self.send_chat_state('inactive') def on_gain_focus(self): self.set_color_state(theme.COLOR_TAB_CURRENT) curses.curs_set(1) + if config.get('send_chat_states', 'true') == 'true': + self.send_chat_state('active') def on_scroll_up(self): self.text_win.scroll_up(self.text_win.height-1) @@ -1221,7 +1227,8 @@ class ConversationTab(ChatTab, TabWithInfoWin): return def on_close(self): - return + if config.get('send_chat_states', 'true') == 'true': + self.send_chat_state('gone') class MucListTab(Tab): """ -- cgit v1.2.3