diff options
Diffstat (limited to 'src/setup.c')
| -rw-r--r-- | src/setup.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/setup.c b/src/setup.c index 9cdf7d5..f0a6f3d 100644 --- a/src/setup.c +++ b/src/setup.c @@ -233,8 +233,8 @@ parse_design_setup_xml (const gchar *filename) image_size->quality = xml_file_get_node_attribute_long_with_default (xml, s, "value", -1); g_free (s); - s = g_strdup_printf ("/design_setup/image_sizes/size[%d]/no_resize", i + 1); - image_size->no_resize = xml_file_get_node_present (xml, s); + s = g_strdup_printf ("/design_setup/image_sizes/size[%d]/fallback", i + 1); + image_size->fallback_size = xml_file_get_node_attribute (xml, s, "size"); g_free (s); } @@ -434,8 +434,10 @@ gboolean validate_design_setup (TGallerySetup *setup) { GList *l; - TImageSize *image_size; + TImageSize *image_size, *isi; TGalleryDesignTheme *theme; + GHashTable *fallback_history; + gboolean res; /* check for version match */ if (! SETUP_IS_NATIVE (setup->design)) { @@ -460,6 +462,28 @@ validate_design_setup (TGallerySetup *setup) fprintf (stderr, "design validation warning: image size %s defined with zero sized element\n", image_size->name); continue; } + if (image_size->fallback_size != NULL && lookup_image_size_for_name (setup, image_size->fallback_size) == NULL) { + fprintf (stderr, "design validation error: specified \"%s\" fallback image size not found\n", image_size->fallback_size); + return FALSE; + } + if (image_size->fallback_size != NULL) { + fallback_history = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + isi = image_size; + res = TRUE; + while (isi != NULL) { + if (g_hash_table_lookup (fallback_history, isi->name)) { + res = FALSE; + break; + } + g_hash_table_insert (fallback_history, g_strdup (isi->name), (gpointer) 0x1); + isi = lookup_image_size_for_name (setup, isi->fallback_size); + } + g_hash_table_unref (fallback_history); + if (! res) { + fprintf (stderr, "design validation error: the fallback path for the \"%s\" image size leads to an endless loop\n", image_size->name); + return FALSE; + } + } } /* validate themes */ @@ -577,6 +601,7 @@ free_image_size_data (TImageSize *image_size) if (image_size) { g_free (image_size->name); g_free (image_size->tagname); + g_free (image_size->fallback_size); g_free (image_size); } } |
