[gnome-photos/wip/rishi/flowbox: 2/3] base-item: Implement GdMainBoxItem
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/flowbox: 2/3] base-item: Implement GdMainBoxItem
- Date: Thu, 8 Dec 2016 07:16:08 +0000 (UTC)
commit fced7336a88e7edf1494c6472a4f0340d63000c9
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Dec 7 11:45:32 2016 +0100
base-item: Implement GdMainBoxItem
https://bugzilla.gnome.org/show_bug.cgi?id=690623
src/photos-base-item.c | 104 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 94 insertions(+), 10 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 43cddf6..5fdc8a7 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -110,7 +110,12 @@ enum
PROP_0,
PROP_CURSOR,
PROP_FAILED_THUMBNAILING,
+ PROP_ICON,
PROP_ID,
+ PROP_MTIME,
+ PROP_PRIMARY_TEXT,
+ PROP_SECONDARY_TEXT,
+ PROP_URI
};
enum
@@ -122,10 +127,13 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
static void photos_base_item_filterable_iface_init (PhotosFilterableInterface *iface);
+static void photos_base_item_main_box_item_iface_init (GdMainBoxItemInterface *iface);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PhotosBaseItem, photos_base_item, G_TYPE_OBJECT,
G_ADD_PRIVATE (PhotosBaseItem)
+ G_IMPLEMENT_INTERFACE (GD_TYPE_MAIN_BOX_ITEM,
+ photos_base_item_main_box_item_iface_init)
G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_FILTERABLE,
photos_base_item_filterable_iface_init));
EGG_DEFINE_COUNTER (instances, "PhotosBaseItem", "Instances", "Number of PhotosBaseItem instances")
@@ -412,6 +420,7 @@ photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
priv->surface = gdk_cairo_surface_create_from_pixbuf (thumbnailed_pixbuf, scale, window);
+ g_object_notify (G_OBJECT (self), "icon");
g_signal_emit (self, signals[INFO_UPDATED], 0);
out:
@@ -627,7 +636,7 @@ photos_base_item_download_in_thread_func (GTask *task,
static const gchar *
-photos_base_item_get_id (PhotosFilterable *filterable)
+photos_base_item_filterable_get_id (PhotosFilterable *filterable)
{
PhotosBaseItem *self = PHOTOS_BASE_ITEM (filterable);
PhotosBaseItemPrivate *priv;
@@ -647,6 +656,47 @@ photos_base_item_icon_updated (PhotosBaseItem *self, GIcon *icon)
}
+static const gchar *
+photos_base_item_main_box_item_get_id (GdMainBoxItem *box_item)
+{
+ PhotosBaseItem *self = PHOTOS_BASE_ITEM (box_item);
+ PhotosBaseItemPrivate *priv;
+
+ priv = photos_base_item_get_instance_private (self);
+ return priv->id;
+}
+
+
+static const gchar *
+photos_base_item_main_box_item_get_primary_text (GdMainBoxItem *box_item)
+{
+ const gchar *name;
+
+ name = photos_base_item_get_name (PHOTOS_BASE_ITEM (box_item));
+ return name;
+}
+
+
+static const gchar *
+photos_base_item_main_box_item_get_secondary_text (GdMainBoxItem *box_item)
+{
+ const gchar *author;
+
+ author = photos_base_item_get_author (PHOTOS_BASE_ITEM (box_item));
+ return author;
+}
+
+
+static const gchar *
+photos_base_item_main_box_item_get_uri (GdMainBoxItem *box_item)
+{
+ const gchar *uri;
+
+ uri = photos_base_item_get_uri (PHOTOS_BASE_ITEM (box_item));
+ return uri;
+}
+
+
static void
photos_base_item_refresh_collection_icon (PhotosBaseItem *self)
{
@@ -2104,15 +2154,18 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
if (uri == NULL)
uri = "";
photos_utils_set_string (&priv->uri, uri);
+ g_object_notify (G_OBJECT (self), "uri");
id = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
photos_utils_set_string (&priv->id, id);
+ g_object_notify (G_OBJECT (self), "id");
identifier = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_IDENTIFIER, NULL);
photos_utils_set_string (&priv->identifier, identifier);
author = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_AUTHOR, NULL);
photos_utils_set_string (&priv->author, author);
+ g_object_notify (G_OBJECT (self), "secondary-text");
resource_urn = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_RESOURCE_URN, NULL);
photos_utils_set_string (&priv->resource_urn, resource_urn);
@@ -2127,6 +2180,7 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
}
else
priv->mtime = g_get_real_time () / 1000000;
+ g_object_notify (G_OBJECT (self), "mtime");
mime_type = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_MIME_TYPE, NULL);
photos_utils_set_string (&priv->mime_type, mime_type);
@@ -2154,6 +2208,7 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
if (title == NULL)
title = "";
photos_utils_set_string (&priv->name, title);
+ g_object_notify (G_OBJECT (self), "primary-text");
filename = g_strdup (tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_FILENAME, NULL));
if ((filename == NULL || filename[0] == '\0') && !priv->collection)
@@ -2315,10 +2370,30 @@ photos_base_item_get_property (GObject *object, guint prop_id, GValue *value, GP
switch (prop_id)
{
+ case PROP_ICON:
+ g_value_set_boxed (value, priv->surface);
+ break;
+
case PROP_ID:
g_value_set_string (value, priv->id);
break;
+ case PROP_MTIME:
+ g_value_set_int64 (value, priv->mtime);
+ break;
+
+ case PROP_PRIMARY_TEXT:
+ g_value_set_string (value, priv->name);
+ break;
+
+ case PROP_SECONDARY_TEXT:
+ g_value_set_string (value, priv->author);
+ break;
+
+ case PROP_URI:
+ g_value_set_string (value, priv->uri);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2400,14 +2475,6 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
FALSE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
- g_object_class_install_property (object_class,
- PROP_ID,
- g_param_spec_string ("id",
- "Uniform Resource Name",
- "An unique ID associated with this item",
- "",
- G_PARAM_READABLE));
-
signals[INFO_UPDATED] = g_signal_new ("info-updated",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
@@ -2418,6 +2485,13 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
G_TYPE_NONE,
0);
+ g_object_class_override_property (object_class, PROP_ICON, "icon");
+ g_object_class_override_property (object_class, PROP_ID, "id");
+ g_object_class_override_property (object_class, PROP_MTIME, "mtime");
+ g_object_class_override_property (object_class, PROP_PRIMARY_TEXT, "primary-text");
+ g_object_class_override_property (object_class, PROP_SECONDARY_TEXT, "secondary-text");
+ g_object_class_override_property (object_class, PROP_URI, "uri");
+
create_thumbnail_pool = g_thread_pool_new (photos_base_item_create_thumbnail_in_thread_func,
NULL,
1,
@@ -2430,7 +2504,17 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
static void
photos_base_item_filterable_iface_init (PhotosFilterableInterface *iface)
{
- iface->get_id = photos_base_item_get_id;
+ iface->get_id = photos_base_item_filterable_get_id;
+}
+
+
+static void
+photos_base_item_main_box_item_iface_init (GdMainBoxItemInterface *iface)
+{
+ iface->get_id = photos_base_item_main_box_item_get_id;
+ iface->get_uri = photos_base_item_main_box_item_get_uri;
+ iface->get_primary_text = photos_base_item_main_box_item_get_primary_text;
+ iface->get_secondary_text = photos_base_item_main_box_item_get_secondary_text;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]