[seahorse] Fix lack of refresh when a keyring is unlocked
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Fix lack of refresh when a keyring is unlocked
- Date: Mon, 19 Dec 2011 10:37:00 +0000 (UTC)
commit 24a839f8ca20e4c246a1c6d4386e9ccca36dc99c
Author: Stef Walter <stefw collabora co uk>
Date: Mon Dec 19 11:36:15 2011 +0100
Fix lack of refresh when a keyring is unlocked
gkr/seahorse-gkr-keyring.c | 15 +++++++++------
libseahorse/seahorse-collection.c | 31 +++++++++++++++++++------------
2 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/gkr/seahorse-gkr-keyring.c b/gkr/seahorse-gkr-keyring.c
index c158fa2..529a29c 100644
--- a/gkr/seahorse-gkr-keyring.c
+++ b/gkr/seahorse-gkr-keyring.c
@@ -554,13 +554,16 @@ on_keyring_xlock_done (GnomeKeyringResult result,
gpointer user_data)
{
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
+ SeahorseGkrKeyring *self = SEAHORSE_GKR_KEYRING (g_async_result_get_source_object (user_data));
GError *error = NULL;
if (seahorse_gkr_propagate_error (result, &error))
g_simple_async_result_take_error (res, error);
- seahorse_gkr_backend_load_async (NULL, NULL, NULL, NULL);
+ seahorse_gkr_keyring_load_async (SEAHORSE_PLACE (self), NULL, NULL, NULL);
g_simple_async_result_complete_in_idle (res);
+
+ g_object_unref (self);
}
static void
@@ -570,13 +573,13 @@ seahorse_gkr_keyring_lock_async (SeahorseLockable *lockable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- SeahorseGkrKeyring *keyring = SEAHORSE_GKR_KEYRING (lockable);
+ SeahorseGkrKeyring *self = SEAHORSE_GKR_KEYRING (lockable);
GSimpleAsyncResult *res;
- res = g_simple_async_result_new (G_OBJECT (lockable), callback, user_data,
+ res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
seahorse_gkr_keyring_lock_async);
- gnome_keyring_lock (seahorse_gkr_keyring_get_name (keyring),
+ gnome_keyring_lock (seahorse_gkr_keyring_get_name (self),
on_keyring_xlock_done, g_object_ref (res), g_object_unref);
g_object_unref (res);
@@ -603,13 +606,13 @@ seahorse_gkr_keyring_unlock_async (SeahorseLockable *lockable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- SeahorseGkrKeyring *keyring = SEAHORSE_GKR_KEYRING (lockable);
+ SeahorseGkrKeyring *self = SEAHORSE_GKR_KEYRING (lockable);
GSimpleAsyncResult *res;
res = g_simple_async_result_new (G_OBJECT (lockable), callback, user_data,
seahorse_gkr_keyring_unlock_async);
- gnome_keyring_unlock (seahorse_gkr_keyring_get_name (keyring), NULL,
+ gnome_keyring_unlock (seahorse_gkr_keyring_get_name (self), NULL,
on_keyring_xlock_done, g_object_ref (res), g_object_unref);
g_object_unref (res);
diff --git a/libseahorse/seahorse-collection.c b/libseahorse/seahorse-collection.c
index 98f05da..936a346 100644
--- a/libseahorse/seahorse-collection.c
+++ b/libseahorse/seahorse-collection.c
@@ -72,14 +72,10 @@ on_object_changed (GObject *obj,
}
static void
-remove_object (gpointer key,
- gpointer value,
- gpointer user_data)
+remove_object (SeahorseCollection *self,
+ GObject *object)
{
- SeahorseCollection *self = SEAHORSE_COLLECTION (user_data);
- GObject *object = G_OBJECT (key);
g_hash_table_remove (self->pv->objects, object);
- g_signal_handlers_disconnect_by_func (object, on_object_changed, self);
remove_update (object, NULL, self);
}
@@ -94,7 +90,6 @@ maybe_add_object (SeahorseCollection *self,
return FALSE;
g_hash_table_replace (self->pv->objects, obj, GINT_TO_POINTER (TRUE));
- g_signal_connect (obj, "notify", G_CALLBACK (on_object_changed), self);
gcr_collection_emit_added (GCR_COLLECTION (self), obj);
return TRUE;
}
@@ -109,7 +104,7 @@ maybe_remove_object (SeahorseCollection *self,
if (self->pv->pred && seahorse_predicate_match (self->pv->pred, obj))
return FALSE;
- remove_object (obj, NULL, self);
+ remove_object (self, obj);
return TRUE;
}
@@ -120,6 +115,7 @@ on_base_added (GcrCollection *base,
{
SeahorseCollection *self = SEAHORSE_COLLECTION (user_data);
+ g_signal_connect (obj, "notify", G_CALLBACK (on_object_changed), self);
maybe_add_object (self, obj);
}
@@ -130,8 +126,10 @@ on_base_removed (GcrCollection *base,
{
SeahorseCollection *self = SEAHORSE_COLLECTION (user_data);
+ g_signal_handlers_disconnect_by_func (object, on_object_changed, self);
+
if (g_hash_table_lookup (self->pv->objects, object))
- remove_object (object, NULL, self);
+ remove_object (self, object);
}
static void
@@ -325,6 +323,8 @@ seahorse_collection_refresh (SeahorseCollection *self)
{
GHashTable *check = g_hash_table_new (g_direct_hash, g_direct_equal);
GList *l, *objects = NULL;
+ GHashTableIter iter;
+ GObject *obj;
g_return_if_fail (SEAHORSE_IS_COLLECTION (self));
@@ -338,12 +338,19 @@ seahorse_collection_refresh (SeahorseCollection *self)
g_hash_table_remove (check, l->data);
/* This will add to set */
- if (!maybe_remove_object (self, l->data))
- maybe_add_object (self, l->data);
+ if (!maybe_remove_object (self, l->data)) {
+ if (maybe_add_object (self, l->data))
+ g_signal_connect (l->data, "notify", G_CALLBACK (on_object_changed), self);
+ }
}
g_list_free (objects);
- g_hash_table_foreach (check, remove_object, self);
+ g_hash_table_iter_init (&iter, check);
+ while (g_hash_table_iter_next (&iter, (gpointer *)&obj, NULL)) {
+ g_signal_handlers_disconnect_by_func (obj, on_object_changed, self);
+ remove_object (self, obj);
+ }
+
g_hash_table_destroy (check);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]