[epiphany/gnome-keyring: 5/6] pdm-dialog.c: Make password removal async.



commit 2c36a2514a2981098a7f13dd24ac941cc8d36ddb
Author: Priit Laes <plaes plaes org>
Date:   Tue Jul 28 21:59:19 2009 +0300

    pdm-dialog.c: Make password removal async.
    
    Signed-off-by: Priit Laes <plaes plaes org>

 src/pdm-dialog.c |   57 +++++++++++++++++++++++------------------------------
 1 files changed, 25 insertions(+), 32 deletions(-)
---
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index e8d4b4b..0ec0210 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -57,7 +57,7 @@ struct PdmActionInfo
 	void (* fill)		(PdmActionInfo *info);
 	void (* add)		(PdmActionInfo *info,
 				 gpointer data);
-	gboolean (* remove)	(PdmActionInfo *info,
+	void (* remove)	(PdmActionInfo *info,
 				 gpointer data);
 	void (* scroll_to)	(PdmActionInfo *info);
 
@@ -140,7 +140,7 @@ EphyDialogProperty properties [] =
 static void pdm_dialog_class_init	(PdmDialogClass *klass);
 static void pdm_dialog_init		(PdmDialog *dialog);
 static void pdm_dialog_finalize		(GObject *object);
-static gboolean pdm_dialog_password_remove (PdmActionInfo *info, gpointer data);
+static void pdm_dialog_password_remove (PdmActionInfo *info, gpointer data);
 
 G_DEFINE_TYPE (PdmDialog, pdm_dialog, EPHY_TYPE_DIALOG)
 
@@ -215,7 +215,7 @@ clear_all_cookies (SoupCookieJar *jar)
 }
 
 static void
-clear_all_passwords_async_cb (GnomeKeyringResult result,
+pdm_dialog_password_remove_cb (GnomeKeyringResult result,
 						gpointer data)
 {
 	GtkTreeRowReference *rowref = (GtkTreeRowReference *)data;
@@ -258,11 +258,10 @@ clear_all_passwords (GtkTreeModel *model,
 
 	gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT,
 			info->keyring_id,
-			(GnomeKeyringOperationDoneCallback) clear_all_passwords_async_cb,
+			(GnomeKeyringOperationDoneCallback) pdm_dialog_password_remove_cb,
 			row,
 			(GDestroyNotify) gtk_tree_row_reference_free);
 	g_value_unset (&val);
-
 	return FALSE;
 }
 
@@ -541,27 +540,16 @@ pdm_cmd_delete_selection (PdmActionInfo *action)
 	gtk_tree_path_free (path);
 
 	/* Removal */
-
-	for (r = rlist; r != NULL; r = r->next)
-	{
+	for (r = rlist; r != NULL; r = r->next) {
 		GValue val = { 0, };
-		gboolean remove;
-
-		path = gtk_tree_row_reference_get_path
-			((GtkTreeRowReference *)r->data);
 
+		path = gtk_tree_row_reference_get_path ((GtkTreeRowReference *)r->data);
 		gtk_tree_model_get_iter (model, &iter, path);
 		gtk_tree_model_get_value (model, &iter, action->data_col, &val);
-		remove = action->remove (action, g_value_get_boxed (&val));
+		action->remove (action, g_value_get_boxed (&val));
 		g_value_unset (&val);
 
-        /*
-         * Remove the item:
-         * cookies are deleted using callback, passwords right here
-         */
-		if (remove)
-			gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-
+		gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 		gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
 		gtk_tree_path_free (path);
 	}
@@ -1131,17 +1119,13 @@ pdm_dialog_cookie_add (PdmActionInfo *info,
 	g_value_unset (&value[3]);
 }
 
-static gboolean
+static void
 pdm_dialog_cookie_remove (PdmActionInfo *info,
 			  gpointer data)
 {
 	SoupCookie *cookie = (SoupCookie *) data;
-	SoupCookieJar *jar;
-
-	jar = get_cookie_jar();
 
-	soup_cookie_jar_delete_cookie (jar, cookie);
-    return FALSE;
+	soup_cookie_jar_delete_cookie (get_cookie_jar(), cookie);
 }
 
 static void
@@ -1448,16 +1432,25 @@ out:
 	return;
 }
 
-static gboolean
+static void
+pdm_dialog_password_remove_dummy_cb (GnomeKeyringResult result,
+						gpointer data)
+{
+}
+
+static void
 pdm_dialog_password_remove (PdmActionInfo *info,
-			    gpointer data)
+                            gpointer data)
 {
 	EphyPasswordInfo *pinfo = (EphyPasswordInfo *) data;
-	GnomeKeyringResult result;
 
-	result = gnome_keyring_item_delete_sync (GNOME_KEYRING_DEFAULT,
-			pinfo->keyring_id);
-	return result == GNOME_KEYRING_RESULT_OK;
+	gnome_keyring_item_delete_sync (GNOME_KEYRING_DEFAULT,
+					pinfo->keyring_id);
+	gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT,
+				pinfo->keyring_id,
+				(GnomeKeyringOperationDoneCallback) pdm_dialog_password_remove_dummy_cb,
+				NULL,
+				NULL);
 }
 
 /* common routines */



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