From 5103ff424131027633f5d5994b03ca885b164421 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 6 Sep 2020 15:41:14 +1000 Subject: [PATCH] automatically sort new items, try to always reselect your item after RenderList --- MainWindow.cs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/MainWindow.cs b/MainWindow.cs index 00ac2d5..a0f1ea3 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -285,7 +285,9 @@ namespace Buypeeb { }).ContinueWith(task => { taskLimit.Release(); if (renderListWhenDone) { - this.RenderList(); + Gtk.Application.Invoke(delegate { + this.RenderList(); + }); } }); } @@ -440,6 +442,11 @@ namespace Buypeeb { } private void RenderList() { + string id = null; + if (this.selectedItem != null) { + id = this.selectedItem.id; + } + this.items.Clear(); var values = this.settings.watchlist.Values; IOrderedEnumerable sorted; @@ -480,6 +487,14 @@ namespace Buypeeb { var m = (TreeModelFilter)this.itemTreeView.Model; m.Refilter(); + + if (id != null) { + // attempt to reselect the item we were just looking at + var pathAndIter = this.GetRow(id); + if (pathAndIter.path != null) { + this.itemTreeView.Selection.SelectPath(pathAndIter.path); + } + } } // event handlers @@ -729,11 +744,7 @@ namespace Buypeeb { if (this.settings.displayFavouritesAtTopOfList) { var id = this.selectedItem.id; - // re-render the list, to ensure the favourites get pushed to the top this.RenderList(); - // attempt to reselect the item we were just looking at - var pathAndIter = this.GetRow(id); - this.itemTreeView.Selection.SelectPath(pathAndIter.path); } else { // i don't know why this is necessary