timers should work now
This commit is contained in:
parent
d5b1cbbd34
commit
e880d1dc2c
|
@ -145,6 +145,8 @@ class Chat:
|
|||
if kind == 'chats':
|
||||
# send 'gone' chatstate to every tabbed chat tab
|
||||
windows[jid].send_chatstate('gone')
|
||||
gobject.source_remove(self.possible_paused_timeout_id[jid])
|
||||
gobject.source_remove(self.possible_inactive_timeout_id[jid])
|
||||
if self.plugin.systray_enabled and self.nb_unread[jid] > 0:
|
||||
self.plugin.systray.remove_jid(jid, self.account)
|
||||
del windows[jid]
|
||||
|
|
|
@ -45,6 +45,10 @@ class TabbedChatWindow(chat.Chat):
|
|||
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
|
||||
self.users = {}
|
||||
self.chatstates = {}
|
||||
# keep check for possible paused timeouts per jid
|
||||
self.possible_paused_timeout_id = {}
|
||||
# keep check for possible inactive timeouts per jid
|
||||
self.possible_inactive_timeout_id = {}
|
||||
self.new_user(user)
|
||||
self.show_title()
|
||||
self.xml.signal_connect('on_tabbed_chat_window_destroy',
|
||||
|
@ -302,16 +306,20 @@ class TabbedChatWindow(chat.Chat):
|
|||
self.mouse_over_in_last_5_secs = False
|
||||
|
||||
self.chatstates[contact.jid] = None # our current chatstate with contact
|
||||
gobject.timeout_add(5000, self.check_for_possible_paused_chatstate,
|
||||
contact)
|
||||
gobject.timeout_add(30000, self.check_for_possible_inactive_chatstate,
|
||||
contact)
|
||||
self.possible_paused_timeout_id[contact.jid] =\
|
||||
gobject.timeout_add(5000, self.check_for_possible_paused_chatstate,
|
||||
contact)
|
||||
self.possible_inactive_timeout_id[contact.jid] =\
|
||||
gobject.timeout_add(30000, self.check_for_possible_inactive_chatstate,
|
||||
contact)
|
||||
|
||||
def check_for_possible_paused_chatstate(self, contact):
|
||||
''' did we move mouse of that window or kbd activity in that window
|
||||
if yes we go active if not already
|
||||
if no we go paused if not already '''
|
||||
current_state = self.chatstates[contact.jid]
|
||||
if current_state = -1: # he doesn't support chatstates
|
||||
return False # stop looping
|
||||
if self.mouse_over_in_last_5_secs:
|
||||
self.send_chatstate('active')
|
||||
if self.kbd_activity_in_last_5_secs:
|
||||
|
@ -320,12 +328,16 @@ class TabbedChatWindow(chat.Chat):
|
|||
self.send_chatstate('paused')
|
||||
self.mouse_over_in_last_5_secs = False
|
||||
self.kbd_activity_in_last_5_secs = False
|
||||
|
||||
return True # loop forever
|
||||
|
||||
def check_for_possible_inactive_chatstate(self, contact):
|
||||
''' did we move mouse of that window or kbd activity in that window
|
||||
if yes we go active if not already
|
||||
if no we go inactive if not already '''
|
||||
current_state = self.chatstates[contact.jid]
|
||||
if current_state = -1: # he doesn't support chatstates
|
||||
return False # stop looping
|
||||
if self.mouse_over_in_last_5_secs:
|
||||
self.send_chatstate('active')
|
||||
elif self.kbd_activity_in_last_5_secs:
|
||||
|
@ -333,6 +345,8 @@ class TabbedChatWindow(chat.Chat):
|
|||
else:
|
||||
self.send_chatstate('inactive')
|
||||
|
||||
return True # loop forever
|
||||
|
||||
def on_message_textview_key_press_event(self, widget, event):
|
||||
"""When a key is pressed:
|
||||
if enter is pressed without the shift key, message (if not empty) is sent
|
||||
|
|
Loading…
Reference in New Issue