[seahorse] pgp: Fix selection of keys for the sync action



commit 6d1271f1bcd585c526b6281eff93243353d64e1b
Author: Stef Walter <stefw collabora co uk>
Date:   Wed Dec 14 07:05:01 2011 +0100

    pgp: Fix selection of keys for the sync action

 libseahorse/seahorse-catalog.c |    1 +
 pgp/seahorse-pgp-actions.c     |   28 ++++++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/libseahorse/seahorse-catalog.c b/libseahorse/seahorse-catalog.c
index acb7815..95970e0 100644
--- a/libseahorse/seahorse-catalog.c
+++ b/libseahorse/seahorse-catalog.c
@@ -539,6 +539,7 @@ seahorse_catalog_include_actions (SeahorseCatalog *self,
 	gtk_ui_manager_insert_action_group (self->pv->ui_manager, actions, 10);
 
 	if (SEAHORSE_IS_ACTIONS (actions)) {
+		seahorse_actions_set_catalog (SEAHORSE_ACTIONS (actions), self);
 		definition = seahorse_actions_get_definition (SEAHORSE_ACTIONS (actions));
 		if (definition != NULL) {
 			gtk_ui_manager_add_ui_from_string (self->pv->ui_manager, definition, -1, &error);
diff --git a/pgp/seahorse-pgp-actions.c b/pgp/seahorse-pgp-actions.c
index c897b60..64565ad 100644
--- a/pgp/seahorse-pgp-actions.c
+++ b/pgp/seahorse-pgp-actions.c
@@ -83,18 +83,30 @@ static void
 on_remote_sync (GtkAction* action,
                 gpointer user_data)
 {
+	SeahorseActions *actions = SEAHORSE_ACTIONS (user_data);
 	SeahorseGpgmeKeyring *keyring;
-	GList* objects = user_data;
+	SeahorseCatalog *catalog;
+	GList *objects = NULL;
+	GList *keys = NULL;
+	GList *l;
+
+	catalog = seahorse_actions_get_catalog (actions);
+	if (catalog != NULL) {
+		objects = seahorse_catalog_get_selected_objects (catalog);
+		for (l = objects; l != NULL; l = g_list_next (l)) {
+			if (SEAHORSE_IS_PGP_KEY (l->data))
+				keys = g_list_prepend (keys, l->data);
+		}
+		g_list_free (objects);
+	}
 
-	if (objects == NULL) {
+	if (keys == NULL) {
 		keyring = seahorse_pgp_backend_get_default_keyring (NULL);
-		objects = gcr_collection_get_objects (GCR_COLLECTION (keyring));
-	} else {
-		objects = g_list_copy (objects);
+		keys = gcr_collection_get_objects (GCR_COLLECTION (keyring));
 	}
 
-	seahorse_keyserver_sync_show (objects, seahorse_action_get_window (action));
-	g_list_free (objects);
+	seahorse_keyserver_sync_show (keys, seahorse_action_get_window (action));
+	g_list_free (keys);
 }
 
 static const GtkActionEntry FIND_ACTIONS[] = {
@@ -115,7 +127,7 @@ seahorse_pgp_backend_actions_init (SeahorsePgpBackendActions *self)
 	gtk_action_group_add_actions (actions, FIND_ACTIONS,
 	                              G_N_ELEMENTS (FIND_ACTIONS), NULL);
 	gtk_action_group_add_actions (actions, SYNC_ACTIONS,
-	                              G_N_ELEMENTS (SYNC_ACTIONS), NULL);
+	                              G_N_ELEMENTS (SYNC_ACTIONS), self);
 	seahorse_actions_register_definition (SEAHORSE_ACTIONS (self), BACKEND_DEFINITION);
 }
 



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