[seahorse/wip/nielsdg/dont-show-empty] sidebar: Don't show System Trust when empty
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/nielsdg/dont-show-empty] sidebar: Don't show System Trust when empty
- Date: Thu, 30 Jan 2020 18:23:41 +0000 (UTC)
commit 97fe295193093a551d08f017236277212817bc61
Author: Niels De Graef <nielsdegraef gmail com>
Date: Wed Jan 29 17:56:48 2020 +0100
sidebar: Don't show System Trust when empty
In most cases, 'Default Trust' is empty, as people generally don't touch
it. See the linked issue for the difference between 'System Trust' and
'Default Trust'.
To implement this, we add a "show-if-empty" property to `SeahorsePlace`,
so we can extend this to other types of collections if needed. That way
we can filter empty collections from the sidebar when they don't make
sense and/or confuse users.
Fixes https://gitlab.gnome.org/GNOME/seahorse/issues/252
common/place.vala | 7 +++++++
gkr/gkr-keyring.vala | 4 ++++
pgp/seahorse-gpgme-keyring.c | 15 ++++++++++++++-
pgp/seahorse-server-source.c | 15 ++++++++++++++-
pgp/seahorse-unknown-source.c | 15 ++++++++++++++-
pkcs11/pkcs11-token.vala | 4 ++++
src/sidebar.vala | 6 ++++--
ssh/source.vala | 4 ++++
8 files changed, 65 insertions(+), 5 deletions(-)
---
diff --git a/common/place.vala b/common/place.vala
index dc66e7dd..c1fd343b 100644
--- a/common/place.vala
+++ b/common/place.vala
@@ -28,6 +28,13 @@ public interface Seahorse.Place : Gcr.Collection {
public abstract string uri { owned get; }
public abstract Icon icon { owned get; }
+ /**
+ * In some cases, we do not want to show the Place in the sidebar
+ * if it's empty (for example p11-kit's System Trust), while we do
+ * want this for others (like libsecret keyrings).
+ */
+ public abstract bool show_if_empty { get; }
+
/**
* Returns the {@link GLib.Action}s that are defined for this Place,
* or null if none.
diff --git a/gkr/gkr-keyring.vala b/gkr/gkr-keyring.vala
index e829edba..ed233748 100644
--- a/gkr/gkr-keyring.vala
+++ b/gkr/gkr-keyring.vala
@@ -61,6 +61,10 @@ public class Keyring : Secret.Collection, Gcr.Collection, Place, Deletable, Lock
owned get { return this._menu_model; }
}
+ public bool show_if_empty {
+ get { return true; }
+ }
+
public bool is_default {
get { return Backend.instance().has_alias ("default", this); }
}
diff --git a/pgp/seahorse-gpgme-keyring.c b/pgp/seahorse-gpgme-keyring.c
index 9b3d45f8..08f5f52f 100644
--- a/pgp/seahorse-gpgme-keyring.c
+++ b/pgp/seahorse-gpgme-keyring.c
@@ -54,7 +54,9 @@ enum {
PROP_URI,
PROP_ACTIONS,
PROP_ACTION_PREFIX,
- PROP_MENU_MODEL
+ PROP_MENU_MODEL,
+ PROP_SHOW_IF_EMPTY,
+ N_PROPS
};
/* Amount of keys to load in a batch */
@@ -802,6 +804,12 @@ seahorse_gpgme_keyring_get_uri (SeahorsePlace *place)
return g_strdup ("gnupg://");
}
+static gboolean
+seahorse_gpgme_keyring_get_show_if_empty (SeahorsePlace *place)
+{
+ return TRUE;
+}
+
static void
seahorse_gpgme_keyring_get_property (GObject *obj,
guint prop_id,
@@ -832,6 +840,9 @@ seahorse_gpgme_keyring_get_property (GObject *obj,
case PROP_MENU_MODEL:
g_value_take_object (value, seahorse_gpgme_keyring_get_menu_model (place));
break;
+ case PROP_SHOW_IF_EMPTY:
+ g_value_set_boolean (value, TRUE);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -914,6 +925,7 @@ seahorse_gpgme_keyring_class_init (SeahorseGpgmeKeyringClass *klass)
g_object_class_override_property (gobject_class, PROP_ACTIONS, "actions");
g_object_class_override_property (gobject_class, PROP_ACTION_PREFIX, "action-prefix");
g_object_class_override_property (gobject_class, PROP_MENU_MODEL, "menu-model");
+ g_object_class_override_property (gobject_class, PROP_SHOW_IF_EMPTY, "show-if-empty");
}
static void
@@ -929,6 +941,7 @@ seahorse_gpgme_keyring_place_iface (SeahorsePlaceIface *iface)
iface->get_label = seahorse_gpgme_keyring_get_label;
iface->set_label = seahorse_gpgme_keyring_set_label;
iface->get_uri = seahorse_gpgme_keyring_get_uri;
+ iface->get_show_if_empty = seahorse_gpgme_keyring_get_show_if_empty;
}
static guint
diff --git a/pgp/seahorse-server-source.c b/pgp/seahorse-server-source.c
index 0c2b2282..1d56c38e 100644
--- a/pgp/seahorse-server-source.c
+++ b/pgp/seahorse-server-source.c
@@ -51,7 +51,9 @@ enum {
PROP_URI,
PROP_ACTIONS,
PROP_ACTION_PREFIX,
- PROP_MENU_MODEL
+ PROP_MENU_MODEL,
+ PROP_SHOW_IF_EMPTY,
+ N_PROPS
};
/* -----------------------------------------------------------------------------
@@ -95,6 +97,7 @@ seahorse_server_source_class_init (SeahorseServerSourceClass *klass)
g_object_class_override_property (gobject_class, PROP_ACTIONS, "actions");
g_object_class_override_property (gobject_class, PROP_ACTION_PREFIX, "action-prefix");
g_object_class_override_property (gobject_class, PROP_MENU_MODEL, "menu-model");
+ g_object_class_override_property (gobject_class, PROP_SHOW_IF_EMPTY, "show-if-empty");
g_object_class_install_property (gobject_class, PROP_KEY_SERVER,
g_param_spec_string ("key-server", "Key Server",
@@ -201,6 +204,12 @@ seahorse_server_source_get_menu_model (SeahorsePlace* self)
return NULL;
}
+static gboolean
+seahorse_server_source_get_show_if_empty (SeahorsePlace *place)
+{
+ return TRUE;
+}
+
static void
seahorse_server_source_place_iface (SeahorsePlaceIface *iface)
{
@@ -214,6 +223,7 @@ seahorse_server_source_place_iface (SeahorsePlaceIface *iface)
iface->get_label = seahorse_server_source_get_label;
iface->set_label = seahorse_server_source_set_label;
iface->get_uri = seahorse_server_source_get_uri;
+ iface->get_show_if_empty = seahorse_server_source_get_show_if_empty;
}
/**
@@ -300,6 +310,9 @@ seahorse_server_get_property (GObject *obj,
case PROP_MENU_MODEL:
g_value_set_object (value, seahorse_server_source_get_menu_model (place));
break;
+ case PROP_SHOW_IF_EMPTY:
+ g_value_set_boolean (value, TRUE);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
diff --git a/pgp/seahorse-unknown-source.c b/pgp/seahorse-unknown-source.c
index fd0503e9..e1ac4d6d 100644
--- a/pgp/seahorse-unknown-source.c
+++ b/pgp/seahorse-unknown-source.c
@@ -37,7 +37,9 @@ enum {
PROP_URI,
PROP_ACTIONS,
PROP_ACTION_PREFIX,
- PROP_MENU_MODEL
+ PROP_MENU_MODEL,
+ PROP_SHOW_IF_EMPTY,
+ N_PROPS
};
struct _SeahorseUnknownSource {
@@ -130,6 +132,12 @@ seahorse_unknown_source_get_menu_model (SeahorsePlace* self)
return NULL;
}
+static gboolean
+seahorse_unknown_source_get_show_if_empty (SeahorsePlace *place)
+{
+ return TRUE;
+}
+
static void
seahorse_unknown_source_get_property (GObject *obj,
guint prop_id,
@@ -160,6 +168,9 @@ seahorse_unknown_source_get_property (GObject *obj,
case PROP_MENU_MODEL:
g_value_take_object (value, seahorse_unknown_source_get_menu_model (place));
break;
+ case PROP_SHOW_IF_EMPTY:
+ g_value_set_boolean (value, TRUE);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -210,6 +221,7 @@ seahorse_unknown_source_class_init (SeahorseUnknownSourceClass *klass)
g_object_class_override_property (gobject_class, PROP_ACTION_PREFIX, "action-prefix");
g_object_class_override_property (gobject_class, PROP_MENU_MODEL, "menu-model");
g_object_class_override_property (gobject_class, PROP_URI, "uri");
+ g_object_class_override_property (gobject_class, PROP_SHOW_IF_EMPTY, "show-if-empty");
}
static guint
@@ -255,6 +267,7 @@ seahorse_unknown_source_place_iface (SeahorsePlaceIface *iface)
iface->get_label = seahorse_unknown_source_get_label;
iface->set_label = seahorse_unknown_source_set_label;
iface->get_uri = seahorse_unknown_source_get_uri;
+ iface->get_show_if_empty = seahorse_unknown_source_get_show_if_empty;
}
SeahorseUnknownSource*
diff --git a/pkcs11/pkcs11-token.vala b/pkcs11/pkcs11-token.vala
index a9494f05..497ee2b7 100644
--- a/pkcs11/pkcs11-token.vala
+++ b/pkcs11/pkcs11-token.vala
@@ -116,6 +116,10 @@ public class Token : GLib.Object, Gcr.Collection, Place, Lockable {
get { return 0; }
}
+ public bool show_if_empty {
+ get { return false; }
+ }
+
public unowned GLib.Array<ulong> mechanisms {
get {
if (this._mechanisms == null)
diff --git a/src/sidebar.vala b/src/sidebar.vala
index 91e4e478..c2f19fa7 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -73,7 +73,9 @@ public class Seahorse.Sidebar : Gtk.ListBox {
return_if_fail (place != null);
debug("New place '%s' added", place.label);
- this.store.insert_sorted(place, compare_places);
+
+ if (place.get_length() > 0 || place.show_if_empty)
+ this.store.insert_sorted(place, compare_places);
place.notify.connect(on_place_changed);
}
@@ -246,7 +248,7 @@ public class Seahorse.Sidebar : Gtk.ListBox {
}
}
- if (!already_in)
+ if (!already_in && (place.get_length() > 0 || place.show_if_empty))
this.store.insert_sorted(place, compare_places);
}
}
diff --git a/ssh/source.vala b/ssh/source.vala
index eb8ba554..5e840499 100644
--- a/ssh/source.vala
+++ b/ssh/source.vala
@@ -67,6 +67,10 @@ public class Seahorse.Ssh.Source : GLib.Object, Gcr.Collection, Seahorse.Place {
owned get { return null; }
}
+ public bool show_if_empty {
+ get { return true; }
+ }
+
/**
* The directory containing the SSH keys.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]