From 6fffe1a21d5acaa544f7796241e13ff37e75349f Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 25 Jan 2015 18:23:03 +0100 Subject: theming: Make custom image size handling fully flexible This commit brings full flexibility of custom image size definition and usage. When a custom image size is defined, it automatically maps to the album tag arguments. Alternatively, this automatic name matching can be overriden by theme setup tags. This allows us to supply image of different sizes that can be also used in templates. Legacy behaviour of "fullsize" and "preview" image size fallback is retained (though not recommended in new theming setups). --- src/job-manager.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'src/job-manager.c') diff --git a/src/job-manager.c b/src/job-manager.c index 3f13b93..28e81ff 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -138,35 +138,37 @@ thread_func (gpointer data) /* actually do some work */ if (item != NULL && job_item != NULL) { - imgname = GET_ITEM_TARGET_FILENAME (item); /* Two-pass check whether images need to be updated. First check does no I/O except of stat() calls. */ needs_update = job->force_update; if (! needs_update) needs_update = generate_image (job->setup, job->items, item, job->path_info, TRUE); - if (needs_update) + + if (needs_update) { + imgname = get_item_target_filename (item); + if (job->setup->verbose) { + G_LOCK (items_print); + g_print (" [%d/%d] Processing item \"%s\"\n", job_item->index, job->total_items, imgname); + G_UNLOCK (items_print); + } + generate_image (job->setup, job->items, item, job->path_info, FALSE); - - if (needs_update && job->setup->verbose) { - G_LOCK (items_print); - g_print (" [%d/%d] Processing item \"%s\"\n", job_item->index, job->total_items, imgname); - G_UNLOCK (items_print); - } - if (needs_update && job->items->type == GALLERY_TYPE_ALBUM) - for (l = g_list_first (job->setup->design->themes); l; l = g_list_next (l)) { - theme = l->data; - /* Do not generate particular image pages when theme doesn't define it */ - if (theme->enabled && theme->picture_template && theme->picture_filename) { - s1 = g_build_filename (job->path_info->templates_root, theme->picture_template, NULL); - s2 = g_strdup_printf (theme->picture_filename, imgname); - s3 = g_build_filename (job->path_info->dest_dir, s2, NULL); - write_html_page (job->setup, job->path_info, theme, s1, s3, job->items, item); - g_free (s1); - g_free (s2); - g_free (s3); + if (job->items->type == GALLERY_TYPE_ALBUM) + for (l = g_list_first (job->setup->design->themes); l; l = g_list_next (l)) { + theme = l->data; + /* Do not generate particular image pages when theme doesn't define it */ + if (theme->enabled && theme->picture_template && theme->picture_filename) { + s1 = g_build_filename (job->path_info->templates_root, theme->picture_template, NULL); + s2 = g_strdup_printf (theme->picture_filename, imgname); + s3 = g_build_filename (job->path_info->dest_dir, s2, NULL); + write_html_page (job->setup, job->path_info, theme, s1, s3, job->items, item); + g_free (s1); + g_free (s2); + g_free (s3); + } } - } - g_free (imgname); + g_free (imgname); + } } } while (item != NULL); @@ -232,7 +234,7 @@ build_tree (TGallerySetup *setup, } /* Read the index file and fill items array */ - items = parse_album_xml (idx_file, path_info); + items = parse_album_xml (setup, idx_file, path_info); if (! items) { log_error ("error reading index file '%s'\n", idx_file); g_free (idx_file); -- cgit v1.2.3