Commit 09770f81 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

Fixed catalog creation

Check whether an attribute is present before using it.
parent a73b8828
......@@ -295,38 +295,49 @@ ss__gth_catalog_write_to_doc (GthCatalog *catalog,
DomElement *root)
{
DomElement *slideshow;
char *delay;
char **playlist_files;
if (! g_value_hash_is_set (catalog->attributes, "slideshow::personalize"))
return;
slideshow = dom_document_create_element (doc,
"slideshow",
"personalize", (g_value_hash_get_boolean (catalog->attributes, "slideshow::personalize") ? "true" : "false"),
"automatic", (g_value_hash_get_boolean (catalog->attributes, "slideshow::automatic") ? "true" : "false"),
"wrap-around", (g_value_hash_get_boolean (catalog->attributes, "slideshow::wrap-around") ? "true" : "false"),
"personalize", (g_value_hash_get_boolean_or_default (catalog->attributes, "slideshow::personalize", FALSE) ? "true" : "false"),
"automatic", (g_value_hash_get_boolean_or_default (catalog->attributes, "slideshow::automatic", FALSE) ? "true" : "false"),
"wrap-around", (g_value_hash_get_boolean_or_default (catalog->attributes, "slideshow::wrap-around", FALSE) ? "true" : "false"),
NULL);
dom_element_append_child (root, slideshow);
delay = g_strdup_printf ("%d", g_value_hash_get_int (catalog->attributes, "slideshow::delay"));
dom_element_append_child (slideshow,
dom_document_create_element_with_text (doc, delay, "delay", NULL));
g_free (delay);
if (g_value_hash_is_set (catalog->attributes, "slideshow::delay")) {
char *delay;
delay = g_strdup_printf ("%d", g_value_hash_get_int (catalog->attributes, "slideshow::delay"));
dom_element_append_child (slideshow,
dom_document_create_element_with_text (doc, delay, "delay", NULL));
g_free (delay);
}
if (g_value_hash_is_set (catalog->attributes, "slideshow::transition"))
dom_element_append_child (slideshow,
dom_document_create_element_with_text (doc,
g_value_hash_get_string (catalog->attributes, "slideshow::transition"),
"transition",
NULL));
dom_element_append_child (slideshow,
dom_document_create_element_with_text (doc,
g_value_hash_get_string (catalog->attributes, "slideshow::transition"),
"transition",
NULL));
if (g_value_hash_is_set (catalog->attributes, "slideshow::playlist")) {
char **playlist_files;
playlist_files = g_value_hash_get_stringv (catalog->attributes, "slideshow::playlist");
if (playlist_files[0] != NULL) {
DomElement *playlist;
int i;
playlist_files = g_value_hash_get_stringv (catalog->attributes, "slideshow::playlist");
if (playlist_files[0] != NULL) {
DomElement *playlist;
int i;
playlist = dom_document_create_element (doc, "playlist", NULL);
dom_element_append_child (slideshow, playlist);
playlist = dom_document_create_element (doc, "playlist", NULL);
dom_element_append_child (slideshow, playlist);
for (i = 0; playlist_files[i] != NULL; i++)
dom_element_append_child (playlist, dom_document_create_element (doc, "file", "uri", playlist_files[i], NULL));
for (i = 0; playlist_files[i] != NULL; i++)
dom_element_append_child (playlist, dom_document_create_element (doc, "file", "uri", playlist_files[i], NULL));
}
}
}
......
......@@ -64,12 +64,18 @@ GValue * g_value_hash_get_value (GValueHash *self,
const char *key);
gboolean g_value_hash_is_set (GValueHash *self,
const char *key);
#define g_value_hash_get_boolean(self, key) (g_value_get_boolean (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_float(self, key) (g_value_get_float (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_int(self, key) (g_value_get_int (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_string(self, key) (g_value_get_string (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_stringv(self, key) ((char **) g_value_get_boxed (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_string_list(self, key) ((GList *) g_value_get_boxed (g_value_hash_get_value ((self), (key))))))
#define g_value_hash_get_boolean(self, key) (g_value_get_boolean (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_float(self, key) (g_value_get_float (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_int(self, key) (g_value_get_int (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_string(self, key) (g_value_get_string (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_stringv(self, key) ((char **) g_value_get_boxed (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_string_list(self, key) ((GList *) g_value_get_boxed (g_value_hash_get_value ((self), (key))))
#define g_value_hash_get_boolean_or_default(self, key, _default) (g_value_hash_is_set ((self), (key)) ? g_value_get_boolean (g_value_hash_get_value ((self), (key))) : (_default))
#define g_value_hash_get_float_or_default(self, key, _default) (g_value_hash_is_set ((self), (key)) ? g_value_get_float (g_value_hash_get_value ((self), (key))) : (_default))
#define g_value_hash_get_int_or_default(self, key, _default) (g_value_hash_is_set ((self), (key)) ? g_value_get_int (g_value_hash_get_value ((self), (key))) : (_default))
#define g_value_hash_get_string_or_default(self, key, _default) (g_value_hash_is_set ((self), (key)) ? g_value_get_string (g_value_hash_get_value ((self), (key))) : (_default))
#define g_value_hash_get_stringv_or_default(self, key, _default) (g_value_hash_is_set ((self), (key)) ? (char **) g_value_get_boxed (g_value_hash_get_value ((self), (key))) : (_default))
#define g_value_hash_get_string_list_or_default(self, key, _default) (g_value_hash_is_set ((self), (key)) ? (GList *) g_value_get_boxed (g_value_hash_get_value ((self), (key))) : (_default))
void g_value_hash_unset (GValueHash *self,
const char *key);
void g_value_hash_clear (GValueHash *self);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment