timers should work now

This commit is contained in:
Nikos Kouremenos 2005-07-19 21:40:08 +00:00
parent d5b1cbbd34
commit e880d1dc2c
2 changed files with 20 additions and 4 deletions

View File

@ -145,6 +145,8 @@ class Chat:
if kind == 'chats': if kind == 'chats':
# send 'gone' chatstate to every tabbed chat tab # send 'gone' chatstate to every tabbed chat tab
windows[jid].send_chatstate('gone') 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: if self.plugin.systray_enabled and self.nb_unread[jid] > 0:
self.plugin.systray.remove_jid(jid, self.account) self.plugin.systray.remove_jid(jid, self.account)
del windows[jid] del windows[jid]

View File

@ -45,6 +45,10 @@ class TabbedChatWindow(chat.Chat):
chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window') chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window')
self.users = {} self.users = {}
self.chatstates = {} 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.new_user(user)
self.show_title() self.show_title()
self.xml.signal_connect('on_tabbed_chat_window_destroy', 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.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
gobject.timeout_add(5000, self.check_for_possible_paused_chatstate, self.possible_paused_timeout_id[contact.jid] =\
contact) gobject.timeout_add(5000, self.check_for_possible_paused_chatstate,
gobject.timeout_add(30000, self.check_for_possible_inactive_chatstate, contact)
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): def check_for_possible_paused_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 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 current_state = -1: # he doesn't support chatstates
return False # stop looping
if self.mouse_over_in_last_5_secs: if self.mouse_over_in_last_5_secs:
self.send_chatstate('active') self.send_chatstate('active')
if self.kbd_activity_in_last_5_secs: if self.kbd_activity_in_last_5_secs:
@ -320,12 +328,16 @@ class TabbedChatWindow(chat.Chat):
self.send_chatstate('paused') self.send_chatstate('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.kbd_activity_in_last_5_secs = False
return True # loop forever
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 current_state = -1: # he doesn't support chatstates
return False # stop looping
if self.mouse_over_in_last_5_secs: if self.mouse_over_in_last_5_secs:
self.send_chatstate('active') self.send_chatstate('active')
elif self.kbd_activity_in_last_5_secs: elif self.kbd_activity_in_last_5_secs:
@ -333,6 +345,8 @@ class TabbedChatWindow(chat.Chat):
else: else:
self.send_chatstate('inactive') self.send_chatstate('inactive')
return True # loop forever
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