From b8b5b146eb7cefb5f126823050be8fccca3249e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20Geh=C3=B6r?= Date: Wed, 17 Dec 2008 15:23:42 +0200 Subject: [PATCH] added irreco_theme_save function --- irreco/src/core/irreco_theme.c | 67 ++++++++++++++++++++++++++++++------------ irreco/src/core/irreco_theme.h | 3 +- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/irreco/src/core/irreco_theme.c b/irreco/src/core/irreco_theme.c index 895bf462..71e3eef7 100644 --- a/irreco/src/core/irreco_theme.c +++ b/irreco/src/core/irreco_theme.c @@ -71,8 +71,8 @@ IrrecoTheme *irreco_theme_new() (GDestroyNotify)irreco_theme_bg_free, NULL); self->buttons = irreco_string_table_new( (GDestroyNotify)irreco_theme_button_free, NULL); - - + + IRRECO_RETURN_PTR(self); } @@ -272,7 +272,7 @@ void irreco_theme_read_button_keyfile_foreach(IrrecoDirForeachData * dir_data) if (irreco_string_table_exists(self->buttons, button->name->str)) { IRRECO_ERROR("Error: Button %s has already been read. " - "You cannot have two buttons with the same name.\n", + "You cannot have two buttons with the same name.\n", button->name->str); irreco_theme_button_free(button); } else { @@ -295,7 +295,7 @@ void irreco_theme_read_bg_keyfile_foreach(IrrecoDirForeachData * dir_data) if (irreco_string_table_exists(self->backgrounds, bg->image_name->str)) { IRRECO_ERROR("Error: Background %s has already been read. " - "You cannot have two backgrounds with the same name.\n", + "You cannot have two backgrounds with the same name.\n", bg->image_name->str); irreco_theme_bg_free(bg); } else { @@ -303,7 +303,7 @@ void irreco_theme_read_bg_keyfile_foreach(IrrecoDirForeachData * dir_data) bg->image_name->str, bg); } - + IRRECO_RETURN } @@ -543,33 +543,33 @@ void irreco_theme_check(IrrecoTheme *self) IrrecoTheme *irreco_theme_copy(IrrecoTheme *self) { IrrecoTheme *new = NULL; - + IRRECO_ENTER - + new = irreco_theme_new(); - + irreco_theme_set(new, self->name->str, self->path->str, self->source->str, self->author->str, self->comment->str, self->preview_button_name->str, self->version->str); - - + + IRRECO_STRING_TABLE_FOREACH(self->backgrounds, key, IrrecoThemeBg *, theme_bg) - irreco_string_table_add(new->backgrounds, key, + irreco_string_table_add(new->backgrounds, key, irreco_theme_bg_copy(theme_bg)); IRRECO_STRING_TABLE_FOREACH_END - + IRRECO_STRING_TABLE_FOREACH(self->buttons, key, IrrecoThemeButton *, theme_button) - irreco_string_table_add(new->buttons, key, + irreco_string_table_add(new->buttons, key, irreco_theme_button_copy(theme_button)); IRRECO_STRING_TABLE_FOREACH_END - - + + IRRECO_RETURN_PTR(new); } @@ -582,7 +582,7 @@ IrrecoTheme *irreco_theme_new_from_dir(const gchar *dir) IrrecoTheme *self = NULL; IRRECO_ENTER - + self = irreco_theme_new(); irreco_theme_read(self, dir); IRRECO_RETURN_PTR(self); @@ -615,11 +615,11 @@ void irreco_theme_read(IrrecoTheme *self, const gchar *dir) irreco_keyfile_get_str(keyfile, "comment", &comment); irreco_keyfile_get_str(keyfile, "preview-button", &preview_button); irreco_keyfile_get_str(keyfile, "version", &version); - + /* call irreco_theme_set() */ irreco_theme_set(self, name, dir, source, author, comment, preview_button, version); - + g_string_free(conf, TRUE); if (keyfile != NULL) irreco_keyfile_destroy(keyfile); if (name != NULL) g_free(name); @@ -632,8 +632,39 @@ void irreco_theme_read(IrrecoTheme *self, const gchar *dir) } +gboolean irreco_theme_save(IrrecoTheme *irreco_theme, IrrecoData *irreco_data, + const gchar *theme_path) +{ + gboolean rvalue = FALSE; + IrrecoTheme *theme; + IRRECO_ENTER + + /* Create ThemeFolder + g_mkdir(theme_path, 0777);*/ + + /*Create new theme*/ + theme = irreco_theme_new(); + irreco_theme_set(theme, + irreco_theme->name->str, + theme_path, + irreco_theme->source->str, + irreco_theme->author->str, + irreco_theme->comment->str, + irreco_theme->preview_button_name->str, + NULL); + + irreco_theme_update_keyfile(theme); + irreco_theme_free(theme); + + + + + IRRECO_RETURN_BOOL(rvalue); + +} + /** @} */ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ diff --git a/irreco/src/core/irreco_theme.h b/irreco/src/core/irreco_theme.h index 91a2a0e1..8241ceaf 100644 --- a/irreco/src/core/irreco_theme.h +++ b/irreco/src/core/irreco_theme.h @@ -109,7 +109,8 @@ IrrecoTheme *irreco_theme_copy(IrrecoTheme *self); IrrecoTheme *theme_new_from_dir(); void irreco_theme_read(IrrecoTheme *self, const gchar *dir); IrrecoTheme *irreco_theme_new_from_dir(const gchar *dir); - +gboolean irreco_theme_save(IrrecoTheme *self, IrrecoData *irreco_data, + const gchar *theme_path); #endif /* __IRRECO_THEME_H__ */ /** @} */ -- 2.11.4.GIT