[seahorse/feature/seahorse-pgp-key-api: 2/8] pgp-key: Add a method to get primary UID name




commit 5c5a43dc5bfbd4a8870daa4a0ba01b0c5f6d23e5
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sun Aug 15 10:51:11 2021 +0200

    pgp-key: Add a method to get primary UID name

 pgp/seahorse-pgp-key.c | 23 +++++++++++++----------
 pgp/seahorse-pgp-key.h |  2 ++
 2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/pgp/seahorse-pgp-key.c b/pgp/seahorse-pgp-key.c
index a0ee0658..37d69e76 100644
--- a/pgp/seahorse-pgp-key.c
+++ b/pgp/seahorse-pgp-key.c
@@ -94,15 +94,6 @@ seahorse_pgp_keyid_equal (gconstpointer v1,
     return g_str_equal (keyid_1, keyid_2);
 }
 
-static const char*
-calc_short_name (SeahorsePgpKey *self)
-{
-    SeahorsePgpKeyPrivate *priv = seahorse_pgp_key_get_instance_private (self);
-    g_autoptr(SeahorsePgpUid) uid = g_list_model_get_item (priv->uids, 0);
-
-    return uid ? seahorse_pgp_uid_get_name (uid) : NULL;
-}
-
 static char*
 calc_name (SeahorsePgpKey *self)
 {
@@ -247,7 +238,7 @@ seahorse_pgp_key_realize (SeahorsePgpKey *self)
 
     name = calc_name (self);
     markup = calc_markup (self);
-    nickname = calc_short_name (self);
+    nickname = seahorse_pgp_key_get_primary_name (self);
 
     g_object_get (self, "usage", &usage, NULL);
 
@@ -311,6 +302,18 @@ seahorse_pgp_key_get_uids (SeahorsePgpKey *self)
     return priv->uids;
 }
 
+const char *
+seahorse_pgp_key_get_primary_name (SeahorsePgpKey *self)
+{
+    SeahorsePgpKeyPrivate *priv = seahorse_pgp_key_get_instance_private (self);
+    g_autoptr(SeahorsePgpUid) uid = NULL;
+
+    g_return_val_if_fail (SEAHORSE_PGP_IS_KEY (self), NULL);
+
+    uid = g_list_model_get_item (priv->uids, 0);
+    return uid ? seahorse_pgp_uid_get_name (uid) : NULL;
+}
+
 void
 seahorse_pgp_key_add_uid (SeahorsePgpKey *self,
                           SeahorsePgpUid *uid)
diff --git a/pgp/seahorse-pgp-key.h b/pgp/seahorse-pgp-key.h
index c435e255..0a659104 100644
--- a/pgp/seahorse-pgp-key.h
+++ b/pgp/seahorse-pgp-key.h
@@ -87,6 +87,8 @@ gboolean          seahorse_pgp_key_is_private_key       (SeahorsePgpKey *self);
 
 const char*       seahorse_pgp_key_calc_identifier      (const char *keyid);
 
+const char *       seahorse_pgp_key_get_primary_name    (SeahorsePgpKey *self);
+
 guint             seahorse_pgp_keyid_hash               (gconstpointer v);
 
 gboolean          seahorse_pgp_keyid_equal              (gconstpointer v1,


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