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
This commit is contained in:
Eisha Chen-yen-su 2018-07-24 10:15:37 +02:00
parent c68fa2d651
commit 198bb0c64d

View file

@ -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::<gtk::ScrolledWindow>("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.");