[seahorse/wip/nielsdg/fix-unlock-empty-keyring: 3/4] KeyManager: Always check state when (un)locking



commit 9e06e995797c330d805b37fc9721abf3ccfdb7fc
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu Feb 21 08:54:44 2019 +0100

    KeyManager: Always check state when (un)locking
    
    This prevents a bug where, if you lock or unlock an empty keyring, the
    empty state shown to the user wouldn't change, since neither:
    
    * the currrent selection changed
    * the current amount of shown object changes
    
    ... which means no signal was thrown.

 src/key-manager.vala | 4 +++-
 src/sidebar.vala     | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/key-manager.vala b/src/key-manager.vala
index f663d130..1ec80e83 100644
--- a/src/key-manager.vala
+++ b/src/key-manager.vala
@@ -393,8 +393,10 @@ public class Seahorse.KeyManager : Catalog {
     private Gcr.Collection setup_sidebar() {
         this.sidebar = new Sidebar();
         sidebar.hexpand = true;
-        /* Make sure we get */
+
+        /* Make sure we update the empty state on any change */
         this.sidebar.get_selection().changed.connect((sel) => check_empty_state());
+        this.sidebar.current_collection_changed.connect (() => check_empty_state ());
 
         this.sidebar_panes.position = this.settings.get_int("sidebar-width");
         this.sidebar_panes.realize.connect(() =>   { this.sidebar_panes.position = 
this.settings.get_int("sidebar-width"); });
diff --git a/src/sidebar.vala b/src/sidebar.vala
index 8a05081c..0bf016bd 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -75,6 +75,12 @@ public class Seahorse.Sidebar : Gtk.TreeView {
     }
     private bool _combined;
 
+    /**
+     * Emitted when the state of the current collection changed.
+     * For example: when going from locked to unlocked and vice versa.
+     */
+    public signal void current_collection_changed();
+
     private enum RowType {
         BACKEND,
         PLACE,
@@ -577,6 +583,7 @@ public class Seahorse.Sidebar : Gtk.TreeView {
         lockable.lock.begin(interaction, cancellable, (obj, res) => {
             try {
                 lockable.lock.end(res);
+                current_collection_changed();
             } catch (Error e) {
                 Util.show_error(window, _("Couldn’t lock"), e.message);
             }
@@ -594,6 +601,7 @@ public class Seahorse.Sidebar : Gtk.TreeView {
         lockable.unlock.begin(interaction, cancellable, (obj, res) => {
             try {
                 lockable.unlock.end(res);
+                current_collection_changed();
             } catch (Error e) {
                 Util.show_error(window, _("Couldn’t unlock"), e.message);
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]