[bijiben] restore: makes the note back into notes
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] restore: makes the note back into notes
- Date: Sun, 2 Mar 2014 22:31:03 +0000 (UTC)
commit 7afa2f0fd0405df28de07f3afd304116adabf437
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sun Mar 2 23:27:10 2014 +0100
restore: makes the note back into notes
When an item is restored, keep track of it.
Add an oldUuid string to ::restored signal so
manager can remove item from trashed table.
src/libbiji/biji-item.c | 16 ++++++++++++----
src/libbiji/biji-item.h | 2 +-
src/libbiji/biji-local-note.c | 3 ++-
src/libbiji/biji-manager.c | 18 ++++++++++++++----
4 files changed, 29 insertions(+), 10 deletions(-)
---
diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
index 6897e0d..8223d73 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -142,9 +142,10 @@ biji_item_class_init (BijiItemClass *klass)
0,
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
- 0);
+ 1,
+ G_TYPE_STRING);
g_type_class_add_private ((gpointer)klass, sizeof (BijiItemPrivate));
}
@@ -261,11 +262,18 @@ gboolean
biji_item_restore (BijiItem *item)
{
gboolean retval;
+ gchar *old_uuid;
+
g_return_val_if_fail (BIJI_IS_ITEM (item), FALSE);
+ old_uuid = NULL;
- retval = BIJI_ITEM_GET_CLASS (item)->restore (item);
+ retval = BIJI_ITEM_GET_CLASS (item)->restore (item, &old_uuid);
if (retval == TRUE)
- g_signal_emit_by_name (item, "restored", NULL);
+ {
+ g_signal_emit_by_name (item, "restored", old_uuid, NULL);
+ if (old_uuid != NULL)
+ g_free (old_uuid);
+ }
return retval;
}
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
index 59d5222..c4dec9b 100644
--- a/src/libbiji/biji-item.h
+++ b/src/libbiji/biji-item.h
@@ -70,7 +70,7 @@ struct BijiItemClass_
gboolean (*has_color) (BijiItem *item);
gboolean (*trash) (BijiItem *item);
- gboolean (*restore) (BijiItem *item);
+ gboolean (*restore) (BijiItem *item, gchar **old_uuid);
gboolean (*delete) (BijiItem *item);
gboolean (*is_collectable) (BijiItem *item);
diff --git a/src/libbiji/biji-local-note.c b/src/libbiji/biji-local-note.c
index 617b03d..9ce6273 100644
--- a/src/libbiji/biji-local-note.c
+++ b/src/libbiji/biji-local-note.c
@@ -205,7 +205,7 @@ local_note_archive (BijiNoteObj *note)
static gboolean
-local_note_restore (BijiItem *item)
+local_note_restore (BijiItem *item, gchar **old_uuid)
{
BijiLocalNote *self;
gchar *root_path, *path;
@@ -239,6 +239,7 @@ local_note_restore (BijiItem *item)
g_error_free (error);
}
+ *old_uuid = g_file_get_path (self->priv->location);
g_object_unref (self->priv->location);
g_object_unref (trash);
g_object_unref (root);
diff --git a/src/libbiji/biji-manager.c b/src/libbiji/biji-manager.c
index d5698db..4630742 100644
--- a/src/libbiji/biji-manager.c
+++ b/src/libbiji/biji-manager.c
@@ -101,11 +101,11 @@ biji_manager_init (BijiManager *self)
priv->archives = g_hash_table_new_full (g_str_hash,
g_str_equal,
NULL,
- g_object_unref);
+ NULL);
/*
* Providers are the different notes storage
* the hash table use an id
- *
+ *
* - local files stored notes = "local"
* - own cloud notes = account_get_id
*/
@@ -298,12 +298,22 @@ on_item_deleted_cb (BijiItem *item, BijiManager *manager)
}
-/* well, works currently : we assume Archives change.
+/*
+ * old uuid : we need this because local provider uses
+ * file name as uuid. Now this proves this is not right.
+ *
+ * notify... BIJI_ARCHIVED_ITEM
+ * well, works currently : we assume Archives change.
* but we might double-ping as well
+ * or improve the whole logic
*/
static void
-on_item_restored_cb (BijiItem *item, BijiManager *manager)
+on_item_restored_cb (BijiItem *item, gchar *old_uuid, BijiManager *manager)
{
+ g_hash_table_insert (manager->priv->items,
+ (gpointer) biji_item_get_uuid (item), item);
+ g_hash_table_remove (manager->priv->archives, old_uuid);
+
biji_manager_notify_changed (manager,
BIJI_ARCHIVED_ITEMS,
BIJI_MANAGER_ITEM_DELETED,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]