Skip to content
Snippets Groups Projects
Commit 82981df0 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist
Browse files

Add Jump to bottom button

parent 6d2d71c0
No related branches found
No related tags found
No related merge requests found
......@@ -175,8 +175,14 @@ def __init__(self, parent_win, widget_name, jid, acct,
self._scrolled_view = ScrolledView()
self._scrolled_view.add(self.conversation_view)
self._scrolled_view.set_focus_vadjustment(Gtk.Adjustment())
self.xml.textview_box.add(self._scrolled_view)
self.xml.textview_box.reorder_child(self._scrolled_view, 2)
overlay = Gtk.Overlay()
overlay.add(self._scrolled_view)
overlay.add_overlay(self.xml.jump_to_end_button)
self.xml.textview_box.add(overlay)
self.xml.textview_box.reorder_child(overlay, 2)
self._scrolled_view.connect('autoscroll-changed',
self._on_autoscroll_changed)
self._scrolled_view.connect('request-history',
self.fetch_n_lines_history, 30)
......@@ -929,6 +935,12 @@ def _on_message_textview_key_press_event(self, textview, event):
return False
def _on_autoscroll_changed(self, _widget, autoscroll):
self.xml.jump_to_end_button.set_visible(not autoscroll)
def _on_jump_to_end(self, _button):
self.scroll_to_end(force=True)
def _on_drag_data_received(self, widget, context, x, y, selection,
target_type, timestamp):
"""
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,6 +23,11 @@ class ScrolledView(Gtk.ScrolledWindow):
GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION,
None,
()
),
'autoscroll-changed': (
GObject.SignalFlags.RUN_LAST,
None,
(bool,)
)
}
......@@ -89,8 +94,10 @@ def _on_adj_value_changed(self, adj, *args):
bottom = adj.get_upper() - adj.get_page_size()
if (bottom - adj.get_value()) < 1:
self._autoscroll = True
self.emit('autoscroll-changed', self._autoscroll)
else:
self._autoscroll = False
self.emit('autoscroll-changed', self._autoscroll)
if self._complete:
self._request_history_at_upper = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment