[Sugar-devel] [PATCH Chat v2] Scroll the chat log
Manuel Kaufmann
humitos at gmail.com
Tue Apr 10 21:46:59 EDT 2012
Check if the user pressed Page Up, Page Down, Home or End and
scroll the window according the pressed key.
This commit solves http://bugs.sugarlabs.org/ticket/2782
Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
activity.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/activity.py b/activity.py
index 297d57b..66f32f2 100644
--- a/activity.py
+++ b/activity.py
@@ -264,6 +264,7 @@ class Chat(activity.Activity):
style.COLOR_WHITE.get_gdk_color())
entry.set_sensitive(False)
entry.connect('activate', self.entry_activate_cb)
+ entry.connect('key-press-event', self.entry_key_press_cb)
self.entry = entry
self.chatbox = ChatBox()
@@ -277,6 +278,25 @@ class Chat(activity.Activity):
return box
+ def entry_key_press_cb(self, widget, event):
+ """Check for scrolling keys.
+
+ Check if the user pressed Page Up, Page Down, Home or End and
+ scroll the window according the pressed key.
+ """
+ vadj = self.chatbox.get_vadjustment()
+ if event.keyval == gtk.keysyms.Page_Down:
+ value = vadj.get_value() + vadj.page_size
+ if value > vadj.upper - vadj.page_size:
+ value = vadj.upper - vadj.page_size
+ vadj.set_value(value)
+ elif event.keyval == gtk.keysyms.Page_Up:
+ vadj.set_value(vadj.get_value() - vadj.page_size)
+ elif event.keyval == gtk.keysyms.Home:
+ vadj.set_value(vadj.lower)
+ elif event.keyval == gtk.keysyms.End:
+ vadj.set_value(vadj.upper - vadj.page_size)
+
def entry_activate_cb(self, entry):
text = entry.props.text
logger.debug('Entry: %s' % text)
--
1.7.9.5
More information about the Sugar-devel
mailing list