[seahorse/refactor: 22/33] Make pgp key items in the main view wrap and show all uids in one item.
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/refactor: 22/33] Make pgp key items in the main view wrap and show all uids in one item.
- Date: Tue, 18 Oct 2011 07:08:32 +0000 (UTC)
commit da784355b67a1b71507f7989277cfb34b5887223
Author: Stef Walter <stefw collabora co uk>
Date: Thu Oct 13 09:14:09 2011 +0200
Make pgp key items in the main view wrap and show all uids in one item.
libseahorse/seahorse-key-manager-store.c | 13 ++-
pgp/seahorse-pgp-key.c | 151 ++++++++++++++++--------------
2 files changed, 89 insertions(+), 75 deletions(-)
---
diff --git a/libseahorse/seahorse-key-manager-store.c b/libseahorse/seahorse-key-manager-store.c
index 7978127..6f5f915 100644
--- a/libseahorse/seahorse-key-manager-store.c
+++ b/libseahorse/seahorse-key-manager-store.c
@@ -346,6 +346,9 @@ append_text_column (SeahorseKeyManagerStore *skstore, GtkTreeView *view,
renderer = gtk_cell_renderer_text_new ();
g_object_set (renderer, "xpad", 3, NULL);
+ g_object_set (renderer, "ypad", 2, NULL);
+ g_object_set (renderer, "yalign", 0.0, NULL);
+ g_object_set (renderer, "scale", PANGO_SCALE_SMALL, NULL);
column = gtk_tree_view_column_new_with_attributes (label, renderer, "text", index, NULL);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (view, column);
@@ -751,8 +754,9 @@ seahorse_key_manager_store_new (GcrCollection *collection,
/* add the icon column */
renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (renderer, "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
- g_object_set (renderer, "xpad", 6, NULL);
+ g_object_set (renderer, "stock-size", GTK_ICON_SIZE_DND, NULL);
+ g_object_set (renderer, "ypad", 2, NULL);
+ g_object_set (renderer, "yalign", 0.0, NULL);
col = gtk_tree_view_column_new_with_attributes ("", renderer, "gicon", COL_ICON, NULL);
gtk_tree_view_column_set_resizable (col, FALSE);
gtk_tree_view_append_column (view, col);
@@ -760,11 +764,13 @@ seahorse_key_manager_store_new (GcrCollection *collection,
/* Name column */
renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer, "ypad", 2, NULL);
+ g_object_set (renderer, "yalign", 0.0, NULL);
+ g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
col = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "markup", COL_NAME, NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_expand (col, TRUE);
gtk_tree_view_append_column (view, col);
- gtk_tree_view_set_expander_column (view, col);
gtk_tree_view_column_set_sort_column_id (col, COL_NAME);
/* Use predicate to figure out which columns to add */
@@ -815,6 +821,7 @@ seahorse_key_manager_store_new (GcrCollection *collection,
}
gtk_tree_view_set_enable_search (view, FALSE);
+ gtk_tree_view_set_show_expanders (view, FALSE);
g_signal_connect_object (settings, "changed", G_CALLBACK (on_manager_settings_changed), view, 0);
diff --git a/pgp/seahorse-pgp-key.c b/pgp/seahorse-pgp-key.c
index c0a9cb9..08f8a76 100644
--- a/pgp/seahorse-pgp-key.c
+++ b/pgp/seahorse-pgp-key.c
@@ -49,11 +49,7 @@ enum {
PROP_ALGO
};
-static void seahorse_pgp_key_collection_iface_init (GcrCollectionIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (SeahorsePgpKey, seahorse_pgp_key, SEAHORSE_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (GCR_TYPE_COLLECTION, seahorse_pgp_key_collection_iface_init);
-);
+G_DEFINE_TYPE (SeahorsePgpKey, seahorse_pgp_key, SEAHORSE_TYPE_OBJECT);
struct _SeahorsePgpKeyPrivate {
gchar *keyid;
@@ -114,13 +110,84 @@ calc_name (SeahorsePgpKey *self)
seahorse_pgp_uid_get_comment (uids->data)) : g_strdup ("");
}
-static gchar*
-calc_markup (SeahorsePgpKey *self, guint flags)
-{
- GList *uids = seahorse_pgp_key_get_uids (self);
- return uids ? seahorse_pgp_uid_calc_markup (seahorse_pgp_uid_get_name (uids->data),
- seahorse_pgp_uid_get_email (uids->data),
- seahorse_pgp_uid_get_comment (uids->data), flags) : g_strdup ("");
+static gchar *
+calc_markup (SeahorsePgpKey *self)
+{
+ guint flags = seahorse_object_get_flags (SEAHORSE_OBJECT (self));
+ GList *uids;
+ GString *result;
+ gchar *text;
+ const gchar *name;
+ const gchar *email;
+ const gchar *comment;
+ const gchar *primary = NULL;
+
+ uids = seahorse_pgp_key_get_uids (self);
+
+ result = g_string_new ("<span");
+ if (flags & SEAHORSE_FLAG_EXPIRED || flags & SEAHORSE_FLAG_REVOKED ||
+ flags & SEAHORSE_FLAG_DISABLED)
+ g_string_append (result, " strikethrough='true'");
+ if (!(flags & SEAHORSE_FLAG_TRUSTED))
+ g_string_append (result, " foreground='#555555'");
+ g_string_append_c (result, '>');
+
+ /* The first name is the key name */
+ if (uids != NULL) {
+ name = seahorse_pgp_uid_get_name (uids->data);
+ text = g_markup_escape_text (name, -1);
+ g_string_append (result, text);
+ g_free (text);
+ primary = name;
+ }
+
+ g_string_append (result, "<span size='small' rise='0'>");
+ if (uids != NULL) {
+ email = seahorse_pgp_uid_get_email (uids->data);
+ if (email && !email[0])
+ email = NULL;
+ 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",
+ email ? email : "",
+ email ? " " : "",
+ comment ? "'" : "",
+ comment ? comment : "",
+ comment ? "'" : "");
+ g_string_append (result, text);
+ g_free (text);
+ uids = uids->next;
+ }
+
+ while (uids != NULL) {
+ name = seahorse_pgp_uid_get_name (uids->data);
+ if (name && !name[0])
+ name = NULL;
+ if (g_strcmp0 (name, primary) == 0)
+ name = NULL;
+ email = seahorse_pgp_uid_get_email (uids->data);
+ if (email && !email[0])
+ email = NULL;
+ 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",
+ name ? name : "",
+ name ? ": " : "",
+ email ? email : "",
+ email ? " " : "",
+ comment ? "'" : "",
+ comment ? comment : "",
+ comment ? "'" : "");
+ g_string_append (result, text);
+ g_free (text);
+ uids = uids->next;
+ }
+
+ g_string_append (result, "</span></span>");
+
+ return g_string_free (result, FALSE);
}
/* -----------------------------------------------------------------------------
@@ -137,32 +204,10 @@ _seahorse_pgp_key_get_uids (SeahorsePgpKey *self)
static void
_seahorse_pgp_key_set_uids (SeahorsePgpKey *self, GList *uids)
{
- GHashTable *checks;
- GHashTableIter iter;
- GObject *uid;
- GList *l;
-
g_return_if_fail (SEAHORSE_IS_PGP_KEY (self));
- checks = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- g_object_unref, NULL);
- for (l = self->pv->uids; l; l = g_list_next (l))
- g_hash_table_insert (checks, g_object_ref (l->data), l->data);
-
seahorse_object_list_free (self->pv->uids);
self->pv->uids = seahorse_object_list_copy (uids);
-
- /* Set parent and source on each new one, except the first */
- for (l = self->pv->uids; l; l = g_list_next (l)) {
- uid = l->data;
- if (!g_hash_table_remove (checks, uid))
- gcr_collection_emit_added (GCR_COLLECTION (self), uid);
- }
-
- g_hash_table_iter_init (&iter, checks);
- while (g_hash_table_iter_next (&iter, (gpointer *)&uid, NULL))
- gcr_collection_emit_removed (GCR_COLLECTION (self), uid);
- g_hash_table_destroy (checks);
g_object_notify (G_OBJECT (self), "uids");
}
@@ -241,7 +286,7 @@ seahorse_pgp_key_realize (SeahorsePgpKey *self)
}
name = calc_name (self);
- markup = calc_markup (self, seahorse_object_get_flags (SEAHORSE_OBJECT (self)));
+ markup = calc_markup (self);
nickname = calc_short_name (self);
g_object_get (self, "usage", &usage, NULL);
@@ -420,44 +465,6 @@ seahorse_pgp_key_class_init (SeahorsePgpKeyClass *klass)
"", G_PARAM_READABLE));
}
-static guint
-seahorse_pgp_key_collection_get_length (GcrCollection *collection)
-{
- SeahorsePgpKey *self = SEAHORSE_PGP_KEY (collection);
- guint length = g_list_length (self->pv->uids);
-
- /* First UID is displayed as the key itself */
- return length ? length - 1 : 0;
-}
-
-static GList *
-seahorse_pgp_key_collection_get_objects (GcrCollection *collection)
-{
- SeahorsePgpKey *self = SEAHORSE_PGP_KEY (collection);
-
- /* First UID is displayed as the key itself */
- return g_list_copy (self->pv->uids ? self->pv->uids->next : NULL);
-}
-
-static gboolean
-seahorse_pgp_key_collection_contains (GcrCollection *collection,
- GObject *object)
-{
- SeahorsePgpKey *self = SEAHORSE_PGP_KEY (collection);
-
- /* First UID is displayed as the key itself */
- return g_list_find (self->pv->uids ? self->pv->uids->next : NULL, object) != NULL;
-}
-
-static void
-seahorse_pgp_key_collection_iface_init (GcrCollectionIface *iface)
-{
- iface->get_length = seahorse_pgp_key_collection_get_length;
- iface->get_objects = seahorse_pgp_key_collection_get_objects;
- iface->contains = seahorse_pgp_key_collection_contains;
-}
-
-
/* -----------------------------------------------------------------------------
* PUBLIC
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]