diff options
author | Priit Laes <plaes@plaes.org> | 2009-07-28 18:21:46 +0800 |
---|---|---|
committer | Priit Laes <plaes@plaes.org> | 2009-07-29 17:42:14 +0800 |
commit | a75e0d2fc04d9f599edccf572afe78f2e48e2e44 (patch) | |
tree | 2d168abe768fa610c56c040b279e770ebd1a7b36 /src/pdm-dialog.c | |
parent | dfbf90543edbb12a4c467db02f60214de3d07d83 (diff) | |
download | gsoc2013-epiphany-a75e0d2fc04d9f599edccf572afe78f2e48e2e44.tar.gz gsoc2013-epiphany-a75e0d2fc04d9f599edccf572afe78f2e48e2e44.tar.zst gsoc2013-epiphany-a75e0d2fc04d9f599edccf572afe78f2e48e2e44.zip |
Make clear all functionality asynchronous.
Signed-off-by: Priit Laes <plaes@plaes.org>
Diffstat (limited to 'src/pdm-dialog.c')
-rw-r--r-- | src/pdm-dialog.c | 75 |
1 files changed, 54 insertions, 21 deletions
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index 20612b7fb..575aab9fd 100644 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -216,6 +216,58 @@ clear_all_cookies (SoupCookieJar *jar) } static void +clear_all_passwords_async_cb (GnomeKeyringResult result, + gpointer data) +{ + GtkTreeRowReference *rowref = (GtkTreeRowReference *)data; + + if (result == GNOME_KEYRING_RESULT_OK) { + GtkTreeIter iter; + GtkTreePath *path; + GtkTreeModel *model; + + if (!gtk_tree_row_reference_valid (rowref)) + return; + + path = gtk_tree_row_reference_get_path (rowref); + model = gtk_tree_row_reference_get_model (rowref); + + if (path != NULL && gtk_tree_model_get_iter (model, &iter, path)) { + /* FIXME! Do we have to drop the data too? */ + gtk_list_store_remove (GTK_LIST_STORE (model), &iter); + + gtk_tree_path_free (path); + } + } +} + +static gboolean +clear_all_passwords (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + GtkTreeRowReference *row; + EphyPasswordInfo *info; + GValue val = { 0, }; + + row = gtk_tree_row_reference_new (model, path); + + gtk_tree_model_get_value (model, iter, + COL_PASSWORDS_DATA, &val); + info = g_value_get_boxed (&val); + + gnome_keyring_item_delete (GNOME_KEYRING_DEFAULT, + info->keyring_id, + (GnomeKeyringOperationDoneCallback) clear_all_passwords_async_cb, + row, + (GDestroyNotify) gtk_tree_row_reference_free); + g_value_unset (&val); + + return FALSE; +} + +static void clear_all_dialog_response_cb (GtkDialog *dialog, int response, PdmClearAllDialogButtons *checkbuttons) @@ -254,27 +306,8 @@ clear_all_dialog_response_cb (GtkDialog *dialog, { PdmDialog *pdialog = EPHY_PDM_DIALOG (checkbuttons->dialog); PdmActionInfo *pinfo = pdialog->priv->passwords; - GtkTreeModel *model = pinfo->model; - GtkTreeIter iter; - gboolean valid; - - valid = gtk_tree_model_get_iter_first (model, &iter); - - while (valid) { - GValue val = { 0, }; - gboolean result; - - gtk_tree_model_get_value (model, &iter, - COL_PASSWORDS_DATA, &val); - result = pdm_dialog_password_remove(pinfo, - g_value_get_boxed (&val)); - g_value_unset (&val); - - if (result) - valid = gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - else - valid = gtk_tree_model_iter_next (model, &iter); - } + + gtk_tree_model_foreach (pinfo->model, (GtkTreeModelForeachFunc) clear_all_passwords, NULL); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbuttons->checkbutton_cache))) |