[bijiben: 2/11] noteObj: use biji_item_get_* accessors



commit d65f81e44236984d81ce6152ac64a090bae57db8
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Sat Apr 27 09:32:30 2013 +0200

    noteObj: use biji_item_get_* accessors
    
    Title, Uuid, Icon, Emblem, Mtime,
    are provided via parent bijiItem rather directly.

 src/bjb-bijiben.c                                 |    4 +-
 src/bjb-controller.c                              |   79 +++++++++++---------
 src/bjb-main-toolbar.c                            |   12 ++-
 src/bjb-share.c                                   |    2 +-
 src/libbiji/biji-item.c                           |   34 ++++++++-
 src/libbiji/biji-item.h                           |   26 ++++++-
 src/libbiji/biji-note-book.c                      |   11 ++--
 src/libbiji/biji-note-book.h                      |    6 +-
 src/libbiji/biji-note-obj.c                       |   53 ++++++++++----
 src/libbiji/biji-note-obj.h                       |   12 ---
 src/libbiji/biji-tracker.c                        |    9 ++-
 src/libbiji/biji-zeitgeist.c                      |    6 +-
 src/libbiji/deserializer/biji-lazy-deserializer.c |    4 +-
 src/libbiji/serializer/biji-lazy-serializer.c     |    9 ++-
 14 files changed, 170 insertions(+), 97 deletions(-)
---
diff --git a/src/bjb-bijiben.c b/src/bjb-bijiben.c
index 78eae83..322c75e 100644
--- a/src/bjb-bijiben.c
+++ b/src/bjb-bijiben.c
@@ -179,7 +179,7 @@ go_through_notes_cb (GFileEnumerator *enumerator, GAsyncResult *res, Bijiben *se
   for (l = notes_proposal; l != NULL; l = l->next)
   {
     BijiNoteObj *note = l->data;
-    gchar *path = biji_note_obj_get_path (note);
+    gchar *path = biji_item_get_uuid (BIJI_ITEM (note));
 
     /* Don't add an already imported note */
     if (note_book_get_note_at_path (self->priv->book, path))
@@ -192,7 +192,7 @@ go_through_notes_cb (GFileEnumerator *enumerator, GAsyncResult *res, Bijiben *se
     {
       /* Title */
       unique_title = biji_note_book_get_unique_title (self->priv->book,
-                                                      biji_note_obj_get_title (note));
+                                                      biji_item_get_title (BIJI_ITEM (note)));
       biji_note_obj_set_title (note, unique_title);
       g_free (unique_title);
 
diff --git a/src/bjb-controller.c b/src/bjb-controller.c
index 663d95d..3afcb84 100644
--- a/src/bjb-controller.c
+++ b/src/bjb-controller.c
@@ -40,7 +40,7 @@ struct _BjbControllerPrivate
   BjbWindowBase *window;
 
   /*  Private  */
-  GList         *notes_to_show ;
+  GList          *items_to_show;
   gboolean       connected;
   gulong         book_change;
 };
@@ -94,7 +94,7 @@ bjb_controller_init (BjbController *self)
                               G_TYPE_BOOLEAN);   // state
 
   priv->model = GTK_TREE_MODEL(store) ;
-  priv->notes_to_show = NULL;
+  priv->items_to_show = NULL;
   priv->needle = NULL;
   priv->connected = FALSE;
 
@@ -123,7 +123,7 @@ bjb_controller_finalize (GObject *object)
 
   g_object_unref (priv->completion);
   g_free (priv->needle);
-  g_list_free (priv->notes_to_show);
+  g_list_free (priv->items_to_show);
 
   G_OBJECT_CLASS (bjb_controller_parent_class)->finalize (object);
 }
