[bijiben: 5/11] Items: start fixing func accessing both notes & collections
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben: 5/11] Items: start fixing func accessing both notes & collections
- Date: Sun, 28 Apr 2013 23:14:42 +0000 (UTC)
commit 0a84c72a5f25bd3cf55faef236133207b045d12f
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sun Apr 28 05:56:41 2013 +0200
Items: start fixing func accessing both notes & collections
Now that collections appear on the main view,
the callbacks should work with both cases
src/bjb-bijiben.c | 2 +-
src/bjb-main-toolbar.c | 4 +-
src/bjb-main-view.c | 79 +++++++++++++++++++++++------------------
src/bjb-main-view.h | 8 ++--
src/bjb-note-tag-dialog.c | 46 ++++++++++++------------
src/bjb-selection-toolbar.c | 8 ++--
src/libbiji/biji-collection.c | 24 ++++++++++--
src/libbiji/biji-item.c | 12 +++++--
src/libbiji/biji-item.h | 19 +++-------
src/libbiji/biji-note-book.c | 17 +++------
src/libbiji/biji-note-book.h | 4 +-
src/libbiji/biji-note-obj.c | 27 ++++++++------
src/libbiji/biji-note-obj.h | 4 --
src/libbiji/biji-tracker.c | 8 ++--
14 files changed, 139 insertions(+), 123 deletions(-)
---
diff --git a/src/bjb-bijiben.c b/src/bjb-bijiben.c
index 322c75e..0a9b37f 100644
--- a/src/bjb-bijiben.c
+++ b/src/bjb-bijiben.c
@@ -182,7 +182,7 @@ go_through_notes_cb (GFileEnumerator *enumerator, GAsyncResult *res, Bijiben *se
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))
+ if (biji_note_book_get_item_at_path (self->priv->book, path))
{
abort_note (note);
}
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 99ea59c..8b023b9 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -481,9 +481,9 @@ delete_item_callback (GtkWidget *item, gpointer user_data)
/* Delete the note from collection
* The deleted note will emit a signal. */
- biji_note_book_remove_note (
+ biji_note_book_remove_item (
bjb_window_base_get_book (GTK_WIDGET (self->priv->window)),
- self->priv->note);
+ BIJI_ITEM (self->priv->note));
}
static void
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index 3d9616c..40ba9d8 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -201,20 +201,25 @@ show_window_if_note (gpointer data, gpointer user_data)
}
static void
-switch_to_note (BjbMainView *view, BijiNoteObj *to_open)
+switch_to_note (BjbMainView *view, BijiItem *to_open)
{
- /* If the note is already opened in another window, just show it. */
- if (biji_note_obj_is_opened (to_open))
+ if (BIJI_IS_NOTE_OBJ (to_open))
{
- GList *notes ;
+ /* If the note is already opened in another window, just show it. */
+ if (biji_note_obj_is_opened (BIJI_NOTE_OBJ (to_open)))
+ {
+ GList *notes ;
+
+ notes = gtk_application_get_windows(GTK_APPLICATION(g_application_get_default()));
+ g_list_foreach (notes, show_window_if_note, to_open);
+ return ;
+ }
- notes = gtk_application_get_windows(GTK_APPLICATION(g_application_get_default()));
- g_list_foreach (notes, show_window_if_note, to_open);
- return ;
+ /* Otherwise, leave main view */
+ switch_to_note_view (view, BIJI_NOTE_OBJ (to_open));
}
- /* Otherwise, leave main view */
- switch_to_note_view(view,to_open);
+ /* TODO : coll */
}
static GList *
@@ -238,7 +243,7 @@ get_note_url_from_tree_path(GtkTreePath *path, BjbMainView *self)
}
void
-action_tag_selected_notes (GtkWidget *w, BjbMainView *view)
+action_tag_selected_items (GtkWidget *w, BjbMainView *view)
{
GList *notes = NULL;
GList *paths, *l;
@@ -249,7 +254,7 @@ action_tag_selected_notes (GtkWidget *w, BjbMainView *view)
for (l=paths ; l != NULL ; l=l->next)
{
gchar *url = get_note_url_from_tree_path (l->data, view) ;
- notes = g_list_prepend (notes, note_book_get_note_at_path
+ notes = g_list_prepend (notes, biji_note_book_get_item_at_path
(bjb_window_base_get_book(view->priv->window),url));
g_free (url);
}
@@ -260,26 +265,29 @@ action_tag_selected_notes (GtkWidget *w, BjbMainView *view)
}
gboolean
-bjb_main_view_get_selected_notes_color (BjbMainView *view, GdkRGBA *color)
+bjb_main_view_get_selected_items_color (BjbMainView *view, GdkRGBA *color)
{
GList *paths;
gchar *url;
- BijiNoteObj *note;
+ BijiItem *item;
/* GtkTreePath */
paths = get_selected_paths(view);
url = get_note_url_from_tree_path (paths->data, view) ;
- note = note_book_get_note_at_path (bjb_window_base_get_book(view->priv->window), url);
+ item = biji_note_book_get_item_at_path (bjb_window_base_get_book(view->priv->window), url);
g_free (url);
g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
- return biji_note_obj_get_rgba (note, color);
+ if (BIJI_IS_NOTE_OBJ (item))
+ return biji_note_obj_get_rgba (BIJI_NOTE_OBJ (item), color);
+
+ return FALSE;
}
void
-action_color_selected_notes (GtkWidget *w, BjbMainView *view)
+action_color_selected_items (GtkWidget *w, BjbMainView *view)
{
- GList *notes = NULL ;
+ GList *items = NULL ;
GList *paths, *l;
GdkRGBA color;
@@ -291,25 +299,26 @@ action_color_selected_notes (GtkWidget *w, BjbMainView *view)
for (l=paths ; l != NULL ; l=l->next)
{
gchar *url = get_note_url_from_tree_path (l->data, view) ;
- notes = g_list_prepend (notes, note_book_get_note_at_path
+ items = g_list_prepend (items, biji_note_book_get_item_at_path
(bjb_window_base_get_book(view->priv->window),url));
g_free (url);
}
g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
- for (l=notes ; l != NULL ; l=l->next)
+ for (l=items ; l != NULL ; l=l->next)
{
- biji_note_obj_set_rgba (BIJI_NOTE_OBJ (l->data), &color);
+ if (BIJI_IS_NOTE_OBJ (l->data))
+ biji_note_obj_set_rgba (BIJI_NOTE_OBJ (l->data), &color);
}
- g_list_free (notes);
+ g_list_free (items);
}
void
-action_delete_selected_notes(GtkWidget *w,BjbMainView *view)
+action_delete_selected_items (GtkWidget *w, BjbMainView *view)
{
- GList *notes = NULL;
+ GList *items = NULL;
GList *paths, *l;
/* GtkTreePath */
@@ -318,20 +327,20 @@ action_delete_selected_notes(GtkWidget *w,BjbMainView *view)
for (l=paths ; l != NULL ; l=l->next)
{
gchar *url = get_note_url_from_tree_path (l->data, view) ;
- notes = g_list_prepend (notes, note_book_get_note_at_path
+ items = g_list_prepend (items, biji_note_book_get_item_at_path
(bjb_window_base_get_book(view->priv->window),url));
g_free (url);
}
g_list_free_full (paths, (GDestroyNotify) gtk_tree_path_free);
- for (l=notes ; l != NULL ; l=l->next)
+ for (l=items ; l != NULL ; l=l->next)
{
- biji_note_book_remove_note (bjb_window_base_get_book (view->priv->window),
- BIJI_NOTE_OBJ (l->data));
+ biji_note_book_remove_item (bjb_window_base_get_book (view->priv->window),
+ BIJI_ITEM (l->data));
}
- g_list_free (notes);
+ g_list_free (items);
}
static void
@@ -388,13 +397,13 @@ on_key_press_event_cb (GtkWidget *widget,
}
static gboolean
-on_item_activated(GdMainView * gd,
- const gchar * id,
- const GtkTreePath * path,
- BjbMainView * view)
+on_item_activated (GdMainView * gd,
+ const gchar * id,
+ const GtkTreePath * path,
+ BjbMainView * view)
{
BijiNoteBook * book ;
- BijiNoteObj * to_open ;
+ BijiItem * to_open ;
GtkTreeIter iter ;
gchar * note_path ;
GtkTreeModel * model ;
@@ -406,7 +415,7 @@ on_item_activated(GdMainView * gd,
/* Switch to that note */
book = bjb_window_base_get_book (view->priv->window);
- to_open = note_book_get_note_at_path (book, note_path);
+ to_open = biji_note_book_get_item_at_path (book, note_path);
g_free (note_path);
switch_to_note (view, to_open);
diff --git a/src/bjb-main-view.h b/src/bjb-main-view.h
index e4a3889..d3155b8 100644
--- a/src/bjb-main-view.h
+++ b/src/bjb-main-view.h
@@ -62,13 +62,13 @@ void action_new_window_callback(GtkAction *action, gpointer bjb_main_view);
/* Currently it simply looks for first selected note found. Maybe most common color?
* Or use default color when several ones including at least one default color?*/
-gboolean bjb_main_view_get_selected_notes_color (BjbMainView *view, GdkRGBA *color);
+gboolean bjb_main_view_get_selected_items_color (BjbMainView *view, GdkRGBA *color);
-void action_color_selected_notes (GtkWidget *w,BjbMainView *view);
+void action_color_selected_items (GtkWidget *w,BjbMainView *view);
-void action_tag_selected_notes (GtkWidget *w, BjbMainView *view);
+void action_tag_selected_items (GtkWidget *w, BjbMainView *view);
-void action_delete_selected_notes(GtkWidget *w,BjbMainView *view);
+void action_delete_selected_items (GtkWidget *w,BjbMainView *view);
gboolean bjb_main_view_get_iter_at_note (BjbMainView *view,
BijiNoteObj *note,
diff --git a/src/bjb-note-tag-dialog.c b/src/bjb-note-tag-dialog.c
index 1d2351c..9590f60 100644
--- a/src/bjb-note-tag-dialog.c
+++ b/src/bjb-note-tag-dialog.c
@@ -41,7 +41,7 @@ enum
{
PROP_0,
PROP_WINDOW,
- PROP_NOTES,
+ PROP_ITEMS,
NUM_PROPERTIES
};
@@ -57,16 +57,16 @@ struct _BjbNoteTagDialogPrivate
GtkTreeView * view;
// data
- GList *notes;
+ GList *items;
GtkListStore *store;
GHashTable *collections;
-
+
// tmp when a new tag added
gchar *tag_to_scroll_to;
// tmp for convenience, when a tag is toggled
gchar *toggled_collection;
-
+
};
#define BJB_NOTE_TAG_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BJB_TYPE_NOTE_TAG_DIALOG,
BjbNoteTagDialogPrivate))
@@ -79,24 +79,24 @@ append_tag (gchar *tag, BjbNoteTagDialog *self)
BjbNoteTagDialogPrivate *priv = self->priv;
GtkTreeIter iter;
- gint note_has_tag;
+ gint item_has_tag;
GList *l;
gtk_list_store_append (priv->store, &iter);
- note_has_tag = biji_note_obj_has_collection (priv->notes->data, tag);
+ item_has_tag = biji_item_has_collection (priv->items->data, tag);
/* Check if other notes have the same */
- for (l = priv->notes; l != NULL; l = l->next)
+ for (l = priv->items; l != NULL; l = l->next)
{
- if (biji_note_obj_has_collection (l->data, tag) != note_has_tag)
+ if (biji_item_has_collection (l->data, tag) != item_has_tag)
{
- note_has_tag = SELECTION_INCONSISTENT;
+ item_has_tag = SELECTION_INCONSISTENT;
break;
}
}
gtk_list_store_set (priv->store, &iter,
- COL_SELECTION, note_has_tag,
+ COL_SELECTION, item_has_tag,
COL_TAG_NAME , tag, -1);
}
@@ -239,12 +239,12 @@ on_tag_toggled (GtkCellRendererToggle *cell,
if (toggle_item == SELECTION_INCONSISTENT || toggle_item == SELECTION_FALSE)
{
- g_list_foreach (priv->notes, note_dialog_add_tag, tag);
+ g_list_foreach (priv->items, note_dialog_add_tag, tag);
toggle_item = SELECTION_TRUE;
}
else
{
- g_list_foreach (priv->notes, note_dialog_remove_tag, self);
+ g_list_foreach (priv->items, note_dialog_remove_tag, self);
toggle_item = SELECTION_FALSE;
}
@@ -260,7 +260,7 @@ on_new_collection_created_cb (gpointer user_data)
BjbNoteTagDialogPrivate *priv = self->priv;
priv->tag_to_scroll_to = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry)));
- g_list_foreach (priv->notes, note_dialog_add_tag, priv->tag_to_scroll_to);
+ g_list_foreach (priv->items, note_dialog_add_tag, priv->tag_to_scroll_to);
update_collections_model_async (self);
gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
@@ -335,7 +335,7 @@ bjb_note_tag_dialog_init (BjbNoteTagDialog *self)
BjbNoteTagDialogPrivate *priv = BJB_NOTE_TAG_DIALOG_GET_PRIVATE(self);
self->priv = priv;
- priv->notes = NULL;
+ priv->items = NULL;
priv->collections = NULL;
priv->window = NULL;
priv->tag_to_scroll_to = NULL;
@@ -445,8 +445,8 @@ bjb_note_tag_dialog_get_property (GObject *object,
case PROP_WINDOW:
g_value_set_object (value, self->priv->window);
break;
- case PROP_NOTES:
- g_value_set_pointer (value, self->priv->notes);
+ case PROP_ITEMS:
+ g_value_set_pointer (value, self->priv->items);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -467,8 +467,8 @@ bjb_note_tag_dialog_set_property (GObject *object,
case PROP_WINDOW:
self->priv->window = g_value_get_object(value);
break;
- case PROP_NOTES:
- self->priv->notes = g_value_get_pointer (value);
+ case PROP_ITEMS:
+ self->priv->items = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -496,9 +496,9 @@ bjb_note_tag_dialog_class_init (BjbNoteTagDialogClass *klass)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS);
- properties[PROP_NOTES] = g_param_spec_pointer ("notes",
- "Biji Notes",
- "The Notes to tag",
+ properties[PROP_ITEMS] = g_param_spec_pointer ("items",
+ "Biji Items",
+ "Notes and Collections to tag",
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
@@ -508,11 +508,11 @@ bjb_note_tag_dialog_class_init (BjbNoteTagDialogClass *klass)
void
bjb_note_tag_dialog_new (GtkWindow *parent,
- GList *biji_note_obj)
+ GList *biji_items)
{
BjbNoteTagDialog *self = g_object_new (BJB_TYPE_NOTE_TAG_DIALOG,
"window", parent,
- "notes", biji_note_obj,
+ "items", biji_items,
NULL);
gtk_dialog_run (GTK_DIALOG (self));
diff --git a/src/bjb-selection-toolbar.c b/src/bjb-selection-toolbar.c
index 674be71..785bb6b 100644
--- a/src/bjb-selection-toolbar.c
+++ b/src/bjb-selection-toolbar.c
@@ -81,7 +81,7 @@ bjb_selection_toolbar_set_item_visibility (BjbSelectionToolbar *self)
gtk_widget_set_visible (priv->toolbar_trash, TRUE);
/* Color */
- if (bjb_main_view_get_selected_notes_color (priv->view, &color))
+ if (bjb_main_view_get_selected_items_color (priv->view, &color))
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->toolbar_color), &color);
}
@@ -238,13 +238,13 @@ bjb_selection_toolbar_constructed(GObject *obj)
self);
g_signal_connect(priv->toolbar_color,"color-set",
- G_CALLBACK(action_color_selected_notes),priv->view);
+ G_CALLBACK(action_color_selected_items),priv->view);
g_signal_connect(priv->toolbar_tag,"clicked",
- G_CALLBACK(action_tag_selected_notes),priv->view);
+ G_CALLBACK(action_tag_selected_items),priv->view);
g_signal_connect(priv->toolbar_trash,"clicked",
- G_CALLBACK(action_delete_selected_notes),priv->view);
+ G_CALLBACK(action_delete_selected_items),priv->view);
}
static void
diff --git a/src/libbiji/biji-collection.c b/src/libbiji/biji-collection.c
index 25052ea..3361bf8 100644
--- a/src/libbiji/biji-collection.c
+++ b/src/libbiji/biji-collection.c
@@ -26,6 +26,7 @@
#include <math.h>
#include "biji-collection.h"
+#include "biji-tracker.h"
struct BijiCollectionPrivate_
{
@@ -185,10 +186,24 @@ biji_collection_get_changed_sec (BijiItem *coll)
return 0;
}
-static BijiItemType
-collection_get_type (BijiItem *item)
+static gboolean
+biji_collection_trash (BijiItem *item)
{
- return BIJI_ITEM_COLLECTION;
+ BijiCollection *self;
+ g_return_val_if_fail (BIJI_IS_COLLECTION (item), FALSE);
+
+ self = BIJI_COLLECTION (item);
+ biji_remove_collection_from_tracker (self->priv->name);
+ g_object_unref (self);
+
+ return TRUE;
+}
+
+static gboolean
+biji_collection_has_collection (BijiItem *item, gchar *collection)
+{
+ //todo
+ return FALSE;
}
static void
@@ -260,7 +275,8 @@ biji_collection_class_init (BijiCollectionClass *klass)
item_class->get_icon = biji_collection_get_icon;
item_class->get_emblem = biji_collection_get_emblem;
item_class->get_change_sec = biji_collection_get_changed_sec;
- item_class->get_type = collection_get_type;
+ item_class->trash = biji_collection_trash;
+ item_class->has_collection = biji_collection_has_collection;
}
diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
index 4f9bd51..b6d88a0 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -87,8 +87,14 @@ biji_item_get_last_change (BijiItem *item)
return BIJI_ITEM_GET_CLASS (item)->get_change_sec (item);
}
-BijiItemType
-biji_item_get_biji_type (BijiItem *item)
+gboolean
+biji_item_trash (BijiItem *item)
{
- return BIJI_ITEM_GET_CLASS (item)->get_type (item);
+ return BIJI_ITEM_GET_CLASS (item)->trash (item);
+}
+
+gboolean
+biji_item_has_collection (BijiItem *item, gchar *coll)
+{
+ return BIJI_ITEM_GET_CLASS (item)->has_collection (item, coll);
}
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
index f2f07bc..893b07a 100644
--- a/src/libbiji/biji-item.h
+++ b/src/libbiji/biji-item.h
@@ -37,17 +37,6 @@ typedef struct BijiItem_ BijiItem;
typedef struct BijiItemClass_ BijiItemClass;
typedef struct BijiItemPrivate_ BijiItemPrivate;
-/* Libbiji base interface
- * NoteBook provides items
- * Items might be NoteObj or Collections
- * Below BijiType rather g_type ? */
-
-typedef enum {
- BIJI_ITEM_0,
- BIJI_ITEM_NOTE_OBJ,
- BIJI_ITEM_COLLECTION
-} BijiItemType;
-
/* Icon */
#define BIJI_ICON_WIDTH 200
#define BIJI_ICON_HEIGHT 200
@@ -73,8 +62,8 @@ struct BijiItemClass_
GdkPixbuf * (*get_icon) (BijiItem *item);
GdkPixbuf * (*get_emblem) (BijiItem *item);
glong (*get_change_sec) (BijiItem *item);
-
- BijiItemType (*get_type) (BijiItem *item);
+ gboolean (*trash) (BijiItem *item);
+ gboolean (*has_collection) (BijiItem *item, gchar *coll);
};
/* Do not create a generic items.
@@ -94,7 +83,9 @@ GdkPixbuf * biji_item_get_emblem (BijiItem *item);
glong biji_item_get_last_change (BijiItem *item);
-BijiItemType biji_item_get_biji_type (BijiItem *item);
+gboolean biji_item_trash (BijiItem *item);
+
+gboolean biji_item_has_collection (BijiItem *item, gchar *collection);
G_END_DECLS
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index 563c15c..0be7c6c 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -134,11 +134,6 @@ title_is_unique (BijiNoteBook *book, gchar *title)
{
iter = BIJI_ITEM (l->data);
- /* this func is just used for notes to ensure unique title
- * don't know yet if useful for collections */
- if (biji_item_get_biji_type (iter) != BIJI_ITEM_NOTE_OBJ)
- break;
-
if (g_strcmp0 (biji_item_get_title (iter), title) == 0)
{
is_unique = FALSE;
@@ -394,16 +389,16 @@ biji_note_book_class_init (BijiNoteBookClass *klass)
}
gboolean
-biji_note_book_remove_note (BijiNoteBook *book, BijiNoteObj *note)
+biji_note_book_remove_item (BijiNoteBook *book, BijiItem *item)
{
g_return_val_if_fail (BIJI_IS_NOTE_BOOK (book), FALSE);
- g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), FALSE);
+ g_return_val_if_fail (BIJI_IS_ITEM (item), FALSE);
BijiNoteObj *to_delete = NULL;
gchar *path;
gboolean retval = FALSE;
- path = biji_item_get_uuid (BIJI_ITEM (note));
+ path = biji_item_get_uuid (item);
to_delete = g_hash_table_lookup (book->priv->items, path);
if (to_delete)
@@ -415,7 +410,7 @@ biji_note_book_remove_note (BijiNoteBook *book, BijiNoteObj *note)
/* Ref note first, hash_table won't finalize it & we can delete it*/
g_object_ref (to_delete);
g_hash_table_remove (book->priv->items, path);
- biji_note_obj_trash (note);
+ biji_item_trash (item);
retval = TRUE;
}
@@ -443,8 +438,8 @@ biji_note_book_get_items (BijiNoteBook *book)
return g_hash_table_get_values (book->priv->items);
}
-BijiNoteObj *
-note_book_get_note_at_path (BijiNoteBook *book, gchar *path)
+BijiItem *
+biji_note_book_get_item_at_path (BijiNoteBook *book, gchar *path)
{
return g_hash_table_lookup (book->priv->items, path);
}
diff --git a/src/libbiji/biji-note-book.h b/src/libbiji/biji-note-book.h
index 33b6c1f..d262c93 100644
--- a/src/libbiji/biji-note-book.h
+++ b/src/libbiji/biji-note-book.h
@@ -55,9 +55,9 @@ gboolean biji_note_book_notify_changed (BijiNoteBook *book,
BijiNoteBookChangeFlag flag,
BijiNoteObj *note);
-gboolean biji_note_book_remove_note (BijiNoteBook *book,BijiNoteObj *note);
+gboolean biji_note_book_remove_item (BijiNoteBook *book, BijiItem *item);
-BijiNoteObj * note_book_get_note_at_path(BijiNoteBook *book,gchar *path);
+BijiItem * biji_note_book_get_item_at_path (BijiNoteBook *book, gchar *path);
/* Get all items, either notes or collections
* Free the GList, not its content */
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index e281682..64d5329 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -82,7 +82,9 @@ 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 gboolean biji_note_obj_trash (BijiItem *note);
static glong biji_note_obj_get_last_change_date_sec (BijiItem *note);
+static gboolean biji_note_obj_has_collection (BijiItem *note, gchar *label);
static void
on_save_timeout (BijiNoteObj *self)
@@ -225,12 +227,6 @@ biji_note_obj_get_property (GObject *object,
}
}
-static BijiItemType
-note_obj_get_type (BijiItem *item)
-{
- return BIJI_ITEM_NOTE_OBJ;
-}
-
static void
biji_note_obj_class_init (BijiNoteObjClass *klass)
{
@@ -299,7 +295,8 @@ biji_note_obj_class_init (BijiNoteObjClass *klass)
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;
- item_class->get_type = note_obj_get_type;
+ item_class->trash = biji_note_obj_trash;
+ item_class->has_collection = biji_note_obj_has_collection;
}
BijiNoteObj *
@@ -347,14 +344,18 @@ biji_note_obj_are_same (BijiNoteObj *a, BijiNoteObj* b)
/* First cancel timeout
* this func is most probably stupid it might exists (move file) */
gboolean
-biji_note_obj_trash (BijiNoteObj *note_to_kill)
+biji_note_obj_trash (BijiItem *item)
{
- BijiNoteObjPrivate *priv = note_to_kill->priv;
+ BijiNoteObj *note_to_kill;
+ BijiNoteObjPrivate *priv;
GFile *to_trash, *parent, *trash, *backup_file, *icon;
gchar *note_name, *parent_path, *trash_path, *backup_path, *icon_path;
GError *error = NULL;
gboolean result = FALSE;
+ note_to_kill = BIJI_NOTE_OBJ (item);
+ priv = note_to_kill->priv;
+
priv->needs_save = FALSE;
biji_timeout_cancel (priv->timeout);
@@ -611,8 +612,10 @@ biji_note_obj_get_collections (BijiNoteObj *n)
}
gboolean
-biji_note_obj_has_collection (BijiNoteObj *note, gchar *label)
+biji_note_obj_has_collection (BijiItem *item, gchar *label)
{
+ BijiNoteObj *note = BIJI_NOTE_OBJ (item);
+
if (g_hash_table_lookup (note->priv->labels, label))
return TRUE;
@@ -624,7 +627,7 @@ biji_note_obj_add_collection (BijiNoteObj *note, gchar *label, gboolean on_user_
{
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), FALSE);
g_return_val_if_fail (label != NULL, FALSE);
- g_return_val_if_fail (!biji_note_obj_has_collection (note, label), FALSE);
+ g_return_val_if_fail (!biji_note_obj_has_collection (BIJI_ITEM (note), label), FALSE);
gchar *tag = g_strdup (label);
@@ -950,7 +953,7 @@ _biji_note_obj_close (BijiNoteObj *note)
* since no change could trigger save */
if (!priv->raw_text)
{
- biji_note_book_remove_note (priv->book, note);
+ biji_note_book_remove_item (priv->book, BIJI_ITEM (note));
}
/* If the note only has one row. put some title */
diff --git a/src/libbiji/biji-note-obj.h b/src/libbiji/biji-note-obj.h
index cd1fa7e..31a1f94 100644
--- a/src/libbiji/biji-note-obj.h
+++ b/src/libbiji/biji-note-obj.h
@@ -73,8 +73,6 @@ gpointer biji_note_obj_get_note_book(BijiNoteObj *note);
void _biji_note_obj_set_book(BijiNoteObj *note, gpointer biji_note_book);
-gboolean biji_note_obj_trash (BijiNoteObj *dead);
-
gboolean biji_note_obj_are_same(BijiNoteObj *a, BijiNoteObj* b);
///////////////////////////////////////////////////////////////////// Metadata
@@ -112,8 +110,6 @@ void biji_note_obj_set_rgba(BijiNoteObj *n, GdkRGBA *rgba) ;
GList * biji_note_obj_get_collections (BijiNoteObj *n);
-gboolean biji_note_obj_has_collection (BijiNoteObj *note, gchar *label);
-
gboolean biji_note_obj_add_collection (BijiNoteObj *note, gchar *label, gboolean on_user_action_cb);
gboolean biji_note_obj_remove_collection (BijiNoteObj *note, gchar *label, gchar *urn);
diff --git a/src/libbiji/biji-tracker.c b/src/libbiji/biji-tracker.c
index 786ed3a..c7db623 100644
--- a/src/libbiji/biji-tracker.c
+++ b/src/libbiji/biji-tracker.c
@@ -220,7 +220,7 @@ biji_get_notes_with_strings_or_collection_finish (GObject *source_object,
{
const gchar *full_path;
gchar *path;
- BijiNoteObj *note = NULL;
+ BijiItem *item = NULL;
while (tracker_sparql_cursor_next (cursor, NULL, NULL))
{
@@ -238,11 +238,11 @@ biji_get_notes_with_strings_or_collection_finish (GObject *source_object,
path = g_strdup (full_path);
}
- note = note_book_get_note_at_path (book, path);
+ item = biji_note_book_get_item_at_path (book, path);
/* Sorting is done in another place */
- if (note)
- result = g_list_prepend (result, note);
+ if (item)
+ result = g_list_prepend (result, item);
g_free (path);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]