diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2013-04-07 18:11:42 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2013-04-07 18:11:42 +0200 |
| commit | ced9539fef270fe133cb0ad6fc04c30bd5fa2dfe (patch) | |
| tree | 91e432faf1482e7adedcd0ea6e6942861325d7dc /src/items.c | |
| parent | d912f084ffbcae0ca4b8fdfb355d6bbd6a6d3506 (diff) | |
| download | cataract-ced9539fef270fe133cb0ad6fc04c30bd5fa2dfe.tar.xz | |
Add ability to specify thumbnail square crop hint
In simple crop square mode it's sometimes viable to specify position
of the square. This is vastly useful for portrait pictures so that you
don't crop the head off the body.
Diffstat (limited to 'src/items.c')
| -rw-r--r-- | src/items.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/src/items.c b/src/items.c index 85f0a26..31ab41f 100644 --- a/src/items.c +++ b/src/items.c @@ -85,6 +85,29 @@ parse_datetime_string (const gchar *str) return rt; } +static TCropHint +parse_thumbnail_crop_hint (const gchar *str) +{ + g_return_val_if_fail (str != NULL, CROP_HINT_UNDEFINED); + + if (g_ascii_strcasecmp (str, "center") == 0) + return CROP_HINT_CENTER; + else + if (g_ascii_strcasecmp (str, "left") == 0) + return CROP_HINT_LEFT; + else + if (g_ascii_strcasecmp (str, "right") == 0) + return CROP_HINT_RIGHT; + else + if (g_ascii_strcasecmp (str, "top") == 0) + return CROP_HINT_TOP; + else + if (g_ascii_strcasecmp (str, "bottom") == 0) + return CROP_HINT_BOTTOM; + else + return CROP_HINT_UNDEFINED; +} + /* * parse_album_xml: XML parser for gallery index.xml files @@ -161,6 +184,12 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info) g_free (s); } + s = xml_file_get_node_attribute (xml, "/gallery/general/thumbnail", "crop"); + if (s != NULL) { + index->thumbnail_crop_hint = parse_thumbnail_crop_hint (s); + g_free (s); + } + index->nofullsize = xml_file_get_node_present (xml, "/gallery/general/nofullsize"); index->fullsize = xml_file_get_node_present (xml, "/gallery/general/fullsize"); @@ -306,6 +335,14 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info) g_free (s2); } + s = g_strdup_printf ("/gallery/items/*[%d]/thumbnail", i + 1); + s2 = xml_file_get_node_attribute (xml, s, "crop"); + g_free (s); + if (s2 != NULL) { + item->thumbnail_crop_hint = parse_thumbnail_crop_hint (s2); + g_free (s2); + } + if (item->path || item->preview) { g_ptr_array_add (index->items, item); } else { @@ -422,15 +459,15 @@ free_album_data (TAlbum *album) * get_album_info: retrieve number of items and protected status in the specified album */ void -get_album_info (const gchar *filename, int *objects_count, gboolean *protected) +get_album_info (const gchar *filename, int *objects_count, gboolean *is_protected) { TXMLFile *xml; int count, hidden; if (objects_count) *objects_count = 0; - if (protected) - *protected = FALSE; + if (is_protected) + *is_protected = FALSE; xml = xml_parser_load (filename); if (xml == NULL) @@ -441,9 +478,9 @@ get_album_info (const gchar *filename, int *objects_count, gboolean *protected) if (objects_count) *objects_count = count - hidden; - if (protected) - *protected = xml_file_get_node_present (xml, "/gallery/general/auth/username") && - xml_file_get_node_present (xml, "/gallery/general/auth/password"); + if (is_protected) + *is_protected = xml_file_get_node_present (xml, "/gallery/general/auth/username") && + xml_file_get_node_present (xml, "/gallery/general/auth/password"); xml_parser_free (xml); } |
