[seahorse] key-manager: last-keyring is sometimes not restored
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] key-manager: last-keyring is sometimes not restored
- Date: Fri, 19 Jun 2020 20:19:05 +0000 (UTC)
commit 65a0ac6a8b483c97839ef55a528f25ca6a2e060c
Author: Niels De Graef <nielsdegraef gmail com>
Date: Fri Jun 19 22:18:02 2020 +0200
key-manager: last-keyring is sometimes not restored
src/key-manager.vala | 48 +++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)
---
diff --git a/src/key-manager.vala b/src/key-manager.vala
index 497bce7a..67299879 100644
--- a/src/key-manager.vala
+++ b/src/key-manager.vala
@@ -414,13 +414,34 @@ public class Seahorse.KeyManager : Catalog {
private Gcr.Collection setup_sidebar() {
this.sidebar = new Sidebar();
- // On setup, select the LRU place from our last session (if any).
- // Since libsecret inits asynchronously, wait a bit beforehand.
- Timeout.add (200, () => {
- var last_keyring = this.settings.get_strv("keyrings-selected");
- if (last_keyring == null || last_keyring.length == 0)
- return GLib.Source.REMOVE;
+ restore_keyring_selection();
+
+ // Make sure we update the empty state on any change
+ this.sidebar.selected_rows_changed.connect(on_sidebar_selected_rows_changed);
+ this.sidebar.current_collection_changed.connect((sidebar) => { check_empty_state (); });
+
+ foreach (weak Backend backend in get_backends()) {
+ ActionGroup actions = backend.actions;
+ actions.catalog = this;
+ insert_action_group(actions.prefix, actions);
+ }
+
+ this.sidebar_area.add(this.sidebar);
+ this.sidebar.show();
+
+ return this.sidebar.objects;
+ }
+ // On setup, select the LRU place from the user's last session (if any).
+ private void restore_keyring_selection() {
+ // Make sure we already get the setting, or it might accidentally be
+ // changed meanwhile. If none is set (yet), then don't even bother
+ var last_keyring = this.settings.get_strv("keyrings-selected");
+ if (last_keyring == null || last_keyring.length == 0)
+ return;
+
+ // Since some backends take time to initialize, wait a bit beforehand.
+ Timeout.add(150, () => {
unowned string uri = last_keyring[0];
debug("Selecting last used place %s", uri);
@@ -437,21 +458,6 @@ public class Seahorse.KeyManager : Catalog {
this.sidebar.select_row(this.sidebar.get_row_at_index(0));
return GLib.Source.REMOVE;
});
-
- // Make sure we update the empty state on any change
- this.sidebar.selected_rows_changed.connect(on_sidebar_selected_rows_changed);
- this.sidebar.current_collection_changed.connect((sidebar) => { check_empty_state (); });
-
- foreach (weak Backend backend in get_backends()) {
- ActionGroup actions = backend.actions;
- actions.catalog = this;
- insert_action_group(actions.prefix, actions);
- }
-
- this.sidebar_area.add(this.sidebar);
- this.sidebar.show();
-
- return this.sidebar.objects;
}
private void on_sidebar_selected_rows_changed(Gtk.ListBox sidebar) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]