Skip to content

Commit

Permalink
[GTK] Add "user is typing" message in chat window
Browse files Browse the repository at this point in the history
  • Loading branch information
jonte committed Aug 10, 2009
1 parent 234fd97 commit 863a772
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion amsn2/gui/front_ends/gtk/chat_window.py
Expand Up @@ -31,6 +31,7 @@
from amsn2.core.views import ContactView, StringView
import gtk_extras
import papyon
import gobject

class aMSNChatWindow(base.aMSNChatWindow, gtk.Window):
def __init__(self, amsn_core):
Expand Down Expand Up @@ -204,6 +205,9 @@ def __init__(self, amsn_conversation, parent, contacts_uid):
self.entry.connect('mykeypress', self.__on_chat_send)
self.entry.connect('key-press-event', self.__on_typing_event)

# timer to display if a user is typing
self.typingTimer = None

def __updateTextFormat(self, textbuffer):
self.reapply_text_effects()
self.__on_changed_text_color(self.button_color)
Expand Down Expand Up @@ -299,6 +303,10 @@ def __set_statusbar_text(self, msg):
self.statusbar.pop(context)
self.statusbar.push(context, msg)

def __typingStopped(self):
self.__set_statusbar_text("")
return False # To stop gobject timer

def onMessageReceived(self, messageview, formatting=None):
text = messageview.toStringView().toHtmlString()
text = self.__clean_string(text)
Expand Down Expand Up @@ -344,8 +352,16 @@ def onUserLeft(self, contact):
self.__print_info("%s left the conversation" % (contact,))

def onUserTyping(self, contact):
""" Set a timer for 10 sec every time a user types. If the user
continues typing during these 10 sec, kill the timer and start over with
10 sec. If the user stops typing; call __typingStopped """

print "%s is typing" % (contact,)
#self.__set_statusbar_text("%s is typing" % (contact,))
self.__set_statusbar_text("%s is typing" % (contact,))
if self.typingTimer != None:
gobject.source_remove(self.typingTimer)
self.typingTimer = None
self.typingTimer = gobject.timeout_add(10000, self.__typingStopped)

def nudge(self):
self.__print_info('Nudge received')
Expand Down
2 changes: 1 addition & 1 deletion papyon
Submodule papyon updated from 23a479 to 5059b8

0 comments on commit 863a772

Please sign in to comment.