Fix the paused status that was sent on /part and other inapropriate situations

This commit is contained in:
Florent Le Coz 2011-05-04 22:52:24 +02:00
commit c784deea9c
2 changed files with 9 additions and 3 deletions

View file

@ -287,6 +287,7 @@ class ChatTab(Tab):
if txt.startswith('//'): if txt.startswith('//'):
txt = txt[1:] txt = txt[1:]
self.command_say(txt) self.command_say(txt)
self.cancel_paused_delay()
def send_chat_state(self, state): def send_chat_state(self, state):
""" """
@ -305,6 +306,7 @@ class ChatTab(Tab):
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates: if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates:
if not empty_before and empty_after: if not empty_before and empty_after:
self.send_chat_state("active") self.send_chat_state("active")
self.cancel_paused_delay()
elif (empty_before or (self.timed_event_paused is not None and not self.timed_event_paused())) and not empty_after: elif (empty_before or (self.timed_event_paused is not None and not self.timed_event_paused())) and not empty_after:
self.send_chat_state("composing") self.send_chat_state("composing")
@ -1483,22 +1485,22 @@ class ConversationTab(ChatTab):
self.input.do_command(key) self.input.do_command(key)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//')) empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_before, empty_after) self.send_composing_chat_state(empty_before, empty_after)
self.set_paused_delay(empty_before and not empty_after)
if not empty_before and empty_after: if not empty_before and empty_after:
self.cancel_paused_delay() self.cancel_paused_delay()
self.set_paused_delay(empty_before and not empty_after)
return False return False
def on_lose_focus(self): def on_lose_focus(self):
self.set_color_state(theme.COLOR_TAB_NORMAL) self.set_color_state(theme.COLOR_TAB_NORMAL)
self.text_win.remove_line_separator() self.text_win.remove_line_separator()
self.text_win.add_line_separator() self.text_win.add_line_separator()
if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text(): if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'):
self.send_chat_state('inactive') self.send_chat_state('inactive')
def on_gain_focus(self): def on_gain_focus(self):
self.set_color_state(theme.COLOR_TAB_CURRENT) self.set_color_state(theme.COLOR_TAB_CURRENT)
curses.curs_set(1) curses.curs_set(1)
if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text(): if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text() or not self.input.get_text().startswith('//'):
self.send_chat_state('active') self.send_chat_state('active')
def on_scroll_up(self): def on_scroll_up(self):

View file

@ -27,6 +27,7 @@ import re
import subprocess import subprocess
from sleekxmpp.xmlstream import ET from sleekxmpp.xmlstream import ET
from xml.etree.ElementTree import ElementTree from xml.etree.ElementTree import ElementTree
from sys import version_info
from config import config from config import config
import logging import logging
@ -82,8 +83,11 @@ def convert_links_to_plaintext(text):
parent.text += link_text parent.text += link_text
parent.remove(child) parent.remove(child)
previous_child = child previous_child = child
if version_info.minor <= 1:
return ET.tostring(xml.getroot())
return ET.tostring(xml.getroot(), encoding=str) return ET.tostring(xml.getroot(), encoding=str)
def clean_text(string): def clean_text(string):
""" """
Remove all \x19 from the string Remove all \x19 from the string