From 198bb0c64de1267e5efe1c56ac9561a36af61645 Mon Sep 17 00:00:00 2001 From: Eisha Chen-yen-su Date: Tue, 24 Jul 2018 10:15:37 +0200 Subject: [PATCH] send.rs: Reset the scrolling position This resets the scrolling position while the `msg_entry` widget isn't at its maximum height, so that the cursor never gets at the top when inserting new lines. Closes https://gitlab.gnome.org/World/fractal/issues/288 --- fractal-gtk/src/app/connect/send.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fractal-gtk/src/app/connect/send.rs b/fractal-gtk/src/app/connect/send.rs index 8f668963..8ddc16b9 100644 --- a/fractal-gtk/src/app/connect/send.rs +++ b/fractal-gtk/src/app/connect/send.rs @@ -7,6 +7,8 @@ use self::sourceview::BufferExt; use app::App; +const MAX_INPUT_HEIGHT: i32 = 100; + impl App { pub fn connect_send(&self) { let room_message_box = self.ui.builder @@ -23,6 +25,17 @@ impl App { .get_object("msg_entry") .expect("Couldn't find msg_entry in ui file."); + let input_scroll = self.ui.builder + .get_object::("input_scroll") + .expect("Can't find input_scroll in ui file."); + if let Some(adjustment) = input_scroll.get_vadjustment() { + adjustment.connect_value_changed(clone!(msg_entry => move |adj| { + if msg_entry.get_allocated_height() < MAX_INPUT_HEIGHT { + adj.set_value(0.0); + } + })); + } + let buffer: sourceview::Buffer = self.ui.builder .get_object("msg_entry_buffer") .expect("Couldn't find msg_entry_buffer in ui file.");