[epiphany/gnome-keyring: 3/6] pdm-dialog.c: Make password loading/showing async.
- From: Priit Laes <plaes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-keyring: 3/6] pdm-dialog.c: Make password loading/showing async.
- Date: Fri, 31 Jul 2009 16:25:17 +0000 (UTC)
commit ce83fa3e6309bdd2fc521e9fcadd64f4cf10369a
Author: Priit Laes <plaes plaes org>
Date: Mon Jul 27 22:45:03 2009 +0300
pdm-dialog.c: Make password loading/showing async.
Signed-off-by: Priit Laes <plaes plaes org>
src/pdm-dialog.c | 99 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 67 insertions(+), 32 deletions(-)
---
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index e917ebf..8c05485 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -1136,38 +1136,68 @@ pdm_dialog_cookie_scroll_to (PdmActionInfo *info)
/* "Passwords" tab */
static void
+passwords_data_func_get_item_cb (GnomeKeyringResult result,
+ GnomeKeyringItemInfo *info,
+ 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)) {
+ EphyPasswordInfo *epinfo;
+ GValue val = {0, };
+
+ gtk_tree_model_get_value (model, &iter, COL_PASSWORDS_DATA, &val);
+ epinfo = g_value_get_boxed (&val);
+ epinfo->secret = gnome_keyring_memory_strdup (gnome_keyring_item_info_get_secret (info));
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_PASSWORDS_DATA, epinfo,
+ COL_PASSWORDS_PASS, epinfo->secret, -1);
+ g_value_unset (&val);
+ }
+ }
+}
+
+static void
passwords_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
- EphyPasswordInfo *info;
- GValue val = { 0, };
-
- if (!gtk_tree_view_column_get_visible (tree_column))
- return;
-
- gtk_tree_model_get_value (model, iter, COL_PASSWORDS_DATA, &val);
- info = g_value_get_boxed (&val);
-
- /* get the password and store it */
- if (info->secret == NULL) {
- GnomeKeyringResult result;
- GnomeKeyringItemInfo *kinfo;
- result = gnome_keyring_item_get_info_full_sync (GNOME_KEYRING_DEFAULT,
- info->keyring_id,
- GNOME_KEYRING_ITEM_INFO_SECRET,
- &kinfo);
-
- /* FIXME: get_secret makes insecure copy... */
- if (result == GNOME_KEYRING_RESULT_OK) {
- info->secret = gnome_keyring_memory_strdup (
- gnome_keyring_item_info_get_secret (kinfo));
- gnome_keyring_item_info_free (kinfo);
- }
-
- /* eek, this will do a strdup in GtkCellRendererText... */
- g_object_set (cell, "text", info->secret, NULL);
- g_value_unset(&val);
- }
+ GValue val = { 0, };
+ EphyPasswordInfo *info;
+
+ if (!gtk_tree_view_column_get_visible (tree_column))
+ return;
+
+ gtk_tree_model_get_value (model, iter, COL_PASSWORDS_DATA, &val);
+ info = g_value_get_boxed (&val);
+
+ if (info->secret == NULL) {
+ GtkTreePath *path;
+ GtkTreeRowReference *rowref;
+
+ path = gtk_tree_model_get_path (model, iter);
+ rowref = gtk_tree_row_reference_new (model, path);
+
+ gnome_keyring_item_get_info_full (GNOME_KEYRING_DEFAULT,
+ info->keyring_id,
+ GNOME_KEYRING_ITEM_INFO_SECRET,
+ (GnomeKeyringOperationGetItemInfoCallback) passwords_data_func_get_item_cb,
+ rowref,
+ (GDestroyNotify) gtk_tree_row_reference_free);
+ gtk_tree_path_free (path);
+ }
+ g_value_unset (&val);
}
static void
@@ -1250,15 +1280,20 @@ pdm_dialog_passwords_construct (PdmActionInfo *info)
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_column_set_sort_column_id (column, COL_PASSWORDS_USER);
- /* Initially shown as hidden colum */
- gtk_tree_view_insert_column_with_data_func (treeview,
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (treeview,
COL_PASSWORDS_PASS,
_("User Password"),
renderer,
+ "text", COL_PASSWORDS_PASS,
+ NULL);
+ column = gtk_tree_view_get_column (treeview, COL_PASSWORDS_PASS);
+ gtk_tree_view_column_set_cell_data_func (column,
+ renderer,
passwords_data_func,
info,
NULL);
- column = gtk_tree_view_get_column (treeview, COL_PASSWORDS_PASS);
+ /* Initially shown as hidden colum */
gtk_tree_view_column_set_visible (column, FALSE);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_reorderable (column, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]