[seahorse/wip/nielsdg/ellipsize-uids] pgp: Ellipsize if there are too many uids
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/nielsdg/ellipsize-uids] pgp: Ellipsize if there are too many uids
- Date: Tue, 1 Oct 2019 19:03:14 +0000 (UTC)
commit c66e01fbac8250b0e4bd0b61835f7acc8b9c2c0c
Author: Niels De Graef <nielsdegraef gmail com>
Date: Tue Oct 1 20:45:41 2019 +0200
pgp: Ellipsize if there are too many uids
The reason for this commit is that some keys have a enormous amount of
UIDs associated with them (think company-wide keys). Thiis makes their
entry in the general list -which shows all UIDs- gets really bloated.
This constrains the amount of showed UIDs to 5. If the user wants to
see more, they will have to go to the key properties dialog.
pgp/seahorse-pgp-key.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/pgp/seahorse-pgp-key.c b/pgp/seahorse-pgp-key.c
index a6882225..ca588a80 100644
--- a/pgp/seahorse-pgp-key.c
+++ b/pgp/seahorse-pgp-key.c
@@ -119,6 +119,7 @@ calc_markup (SeahorsePgpKey *self)
const gchar *email;
const gchar *comment;
const gchar *primary = NULL;
+ guint i = 0;
uids = seahorse_pgp_key_get_uids (self);
@@ -158,7 +159,24 @@ calc_markup (SeahorsePgpKey *self)
uids = uids->next;
}
- while (uids != NULL) {
+ for (i = 0; uids != NULL; i++, uids = g_list_next (uids)) {
+ g_string_append_c (result, '\n');
+
+ // If we already have more than 5 UIDs, ellipsze the list.
+ // Otherwise we get huge rows in the list of GPG keys
+ if (i == 4) {
+ int n_others = g_list_length (uids);
+ g_autofree char *others_str = NULL;
+
+ g_string_append_printf (result,
+ ngettext ("(and %d other)",
+ "(and %d others)",
+ n_others),
+ n_others);
+
+ break;
+ }
+
name = seahorse_pgp_uid_get_name (uids->data);
if (name && !name[0])
name = NULL;
@@ -170,7 +188,7 @@ calc_markup (SeahorsePgpKey *self)
comment = seahorse_pgp_uid_get_comment (uids->data);
if (comment && !comment[0])
comment = NULL;
- text = g_markup_printf_escaped ("\n%s%s%s%s%s%s%s",
+ text = g_markup_printf_escaped ("%s%s%s%s%s%s%s",
name ? name : "",
name ? ": " : "",
email ? email : "",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]