send composing for kbd activity
This commit is contained in:
parent
09fe8a83da
commit
caf0a85b84
|
@ -298,7 +298,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
self.childs[contact.jid].show_all()
|
self.childs[contact.jid].show_all()
|
||||||
|
|
||||||
# chatstates
|
# chatstates
|
||||||
self.kdb_activity_in_last_5_secs = False
|
self.kbd_activity_in_last_5_secs = False
|
||||||
self.mouse_over_in_last_5_secs = False
|
self.mouse_over_in_last_5_secs = False
|
||||||
|
|
||||||
self.chatstates[contact.jid] = None # our current chatstate with contact
|
self.chatstates[contact.jid] = None # our current chatstate with contact
|
||||||
|
@ -312,36 +312,32 @@ class TabbedChatWindow(chat.Chat):
|
||||||
if yes we go active if not already
|
if yes we go active if not already
|
||||||
if no we go paused if not already '''
|
if no we go paused if not already '''
|
||||||
current_state = self.chatstates[contact.jid]
|
current_state = self.chatstates[contact.jid]
|
||||||
if self.mouse_over_in_last_5_secs or self.kdb_activity_in_last_5_secs:
|
if self.mouse_over_in_last_5_secs:
|
||||||
if current_state != 'active': # if we were not active
|
self.send_chatstate('active')
|
||||||
self.send_chatstate('active') # send we became active
|
if self.kbd_activity_in_last_5_secs:
|
||||||
print 'active'
|
self.send_chatstate('composing')
|
||||||
else:
|
else:
|
||||||
if current_state != 'paused': # if we were not paused
|
self.send_chatstate('paused')
|
||||||
self.send_chatstate('paused') # send we became paused
|
self.mouse_over_in_last_5_secs = False
|
||||||
self.mouse_over_in_last_5_secs = False
|
self.kbd_activity_in_last_5_secs = False
|
||||||
self.kdb_activity_in_last_5_secs = False
|
|
||||||
print 'paused'
|
|
||||||
|
|
||||||
def check_for_possible_inactive_chatstate(self, contact):
|
def check_for_possible_inactive_chatstate(self, contact):
|
||||||
''' did we move mouse of that window or kbd activity in that window
|
''' did we move mouse of that window or kbd activity in that window
|
||||||
if yes we go active if not already
|
if yes we go active if not already
|
||||||
if no we go inactive if not already '''
|
if no we go inactive if not already '''
|
||||||
current_state = self.chatstates[contact.jid]
|
current_state = self.chatstates[contact.jid]
|
||||||
if self.mouse_over_in_last_5_secs or self.kdb_activity_in_last_5_secs:
|
if self.mouse_over_in_last_5_secs:
|
||||||
if current_state != 'active': # if we were not active
|
self.send_chatstate('active')
|
||||||
self.send_chatstate('active') # send we became active
|
elif self.kbd_activity_in_last_5_secs:
|
||||||
print 'active'
|
self.send_chatstate('composing')
|
||||||
else:
|
else:
|
||||||
if current_state != 'inactive': # if we were not inactive
|
self.send_chatstate('inactive')
|
||||||
self.send_chatstate('inactive') # send we became inactive
|
|
||||||
print 'INactive'
|
|
||||||
|
|
||||||
def on_message_textview_key_press_event(self, widget, event):
|
def on_message_textview_key_press_event(self, widget, event):
|
||||||
"""When a key is pressed:
|
"""When a key is pressed:
|
||||||
if enter is pressed without the shift key, message (if not empty) is sent
|
if enter is pressed without the shift key, message (if not empty) is sent
|
||||||
and printed in the conversation"""
|
and printed in the conversation"""
|
||||||
self.kdb_activity_in_last_5_secs = True
|
self.kbd_activity_in_last_5_secs = True
|
||||||
jid = self.get_active_jid()
|
jid = self.get_active_jid()
|
||||||
conversation_textview = self.xmls[jid].get_widget('conversation_textview')
|
conversation_textview = self.xmls[jid].get_widget('conversation_textview')
|
||||||
message_buffer = widget.get_buffer()
|
message_buffer = widget.get_buffer()
|
||||||
|
@ -396,7 +392,8 @@ class TabbedChatWindow(chat.Chat):
|
||||||
self.send_chatstate('composing')
|
self.send_chatstate('composing')
|
||||||
|
|
||||||
def send_chatstate(self, state):
|
def send_chatstate(self, state):
|
||||||
''' sends our chatstate to the current tab '''
|
''' sends our chatstate to the current tab only if new chatstate
|
||||||
|
is different for the previous one'''
|
||||||
# please read jep-85 to get an idea of this
|
# please read jep-85 to get an idea of this
|
||||||
# we keep track of jep85 support by the peer by three extra states:
|
# we keep track of jep85 support by the peer by three extra states:
|
||||||
# None, -1 and 'ask'
|
# None, -1 and 'ask'
|
||||||
|
@ -463,7 +460,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
|
|
||||||
# if peer supports jep85, send 'active'
|
# if peer supports jep85, send 'active'
|
||||||
elif self.chatstates[jid] != -1:
|
elif self.chatstates[jid] != -1:
|
||||||
#FIXME: only when we open the tab
|
#send active chatstate on every message (as JEP says)
|
||||||
gajim.connections[self.account].send_message(jid, message, keyID,
|
gajim.connections[self.account].send_message(jid, message, keyID,
|
||||||
chatstate = 'active')
|
chatstate = 'active')
|
||||||
else: # just send the message
|
else: # just send the message
|
||||||
|
|
Loading…
Reference in New Issue