@@ -189,7 +189,9 @@ bjb_controller_add_note (BjbController *self,
   GtkTreeIter    iter;
   GtkListStore  *store;
   GdkPixbuf     *pix = NULL;
-  gchar         *path;
+  gchar         *uuid;
+
+  BijiItem *item = BIJI_ITEM (note);
 
   g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
   store = GTK_LIST_STORE (self->priv->model);
@@ -209,27 +211,27 @@ bjb_controller_add_note (BjbController *self,
         && bjb_window_base_get_main_view (self->priv->window)
         && bjb_main_view_get_view_type
                   (bjb_window_base_get_main_view (self->priv->window)) == GD_MAIN_VIEW_LIST)
-      pix = biji_note_obj_get_emblem (note);
+      pix = biji_item_get_emblem (item);
 
     /* Else, load the icon */
     if (!pix)
-      pix = biji_note_obj_get_icon (note);
+      pix = biji_item_get_icon (item);
 
     /* Appart from pixbuf, both icon & list view types
      * currently use the same model */
-    path = biji_note_obj_get_path (note);
+    uuid = biji_item_get_uuid (item);
 
     gtk_list_store_set (store, &iter,
-         GD_MAIN_COLUMN_ID, path,
-         GD_MAIN_COLUMN_URI, path,
-         GD_MAIN_COLUMN_PRIMARY_TEXT, biji_note_obj_get_title (note),
+         GD_MAIN_COLUMN_ID, uuid,
+         GD_MAIN_COLUMN_URI, uuid,
+         GD_MAIN_COLUMN_PRIMARY_TEXT, biji_item_get_title (item),
          GD_MAIN_COLUMN_SECONDARY_TEXT, NULL,
          GD_MAIN_COLUMN_ICON, pix,
-         GD_MAIN_COLUMN_MTIME, biji_note_obj_get_last_change_date_sec (note),
+         GD_MAIN_COLUMN_MTIME, biji_item_get_last_change (item),
          GD_MAIN_COLUMN_SELECTED, FALSE,
          -1);
 
-    g_free (path);
+    g_free (uuid);
   }
 
 
