From aaaa58072cdc430d5b0bc60edd248fc23b5ccf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Fri, 18 Feb 2022 16:51:00 +0100 Subject: [PATCH] logger: display the most recent log on top The most recent log arrives on top of the list and is always visible. --- src/ui/logger.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ui/logger.rs b/src/ui/logger.rs index 8eebc49..c28c9a8 100644 --- a/src/ui/logger.rs +++ b/src/ui/logger.rs @@ -42,6 +42,19 @@ pub fn add_to_logger_list(app: &GPSApp, log_entry: &str) { .dynamic_cast::() .expect("Could not cast to ListStore"); let log: Vec<&str> = log_entry.splitn(3, ' ').collect(); - list_store.insert_with_values(None, &[(0, &log[0]), (1, &log[1]), (2, &log[2])]); + list_store.insert_with_values(Some(0), &[(0, &log[0]), (1, &log[1]), (2, &log[2])]); + // Scroll to the first element. + if let Some(model) = logger_list.model() { + if let Some(iter) = model.iter_first() { + let path = model.path(&iter); + logger_list.scroll_to_cell( + Some(&path), + None::<>k::TreeViewColumn>, + false, + 0.0, + 0.0, + ); + } + } } }