From 82bd2546e656409138ad5ab333e6d657f9a4354f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20Geh=C3=B6r?= Date: Wed, 7 Jan 2009 10:41:52 +0200 Subject: [PATCH] update irreco_theme_bg_save(). Added get image type functio(g_strrstr()) --- irreco/src/core/irreco_theme_bg.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/irreco/src/core/irreco_theme_bg.c b/irreco/src/core/irreco_theme_bg.c index 21e62337..483ee093 100644 --- a/irreco/src/core/irreco_theme_bg.c +++ b/irreco/src/core/irreco_theme_bg.c @@ -192,10 +192,13 @@ gboolean irreco_theme_bg_save(IrrecoThemeBg *self, const gchar *path) gchar *folder_name; GKeyFile *keyfile; gchar *cp_cmd; + gchar *type; + GString *image_name; IRRECO_ENTER keyfile = g_key_file_new(); + image_name = g_string_new(NULL); image_path = g_string_new(path); keyfile_path = g_string_new(path); folder = g_string_new(self->image_name->str); @@ -212,26 +215,36 @@ gboolean irreco_theme_bg_save(IrrecoThemeBg *self, const gchar *path) IRRECO_DEBUG("mkdir %s\n",image_path->str); g_mkdir(image_path->str, 0777); - g_string_append_printf(image_path, "/%s", "image.png"); + /* get file type */ + type = g_strrstr(self->image_path->str, "."); + g_string_printf(image_name, "%s%s", "image", type); + IRRECO_PRINTF("TYPE: %s \n", type); + IRRECO_PRINTF("IMAGE: %s \n", image_name->str); + + IRRECO_PAUSE + g_string_append_printf(image_path, "/%s%s", "image", type); + /* Copy image to bg folder */ cp_cmd = g_strconcat("cp -f ", self->image_path->str, " ", image_path->str, NULL); system(cp_cmd); - g_free(cp_cmd); - /* Create keyfile and save it to folder*/ irreco_gkeyfile_set_string(keyfile, "theme-bg" , "name", self->image_name->str); - irreco_gkeyfile_set_string(keyfile, "theme-bg", "image", "image.png"); + irreco_gkeyfile_set_string(keyfile, "theme-bg", "image", image_name->str); g_string_append_printf(keyfile_path, "/bg.conf"); irreco_write_keyfile(keyfile, keyfile_path->str); /* No error occured. */ rvalue = TRUE; + + g_free(cp_cmd); + /*g_free(type);*/ + g_string_free(image_name, TRUE); g_key_file_free(keyfile); g_string_free(keyfile_path, TRUE); g_string_free(image_path, TRUE); -- 2.11.4.GIT