[bijiben: 4/11] Collections: Read-Only first draft
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben: 4/11] Collections: Read-Only first draft
- Date: Sun, 28 Apr 2013 23:14:37 +0000 (UTC)
commit f154ac73f581cc091c45f0412c80ee0941a28358
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sat Apr 27 20:44:43 2013 +0200
Collections: Read-Only first draft
Collections are now created and returned per NoteBook.
Visible on retrieve, but cannot be activated
src/bjb-controller.c | 26 ++++-
src/libbiji/Makefile.am | 2 +
src/libbiji/biji-collection.c | 291 +++++++++++++++++++++++++++++++++++++++++
src/libbiji/biji-collection.h | 59 +++++++++
src/libbiji/biji-item.c | 13 +-
src/libbiji/biji-item.h | 30 ++++-
src/libbiji/biji-note-book.c | 68 +++++++---
src/libbiji/biji-note-book.h | 2 -
src/libbiji/biji-note-obj.c | 40 +++---
src/libbiji/libbiji.h | 3 +-
10 files changed, 474 insertions(+), 60 deletions(-)
---
diff --git a/src/bjb-controller.c b/src/bjb-controller.c
index 807d1c4..425d3c9 100644
--- a/src/bjb-controller.c
+++ b/src/bjb-controller.c
@@ -310,9 +310,29 @@ most_recent_item_first (gconstpointer a, gconstpointer b)
{
BijiItem *one = BIJI_ITEM (a);
BijiItem *other = BIJI_ITEM (b);
-
- glong result = biji_item_get_last_change (other);
- return result - biji_item_get_last_change (one);
+ glong result = 0;
+
+ /* Always sort collections before notes */
+ if (BIJI_IS_COLLECTION (a))
+ {
+ if (BIJI_IS_NOTE_OBJ (b))
+ result = -1;
+ }
+
+ else if (BIJI_IS_COLLECTION (b))
+ {
+ result = 1;
+ }
+
+ /* If comparing two notes or
+ * two collections, use the most recent cookbook */
+ else
+ {
+ result = biji_item_get_last_change (other)
+ - biji_item_get_last_change (one);
+ }
+
+ return result;
}
static void
diff --git a/src/libbiji/Makefile.am b/src/libbiji/Makefile.am
index f3ba8c3..94e2216 100644
--- a/src/libbiji/Makefile.am
+++ b/src/libbiji/Makefile.am
@@ -9,6 +9,8 @@ libbiji_la_built_sources = \
libbiji_la_SOURCES = \
$(libbiji_la_built_sources) \
libbiji.h \
+ biji-collection.c \
+ biji-collection.h \
biji-date-time.c \
biji-date-time.h \
biji-item.h \
diff --git a/src/libbiji/biji-collection.c b/src/libbiji/biji-collection.c
new file mode 100644
index 0000000..25052ea
--- /dev/null
+++ b/src/libbiji/biji-collection.c
@@ -0,0 +1,291 @@
+/*
+ * biji-collection.c
+ *
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * biji_create_collection_icon
+ * is adapted from Photos (photos_utils_create_collection_icon),
+ * which is ported from Documents
+ */
+
+#include <math.h>
+
+#include "biji-collection.h"
+
+struct BijiCollectionPrivate_
+{
+ /* String is both the collection title & uuid */
+ gchar * name;
+};
+
+static void biji_collection_finalize (GObject *object);
+
+G_DEFINE_TYPE (BijiCollection, biji_collection, BIJI_TYPE_ITEM)
+
+/* Properties */
+enum {
+ PROP_0,
+ PROP_NAME,
+ BIJI_COLL_PROPERTIES
+};
+
+static GParamSpec *properties[BIJI_COLL_PROPERTIES] = { NULL, };
+
+static gchar *
+biji_collection_get_title (BijiItem *coll)
+{
+ BijiCollection *collection;
+
+ g_return_val_if_fail (BIJI_IS_COLLECTION (coll), NULL);
+ collection = BIJI_COLLECTION (coll);
+
+ return collection->priv->name;
+}
+
+static gchar *
+biji_collection_get_uuid (BijiItem *coll)
+{
+ BijiCollection *collection;
+
+ g_return_val_if_fail (BIJI_IS_COLLECTION (coll), NULL);
+ collection = BIJI_COLLECTION (coll);
+
+ return g_strdup (collection->priv->name);
+}
+
+GdkPixbuf *
+biji_create_collection_icon (gint base_size, GList *pixbufs)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ GdkPixbuf *pix;
+ GdkPixbuf *ret_val;
+ GList *l;
+ GtkStyleContext *context;
+ GtkWidgetPath *path;
+ gint cur_x;
+ gint cur_y;
+ gint idx;
+ gint padding;
+ gint pix_height;
+ gint pix_width;
+ gint scale_size;
+ gint tile_size;
+
+ /* TODO: use notes thumbs */
+
+ padding = MAX (floor (base_size / 10), 4);
+ tile_size = (base_size - (3 * padding)) / 2;
+
+ context = gtk_style_context_new ();
+ gtk_style_context_add_class (context, "documents-collection-icon");
+
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
+ gtk_style_context_set_path (context, path);
+ gtk_widget_path_unref (path);
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, base_size, base_size);
+ cr = cairo_create (surface);
+
+ gtk_render_background (context, cr, 0, 0, base_size, base_size);
+
+ l = pixbufs;
+ idx = 0;
+ cur_x = padding;
+ cur_y = padding;
+
+
+ while (l != NULL && idx < 4)
+ {
+ pix = l->data;
+ pix_width = gdk_pixbuf_get_width (pix);
+ pix_height = gdk_pixbuf_get_height (pix);
+
+ scale_size = MIN (pix_width, pix_height);
+
+ cairo_save (cr);
+
+ cairo_translate (cr, cur_x, cur_y);
+
+ cairo_rectangle (cr, 0, 0,
+ tile_size, tile_size);
+ cairo_clip (cr);
+
+ cairo_scale (cr, (gdouble) tile_size / (gdouble) scale_size, (gdouble) tile_size / (gdouble)
scale_size);
+ gdk_cairo_set_source_pixbuf (cr, pix, 0, 0);
+
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ if ((idx % 2) == 0)
+ {
+ cur_x += tile_size + padding;
+ }
+ else
+ {
+ cur_x = padding;
+ cur_y += tile_size + padding;
+ }
+
+ idx++;
+ l = l->next;
+ }
+
+ ret_val = gdk_pixbuf_get_from_surface (surface, 0, 0, base_size, base_size);
+
+ cairo_surface_destroy (surface);
+ cairo_destroy (cr);
+ g_object_unref (context);
+
+ return ret_val;
+}
+
+/* TODO */
+static GList *
+_get_notes_pix (BijiItem *coll)
+{
+ return NULL;
+}
+
+
+static GdkPixbuf *
+biji_collection_get_icon (BijiItem *coll)
+{
+ return biji_create_collection_icon (BIJI_ICON_WIDTH, _get_notes_pix (coll));
+}
+
+
+static GdkPixbuf *
+biji_collection_get_emblem (BijiItem *coll)
+{
+ return biji_create_collection_icon (BIJI_EMBLEM_WIDTH, _get_notes_pix (coll));
+}
+
+/* TODO
+ * Maybe return most recent note value */
+static glong
+biji_collection_get_changed_sec (BijiItem *coll)
+{
+ return 0;
+}
+
+static BijiItemType
+collection_get_type (BijiItem *item)
+{
+ return BIJI_ITEM_COLLECTION;
+}
+
+static void
+biji_collection_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BijiCollection *self = BIJI_COLLECTION (object);
+
+
+ switch (property_id)
+ {
+ case PROP_NAME:
+ self->priv->name = g_strdup (g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+biji_collection_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BijiCollection *self = BIJI_COLLECTION (object);
+
+ switch (property_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, self->priv->name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+biji_collection_class_init (BijiCollectionClass *klass)
+{
+ GObjectClass *g_object_class;
+ BijiItemClass* item_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+ item_class = BIJI_ITEM_CLASS (klass);
+
+ g_object_class->finalize = biji_collection_finalize;
+ g_object_class->set_property = biji_collection_set_property;
+ g_object_class->get_property = biji_collection_get_property;
+
+ g_type_class_add_private ((gpointer)klass, sizeof (BijiCollectionPrivate));
+
+ properties[PROP_NAME] =
+ g_param_spec_string ("name",
+ "Collection label",
+ "The tag as a string",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (g_object_class, BIJI_COLL_PROPERTIES, properties);
+
+ /* Interface */
+ item_class->get_title = biji_collection_get_title;
+ item_class->get_uuid = biji_collection_get_uuid;
+ 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;
+}
+
+
+static void
+biji_collection_finalize (GObject *object)
+{
+ BijiCollection *self;
+ g_return_if_fail (BIJI_IS_COLLECTION (object));
+
+ self = BIJI_COLLECTION (object);
+ g_free (self->priv->name);
+
+ G_OBJECT_CLASS (biji_collection_parent_class)->finalize (object);
+}
+
+
+static void
+biji_collection_init (BijiCollection *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_COLLECTION, BijiCollectionPrivate);
+}
+
+
+BijiCollection *
+biji_collection_new (gchar *name)
+{
+ return g_object_new (BIJI_TYPE_COLLECTION, "name", name, NULL);
+}
diff --git a/src/libbiji/biji-collection.h b/src/libbiji/biji-collection.h
new file mode 100644
index 0000000..5385bc5
--- /dev/null
+++ b/src/libbiji/biji-collection.h
@@ -0,0 +1,59 @@
+/*
+ * biji-collection.h
+ *
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef BIJI_COLLECTION_H_
+#define BIJI_COLLECTION_H_ 1
+
+#include "biji-item.h"
+
+G_BEGIN_DECLS
+
+
+#define BIJI_TYPE_COLLECTION (biji_collection_get_type ())
+#define BIJI_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIJI_TYPE_COLLECTION,
BijiCollection))
+#define BIJI_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIJI_TYPE_COLLECTION,
BijiCollectionClass))
+#define BIJI_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIJI_TYPE_COLLECTION))
+#define BIJI_IS_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_COLLECTION))
+#define BIJI_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_COLLECTION,
BijiCollectionClass))
+
+typedef struct BijiCollection_ BijiCollection;
+typedef struct BijiCollectionClass_ BijiCollectionClass;
+typedef struct BijiCollectionPrivate_ BijiCollectionPrivate;
+
+struct BijiCollection_
+{
+ BijiItem parent;
+
+ BijiCollectionPrivate *priv;
+};
+
+struct BijiCollectionClass_
+{
+ BijiItemClass parent_class;
+};
+
+
+GType biji_collection_get_type (void);
+
+BijiCollection * biji_collection_new (gchar *name);
+
+G_END_DECLS
+
+#endif /* BIJI_COLLECTION_H_ */
diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
index f59bbfb..4f9bd51 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -57,13 +57,6 @@ biji_item_init (BijiItem *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_ITEM, BijiItemPrivate);
}
-
-GObject *
-biji_item_new (void)
-{
- return g_object_new (BIJI_TYPE_ITEM, NULL);
-}
-
gchar *
biji_item_get_title (BijiItem *item)
{
@@ -93,3 +86,9 @@ 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)
+{
+ return BIJI_ITEM_GET_CLASS (item)->get_type (item);
+}
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
index e20ace7..f2f07bc 100644
--- a/src/libbiji/biji-item.h
+++ b/src/libbiji/biji-item.h
@@ -39,7 +39,23 @@ typedef struct BijiItemPrivate_ BijiItemPrivate;
/* Libbiji base interface
* NoteBook provides items
- * Items might be NoteObj or Collections */
+ * 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
+#define BIJI_ICON_FONT "Purusa 10"
+
+/* a cute baby icon without txt. squared. */
+#define BIJI_EMBLEM_WIDTH BIJI_ICON_WIDTH / 6
+#define BIJI_EMBLEM_HEIGHT BIJI_EMBLEM_WIDTH
struct BijiItem_
{
@@ -57,15 +73,19 @@ struct BijiItemClass_
GdkPixbuf * (*get_icon) (BijiItem *item);
GdkPixbuf * (*get_emblem) (BijiItem *item);
glong (*get_change_sec) (BijiItem *item);
+
+ BijiItemType (*get_type) (BijiItem *item);
};
+/* Do not create a generic items.
+ * It's rather an iface */
GType biji_item_get_type (void);
-GObject * biji_item_new (void);
-
+/* Do not free title */
gchar * biji_item_get_title (BijiItem *item);
-/* NoteObj uuid is a location */
+/* Always g_free uuid
+ * NoteObj uuid is a location */
gchar * biji_item_get_uuid (BijiItem *item);
GdkPixbuf * biji_item_get_icon (BijiItem *item);
@@ -74,6 +94,8 @@ GdkPixbuf * biji_item_get_emblem (BijiItem *item);
glong biji_item_get_last_change (BijiItem *item);
+BijiItemType biji_item_get_biji_type (BijiItem *item);
+
G_END_DECLS
#endif /* BIJI_ITEM_H_ */
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index c78fcf0..563c15c 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -19,11 +19,13 @@
#include <uuid/uuid.h>
#include "libbiji.h"
+#include "biji-collection.h"
struct _BijiNoteBookPrivate
{
- GHashTable *notes;
+ /* Notes & Collections */
+ GHashTable *items;
/* Signals */
gulong note_renamed ;
@@ -59,7 +61,7 @@ biji_note_book_init (BijiNoteBook *self)
BijiNoteBookPrivate);
/* Note path is key for table. It's freed by note itself */
- self->priv->notes = g_hash_table_new_full (g_str_hash,
+ self->priv->items = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_object_unref);
@@ -75,7 +77,7 @@ biji_note_book_finalize (GObject *object)
g_clear_object (&book->priv->load_cancellable);
g_clear_object (&book->priv->location);
- g_hash_table_destroy (book->priv->notes);
+ g_hash_table_destroy (book->priv->items);
G_OBJECT_CLASS (biji_note_book_parent_class)->finalize (object);
}
@@ -120,26 +122,31 @@ biji_note_book_get_property (GObject *object,
}
static gboolean
-title_is_unique (BijiNoteBook *book,gchar *title)
+title_is_unique (BijiNoteBook *book, gchar *title)
{
gboolean is_unique = TRUE;
- BijiNoteObj *iter;
- GList *notes, *l;
+ BijiItem *iter;
+ GList *items, *l;
- notes = g_hash_table_get_values (book->priv->notes);
+ items = g_hash_table_get_values (book->priv->items);
- for ( l=notes ; l != NULL ; l = l->next)
+ for ( l=items ; l != NULL ; l = l->next)
{
- iter = BIJI_NOTE_OBJ (l->data);
+ iter = BIJI_ITEM (l->data);
- if (g_strcmp0 (biji_item_get_title (BIJI_ITEM (iter)), title) == 0)
+ /* 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;
break;
}
}
- g_list_free (notes);
+ g_list_free (items);
return is_unique;
}
@@ -190,16 +197,34 @@ book_on_note_color_changed_cb (BijiNoteObj *note, BijiNoteBook *book)
}
static void
-_biji_note_book_add_one_note(BijiNoteBook *book,BijiNoteObj *note)
+_biji_note_book_add_one_note (BijiNoteBook *book, BijiNoteObj *note)
{
- g_return_if_fail(BIJI_IS_NOTE_OBJ(note));
+ GList *collections, *l;
+ g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
- _biji_note_obj_set_book(note,(gpointer)book);
+ _biji_note_obj_set_book (note, (gpointer) book);
- // Add it to the list and emit signal
- g_hash_table_insert (book->priv->notes,
+ /* Add it to the list */
+ g_hash_table_insert (book->priv->items,
biji_item_get_uuid (BIJI_ITEM (note)), note);
+ /* Check for new collections */
+ collections = biji_note_obj_get_collections (note);
+ for (l = collections ; l != NULL; l = l->next)
+ {
+ BijiCollection *collection;
+
+ /* If the collection already existed,
+ * previous is finalized (GHashTable)
+ * We could also check before creating it */
+
+ collection = biji_collection_new ((gchar*) l->data);
+ g_hash_table_insert (book->priv->items,
+ biji_item_get_uuid (BIJI_ITEM (collection)),
+ collection);
+ }
+
+ /* Notify */
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);
g_signal_connect (note, "color-changed", G_CALLBACK (book_on_note_color_changed_cb), book);
@@ -379,7 +404,7 @@ biji_note_book_remove_note (BijiNoteBook *book, BijiNoteObj *note)
gboolean retval = FALSE;
path = biji_item_get_uuid (BIJI_ITEM (note));
- to_delete = g_hash_table_lookup (book->priv->notes, path);
+ to_delete = g_hash_table_lookup (book->priv->items, path);
if (to_delete)
{
@@ -389,7 +414,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->notes, path);
+ g_hash_table_remove (book->priv->items, path);
biji_note_obj_trash (note);
retval = TRUE;
@@ -412,17 +437,16 @@ biji_note_book_append_new_note (BijiNoteBook *book, BijiNoteObj *note, gboolean
biji_note_book_notify_changed (book, BIJI_BOOK_NOTE_ADDED, note);
}
-// TODO : also return collections
GList *
biji_note_book_get_items (BijiNoteBook *book)
{
- return g_hash_table_get_values (book->priv->notes);
+ return g_hash_table_get_values (book->priv->items);
}
BijiNoteObj *
note_book_get_note_at_path (BijiNoteBook *book, gchar *path)
{
- return g_hash_table_lookup (book->priv->notes, path);
+ return g_hash_table_lookup (book->priv->items, path);
}
BijiNoteBook *
@@ -470,7 +494,7 @@ get_note_skeleton (BijiNoteBook *book)
path = g_build_filename (folder, name, NULL);
g_free (name);
- if (!g_hash_table_lookup (book->priv->notes, path))
+ if (!g_hash_table_lookup (book->priv->items, path))
ret = biji_note_obj_new_from_path (path);
g_free (path);
diff --git a/src/libbiji/biji-note-book.h b/src/libbiji/biji-note-book.h
index eee9f9a..33b6c1f 100644
--- a/src/libbiji/biji-note-book.h
+++ b/src/libbiji/biji-note-book.h
@@ -49,8 +49,6 @@ BijiNoteBook * biji_note_book_new (GFile *location);
gchar * biji_note_book_get_unique_title (BijiNoteBook *book, gchar *title);
-void _biji_note_book_add_note_to_tag_book(BijiNoteBook *book,BijiNoteObj *note,gchar *tag);
-
void biji_note_book_append_new_note (BijiNoteBook *book, BijiNoteObj *note, gboolean notify);
gboolean biji_note_book_notify_changed (BijiNoteBook *book,
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index c509c6f..e281682 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -27,15 +27,6 @@
#include <libgd/gd.h>
-/* Icon */
-#define ICON_WIDTH 200
-#define ICON_HEIGHT 200
-#define ICON_FONT "Purusa 10"
-
-/* a cute baby icon without txt. squared. */
-#define EMBLEM_WIDTH ICON_WIDTH / 6
-#define EMBLEM_HEIGHT EMBLEM_WIDTH
-
struct _BijiNoteObjPrivate
{
/* Notebook might be null. */
@@ -234,6 +225,12 @@ 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)
{
@@ -302,6 +299,7 @@ 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;
}
BijiNoteObj *
@@ -751,12 +749,12 @@ biji_note_obj_get_icon (BijiItem *item)
/* Create & Draw surface */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- ICON_WIDTH,
- ICON_HEIGHT) ;
+ BIJI_ICON_WIDTH,
+ BIJI_ICON_HEIGHT) ;
cr = cairo_create (surface);
/* Background */
- cairo_rectangle (cr, 0, 0, ICON_WIDTH, ICON_HEIGHT);
+ cairo_rectangle (cr, 0, 0, BIJI_ICON_WIDTH, BIJI_ICON_HEIGHT);
if (biji_note_obj_get_rgba (note, ¬e_color))
gdk_cairo_set_source_rgba (cr, ¬e_color);
@@ -774,7 +772,7 @@ biji_note_obj_get_icon (BijiItem *item)
pango_layout_set_height (layout, 180000 ) ;
pango_layout_set_text (layout, text, -1);
- desc = pango_font_description_from_string (ICON_FONT);
+ desc = pango_font_description_from_string (BIJI_ICON_FONT);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
@@ -789,8 +787,8 @@ biji_note_obj_get_icon (BijiItem *item)
ret = gdk_pixbuf_get_from_surface (surface,
0, 0,
- ICON_WIDTH,
- ICON_HEIGHT);
+ BIJI_ICON_WIDTH,
+ BIJI_ICON_HEIGHT);
cairo_surface_destroy (surface);
note->priv->icon = gd_embed_image_in_frame (ret, "resource:///org/gnome/bijiben/thumbnail-frame.png",
@@ -814,12 +812,12 @@ biji_note_obj_get_emblem (BijiItem *item)
/* Create & Draw surface */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- EMBLEM_WIDTH,
- EMBLEM_HEIGHT) ;
+ BIJI_EMBLEM_WIDTH,
+ BIJI_EMBLEM_HEIGHT) ;
cr = cairo_create (surface);
/* Background */
- cairo_rectangle (cr, 0, 0, EMBLEM_WIDTH, EMBLEM_HEIGHT);
+ cairo_rectangle (cr, 0, 0, BIJI_EMBLEM_WIDTH, BIJI_EMBLEM_HEIGHT);
if (biji_note_obj_get_rgba (note, ¬e_color))
gdk_cairo_set_source_rgba (cr, ¬e_color);
@@ -828,15 +826,15 @@ biji_note_obj_get_emblem (BijiItem *item)
/* Border */
cairo_set_source_rgba (cr, 0.3, 0.3, 0.3, 1);
cairo_set_line_width (cr, 1);
- cairo_rectangle (cr, 0, 0, EMBLEM_WIDTH, EMBLEM_HEIGHT);
+ cairo_rectangle (cr, 0, 0, BIJI_EMBLEM_WIDTH, BIJI_EMBLEM_HEIGHT);
cairo_stroke (cr);
cairo_destroy (cr);
note->priv->emblem = gdk_pixbuf_get_from_surface (surface,
0, 0,
- EMBLEM_WIDTH,
- EMBLEM_HEIGHT);
+ BIJI_EMBLEM_WIDTH,
+ BIJI_EMBLEM_HEIGHT);
cairo_surface_destroy (surface);
note->priv->emblem_needs_update = FALSE;
diff --git a/src/libbiji/libbiji.h b/src/libbiji/libbiji.h
index 0d29b68..1401508 100644
--- a/src/libbiji/libbiji.h
+++ b/src/libbiji/libbiji.h
@@ -20,9 +20,10 @@
#define _LIBBIJI_INSIDE_H
+#include "biji-collection.h"
#include "biji-date-time.h"
-#include "biji-marshalers.h"
#include "biji-item.h"
+#include "biji-marshalers.h"
#include "biji-note-book.h"
#include "biji-note-obj.h"
#include "biji-string.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]