Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan Collett <morgan.collett@gmail.com>2007-11-28 14:00:43 (GMT)
committer Morgan Collett <morgan.collett@gmail.com>2007-11-28 14:00:43 (GMT)
commitf37c1a70d2c1a72b939637273965e3d77a645caa (patch)
tree8c6d2c9f54d88e61bc94583725e0ab4333e85dc5
parent2067ddc6e6e98bb457373620385d3198afa2ecb9 (diff)
#5160: Don't autoscroll while scrolled up
-rw-r--r--NEWS2
-rw-r--r--chat.py21
2 files changed, 21 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 607880c..ac8516e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* #5160: Chat should not autoscroll while you scroll up (morgs)
+
29
* #5080: add a "copy to clipboard" palette for URL's (cassidy)
diff --git a/chat.py b/chat.py
index c560171..4da4376 100644
--- a/chat.py
+++ b/chat.py
@@ -66,6 +66,9 @@ class Chat(Activity):
self.owner = self._pservice.get_owner()
self._chat_log = ''
+ # Auto vs manual scrolling:
+ self._scroll_auto = True
+ self._scroll_value = 0.0
self.connect('shared', self._shared_cb)
self.text_channel = None
@@ -176,7 +179,8 @@ class Chat(Activity):
self.scrolled_window = sw
vadj = self.scrolled_window.get_vadjustment()
- vadj.connect('changed', self.rescroll)
+ vadj.connect('changed', self.rescroll)
+ vadj.connect('value-changed', self.scroll_value_changed_cb)
widget = hippo.CanvasWidget(widget=sw)
@@ -188,7 +192,20 @@ class Chat(Activity):
def rescroll(self, adj, scroll=None):
"""Scroll the chat window to the bottom"""
- adj.set_value(adj.upper-adj.page_size)
+ if self._scroll_auto:
+ adj.set_value(adj.upper-adj.page_size)
+ self._scroll_value = adj.get_value()
+
+ def scroll_value_changed_cb(self, adj, scroll=None):
+ """Turn auto scrolling on or off.
+
+ If the user scrolled up, turn it off.
+ If the user scrolled to the bottom, turn it back on.
+ """
+ if adj.get_value() < self._scroll_value:
+ self._scroll_auto = False
+ elif adj.get_value() == adj.upper-adj.page_size:
+ self._scroll_auto = True
def _link_activated_cb(self, link):
activityfactory.create_with_uri(