Changeset 2399 for trunk/src/tabbed_chat_window.py
- Timestamp:
- 07/19/05 16:38:58 (3 years ago)
- Files:
-
- 1 modified
-
trunk/src/tabbed_chat_window.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tabbed_chat_window.py
r2393 r2399 45 45 chat.Chat.__init__(self, plugin, account, 'tabbed_chat_window') 46 46 self.users = {} 47 self.chatstates = {} 47 48 self.new_user(user) 48 49 self.show_title() … … 53 54 self.xml.signal_connect('on_tabbed_chat_window_focus_in_event', 54 55 self.on_tabbed_chat_window_focus_in_event) 56 self.xml.signal_connect('on_tabbed_chat_window_focus_out_event', 57 self.on_tabbed_chat_window_focus_out_event) 55 58 self.xml.signal_connect('on_tabbed_chat_window_button_press_event', 56 59 self.on_chat_window_button_press_event) … … 61 64 62 65 if gajim.config.get('saveposition'): 63 # get window position and size from config66 # get window position and size from config 64 67 self.window.move(gajim.config.get('chat-x-position'), 65 68 gajim.config.get('chat-y-position')) … … 198 201 199 202 if gajim.config.get('saveposition'): 200 # save the window size and position203 # save the window size and position 201 204 x, y = self.window.get_position() 202 205 gajim.config.set('chat-x-position', x) … … 208 211 def on_tabbed_chat_window_destroy(self, widget): 209 212 #clean self.plugin.windows[self.account]['chats'] 213 # on window destroy, send 'gone' chatstate 214 self.send_chatstate('gone') 210 215 chat.Chat.on_window_destroy(self, widget, 'chats') 211 216 212 217 def on_tabbed_chat_window_focus_in_event(self, widget, event): 213 218 chat.Chat.on_chat_window_focus_in_event(self, widget, event) 219 # on focus in, send 'active' chatstate 220 self.send_chatstate('active') 221 222 def on_tabbed_chat_window_focus_out_event(self, widget, event): 223 gobject.timeout_add(500, self.check_window_state, widget) 224 225 def check_window_state(self, widget): 226 ''' we want: "minimized" or "focus-out" 227 not "focus-out, minimized" or "focus-out" ''' 228 new_state = widget.window.get_state() 229 if new_state & gtk.gdk.WINDOW_STATE_ICONIFIED: 230 print 'iconify' 231 self.send_chatstate('inactive') 232 else: 233 print 'just focus-out' 234 self.send_chatstate('paused') 214 235 215 236 def on_chat_notebook_key_press_event(self, widget, event): … … 238 259 return 239 260 261 # chatstates - window is destroyed, send gone 262 self.send_chatstate('gone') 263 240 264 chat.Chat.remove_tab(self, jid, 'chats') 241 265 if len(self.xmls) > 0: … … 275 299 gajim.connections[self.account].request_vcard(user.jid) 276 300 self.childs[user.jid].show_all() 301 302 # chatstates 303 self.chatstates[user.jid] = None 277 304 278 305 def on_message_textview_key_press_event(self, widget, event): … … 327 354 self.sent_messages_scroll(jid, 'down', widget.get_buffer()) 328 355 return True # override the default gtk+ thing for ctrl+down 329 356 357 else: 358 # chatstates 359 # if composing, send chatstate 360 self.send_chatstate('composing') 361 362 def send_chatstate(self, state): 363 # please read jep-85 to get an idea of this 364 # we keep track of jep85 support by the peer by three extra states: None, -1 and 'ask' 365 # None if no info about peer 366 # -1 if peer does not support jep85 367 # 'ask' if we sent 'active' chatstate and are waiting for reply 368 369 jid = self.get_active_jid() 370 371 # print jid, self.chatstates[jid], state 372 if self.chatstates[jid] == -1: 373 return 374 375 # if current state equals last state, return 376 if self.chatstates[jid] == state: 377 return 378 379 if self.chatstates[jid] is None: 380 # state = 'ask' 381 # send and return 382 return 383 384 if self.chatstates[jid] == 'ask': 385 return 386 387 # if last state was composing, don't send active 388 if self.chatstates[jid] == 'composing' and state == 'active': 389 return 390 391 self.chatstates[jid] = state 392 gajim.connections[self.account].send_message(jid, None, None, chatstate = state) 393 394 330 395 def send_message(self, message): 331 396 """Send the message given to the active tab""" … … 351 416 keyID = self.users[jid].keyID 352 417 encrypted = True 353 gajim.connections[self.account].send_message(jid, message, keyID) 418 419 # chatstates - if no info about peer, discover 420 if self.chatstates[jid] is None: 421 422 gajim.connections[self.account].send_message(jid, message, keyID, chatstate = 'active') 423 self.chatstates[jid] = 'ask' 424 # if peer supports jep85, send 'active' 425 elif self.chatstates[jid] != -1: 426 gajim.connections[self.account].send_message(jid, message, keyID, chatstate = 'active') 427 else: 428 gajim.connections[self.account].send_message(jid, message, keyID) 429 print self.chatstates[jid] 354 430 message_buffer.set_text('', -1) 355 431 self.print_conversation(message, jid, jid, encrypted = encrypted)
