summaryrefslogtreecommitdiff
path: root/src/generators.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2011-01-23 10:56:14 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2011-01-23 10:56:14 +0100
commit7df97fbe8fa93141e7922a95f5ce0f9254bf41ab (patch)
tree84c519692470b7a597f72acc2614d9d85bfa8ff6 /src/generators.c
parentbb58d822fb517f4a7a242994bbda3693255b2c74 (diff)
downloadcataract-7df97fbe8fa93141e7922a95f5ce0f9254bf41ab.tar.xz
Consolidate paths in a separate struct
This will allow us to pass detailed path info to worker methods. Each path info instance is bound to a currently processed album and directory. Possibly move to struct TItems in the future.
Diffstat (limited to 'src/generators.c')
-rw-r--r--src/generators.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/generators.c b/src/generators.c
index 2cea20a..2329953 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -108,7 +108,7 @@ generate_image (TGallerySetup *setup,
TAlbum *items,
TIndexItem *item,
unsigned int item_index,
- const gchar *dst_dir,
+ TPathInfo *path_info,
gboolean update_when_necessary,
gboolean *thumb_portrait)
{
@@ -133,26 +133,26 @@ generate_image (TGallerySetup *setup,
if (items->type == GALLERY_TYPE_INDEX) {
if (item->thumbnail == NULL || strlen (item->thumbnail) == 0)
return FALSE;
- img_src_full = g_strconcat (items->base_dir, "/", item->thumbnail, NULL);
- thumb_src_full = g_strconcat (items->base_dir, "/", item->thumbnail, NULL);
+ img_src_full = g_strconcat (path_info->src_dir, "/", item->thumbnail, NULL);
+ thumb_src_full = g_strconcat (path_info->src_dir, "/", item->thumbnail, NULL);
}
else
if (items->type == GALLERY_TYPE_ALBUM) {
s1 = (item->path == NULL && item->preview) ? item->preview : item->path;
thumb_src_full = (item->thumbnail) ? item->thumbnail : s1;
- img_src_full = g_strconcat (items->base_dir, "/", s1, NULL);
- thumb_src_full = g_strconcat (items->base_dir, "/", thumb_src_full, NULL);
+ img_src_full = g_strconcat (path_info->src_dir, "/", s1, NULL);
+ thumb_src_full = g_strconcat (path_info->src_dir, "/", thumb_src_full, NULL);
}
/* Make paths */
s1 = item_get_thumbnail_src (setup, items, item, item_index);
- thumb_dst = g_strconcat (dst_dir, "/", setup->thumbnail_dir, "/", s1, NULL);
+ thumb_dst = g_strconcat (path_info->dest_dir, "/", setup->thumbnail_dir, "/", s1, NULL);
g_free (s1);
s1 = item_get_img_src (setup, items, item);
- big_dst = g_strconcat (dst_dir, "/", setup->img_big_dir, "/", s1, NULL);
+ big_dst = g_strconcat (path_info->dest_dir, "/", setup->img_big_dir, "/", s1, NULL);
if (item->force_fullsize || setup->override_nofullsize || (items->fullsize && ! item->force_nofullsize) ||
(! item->force_nofullsize && ! items->nofullsize && ! setup->nofullsize))
- orig_dst = g_strconcat (dst_dir, "/", setup->img_orig_dir, "/", s1, NULL);
+ orig_dst = g_strconcat (path_info->dest_dir, "/", setup->img_orig_dir, "/", s1, NULL);
res = (! update_when_necessary) || needs_update (thumb_src_full, thumb_dst) ||
(items->type == GALLERY_TYPE_ALBUM && (needs_update (img_src_full, big_dst) || (orig_dst && needs_update (img_src_full, orig_dst))));
g_free (s1);
@@ -220,7 +220,7 @@ generate_image (TGallerySetup *setup,
else
{
/* Copy the preview (big) image provided */
- big_src = g_strconcat (items->base_dir, "/", item->preview, NULL);
+ big_src = g_strconcat (path_info->src_dir, "/", item->preview, NULL);
if (! copy_file (big_src, big_dst))
log_error ("generate_image: error copying preview image %s\n", big_src);
g_free (big_src);
@@ -259,6 +259,7 @@ generate_image (TGallerySetup *setup,
*/
gboolean
write_html_album (TGallerySetup *setup,
+ TPathInfo *path_info,
const gchar *template_src,
const gchar *dst,
TAlbum *items)
@@ -475,10 +476,8 @@ write_html_album (TGallerySetup *setup,
s3 = item_get_thumbnail_src (setup, items, item, i);
if (s3 != NULL) {
replace_table_add_key_printf (local_replace_table, "IMG_THUMBNAIL", "%s/%s", setup->thumbnail_dir, s3);
- s5 = g_path_get_dirname (dst);
- s4 = g_build_filename (s5, setup->thumbnail_dir, s3, NULL);
+ s4 = g_build_filename (path_info->dest_dir, setup->thumbnail_dir, s3, NULL);
get_image_sizes (s4, &img_thumb_w, &img_thumb_h);
- g_free (s5);
g_free (s4);
replace_table_add_key_int (local_replace_table, "IMG_SIZE_THUMB_W", img_thumb_w);
replace_table_add_key_int (local_replace_table, "IMG_SIZE_THUMB_H", img_thumb_h);
@@ -488,7 +487,7 @@ write_html_album (TGallerySetup *setup,
replace_table_add_key (local_replace_table, "IMG_DESCRIPTION", item->title_description);
replace_table_add_key_printf (local_replace_table, "IMG_LIST_ID", "i%d", i + 1);
if (items->type == GALLERY_TYPE_INDEX) {
- s3 = g_strconcat (items->base_dir, "/", item->path, "/index.xml", NULL);
+ s3 = g_strconcat (path_info->src_dir, "/", item->path, "/index.xml", NULL);
replace_table_add_key_int (local_replace_table, "ALBUM_NUM_ITEMS", get_album_objects_count (s3));
g_free (s3);
}
@@ -545,7 +544,6 @@ write_html_album (TGallerySetup *setup,
* write_html_image: process single image template file
*
* template_src = template file of the album/index
- * original_img = source image file (original full-size) to get EXIF data from
* dst = save generated file as
* item = data for the current item
* parent_items = array of items in the album, to determine our position and make links to previous/next image
@@ -553,8 +551,8 @@ write_html_album (TGallerySetup *setup,
*/
gboolean
write_html_image (TGallerySetup *setup,
+ TPathInfo *path_info,
const gchar *template_src,
- const gchar *original_img,
const gchar *dst,
TIndexItem *item,
TAlbum *parent_items)
@@ -635,14 +633,14 @@ write_html_image (TGallerySetup *setup,
preload_imgname = g_strconcat (setup->img_big_dir, "/", s1, NULL);
g_free (s1);
}
- s1 = g_path_get_dirname (dst);
- big_dst = g_strconcat (s1, "/", setup->img_big_dir, "/", imgname, NULL);
- orig_dst = g_strconcat (s1, "/", setup->img_orig_dir, "/", imgname, NULL);
- g_free (s1);
+ big_dst = g_strconcat (path_info->dest_dir, "/", setup->img_big_dir, "/", imgname, NULL);
+ orig_dst = g_strconcat (path_info->dest_dir, "/", setup->img_orig_dir, "/", imgname, NULL);
res = TRUE;
/* Get EXIF data from the original image */
- exif = get_exif (original_img);
+ s1 = g_strconcat (path_info->src_dir, "/", (item->path == NULL && item->preview) ? item->preview : item->path, NULL);
+ exif = get_exif (s1);
+ g_free (s1);
if (exif == NULL)
log_error ("write_html_image: error getting exif data from file \"%s\"\n", orig_dst);