[bijiben] collections: do not use borders for collected items icons
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] collections: do not use borders for collected items icons
- Date: Sun, 5 May 2013 23:39:44 +0000 (UTC)
commit f477332199ffc9e478c71727b1fa8c1da314c4d5
Author: Pierre-Yves Luyten <py luyten fr>
Date: Mon May 6 00:45:52 2013 +0200
collections: do not use borders for collected items icons
setup a dedicated get_pristine method for items
src/libbiji/biji-collection.c | 3 +-
src/libbiji/biji-item.c | 6 +++++
src/libbiji/biji-item.h | 4 +++
src/libbiji/biji-note-obj.c | 43 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/src/libbiji/biji-collection.c b/src/libbiji/biji-collection.c
index a65fb9e..8077f3b 100644
--- a/src/libbiji/biji-collection.c
+++ b/src/libbiji/biji-collection.c
@@ -189,7 +189,7 @@ get_collected_pix (BijiCollection *self)
if (BIJI_IS_ITEM (l->data))
result = g_list_prepend (
result,
- biji_item_get_emblem (BIJI_ITEM (l->data)));
+ biji_item_get_pristine (BIJI_ITEM (l->data)));
}
return result;
@@ -421,6 +421,7 @@ biji_collection_class_init (BijiCollectionClass *klass)
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_pristine = biji_collection_get_emblem;
item_class->get_change_sec = biji_collection_get_changed_sec;
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 b494d05..2862247 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -81,6 +81,12 @@ biji_item_get_emblem (BijiItem *item)
return BIJI_ITEM_GET_CLASS (item)->get_emblem (item);
}
+GdkPixbuf *
+biji_item_get_pristine (BijiItem *item)
+{
+ return BIJI_ITEM_GET_CLASS (item)->get_pristine (item);
+}
+
glong
biji_item_get_last_change (BijiItem *item)
{
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
index 311e21d..5499827 100644
--- a/src/libbiji/biji-item.h
+++ b/src/libbiji/biji-item.h
@@ -61,6 +61,7 @@ struct BijiItemClass_
gchar * (*get_uuid) (BijiItem *item);
GdkPixbuf * (*get_icon) (BijiItem *item);
GdkPixbuf * (*get_emblem) (BijiItem *item);
+ GdkPixbuf * (*get_pristine) (BijiItem *item);
glong (*get_change_sec) (BijiItem *item);
gboolean (*trash) (BijiItem *item);
gboolean (*has_collection) (BijiItem *item, gchar *coll);
@@ -91,6 +92,9 @@ GdkPixbuf * biji_item_get_icon (BijiItem *item);
GdkPixbuf * biji_item_get_emblem (BijiItem *item);
+GdkPixbuf * biji_item_get_pristine (BijiItem *item);
+
+
glong biji_item_get_last_change (BijiItem *item);
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index e724748..7130f6a 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -49,6 +49,7 @@ struct _BijiNoteObjPrivate
* Emblem is smaller & just shows the color */
GdkPixbuf *icon;
GdkPixbuf *emblem;
+ GdkPixbuf *pristine;
/* Tags
* In Tomboy, templates are 'system:notebook:%s' tags.*/
@@ -80,6 +81,7 @@ 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 GdkPixbuf * biji_note_obj_get_pristine (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);
@@ -134,6 +136,7 @@ biji_note_obj_init (BijiNoteObj *self)
/* Icon is only computed when necessary */
priv->icon = NULL;
priv->emblem = NULL;
+ priv->pristine = NULL;
/* Keep value unitialied, so bijiben knows to assign default color */
priv->color = NULL;
@@ -169,6 +172,9 @@ biji_note_obj_finalize (GObject *object)
if (priv->emblem)
g_object_unref (priv->emblem);
+ if (priv->pristine)
+ g_object_unref (priv->pristine);
+
gdk_rgba_free (priv->color);
G_OBJECT_CLASS (biji_note_obj_parent_class)->finalize (object);
@@ -298,6 +304,7 @@ biji_note_obj_class_init (BijiNoteObjClass *klass)
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_pristine = biji_note_obj_get_pristine;
item_class->get_change_sec = biji_note_obj_get_last_change_date_sec;
item_class->trash = biji_note_obj_trash;
item_class->has_collection = biji_note_obj_has_collection;
@@ -545,6 +552,7 @@ biji_note_obj_clear_icons (BijiNoteObj *note)
{
g_clear_pointer (¬e->priv->icon, g_object_unref);
g_clear_pointer (¬e->priv->emblem, g_object_unref);
+ g_clear_pointer (¬e->priv->pristine, g_object_unref);
}
static void
@@ -799,6 +807,41 @@ biji_note_obj_get_icon (BijiItem *item)
}
static GdkPixbuf *
+biji_note_obj_get_pristine (BijiItem *item)
+{
+ GdkRGBA note_color;
+ cairo_t *cr;
+ cairo_surface_t *surface = NULL;
+ BijiNoteObj *note = BIJI_NOTE_OBJ (item);
+
+ if (note->priv->pristine)
+ return note->priv->pristine;
+
+ /* Create & Draw surface */
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ BIJI_EMBLEM_WIDTH,
+ BIJI_EMBLEM_HEIGHT) ;
+ cr = cairo_create (surface);
+
+ /* Background */
+ 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);
+
+ cairo_fill (cr);
+ cairo_destroy (cr);
+
+ note->priv->pristine = gdk_pixbuf_get_from_surface (surface,
+ 0, 0,
+ BIJI_EMBLEM_WIDTH,
+ BIJI_EMBLEM_HEIGHT);
+
+ cairo_surface_destroy (surface);
+
+ return note->priv->pristine;
+}
+
+static GdkPixbuf *
biji_note_obj_get_emblem (BijiItem *item)
{
GdkRGBA note_color;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]