Commit c9393092 authored by Debarshi Ray's avatar Debarshi Ray

base-item: Add some rudimentary icon creation code

Added gdk-pixbuf-2.0 to the list of build requirements.
parent 8ed9174a
......@@ -41,6 +41,7 @@ LT_INIT
PKG_CHECK_MODULES(CLUTTER, [clutter-1.0])
PKG_CHECK_MODULES(CLUTTER_GTK, [clutter-gtk-1.0])
PKG_CHECK_MODULES(GDK_PIXBUF, [gdk-pixbuf-2.0])
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= $GLIB_MIN_VERSION])
PKG_CHECK_MODULES(GIO, [gio-2.0])
PKG_CHECK_MODULES(GTK, [gtk+-3.0])
......
......@@ -73,6 +73,7 @@ AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""${datadir}/locale"\" \
$(CLUTTER_CFLAGS) \
$(CLUTTER_GTK_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(GIO_CFLAGS) \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
......@@ -84,6 +85,7 @@ gnome_photos_LDFLAGS =
gnome_photos_LDADD = \
$(CLUTTER_LIBS) \
$(CLUTTER_GTK_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(GIO_LIBS) \
$(GLIB_LIBS) \
$(GTK_LIBS) \
......
......@@ -32,6 +32,7 @@
struct _PhotosBaseItemPrivate
{
GdkPixbuf *icon;
gboolean favorite;
gchar *author;
gchar *id;
......@@ -55,6 +56,47 @@ enum
G_DEFINE_TYPE (PhotosBaseItem, photos_base_item, G_TYPE_OBJECT);
static void
photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
{
}
static void
photos_base_item_update_icon_from_type (PhotosBaseItem *self)
{
PhotosBaseItemPrivate *priv = self->priv;
GIcon *icon = NULL;
GtkIconInfo *info;
GtkIconTheme *theme;
if (priv->mime_type != NULL)
icon = g_content_type_get_icon (priv->mime_type);
/* TODO: Get icon from RDF type */
theme = gtk_icon_theme_get_default ();
info = gtk_icon_theme_lookup_by_gicon (theme,
icon,
128,
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (info != NULL)
{
priv->icon = gtk_icon_info_load_icon (info, NULL);
/* TODO: use a GError */
}
photos_base_item_check_effects_and_update_info (self);
}
static void
photos_base_item_refresh_icon (PhotosBaseItem *self)
{
photos_base_item_update_icon_from_type (self);
}
static void
photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor *cursor)
{
......@@ -89,6 +131,8 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
title = photos_utils_filename_strip_extension (title);
}
priv->name = g_strdup (title);
photos_base_item_refresh_icon (self);
}
......@@ -104,6 +148,18 @@ photos_base_item_update_type_description (PhotosBaseItem *self)
}
static void
photos_base_item_dispose (GObject *object)
{
PhotosBaseItem *self = PHOTOS_BASE_ITEM (object);
PhotosBaseItemPrivate *priv = self->priv;
g_clear_object (&priv->icon);
G_OBJECT_CLASS (photos_base_item_parent_class)->dispose (object);
}
static void
photos_base_item_finalize (GObject *object)
{
......@@ -155,6 +211,7 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = photos_base_item_dispose;
object_class->finalize = photos_base_item_finalize;
object_class->set_property = photos_base_item_set_property;
class->update_type_description = photos_base_item_update_type_description;
......@@ -178,6 +235,13 @@ photos_base_item_get_author (PhotosBaseItem *self)
}
GdkPixbuf *
photos_base_item_get_icon (PhotosBaseItem *self)
{
return self->priv->icon;
}
const gchar *
photos_base_item_get_id (PhotosBaseItem *self)
{
......
......@@ -21,6 +21,7 @@
#ifndef PHOTOS_BASE_ITEM_H
#define PHOTOS_BASE_ITEM_H
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib-object.h>
G_BEGIN_DECLS
......@@ -67,6 +68,8 @@ GType photos_base_item_get_type (void) G_GNUC_CONST;
const gchar *photos_base_item_get_author (PhotosBaseItem *self);
GdkPixbuf *photos_base_item_get_icon (PhotosBaseItem *self);
const gchar *photos_base_item_get_id (PhotosBaseItem *self);
glong photos_base_item_get_mtime (PhotosBaseItem *self);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment