Add methods for scrolling in a GtkScrolledWindow

This commit is contained in:
lovetox 2016-09-26 10:44:34 +02:00
parent f5122ff480
commit 9dc2cef6ac
1 changed files with 32 additions and 0 deletions

View File

@ -300,6 +300,38 @@ def resize_window(window, w, h):
h = screen_h
window.resize(abs(w), abs(h))
def at_the_end(widget):
"""Determines if a Scrollbar in a GtkScrolledWindow is at the end.
Args:
widget (GtkScrolledWindow)
Returns:
bool: The return value is True if at the end, False if not.
"""
adj_v = widget.get_vadjustment()
max_scroll_pos = adj_v.get_upper() - adj_v.get_page_size()
at_the_end = (adj_v.get_value() == max_scroll_pos)
return at_the_end
def scroll_to_end(widget):
"""Scrolls to the end of a GtkScrolledWindow.
Args:
widget (GtkScrolledWindow)
Returns:
bool: The return value is False so it can be used with GLib.idle_add.
"""
adj_v = widget.get_vadjustment()
max_scroll_pos = adj_v.get_upper() - adj_v.get_page_size()
adj_v.set_value(max_scroll_pos)
adj_h = widget.get_hadjustment()
adj_h.set_value(0)
return False
class HashDigest:
def __init__(self, algo, digest):
self.algo = self.cleanID(algo)