Index: libseahorse/seahorse-key-source.c
===================================================================
RCS file: /cvs/gnome/seahorse/libseahorse/seahorse-key-source.c,v
retrieving revision 1.6
diff -u -r1.6 seahorse-key-source.c
--- libseahorse/seahorse-key-source.c	5 Apr 2005 20:56:24 -0000	1.6
+++ libseahorse/seahorse-key-source.c	8 May 2005 00:32:08 -0000
@@ -275,6 +275,29 @@
 }
 
 /**
+ * seahorse_key_source_find_keys
+ * @sksrc: A #SeahorseKeySource object
+ * @search_str: return keys matching string
+ * 
+ * Get a list of all the keys in the key source matching the search string.
+ * 
+ * Returns: An allocated list of keys.
+ **/
+GList*
+seahorse_key_source_find_keys (SeahorseKeySource *sksrc,
+                              gchar *search_str)
+{
+    SeahorseKeySourceClass *klass;
+    
+    g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
+    g_return_val_if_fail (search_str != NULL, NULL);
+    klass = SEAHORSE_KEY_SOURCE_GET_CLASS (sksrc);
+    g_return_val_if_fail (klass->find_keys != NULL, NULL);
+    
+    return (*klass->find_keys) (sksrc, search_str);
+}
+
+/**
  * seahorse_key_source_get_state
  * @sksrc: A #SeahorseKeySource object
  * 
Index: libseahorse/seahorse-key-source.h
===================================================================
RCS file: /cvs/gnome/seahorse/libseahorse/seahorse-key-source.h,v
retrieving revision 1.5
diff -u -r1.5 seahorse-key-source.h
--- libseahorse/seahorse-key-source.h	5 Apr 2005 20:56:24 -0000	1.5
+++ libseahorse/seahorse-key-source.h	8 May 2005 00:32:08 -0000
@@ -85,6 +85,9 @@
     /* Get a list of all the keys in the key source. No loading done */
     GList* (*get_keys) (SeahorseKeySource *sksrc, gboolean secret_only);
     
+    /* Get a list of all the keys in the key source matching a string */
+    GList* (*find_keys) (SeahorseKeySource *sksrc, gchar *search_str);
+    
     /* Get a new GPGME context for this source */
     gpgme_ctx_t (*new_context) (SeahorseKeySource *sksrc);
     
@@ -140,6 +143,9 @@
 
 GList*       seahorse_key_source_get_keys    (SeahorseKeySource *sksrc,
                                               gboolean secret_only);
+                                              
+GList*       seahorse_key_source_find_keys    (SeahorseKeySource *sksrc,
+                                              gchar *search_str);
 
 guint        seahorse_key_source_get_count   (SeahorseKeySource *sksrc,
                                               gboolean secret_only);
Index: libseahorse/seahorse-multi-source.c
===================================================================
RCS file: /cvs/gnome/seahorse/libseahorse/seahorse-multi-source.c,v
retrieving revision 1.7
diff -u -r1.7 seahorse-multi-source.c
--- libseahorse/seahorse-multi-source.c	5 Apr 2005 21:14:25 -0000	1.7
+++ libseahorse/seahorse-multi-source.c	8 May 2005 00:32:08 -0000
@@ -41,6 +41,8 @@
                                                        const gchar *fpr);
 static GList*       seahorse_multi_source_get_keys    (SeahorseKeySource *src,
                                                        gboolean secret_only);
+static GList*       seahorse_multi_source_find_keys   (SeahorseKeySource *src,
+                                                       gchar *search_str);
 static guint        seahorse_multi_source_get_count   (SeahorseKeySource *src,
                                                        gboolean secret_only);                                                                                                              
 static gpgme_ctx_t  seahorse_multi_source_new_context (SeahorseKeySource *src);