@@ -246,6 +248,8 @@ bjb_controller_add_note_if_needed (BjbController *self,
   GList *collections, *l;
   BjbControllerPrivate *priv = self->priv;
 
+  BijiItem *item = BIJI_ITEM (note);
+
   /* No note... */
   if (!note || !BIJI_IS_NOTE_OBJ (note))
     return;
@@ -260,7 +264,7 @@ bjb_controller_add_note_if_needed (BjbController *self,
   else
   {
 
-    title = biji_note_obj_get_title (note);
+    title = biji_item_get_title (item);
     content = biji_note_get_raw_text (note);
 
     /* matching title or content ... */
@@ -299,7 +303,7 @@ bjb_controller_update_view (BjbController *self)
   if (bjb_window_base_get_view_type (self->priv->window) != BJB_WINDOW_BASE_MAIN_VIEW)
     return;
 
-  notes = self->priv->notes_to_show ;
+  notes = self->priv->items_to_show ;
   free_notes_store (self);
 
   for (l = notes; l != NULL; l = l->next)
@@ -309,26 +313,26 @@ bjb_controller_update_view (BjbController *self)
 }
 
 static gint
-most_recent_note_first (gconstpointer a, gconstpointer b)
+most_recent_item_first (gconstpointer a, gconstpointer b)
 {
-  BijiNoteObj *one = BIJI_NOTE_OBJ (a);
-  BijiNoteObj *other = BIJI_NOTE_OBJ (b);
+  BijiItem *one = BIJI_ITEM (a);
+  BijiItem *other = BIJI_ITEM (b);
   
-  glong result = biji_note_obj_get_last_change_date_sec (other);
-  return result - biji_note_obj_get_last_change_date_sec (one);
+  glong result = biji_item_get_last_change (other);
+  return result - biji_item_get_last_change (one);
 }
 
 static void
-sort_notes( BjbController *self)
+sort_items (BjbController *self)
 {
-  self->priv->notes_to_show = g_list_sort (self->priv->notes_to_show,
-                                           most_recent_note_first);
+  self->priv->items_to_show = g_list_sort (self->priv->items_to_show,
+                                           most_recent_item_first);
 }
 
 static void
 sort_and_update (BjbController *self)
 {
-  sort_notes (self);
+  sort_items (self);
   bjb_controller_update_view (self);
 
   g_signal_emit (G_OBJECT (self), bjb_controller_signals[DISPLAY_NOTES_CHANGED],0);
@@ -343,7 +347,7 @@ update_controller_callback (GObject *source_object,
   BjbController *self = BJB_CONTROLLER (user_data);
 
   result = biji_get_notes_with_strings_or_collection_finish (source_object, res, self->priv->book);
-  self->priv->notes_to_show = result;
+  self->priv->items_to_show = result;
 
   sort_and_update (self);
 }          
@@ -354,18 +358,18 @@ bjb_controller_apply_needle (BjbController *self)
   BjbControllerPrivate *priv = self->priv;
   gchar *needle;
 
-  if (priv->notes_to_show)
-    g_clear_pointer (&priv->notes_to_show, g_list_free);
+  if (priv->items_to_show)
+    g_clear_pointer (&priv->items_to_show, g_list_free);
   
   needle = priv->needle;
 
   /* Show all notes */
   if (needle == NULL || g_strcmp0 (needle,"") == 0)
   {
-    priv->notes_to_show = biji_note_book_get_notes (self->priv->book);
+    priv->items_to_show = biji_note_book_get_items (self->priv->book);
 
     /* If there are no note, report this */
-    if (!priv->notes_to_show)
+    if (!priv->items_to_show)
       bjb_window_base_switch_to (self->priv->window,
                                  BJB_WINDOW_BASE_NO_NOTE);
 
@@ -392,22 +396,24 @@ add_note_to_completion(BijiNoteObj *note , BjbController *self)
 {
   GtkListStore *store;
   GtkTreeIter iter;
+  BijiItem *item = BIJI_ITEM (note);
 
   store = GTK_LIST_STORE(self->priv->completion);
 
+
   // Search Tag.
   gtk_list_store_append (store, &iter);
   gtk_list_store_set (store, 
                       &iter, 
                       0, 
-                      biji_note_obj_get_title(note),
+                      biji_item_get_title (item),
                       -1);
 }
 
 static void
 refresh_completion(BjbController *self)
 {
-  GList *notes = biji_note_book_get_notes (self->priv->book);
+  GList *notes = biji_note_book_get_items (self->priv->book);
   gtk_list_store_clear(GTK_LIST_STORE(self->priv->completion));
 
   if (notes)
@@ -421,7 +427,7 @@ static gboolean
 bjb_controller_get_iter_at_note (BjbController *self, BijiNoteObj *note, GtkTreeIter **iter)
 {
   BjbControllerPrivate *priv = self->priv;
-  gchar *needle = biji_note_obj_get_path (note);
+  gchar *needle = biji_item_get_uuid (BIJI_ITEM (note));
   gboolean retval = FALSE;
   gboolean still = gtk_tree_model_get_iter_first (priv->model, *iter);
 
@@ -457,6 +463,7 @@ on_book_changed (BijiNoteBook           *book,
 {
   BjbControllerPrivate *priv = self->priv;
   BijiNoteObj *note = BIJI_NOTE_OBJ (note_obj);
+  BijiItem    *item = BIJI_ITEM (note);
   GtkTreeIter iter;
   GtkTreeIter *p_iter = &iter;
 
@@ -466,7 +473,7 @@ on_book_changed (BijiNoteBook           *book,
      * But do not add a new note to a search window */
     case BIJI_BOOK_NOTE_ADDED:
         bjb_controller_add_note_if_needed (self, note, TRUE);
-        priv->notes_to_show = g_list_prepend (priv->notes_to_show, note);
+        priv->items_to_show = g_list_prepend (priv->items_to_show, note);
         g_signal_emit (G_OBJECT (self), bjb_controller_signals[DISPLAY_NOTES_CHANGED],0);
       break;
 
@@ -486,19 +493,19 @@ on_book_changed (BijiNoteBook           *book,
              bjb_window_base_get_main_view (self->priv->window)) == GD_MAIN_VIEW_ICON
           && bjb_controller_get_iter_at_note (self, note, &p_iter))
         gtk_list_store_set (GTK_LIST_STORE (priv->model), p_iter,
-                            GD_MAIN_COLUMN_ICON, biji_note_obj_get_icon (note), -1);
+                            GD_MAIN_COLUMN_ICON, biji_item_get_icon (item), -1);
       else if (bjb_main_view_get_view_type (
              bjb_window_base_get_main_view (self->priv->window)) == GD_MAIN_VIEW_LIST
           && bjb_controller_get_iter_at_note (self, note, &p_iter))
         gtk_list_store_set (GTK_LIST_STORE (priv->model), p_iter,
-                            GD_MAIN_COLUMN_ICON, biji_note_obj_get_emblem (note), -1);
+                            GD_MAIN_COLUMN_ICON, biji_item_get_emblem (item), -1);
       break;
 
     case BIJI_BOOK_NOTE_TRASHED:
       if (bjb_controller_get_iter_at_note (self, note, &p_iter))
         gtk_list_store_remove (GTK_LIST_STORE (priv->model), p_iter);
 
-      priv->notes_to_show = g_list_remove (priv->notes_to_show, note);
+      priv->items_to_show = g_list_remove (priv->items_to_show, note);
       g_signal_emit (G_OBJECT (self), bjb_controller_signals[DISPLAY_NOTES_CHANGED],0);
       break;
 
@@ -664,7 +671,7 @@ bjb_controller_get_completion(BjbController *self)
 gboolean
 bjb_controller_shows_notes (BjbController *self)
 {
-  if (self->priv->notes_to_show)
+  if (self->priv->items_to_show)
     return TRUE;
 
   return FALSE;
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index ac7bafa..96f9d2e 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -425,7 +425,7 @@ on_note_renamed (BijiNoteObj *note,
 {
   gd_main_toolbar_set_labels (
             GD_MAIN_TOOLBAR (self),
-            biji_note_obj_get_title (note),
+            biji_item_get_title (BIJI_ITEM (note)),
             NULL);
 }
 
@@ -487,18 +487,20 @@ delete_item_callback (GtkWidget *item, gpointer user_data)
 }
 
 static void
-action_rename_note_callback (GtkWidget *item, gpointer user_data)
+action_rename_note_callback (GtkWidget *w, gpointer user_data)
 {
   BjbMainToolbar        *bar;
   BjbMainToolbarPrivate *priv;
   gchar                 *title;
+  BijiItem *item;
 
   bar = BJB_MAIN_TOOLBAR (user_data);
   priv = bar->priv;
+  item = BIJI_ITEM (priv->note);
 
   title = note_title_dialog (priv->window,
                              _("Rename Note"),
-                             biji_note_obj_get_title (priv->note));
+                             biji_item_get_title (item));
 
   if (!title)
     return;
@@ -592,8 +594,10 @@ populate_bar_for_note_view (BjbMainToolbar *self)
   BjbSettings           *settings;
   GtkWidget             *grid, *notes_icon, *notes_label, *button;
   GdkRGBA                color;
+  BijiItem *item;
 
   priv->note = bjb_window_base_get_note (BJB_WINDOW_BASE (self->priv->window));
+  item = BIJI_ITEM (priv->note);
 
   if (!priv->note) /* no reason this would happen */
     return;
@@ -620,7 +624,7 @@ populate_bar_for_note_view (BjbMainToolbar *self)
                               GDK_KEY_w, GDK_CONTROL_MASK, GTK_ACCEL_MASK);
 
   /* Note Title */
-  gd_main_toolbar_set_labels (bar, biji_note_obj_get_title (priv->note), NULL);
+  gd_main_toolbar_set_labels (bar, biji_item_get_title (item), NULL);
 
   self->priv->note_renamed = g_signal_connect (priv->note,"renamed",
                                     G_CALLBACK (on_note_renamed), self);
diff --git a/src/bjb-share.c b/src/bjb-share.c
index dc5c25e..4a243fc 100644
--- a/src/bjb-share.c
+++ b/src/bjb-share.c
@@ -33,7 +33,7 @@ on_email_note_callback(GtkWidget *widget, BijiNoteObj *note)
   error = NULL;
   gchar *title_mail, *text_mail;
 
-  title_mail = mail_str (biji_note_obj_get_title (note));
+  title_mail = mail_str (biji_item_get_title (BIJI_ITEM (note)));
   text_mail = mail_str (biji_note_get_raw_text (note));
 
   gchar *execute[7] = { "xdg-email",
diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
index d30a81c..f59bbfb 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -45,12 +45,8 @@ biji_item_class_init (BijiItemClass *klass)
 static void
 biji_item_finalize (GObject *object)
 {
-  BijiItem *self;
-
   g_return_if_fail (BIJI_IS_ITEM (object));
 
-  self = BIJI_ITEM (object);
-
   G_OBJECT_CLASS (biji_item_parent_class)->finalize (object);
 }
 
@@ -67,3 +63,33 @@ biji_item_new (void)
 {
   return g_object_new (BIJI_TYPE_ITEM, NULL);
 }
+
+gchar *
+biji_item_get_title         (BijiItem *item)
+{
+  return BIJI_ITEM_GET_CLASS (item)->get_title (item);
+}
+
+gchar *
+biji_item_get_uuid          (BijiItem *item)
+{
+  return BIJI_ITEM_GET_CLASS (item)->get_uuid (item);
+}
+
+GdkPixbuf *
+biji_item_get_icon          (BijiItem *item)
+{
+  return BIJI_ITEM_GET_CLASS (item)->get_icon (item);
+}
+
+GdkPixbuf *
+biji_item_get_emblem        (BijiItem *item)
+{
+  return BIJI_ITEM_GET_CLASS (item)->get_emblem (item);
+}
+
+glong
+biji_item_get_last_change    (BijiItem *item)
+{
+  return BIJI_ITEM_GET_CLASS (item)->get_change_sec (item);
+}
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
index 682e1af..e20ace7 100644
--- a/src/libbiji/biji-item.h
+++ b/src/libbiji/biji-item.h
@@ -22,6 +22,7 @@
 #define BIJI_ITEM_H_ 1
 
 #include <glib-object.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
@@ -36,23 +37,42 @@ typedef struct BijiItem_         BijiItem;
 typedef struct BijiItemClass_    BijiItemClass;
 typedef struct BijiItemPrivate_  BijiItemPrivate;
 
+/* Libbiji base interface
+ * NoteBook provides items
+ * Items might be NoteObj or Collections */
+
 struct BijiItem_
 {
   GObject parent;
-  /* add your public declarations here */
+
   BijiItemPrivate *priv;
 };
 
 struct BijiItemClass_
 {
   GObjectClass parent_class;
-};
 
+  gchar *       (*get_title)            (BijiItem *item);
+  gchar *       (*get_uuid)             (BijiItem *item);
+  GdkPixbuf *   (*get_icon)             (BijiItem *item);
+  GdkPixbuf *   (*get_emblem)           (BijiItem *item);
+  glong         (*get_change_sec)       (BijiItem *item);
+};
 
 GType biji_item_get_type (void);
 
-GObject *biji_item_new (void);
+GObject * biji_item_new (void);
+
+gchar *          biji_item_get_title           (BijiItem *item);
+
+/* NoteObj uuid is a location */
+gchar *          biji_item_get_uuid            (BijiItem *item);
+
+GdkPixbuf *      biji_item_get_icon            (BijiItem *item);
+
+GdkPixbuf *      biji_item_get_emblem          (BijiItem *item);
 
+glong            biji_item_get_last_change     (BijiItem *item);
 
 G_END_DECLS
 
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index 22a5f73..c78fcf0 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -132,7 +132,7 @@ title_is_unique (BijiNoteBook *book,gchar *title)
   {
     iter = BIJI_NOTE_OBJ (l->data);
 
-    if (g_strcmp0 (biji_note_obj_get_title (iter), title) == 0)
+    if (g_strcmp0 (biji_item_get_title (BIJI_ITEM (iter)), title) == 0)
     {
      is_unique = FALSE;
      break;
@@ -198,7 +198,7 @@ _biji_note_book_add_one_note(BijiNoteBook *book,BijiNoteObj *note)
 
   // Add it to the list and emit signal
   g_hash_table_insert (book->priv->notes,
-                       biji_note_obj_get_path (note), note);
+                       biji_item_get_uuid (BIJI_ITEM (note)), note);
 
   g_signal_connect (note, "changed", G_CALLBACK (book_on_note_changed_cb), book);
   g_signal_connect (note, "renamed", G_CALLBACK (book_on_note_changed_cb), book);
@@ -378,7 +378,7 @@ biji_note_book_remove_note (BijiNoteBook *book, BijiNoteObj *note)
   gchar *path;
   gboolean retval = FALSE;
 
-  path = biji_note_obj_get_path (note);
+  path = biji_item_get_uuid (BIJI_ITEM (note));
   to_delete = g_hash_table_lookup (book->priv->notes, path);
 
   if (to_delete)
@@ -411,9 +411,10 @@ biji_note_book_append_new_note (BijiNoteBook *book, BijiNoteObj *note, gboolean
   if (notify)
     biji_note_book_notify_changed (book, BIJI_BOOK_NOTE_ADDED, note);
 }
- 
+
+// TODO : also return collections
 GList *
-biji_note_book_get_notes (BijiNoteBook *book)
+biji_note_book_get_items (BijiNoteBook *book)
 {
   return g_hash_table_get_values (book->priv->notes);
 }
diff --git a/src/libbiji/biji-note-book.h b/src/libbiji/biji-note-book.h
index 05b2062..eee9f9a 100644
--- a/src/libbiji/biji-note-book.h
+++ b/src/libbiji/biji-note-book.h
@@ -61,9 +61,9 @@ gboolean biji_note_book_remove_note (BijiNoteBook *book,BijiNoteObj *note);
 
 BijiNoteObj * note_book_get_note_at_path(BijiNoteBook *book,gchar *path);
 
-/* GList return values should be freed, and never the content */
-
-GList * biji_note_book_get_notes (BijiNoteBook *book);
+/* Get all items, either notes or collections
+ * Free the GList, not its content */
+GList * biji_note_book_get_items (BijiNoteBook *book);
 
 /* New Notes */
 BijiNoteObj* biji_note_get_new_from_file (const gchar* tomboy_format_note_path);
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index bc895b0..c509c6f 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -86,6 +86,13 @@ static GParamSpec *properties[BIJI_OBJ_PROPERTIES] = { NULL, };
 
 G_DEFINE_TYPE (BijiNoteObj, biji_note_obj, BIJI_TYPE_ITEM);
 
+/* BijiItem iface */
+static gchar     * biji_note_obj_get_title                (BijiItem *note);
+static gchar     * biji_note_obj_get_path                 (BijiItem *note);
+static GdkPixbuf * biji_note_obj_get_icon                 (BijiItem *note);
+static GdkPixbuf * biji_note_obj_get_emblem               (BijiItem *note);
+static glong       biji_note_obj_get_last_change_date_sec (BijiItem *note);
+
 static void
 on_save_timeout (BijiNoteObj *self)
 {
@@ -230,7 +237,8 @@ biji_note_obj_get_property (GObject    *object,
 static void
 biji_note_obj_class_init (BijiNoteObjClass *klass)
 {
-  GObjectClass* object_class = G_OBJECT_CLASS (klass);
+  BijiItemClass*  item_class = BIJI_ITEM_CLASS (klass);
+  GObjectClass* object_class = G_OBJECT_CLASS  (klass);
 
   object_class->constructed = biji_note_obj_constructed;
   object_class->finalize = biji_note_obj_finalize;
@@ -287,6 +295,13 @@ biji_note_obj_class_init (BijiNoteObjClass *klass)
                                                   0);
 
   g_type_class_add_private (klass, sizeof (BijiNoteObjPrivate));
+
+  /* Interface */
+  item_class->get_title = biji_note_obj_get_title;
+  item_class->get_uuid = biji_note_obj_get_path;
+  item_class->get_icon = biji_note_obj_get_icon;
+  item_class->get_emblem = biji_note_obj_get_emblem;
+  item_class->get_change_sec = biji_note_obj_get_last_change_date_sec;
 }
 
 BijiNoteObj *
@@ -403,11 +418,14 @@ biji_note_obj_trash (BijiNoteObj *note_to_kill)
   return result;
 }
 
-gchar* biji_note_obj_get_path (BijiNoteObj* n)
+static gchar *
+biji_note_obj_get_path (BijiItem *item)
 {
-  g_return_val_if_fail (BIJI_IS_NOTE_OBJ (n), NULL);
+  g_return_val_if_fail (BIJI_IS_NOTE_OBJ (item), NULL);
+
+  BijiNoteObj *note = BIJI_NOTE_OBJ (item);
 
-  return biji_note_id_get_path(n->priv->id) ;
+  return biji_note_id_get_path (note->priv->id);
 }
 
 BijiNoteID* note_get_id(BijiNoteObj* n)
@@ -415,12 +433,12 @@ BijiNoteID* note_get_id(BijiNoteObj* n)
   return n->priv->id;
 }
 
-gchar *
-biji_note_obj_get_title(BijiNoteObj *obj)
+static gchar *
+biji_note_obj_get_title (BijiItem *note)
 {
-  g_return_val_if_fail (BIJI_IS_NOTE_OBJ(obj), NULL);
+  g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL);
 
-  return biji_note_id_get_title (obj->priv->id);
+  return biji_note_id_get_title (BIJI_NOTE_OBJ (note)->priv->id);
 }
 
 /* If already a title, then note is renamed */
@@ -478,10 +496,12 @@ biji_note_obj_set_last_change_date (BijiNoteObj* n,gchar* date)
   return biji_note_id_set_last_change_date (n->priv->id,date);
 }
 
-glong 
-biji_note_obj_get_last_change_date_sec ( BijiNoteObj *n )
+static glong
+biji_note_obj_get_last_change_date_sec (BijiItem *item)
 {
-  return biji_note_id_get_last_change_date_sec(note_get_id(n)); 
+  BijiNoteObj *n = BIJI_NOTE_OBJ (item);
+
+  return biji_note_id_get_last_change_date_sec(note_get_id(n));
 }
 
 gchar *
@@ -712,8 +732,8 @@ biji_note_obj_set_icon (BijiNoteObj *note, GdkPixbuf *pix)
     g_warning ("Cannot use _set_icon_ with iconified note. This has no sense.");
 }
 
-GdkPixbuf *
-biji_note_obj_get_icon (BijiNoteObj *note)
+static GdkPixbuf *
+biji_note_obj_get_icon (BijiItem *item)
 {
   GdkRGBA               note_color;
   gchar                 *text;
@@ -724,6 +744,8 @@ biji_note_obj_get_icon (BijiNoteObj *note)
   cairo_surface_t       *surface = NULL;
   GtkBorder              frame_slice = { 4, 3, 3, 6 };
 
+  BijiNoteObj *note = BIJI_NOTE_OBJ (item);
+
   if (note->priv->icon && !note->priv->icon_needs_update)
     return note->priv->icon;
 
@@ -779,12 +801,13 @@ biji_note_obj_get_icon (BijiNoteObj *note)
   return note->priv->icon;
 }
 
-GdkPixbuf *
-biji_note_obj_get_emblem (BijiNoteObj *note)
+static GdkPixbuf *
+biji_note_obj_get_emblem (BijiItem *item)
 {
   GdkRGBA                note_color;
   cairo_t               *cr;
   cairo_surface_t       *surface = NULL;
+  BijiNoteObj           *note = BIJI_NOTE_OBJ (item);
 
   if (note->priv->emblem && !note->priv->emblem_needs_update)
     return note->priv->emblem;
diff --git a/src/libbiji/biji-note-obj.h b/src/libbiji/biji-note-obj.h
index aa05e88..cd1fa7e 100644
--- a/src/libbiji/biji-note-obj.h
+++ b/src/libbiji/biji-note-obj.h
@@ -79,20 +79,14 @@ gboolean biji_note_obj_are_same(BijiNoteObj *a, BijiNoteObj* b);
 
 ///////////////////////////////////////////////////////////////////// Metadata 
 
-gchar * biji_note_obj_get_title (BijiNoteObj *obj);
-
 /* will enter hit make title renamed? */
 gboolean biji_note_obj_title_survives (BijiNoteObj *note);
 void biji_note_obj_set_title_survives (BijiNoteObj *obj, gboolean value);
 
-gchar* biji_note_obj_get_path (BijiNoteObj *n);
-
 gboolean biji_note_obj_set_last_change_date (BijiNoteObj* n,gchar* date);
 
 void biji_note_obj_set_last_change_date_now (BijiNoteObj* n) ;
 
-glong biji_note_obj_get_last_change_date_sec ( BijiNoteObj *n );
-
 gchar * biji_note_obj_get_last_change_date_string (BijiNoteObj *self);
 
 gchar * biji_note_obj_get_last_metadata_change_date (BijiNoteObj *note);
@@ -124,18 +118,12 @@ gboolean biji_note_obj_add_collection (BijiNoteObj *note, gchar *label, gboolean
 
 gboolean biji_note_obj_remove_collection (BijiNoteObj *note, gchar *label, gchar *urn);
 
-///////////////////////////////////////////////////////////////////  templates
 gboolean note_obj_is_template(BijiNoteObj *n) ;
 
 void note_obj_set_is_template(BijiNoteObj *n,gboolean is_template);
 
-/////////////////////////////////////////////////////////////////// Save
 void biji_note_obj_save_note (BijiNoteObj *self);
 
-GdkPixbuf * biji_note_obj_get_icon (BijiNoteObj *note);
-
-GdkPixbuf * biji_note_obj_get_emblem (BijiNoteObj *note);
-
 void biji_note_obj_set_icon (BijiNoteObj *note, GdkPixbuf *pix);
 
 gchar *biji_note_obj_get_icon_file (BijiNoteObj *note);
diff --git a/src/libbiji/biji-tracker.c b/src/libbiji/biji-tracker.c
index 4356d8f..786ed3a 100644
--- a/src/libbiji/biji-tracker.c
+++ b/src/libbiji/biji-tracker.c
@@ -15,6 +15,7 @@
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "biji-item.h"
 #include "biji-tracker.h"
 
 /* To perform something after async tracker query */
@@ -139,7 +140,7 @@ get_note_url (BijiNoteObj *note)
 {
   gchar *path, *retval;
 
-  path = biji_note_obj_get_path (note);
+  path = biji_item_get_uuid (BIJI_ITEM (note));
   retval = g_strdup_printf ("file://%s", path);
   g_free (path);
   return retval;
@@ -312,7 +313,7 @@ biji_note_delete_from_tracker (BijiNoteObj *note)
 {
   gchar *query, *path;
 
-  path = biji_note_obj_get_path (note);
+  path = biji_item_get_uuid (BIJI_ITEM (note));
   query = g_strdup_printf ("DELETE { <%s> a rdfs:Resource }", path);
   g_free (path);
 
@@ -324,8 +325,8 @@ bijiben_push_note_to_tracker (BijiNoteObj *note)
 {
   gchar *title,*content,*file,*date, *create_date,*last_change_date, *path;
 
-  path = biji_note_obj_get_path (note);    
-  title = tracker_str (biji_note_obj_get_title (note));
+  path = biji_item_get_uuid (BIJI_ITEM (note));
+  title = tracker_str (biji_item_get_title (BIJI_ITEM (note)));
   file = g_strdup_printf ("file://%s", path);
 
   date = biji_note_obj_get_create_date (note);
diff --git a/src/libbiji/biji-zeitgeist.c b/src/libbiji/biji-zeitgeist.c
index 9b31467..ba5e9c2 100644
--- a/src/libbiji/biji-zeitgeist.c
+++ b/src/libbiji/biji-zeitgeist.c
@@ -31,14 +31,14 @@ get_log (void)
 }
 
 void 
-insert_zeitgeist(BijiNoteObj *note, const char *action)
+insert_zeitgeist (BijiNoteObj *note, const char *action)
 {
   gchar *uri, *path;
   ZeitgeistEvent     *event;
   ZeitgeistSubject   *subject ;
   ZeitgeistLog       *log = get_log() ;
 
-  path = biji_note_obj_get_path (note);
+  path = biji_item_get_uuid (BIJI_ITEM (note));
   uri = g_strdup_printf ("file://%s", path);
   g_free (path);
 
@@ -47,7 +47,7 @@ insert_zeitgeist(BijiNoteObj *note, const char *action)
                                         ZEITGEIST_NFO_FILE_DATA_OBJECT, //mani
                                         "application/x-note",           //mime
                                         "",                             //origin
-                                        biji_note_obj_get_title (note),     //text
+                                        biji_item_get_title (BIJI_ITEM (note)),     //text
                                         "") ;                           //storage
 
   g_free (uri);
diff --git a/src/libbiji/deserializer/biji-lazy-deserializer.c 
b/src/libbiji/deserializer/biji-lazy-deserializer.c
index d381566..7985ac2 100644
--- a/src/libbiji/deserializer/biji-lazy-deserializer.c
+++ b/src/libbiji/deserializer/biji-lazy-deserializer.c
@@ -523,7 +523,7 @@ biji_lazy_deserialize_internal (BijiLazyDeserializer *self)
   xmlNodePtr cur;
   xmlChar     *version; 
 
-  path = biji_note_obj_get_path (n);
+  path = biji_item_get_uuid (BIJI_ITEM (n));
   doc = xmlParseFile (path);
   g_free (path);
 
@@ -581,7 +581,7 @@ biji_lazy_deserialize_internal (BijiLazyDeserializer *self)
 
   xmlFree (version);
 
-  path = biji_note_obj_get_path (n);
+  path = biji_item_get_uuid (BIJI_ITEM (n));
   self->priv->r = xmlNewTextReaderFilename (path);
   g_free (path);
   biji_parse_file (self);
diff --git a/src/libbiji/serializer/biji-lazy-serializer.c b/src/libbiji/serializer/biji-lazy-serializer.c
index 9c6c558..1da1080 100644
--- a/src/libbiji/serializer/biji-lazy-serializer.c
+++ b/src/libbiji/serializer/biji-lazy-serializer.c
@@ -21,6 +21,7 @@
 #include <string.h>
 
 #include "biji-lazy-serializer.h"
+#include "../biji-item.h"
 #include "../biji-note-obj.h"
 #include "../biji-string.h"
 
@@ -188,7 +189,9 @@ biji_lazy_serialize_internal (BijiLazySerializer *self)
                                  BAD_CAST "http://projects.gnome.org/bijiben";);
 
   // <Title>
-  serialize_node (priv->writer, "title", biji_note_obj_get_title (priv->note));
+  serialize_node (priv->writer,
+                  "title",
+                  biji_item_get_title (BIJI_ITEM (priv->note)));
 
   // <text> 
   xmlTextWriterWriteRaw(priv->writer, BAD_CAST "\n  ");
@@ -244,7 +247,7 @@ biji_lazy_serialize_internal (BijiLazySerializer *self)
 
   xmlFreeTextWriter(priv->writer);
 
-  path = biji_note_obj_get_path (priv->note);
+  path = biji_item_get_uuid (BIJI_ITEM (priv->note));
   retval = g_file_set_contents (path, (gchar*) priv->buf->content, -1, NULL);
   g_free (path);
   return retval;
@@ -260,7 +263,7 @@ biji_note_obj_save_icon (BijiNoteObj *note)
 
   /* Png */
   filename = biji_note_obj_get_icon_file (note);
-  gdk_pixbuf_save (biji_note_obj_get_icon (note), filename, "png", &error, NULL);
+  gdk_pixbuf_save (biji_item_get_icon (BIJI_ITEM (note)), filename, "png", &error, NULL);
 
   if (error)
   {


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