[seahorse] pgp-subkey: Generate 'Certify' and 'Authenticate' names for the new flags



commit 5e57e088da9d5dc64231f11745c3c4d1cb2e9a97
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jul 29 08:55:23 2014 -0500

    pgp-subkey: Generate 'Certify' and 'Authenticate' names for the new flags
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733920
    Signed-off-by: Federico Mena Quintero <federico gnome org>
    Signed-off-by: Stef Walter <stefw gnome org>
     * Whitespace, make struct definition local

 pgp/seahorse-pgp-subkey.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/pgp/seahorse-pgp-subkey.c b/pgp/seahorse-pgp-subkey.c
index 3fd78fc..36f552b 100644
--- a/pgp/seahorse-pgp-subkey.c
+++ b/pgp/seahorse-pgp-subkey.c
@@ -282,8 +282,21 @@ seahorse_pgp_subkey_set_length (SeahorsePgpSubkey *self, guint length)
 gchar *
 seahorse_pgp_subkey_get_usage (SeahorsePgpSubkey *self)
 {
+       typedef struct {
+               unsigned int flag;
+               const char *name;
+       } FlagNames;
+
+       const FlagNames const flag_names[] = {
+               { SEAHORSE_FLAG_CAN_ENCRYPT,      N_("Encrypt") },
+               { SEAHORSE_FLAG_CAN_SIGN,         N_("Sign") },
+               { SEAHORSE_FLAG_CAN_CERTIFY,      N_("Certify") },
+               { SEAHORSE_FLAG_CAN_AUTHENTICATE, N_("Authenticate") }
+       };
+
        GString *str;
        gboolean previous;
+       int i;
 
        g_return_val_if_fail (SEAHORSE_IS_PGP_SUBKEY (self), NULL);
 
@@ -291,16 +304,14 @@ seahorse_pgp_subkey_get_usage (SeahorsePgpSubkey *self)
 
        previous = FALSE;
 
-       if (self->pv->flags & SEAHORSE_FLAG_CAN_ENCRYPT) {
-               previous = TRUE;
-               g_string_append (str, _("Encrypt"));
-       }
-
-       if (self->pv->flags & SEAHORSE_FLAG_CAN_SIGN) {
-               if (previous)
-                       g_string_append (str, ", ");
+       for (i = 0; i < G_N_ELEMENTS (flag_names); i++) {
+               if (self->pv->flags & flag_names[i].flag) {
+                       if (previous)
+                               g_string_append (str, ", ");
 
-               g_string_append (str, _("Sign"));
+                       previous = TRUE;
+                       g_string_append (str, _(flag_names[i].name));
+               }
        }
 
        return g_string_free (str, FALSE);


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