@@ -98,6 +100,7 @@
     key_class->get_count = seahorse_multi_source_get_count;
     key_class->get_key = seahorse_multi_source_get_key;
     key_class->get_keys = seahorse_multi_source_get_keys;
+    key_class->find_keys = seahorse_multi_source_find_keys;
     key_class->get_state = seahorse_multi_source_get_state;
     key_class->get_operation = seahorse_multi_source_get_operation;
     key_class->new_context = seahorse_multi_source_new_context;    
@@ -267,6 +270,26 @@
     return keys;    
 }
 
+static GList*
+seahorse_multi_source_find_keys (SeahorseKeySource *src,
+                                 gchar *search_str)  
+{
+    SeahorseMultiSource *msrc;
+    GList *keys = NULL;
+    GSList *l;
+    
+    msrc = SEAHORSE_MULTI_SOURCE (src);   
+
+    /* Go through our sources */
+    for (l = msrc->sources; l != NULL; l = g_slist_next (l)) {
+        g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (l->data), keys);
+        keys = g_list_concat (keys, 
+            seahorse_key_source_find_keys (SEAHORSE_KEY_SOURCE (l->data), search_str));
+    }
+    
+    return keys;    
+}
+
 static guint
 seahorse_multi_source_get_state (SeahorseKeySource *src)
 {
Index: libseahorse/seahorse-pgp-source.c
===================================================================
RCS file: /cvs/gnome/seahorse/libseahorse/seahorse-pgp-source.c,v
retrieving revision 1.15
diff -u -r1.15 seahorse-pgp-source.c
--- libseahorse/seahorse-pgp-source.c	5 Apr 2005 21:14:25 -0000	1.15
+++ libseahorse/seahorse-pgp-source.c	8 May 2005 00:32:08 -0000
@@ -116,6 +116,8 @@
                                                      const gchar *fpr);
 static GList*       seahorse_pgp_source_get_keys    (SeahorseKeySource *src,
                                                      gboolean secret_only);
+static GList*       seahorse_pgp_source_find_keys   (SeahorseKeySource *src,
+                                                     gchar *search_str);
 static guint        seahorse_pgp_source_get_count   (SeahorseKeySource *src,
                                                      gboolean secret_only);
 static gpgme_ctx_t  seahorse_pgp_source_new_context (SeahorseKeySource *src);
@@ -180,6 +182,7 @@
     key_class->get_count = seahorse_pgp_source_get_count;
     key_class->get_key = seahorse_pgp_source_get_key;
     key_class->get_keys = seahorse_pgp_source_get_keys;
+    key_class->find_keys = seahorse_pgp_source_find_keys;
     key_class->get_state = seahorse_pgp_source_get_state;
     key_class->get_operation = seahorse_pgp_source_get_operation;
     key_class->new_context = seahorse_pgp_source_new_context;    
@@ -448,6 +451,34 @@
         (*n)++;
 }
 
+struct matching_struct{
+	gchar *search_str;
+	GList *l;
+};
+
+static void
+matching_keys_to_list(const gchar *id, SeahorseKey *skey, struct matching_struct **matching)
+{
+	gint numids, i;
+	gchar *search_str;
+	GList *l;
+	
+	search_str = (*matching)->search_str;
+	l = (*matching)->l;
+	
+	numids = seahorse_key_get_num_uids(skey);
+	
+	for(i = 0; i < numids; i++)
+	{
+		if((strstr(seahorse_key_get_userid_name(skey, i), search_str))||
+		   (strstr(seahorse_key_get_userid_comment(skey, i), search_str))||
+		   (strstr(seahorse_key_get_userid_email(skey, i), search_str)))
+		   {
+		   		l = g_list_append (l, skey);
+		   }
+	}
+}
+
 /* -----------------------------------------------------------------------------
  *  GPG HOME DIR MONITORING
  */
@@ -798,6 +829,25 @@
     return l;
 }
 
