[chronojump] After session/persons grow/shrink ensure treeview scrolls to selected person
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] After session/persons grow/shrink ensure treeview scrolls to selected person
- Date: Fri, 23 Jul 2021 12:18:02 +0000 (UTC)
commit 3398cb5a86f397418898861beeef03b94ff817eb
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jul 23 14:17:26 2021 +0200
After session/persons grow/shrink ensure treeview scrolls to selected person
src/gui/app1/menu.cs | 12 ++++++++++++
src/treeview/person.cs | 13 +++++++++++++
2 files changed, 25 insertions(+)
---
diff --git a/src/gui/app1/menu.cs b/src/gui/app1/menu.cs
index 7c98db499..17e1f0231 100644
--- a/src/gui/app1/menu.cs
+++ b/src/gui/app1/menu.cs
@@ -326,6 +326,18 @@ public partial class ChronoJumpWindow
if(preferences.personPhoto)
vbox_persons_bottom.Visible =
(! check_menu_session.Active && ! check_manage_persons.Active);
+
+ //scroll it, but wait a bit before to be all the things at place
+ if(myTreeViewPersons != null)
+ GLib.Timeout.Add(50, new GLib.TimeoutHandler(scrollTreeviewPersons));
+ }
+
+ private bool scrollTreeviewPersons ()
+ {
+ if(myTreeViewPersons != null) //extra check
+ myTreeViewPersons.ScrollToSelectedRow ();
+
+ return false;
}
private void on_button_menu_help_clicked (object o, EventArgs args)
diff --git a/src/treeview/person.cs b/src/treeview/person.cs
index fc821c8f0..e48455499 100644
--- a/src/treeview/person.cs
+++ b/src/treeview/person.cs
@@ -202,6 +202,19 @@ public class TreeViewPersons
return found;
}
+ //to scroll when elements of gui are resized changed, like the sidebar session/persons shrink
+ public void ScrollToSelectedRow ()
+ {
+ TreeIter iter;
+ Gtk.TreeModel model = treeview.Model;
+
+ if (! treeview.Selection.GetSelected (out model, out iter))
+ return;
+
+ TreePath path = store.GetPath (iter);
+ treeview.ScrollToCell (path, null, true, 0, 0);
+ }
+
public void SelectRowByUniqueID(int personID)
{
SelectRow(FindRow(personID));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]