summaryrefslogtreecommitdiff
path: root/items.c
diff options
context:
space:
mode:
Diffstat (limited to 'items.c')
-rw-r--r--items.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/items.c b/items.c
index cf2d90f..97202f2 100644
--- a/items.c
+++ b/items.c
@@ -39,7 +39,7 @@ parse_album_xml (const char *filename, TAlbum *index)
char *gallery_type;
int count;
int i;
- char *s;
+ char *s, *s2;
char *node_name;
TIndexItem *item;
@@ -140,6 +140,26 @@ parse_album_xml (const char *filename, TAlbum *index)
item->hidden = (xml_file_get_node_present (xml, s));
g_free (s);
+ /* Retrieve title and description from linked album if not defined here */
+ if (index->type == GALLERY_TYPE_INDEX &&
+ item->title == NULL && item->title_description == NULL) {
+ s = g_strconcat (index->base_dir, "/", item->path, "/index.xml", NULL);
+ get_album_titles (s, &item->title, &item->title_description, NULL);
+ g_free (s);
+ }
+
+ /* Retrieve thumbnail from linked album if not defined here */
+ if (index->type == GALLERY_TYPE_INDEX && item->thumbnail == NULL) {
+ s = g_strconcat (index->base_dir, "/", item->path, "/index.xml", NULL);
+ s2 = NULL;
+ get_album_titles (s, NULL, NULL, &s2);
+ if (s2) {
+ item->thumbnail = g_strconcat (item->path, "/", s2, NULL);
+ g_free (s2);
+ }
+ g_free (s);
+ }
+
if (item->path || item->preview)
{
g_ptr_array_add (index->items, item);
@@ -245,7 +265,7 @@ get_album_objects_count (const char *filename)
xml = xml_parser_load (filename);
if (xml == NULL)
- return 0;
+ return 0;
count = xml_file_node_get_children_count (xml, "/gallery/items/item");
xml_parser_close (xml);
@@ -255,3 +275,30 @@ get_album_objects_count (const char *filename)
#endif
return count;
}
+
+/*
+ * get_album_titles: retrieve title, description and first thumbnail from specified album
+ */
+void
+get_album_titles (const char *filename, char **title, char **description, char **thumbnail)
+{
+ TXMLFile *xml;
+
+ xml = xml_parser_load (filename);
+ if (xml == NULL)
+ return;
+
+ if (title)
+ *title = xml_file_get_node_value (xml, "/gallery/general/title/text()");
+ if (description)
+ *description = xml_file_get_node_value (xml, "/gallery/general/description/text()");
+ if (thumbnail) {
+ *thumbnail = xml_file_get_node_attribute (xml, "/gallery/items/item[1]/thumbnail", "src");
+ if (! *thumbnail)
+ *thumbnail = xml_file_get_node_attribute (xml, "/gallery/items/item[1]", "src");
+ if (! *thumbnail)
+ *thumbnail = xml_file_get_node_attribute (xml, "/gallery/items/item[1]", "preview");
+ }
+
+ xml_parser_close (xml);
+}