Skip to content
Snippets Groups Projects
Commit e880d1dc authored by nkour's avatar nkour
Browse files

timers should work now

parent d5b1cbbd
No related branches found
No related tags found
No related merge requests found
......@@ -145,6 +145,8 @@ def on_window_destroy(self, widget, kind): #kind is 'chats' or 'gc'
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 @@ def __init__(self, user, plugin, account):
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 @@ def new_user(self, contact):
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 @@ def check_for_possible_paused_chatstate(self, contact):
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 @@ def check_for_possible_inactive_chatstate(self, contact):
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment