diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2014-09-13 20:37:57 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2014-09-13 20:37:57 +0200 |
| commit | dc32c58499caa8b1ec4e975afad75ca0d862e990 (patch) | |
| tree | 91322afabcb457406ab512d20163f0dd73ce2c5a /src/generators.c | |
| parent | 302127b03d44277c829642468561ac9e518b7a21 (diff) | |
| download | cataract-dc32c58499caa8b1ec4e975afad75ca0d862e990.tar.xz | |
Introduce properties table
This is a new internal properties storage for attributes that can be
defined both in the item and album scope, with the item scope taking
priority.
The big advantage is a better distinguishment from an undefined, default
value. It also makes easier to retrieve attributes with properly defined
scope priorities.
Diffstat (limited to 'src/generators.c')
| -rw-r--r-- | src/generators.c | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/src/generators.c b/src/generators.c index c51f24e..2483175 100644 --- a/src/generators.c +++ b/src/generators.c @@ -159,21 +159,11 @@ metadata_apply_overrides (ExifData *exif_data, g_free (exif_data->override_copyright); exif_data->override_copyright = g_strdup (setup->add_copyright); - exif_data->timezone_shift = item->metadata_tz_shift; - if (exif_data->timezone_shift == 0) - exif_data->timezone_shift = items->metadata_tz_shift; + exif_data->timezone_shift = get_prop_int (items, item, PROP_METADATA_TZ_SHIFT, 0); - exif_data->override_datetime = item->metadata_override_datetime; - if (exif_data->override_datetime == (time_t) -1) - exif_data->override_datetime = items->metadata_override_datetime; - - exif_data->override_aperture = item->metadata_override_aperture; - if (exif_data->override_aperture == -1) - exif_data->override_aperture = items->metadata_override_aperture; - - exif_data->override_focal_length = item->metadata_override_focal_length; - if (exif_data->override_focal_length == -1) - exif_data->override_focal_length = items->metadata_override_focal_length; + exif_data->override_datetime = get_prop_double (items, item, PROP_METADATA_OVERRIDE_DATETIME, (time_t) -1); + exif_data->override_aperture = get_prop_double (items, item, PROP_METADATA_OVERRIDE_APERTURE, -1); + exif_data->override_focal_length = get_prop_double (items, item, PROP_METADATA_OVERRIDE_FOCAL_LENGTH, -1); g_free (exif_data->external_exif_data); exif_data->external_exif_data = NULL; @@ -182,9 +172,7 @@ metadata_apply_overrides (ExifData *exif_data, exif_data->squared_thumbnail_type = setup->squared_thumbnail_type; - exif_data->thumbnail_crop_hint = item->thumbnail_crop_hint; - if (exif_data->thumbnail_crop_hint == CROP_HINT_UNDEFINED) - exif_data->thumbnail_crop_hint = items->thumbnail_crop_hint; + exif_data->thumbnail_crop_hint = get_prop_int (items, item, PROP_THUMB_CROP_HINT, CROP_HINT_UNDEFINED); } @@ -206,6 +194,7 @@ generate_image (TGallerySetup *setup, gchar *img_src; gchar *img_dst; unsigned long img_w, img_h; + unsigned long tmpw, tmph; int quality; GList *l; TImageSize *image_size; @@ -251,29 +240,37 @@ generate_image (TGallerySetup *setup, if (img_w > 0 && img_h > 0) { stats_images_inc (); - /* Calculate sizes */ + /* Only the "preview" size is affected by deprecated item and album overrides */ + if (is_preview) { + tmpw = get_prop_int (items, item, PROP_WIDTH, img_w); + tmph = get_prop_int (items, item, PROP_HEIGHT, img_h); + calculate_sizes (tmpw, tmph, &img_w, &img_h); + } if (is_thumbnail && setup->squared_thumbnail_type != THUMBNAIL_SQUARE_TYPE_NONE) - img_w = img_h = image_size->square_size; + tmpw = tmph = image_size->square_size; else - if (is_preview && item->width > 0 && item->height > 0) - calculate_sizes (item->width, item->height, &img_w, &img_h); + /* Calculate sizes */ if (img_w > img_h) { - if (is_preview && items->landscape_width > 0 && items->landscape_height > 0) - calculate_sizes (items->landscape_width, items->landscape_height, &img_w, &img_h); - else - calculate_sizes (image_size->landscape_width, image_size->landscape_height, &img_w, &img_h); + tmpw = image_size->landscape_width; + tmph = image_size->landscape_height; + if (is_preview) { + tmpw = get_prop_int (items, item, PROP_LANDSCAPE_W, tmpw); + tmph = get_prop_int (items, item, PROP_LANDSCAPE_H, tmph); + } } else { - if (is_preview && items->portrait_width > 0 && items->portrait_height > 0) - calculate_sizes (items->portrait_width, items->portrait_height, &img_w, &img_h); - else - calculate_sizes (image_size->portrait_width, image_size->portrait_height, &img_w, &img_h); + tmpw = image_size->portrait_width; + tmph = image_size->portrait_height; + if (is_preview) { + tmpw = get_prop_int (items, item, PROP_PORTRAIT_W, tmpw); + tmph = get_prop_int (items, item, PROP_PORTRAIT_H, tmph); + } } + calculate_sizes (tmpw, tmph, &img_w, &img_h); /* Calculate quality */ - quality = image_size->quality; - if (is_preview && items->quality > 0 && items->quality <= 100) - quality = items->quality; - if (is_preview && item->quality > 0 && item->quality <= 100) - quality = item->quality; + if (is_preview) + quality = get_prop_int (items, item, PROP_QUALITY, image_size->quality); + else + quality = image_size->quality; /* Perform resize and strip */ if (! resize_image (img_src, img_dst, img_w, img_h, quality, is_thumbnail, setup->autorotate, exif_data)) @@ -946,11 +943,9 @@ write_html_image (TGallerySetup *setup, block_parser_register_function (block_parser, "has_exif_key", has_exif_key_cb, exif); /* Border style */ - s1 = item->border_style; - if (s1 == NULL) - s1 = parent_items->border_style; + s1 = get_prop_string (parent_items, item, PROP_BORDER_STYLE, NULL); if (s1) - g_hash_table_replace (defines, g_strdup ("BORDER_STYLE"), g_strdup (s1)); + g_hash_table_replace (defines, g_strdup ("BORDER_STYLE"), s1); /* Next/Previous links */ if (next_item) { |
