summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-02-24 20:50:21 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-02-24 20:50:21 +0100
commit1d94e80da7144922e96ffc6ed6c91722f82ddf52 (patch)
tree035263b9cf192fd24901f31181acb80eef5163fb
parent3084a9cff7a25cb9868562951e768daa18a7d546 (diff)
downloadpoezio-1d94e80da7144922e96ffc6ed6c91722f82ddf52.tar.gz
poezio-1d94e80da7144922e96ffc6ed6c91722f82ddf52.tar.bz2
poezio-1d94e80da7144922e96ffc6ed6c91722f82ddf52.tar.xz
poezio-1d94e80da7144922e96ffc6ed6c91722f82ddf52.zip
Send active/inactive if we are focused on the tab or not. And send
"gone" when we close the tab
-rw-r--r--src/tabs.py27
1 files changed, 17 insertions, 10 deletions
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):
"""