summaryrefslogtreecommitdiff
path: root/src/setup.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2014-09-13 20:37:57 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2014-09-13 20:37:57 +0200
commitdc32c58499caa8b1ec4e975afad75ca0d862e990 (patch)
tree91322afabcb457406ab512d20163f0dd73ce2c5a /src/setup.c
parent302127b03d44277c829642468561ac9e518b7a21 (diff)
downloadcataract-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/setup.c')
-rw-r--r--src/setup.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/setup.c b/src/setup.c
index d9b5ed3..cf4ca3f 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -91,20 +91,20 @@ parse_setup_xml (const gchar *filename)
setup = g_malloc0 (sizeof (TGallerySetup));
setup->setup_xml_path = g_strdup (filename);
- setup->version = nearbyint (xml_file_get_node_attribute_double (xml, "/gallery_setup", "version", -1) * 100);
+ setup->version = nearbyint (xml_file_get_node_attribute_double_with_default (xml, "/gallery_setup", "version", -1) * 100);
/* design section */
setup->design_setup_file = xml_file_get_node_value (xml, "/gallery_setup/design/setup_file/text()");
- setup->supplemental_files_use_common_root = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/design/supplemental_files_use_common_root", "value", FALSE);
+ setup->supplemental_files_use_common_root = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/design/supplemental_files_use_common_root", "value", FALSE);
/* images section */
- setup->preload = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/images/preload", "value", TRUE);
- setup->use_iptc_exif = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/images/use_iptc_exif", "value", FALSE);
- setup->erase_exif_thumbnail = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/images/erase_embed_thumbnail", "value", FALSE);
- setup->strip_xmp = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/images/strip_xmp", "value", TRUE);
- setup->write_supplied_exif = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/images/write_supplied_exif", "value", FALSE);
+ setup->preload = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/preload", "value", TRUE);
+ setup->use_iptc_exif = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/use_iptc_exif", "value", FALSE);
+ setup->erase_exif_thumbnail = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/erase_embed_thumbnail", "value", FALSE);
+ setup->strip_xmp = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/strip_xmp", "value", TRUE);
+ setup->write_supplied_exif = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/write_supplied_exif", "value", FALSE);
setup->nofullsize = xml_file_get_node_present (xml, "/gallery_setup/images/nofullsize");
- setup->autorotate = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/images/autorotate", "value", TRUE);
+ setup->autorotate = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/autorotate", "value", TRUE);
s = xml_file_get_node_attribute (xml, "/gallery_setup/images/squared_thumbnails", "type");
if (s && g_ascii_strcasecmp (s, "simple") == 0)
@@ -118,17 +118,17 @@ parse_setup_xml (const gchar *filename)
setup->meta_author_email = xml_file_get_node_value (xml, "/gallery_setup/meta/author_email/text()");
setup->meta_description = xml_file_get_node_value (xml, "/gallery_setup/meta/description/text()");
setup->meta_keywords = xml_file_get_node_value (xml, "/gallery_setup/meta/keywords/text()");
- setup->use_title_as_meta = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/meta/use_title_as_meta", "value", TRUE);
+ setup->use_title_as_meta = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/meta/use_title_as_meta", "value", TRUE);
setup->site_title = xml_file_get_node_attribute (xml, "/gallery_setup/meta/site", "title");
setup->add_copyright = xml_file_get_node_value (xml, "/gallery_setup/meta/add_copyright/text()");
setup->favicon_file = xml_file_get_node_value (xml, "/gallery_setup/meta/favicon/text()");
setup->favicon_type = xml_file_get_node_attribute (xml, "/gallery_setup/meta/favicon", "type");
/* navigation section */
- setup->use_inpage_links = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/navigation/use_inpage_links", "value", TRUE);
+ setup->use_inpage_links = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/navigation/use_inpage_links", "value", TRUE);
/* feed section */
- setup->feed_enabled = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/feed", "enable", FALSE);
+ setup->feed_enabled = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/feed", "enable", FALSE);
setup->feed_filename = xml_file_get_node_value (xml, "/gallery_setup/feed/filename/text()");
setup->feed_title = xml_file_get_node_value (xml, "/gallery_setup/feed/title/text()");
@@ -142,7 +142,7 @@ parse_setup_xml (const gchar *filename)
/* legacy mode */
if (SETUP_IS_LEGACY (setup)) {
setup->design_setup_file = xml_file_get_node_value (xml, "/gallery_setup/templates/path/text()");
- setup->supplemental_files_use_common_root = xml_file_get_node_attribute_boolean (xml, "/gallery_setup/templates/support_files_use_common_root", "value", FALSE);
+ setup->supplemental_files_use_common_root = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/templates/support_files_use_common_root", "value", FALSE);
setup->location_base_url = xml_file_get_node_value (xml, "/gallery_setup/feed/base_url/text()");
}
@@ -172,7 +172,7 @@ parse_design_setup_xml (const gchar *filename)
return NULL;
design = g_malloc0 (sizeof (TGalleryDesign));
- design->version = nearbyint (xml_file_get_node_attribute_double (xml, "/design_setup", "version", -1) * 100);
+ design->version = nearbyint (xml_file_get_node_attribute_double_with_default (xml, "/design_setup", "version", -1) * 100);
s2 = xml_file_get_node_value (xml, "/design_setup/supplemental_files/text()");
if (s2) {
@@ -192,21 +192,21 @@ parse_design_setup_xml (const gchar *filename)
g_free (s);
s = g_strdup_printf ("/design_setup/image_sizes/size[%d]/landscape", i + 1);
- image_size->landscape_width = xml_file_get_node_attribute_long (xml, s, "w", 0);
- image_size->landscape_height = xml_file_get_node_attribute_long (xml, s, "h", 0);
+ image_size->landscape_width = xml_file_get_node_attribute_long_with_default (xml, s, "w", 0);
+ image_size->landscape_height = xml_file_get_node_attribute_long_with_default (xml, s, "h", 0);
g_free (s);
s = g_strdup_printf ("/design_setup/image_sizes/size[%d]/portrait", i + 1);
- image_size->portrait_width = xml_file_get_node_attribute_long (xml, s, "w", 0);
- image_size->portrait_height = xml_file_get_node_attribute_long (xml, s, "h", 0);
+ image_size->portrait_width = xml_file_get_node_attribute_long_with_default (xml, s, "w", 0);
+ image_size->portrait_height = xml_file_get_node_attribute_long_with_default (xml, s, "h", 0);
g_free (s);
s = g_strdup_printf ("/design_setup/image_sizes/size[%d]/square", i + 1);
- image_size->square_size = xml_file_get_node_attribute_long (xml, s, "size", 0);
+ image_size->square_size = xml_file_get_node_attribute_long_with_default (xml, s, "size", 0);
g_free (s);
s = g_strdup_printf ("/design_setup/image_sizes/size[%d]/quality", i + 1);
- image_size->quality = xml_file_get_node_attribute_long (xml, s, "value", -1);
+ 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);
@@ -222,7 +222,7 @@ parse_design_setup_xml (const gchar *filename)
design->themes = g_list_append (design->themes, theme);
s = g_strdup_printf ("/design_setup/theme[%d]", i + 1);
- theme->enabled = xml_file_get_node_attribute_boolean (xml, s, "enabled", TRUE);
+ theme->enabled = xml_file_get_node_attribute_boolean_with_default (xml, s, "enabled", TRUE);
g_free (s);
s = g_strdup_printf ("/design_setup/theme[%d]/index/template/text()", i + 1);
@@ -312,12 +312,12 @@ makeup_legacy_design (const gchar *filename)
image_size = g_malloc0 (sizeof (TImageSize));
image_size->name = g_strdup (image_sizes[i]);
s = g_strdup_printf ("/gallery_setup/images/%s", image_sizes[i]);
- image_size->landscape_width = xml_file_get_node_attribute_long (xml, s, "landscape_w", 0);
- image_size->landscape_height = xml_file_get_node_attribute_long (xml, s, "landscape_h", 0);
- image_size->portrait_width = xml_file_get_node_attribute_long (xml, s, "portrait_w", 0);
- image_size->portrait_height = xml_file_get_node_attribute_long (xml, s, "portrait_h", 0);
- image_size->square_size = xml_file_get_node_attribute_long (xml, s, "square", 0);
- image_size->quality = xml_file_get_node_attribute_long (xml, s, "quality", -1);
+ image_size->landscape_width = xml_file_get_node_attribute_long_with_default (xml, s, "landscape_w", 0);
+ image_size->landscape_height = xml_file_get_node_attribute_long_with_default (xml, s, "landscape_h", 0);
+ image_size->portrait_width = xml_file_get_node_attribute_long_with_default (xml, s, "portrait_w", 0);
+ image_size->portrait_height = xml_file_get_node_attribute_long_with_default (xml, s, "portrait_h", 0);
+ image_size->square_size = xml_file_get_node_attribute_long_with_default (xml, s, "square", 0);
+ image_size->quality = xml_file_get_node_attribute_long_with_default (xml, s, "quality", -1);
image_size->no_resize = (i == G_N_ELEMENTS (image_sizes) - 1);
g_free (s);
design->image_sizes = g_list_append (design->image_sizes, image_size);
@@ -352,9 +352,9 @@ makeup_legacy_design (const gchar *filename)
theme->picture_image_size = g_strdup (image_sizes[1]);
theme->defines = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- if (xml_file_get_node_attribute_boolean (xml, "/gallery_setup/navigation/show_go_up", "value", TRUE))
+ if (xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/navigation/show_go_up", "value", TRUE))
g_hash_table_replace (theme->defines, g_strdup ("SHOW_GO_UP"), g_strdup (""));
- if (xml_file_get_node_attribute_boolean (xml, "/gallery_setup/navigation/show_exif_table", "value", TRUE))
+ if (xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/navigation/show_exif_table", "value", TRUE))
g_hash_table_replace (theme->defines, g_strdup ("SHOW_EXIF_TABLE"), g_strdup (""));
s = xml_file_get_node_attribute (xml, "/gallery_setup/images/border", "style");
g_hash_table_replace (theme->defines, g_strdup ("BORDER_STYLE"), s ? s : g_strdup ("border_single"));