[bijiben] Collections : start fixing deletion



commit 81ea66c9f395a39e8db54f41c94db351fbb37ca7
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Fri May 3 00:36:34 2013 +0200

    Collections : start fixing deletion
    
    Now we have the urn, we should allow to delete a collection

 src/libbiji/biji-collection.c |   23 ++++++++++++++++++++++-
 src/libbiji/biji-note-book.c  |   11 +++++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/libbiji/biji-collection.c b/src/libbiji/biji-collection.c
index e4f1cd6..f0500e8 100644
--- a/src/libbiji/biji-collection.c
+++ b/src/libbiji/biji-collection.c
@@ -46,8 +46,16 @@ enum {
   BIJI_COLL_PROPERTIES
 };
 
+// Signals to be used by biji note obj
+enum {
+  COLLECTION_DELETED,
+  BIJI_COLLECTIONS_SIGNALS
+};
+
 static GParamSpec *properties[BIJI_COLL_PROPERTIES] = { NULL, };
 
+static guint biji_collections_signals [BIJI_COLLECTIONS_SIGNALS] = { 0 };
+
 static gchar *
 biji_collection_get_title (BijiItem *coll)
 {
@@ -194,7 +202,9 @@ biji_collection_trash (BijiItem *item)
   g_return_val_if_fail (BIJI_IS_COLLECTION (item), FALSE);
 
   self = BIJI_COLLECTION (item);
-  biji_remove_collection_from_tracker (self->priv->name);
+
+  g_signal_emit (G_OBJECT (item), biji_collections_signals[COLLECTION_DELETED], 0);
+  biji_remove_collection_from_tracker (self->priv->urn);
   g_object_unref (self);
 
   return TRUE;
@@ -297,6 +307,17 @@ biji_collection_class_init (BijiCollectionClass *klass)
 
   g_object_class_install_properties (g_object_class, BIJI_COLL_PROPERTIES, properties);
 
+  biji_collections_signals[COLLECTION_DELETED] =
+    g_signal_new ("deleted" ,
+                  G_OBJECT_CLASS_TYPE (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL,
+                  NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE,
+                  0);
+
   /* Interface */
   item_class->get_title = biji_collection_get_title;
   item_class->get_uuid = biji_collection_get_uuid;
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index 299c75e..03726b2 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -179,6 +179,14 @@ biji_note_book_notify_changed (BijiNoteBook            *book,
   return FALSE;
 }
 
+/* TODO : use the same for note, put everything there
+ * rather calling a func */
+static void
+on_item_deleted_cb (BijiItem *item, BijiNoteBook *book)
+{
+  biji_note_book_remove_item (book, item);
+}
+
 void
 book_on_note_changed_cb (BijiNoteObj *note, BijiNoteBook *book)
 {
@@ -246,6 +254,9 @@ create_collection_if_needed (gpointer key,
     g_hash_table_insert (book->priv->items,
                          g_strdup (key),
                          collection);
+
+    g_signal_connect (collection, "deleted",
+                      G_CALLBACK (on_item_deleted_cb), book);
   }
 }
 


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