summaryrefslogtreecommitdiff
path: root/src/items.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/items.c')
-rw-r--r--src/items.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/items.c b/src/items.c
index d720415..af36ab9 100644
--- a/src/items.c
+++ b/src/items.c
@@ -113,18 +113,20 @@ parse_thumbnail_crop_hint (const gchar *str)
* parse_album_xml: XML parser for gallery index.xml files
*/
TAlbum *
-parse_album_xml (const gchar *filename, TPathInfo *path_info)
+parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_info)
{
TXMLFile *xml;
gchar *gallery_type;
int count;
int i;
+ GList *l;
gchar *s, *s2;
gchar *node_name;
gchar *base_dir;
TIndexItem *item;
TAtomFeedItem *feed_item;
TAlbum *index;
+ TImageSize *image_size;
xml = xml_parser_load (filename);
if (xml == NULL)
@@ -263,13 +265,22 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info)
item->path = xml_file_get_node_attribute (xml, s, "path");
else
item->path = xml_file_get_node_attribute (xml, s, "src");
- item->preview = xml_file_get_node_attribute (xml, s, "preview");
prop_xml_attr_long (item->properties, PROP_QUALITY, xml, s, "quality");
prop_xml_attr_long (item->properties, PROP_WIDTH, xml, s, "width");
prop_xml_attr_long (item->properties, PROP_HEIGHT, xml, s, "height");
prop_xml_attr (item->properties, PROP_BORDER_STYLE, xml, s, "border");
- if (index->type == GALLERY_TYPE_ALBUM)
- item->thumbnail = xml_file_get_node_attribute (xml, s, "thumbnail");
+
+ /* custom image size attributes */
+ for (l = g_list_first (setup->design->image_sizes); l; l = g_list_next (l)) {
+ image_size = l->data;
+ g_assert (image_size != NULL);
+ s2 = xml_file_get_node_attribute (xml, s, image_size->tagname ? image_size->tagname : image_size->name);
+ if (s2) {
+ if (item->image_sizes == NULL)
+ item->image_sizes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ g_assert (g_hash_table_insert (item->image_sizes, g_strdup (image_size->tagname ? image_size->tagname : image_size->name), s2));
+ }
+ }
g_free (s);
s = g_strdup_printf ("/gallery/items/*[%d]/title/text()", i + 1);
@@ -349,10 +360,10 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info)
g_free (s2);
}
- if (item->path || item->preview) {
+ if (item->path || item->image_sizes) {
g_ptr_array_add (index->items, item);
} else {
- log_error ("%s: No image src specified, skipping!\n", filename);
+ log_error ("%s: No image src specified (title = '%s'), skipping!\n", filename, item->title);
free_index_item (item);
}
}
@@ -407,9 +418,10 @@ dup_index_item (TIndexItem *item)
i->title = g_strdup (item->title);
i->title_description = g_strdup (item->title_description);
i->thumbnail = g_strdup (item->thumbnail);
- i->preview = g_strdup (item->preview);
i->metadata_external_exif = g_strdup (item->metadata_external_exif);
i->properties = properties_table_dup (item->properties);
+ if (item->image_sizes)
+ i->image_sizes = clone_string_hash_table (item->image_sizes);
return i;
}
@@ -425,9 +437,10 @@ free_index_item (TIndexItem *item)
g_free (item->title);
g_free (item->title_description);
g_free (item->thumbnail);
- g_free (item->preview);
g_free (item->metadata_external_exif);
properties_table_free (item->properties);
+ if (item->image_sizes)
+ g_hash_table_destroy (item->image_sizes);
g_free (item);
}
}
@@ -566,6 +579,23 @@ free_path_info (TPathInfo *path_info)
}
}
+/*
+ * get_item_target_filename: get target item filename
+ */
+gchar *
+get_item_target_filename (TIndexItem *item)
+{
+ const gchar *s;
+
+ s = item->path;
+ if (s == NULL && item->image_sizes)
+ s = g_hash_table_lookup (item->image_sizes, "preview");
+ if (s == NULL)
+ return NULL;
+
+ return g_path_get_basename (s);
+}
+
/*
* get_prop_*: retrieve attribute value from properties tables, with item taking priority, using items otherwise or falling back to default if not set anywhere