+static GList*
+seahorse_pgp_source_find_keys (SeahorseKeySource *src,
+                              gchar *search_str)  
+{
+    SeahorsePGPSource *psrc;
+    GList *l = NULL;
+    struct matching_struct matching;
+    
+    matching.search_str = search_str;
+    matching.l = l;
+    
+    g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (src), NULL);
+    psrc = SEAHORSE_PGP_SOURCE (src);
+    
+    g_hash_table_foreach (psrc->priv->keys, 
+            (GHFunc)matching_keys_to_list, &matching);
+    return l;
+}
+
 static guint
 seahorse_pgp_source_get_state (SeahorseKeySource *src)
 {
Index: libseahorse/seahorse-server-source.c
===================================================================
RCS file: /cvs/gnome/seahorse/libseahorse/seahorse-server-source.c,v
retrieving revision 1.9
diff -u -r1.9 seahorse-server-source.c
--- libseahorse/seahorse-server-source.c	25 Apr 2005 00:28:05 -0000	1.9
+++ libseahorse/seahorse-server-source.c	8 May 2005 00:32:08 -0000
@@ -74,6 +74,9 @@
                                                         const gchar *fpr);
 static GList*       seahorse_server_source_get_keys    (SeahorseKeySource *src,
                                                         gboolean secret_only);
+static GList*       seahorse_server_source_find_keys   (SeahorseKeySource *src,
+                                                        gchar *search_str);
+                                                        
 static guint        seahorse_server_source_get_count   (SeahorseKeySource *src,
                                                         gboolean secret_only);
 static gpgme_ctx_t  seahorse_server_source_new_context (SeahorseKeySource *src);
@@ -124,6 +127,7 @@
     key_class->get_count = seahorse_server_source_get_count;
     key_class->get_key = seahorse_server_source_get_key;
     key_class->get_keys = seahorse_server_source_get_keys;
+    key_class->find_keys = seahorse_server_source_find_keys;
     key_class->get_state = seahorse_server_source_get_state;
     key_class->get_operation = seahorse_server_source_get_operation;
     key_class->new_context = seahorse_server_source_new_context;    
@@ -421,6 +425,35 @@
     *l = g_list_append (*l, skey);
 }
 
+struct matching_struct{
+	gchar *search_str;
+	GList *l;
+};
+
+/* Callback for copying internal keys that match a string to a list */
+static void
+matching_keys_to_list (const gchar *id, SeahorseKey *skey, struct matching_struct **matching)
+{
+    gint numids, i;
+	gchar *search_str;
+	GList *l;
+	
+	search_str = (*matching)->search_str;
+	l = (*matching)->l;
+	
+	numids = seahorse_key_get_num_uids(skey);
+	
+	for(i = 0; i < numids; i++)
+	{
+		if((strstr(seahorse_key_get_userid_name(skey, i), search_str))||
+		   (strstr(seahorse_key_get_userid_comment(skey, i), search_str))||
+		   (strstr(seahorse_key_get_userid_email(skey, i), search_str)))
+		   {
+		   		l = g_list_append (l, skey);
+		   }
+	}
+}
+
 void
 seahorse_server_source_set_operation (SeahorseServerSource *ssrc, SeahorseOperation *op)
 {
@@ -515,6 +548,25 @@
     return l;
 }
 
+static GList*
+seahorse_server_source_find_keys (SeahorseKeySource *src,
+                                  gchar *search_str)  
+{
+    SeahorseServerSource *ssrc;
+    GList *l = NULL;
+    struct matching_struct matching;
+    
+    matching.search_str = search_str;
+    matching.l = l;
+    
+    g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (src), NULL);
+    ssrc = SEAHORSE_SERVER_SOURCE (src);
+    
+    g_hash_table_foreach (ssrc->priv->keys, (GHFunc)matching_keys_to_list, &matching);
+        
+    return l;
+}
+
 static guint
 seahorse_server_source_get_state (SeahorseKeySource *src)
 {
