fixed small syntax problem in code
[livewp] / applet / src / livewp-config.c
1 /* vim: set sw=4 ts=4 et: */
2 /*
3  * This file is part of Live Wallpaper (livewp)
4  * 
5  * Copyright (C) 2010 Vlad Vasiliev
6  * Copyright (C) 2010 Tanya Makova
7  *       for the code
8  * 
9  * This software is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1 of
12  * the License, or (at your option) any later version.
13  * 
14  * This software is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this software; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23 */
24 /*******************************************************************************/
25 #include "livewp-config.h"
26 /*******************************************************************************/
27 gint 
28 current_active_view(void){
29     GConfClient *gconf_client = NULL;
30     GConfValue *value = NULL;
31     gint result = -1;
32
33     gconf_client = gconf_client_get_default();
34     if (!gconf_client) {
35         fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
36         return result;
37     }
38     result = gconf_client_get_int(gconf_client, "/apps/osso/hildon-desktop/views/current", NULL);
39
40     return result;
41 }
42 /*******************************************************************************/
43 gint 
44 read_config(Animation_WallpaperPrivate *priv) {
45
46     GConfClient *gconf_client = NULL;
47     gchar *tmp = NULL;
48     GConfValue *value = NULL;
49     gint id = priv->view;
50     gchar * str = NULL;
51
52     gconf_client = gconf_client_get_default();
53     if (!gconf_client) {
54         fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
55         return -1;
56     }
57     /* get Theme default Modern */
58     str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id);
59     tmp = gconf_client_get_string(gconf_client,
60                                   str, NULL);
61     if (str){ 
62         g_free(str);
63         str = NULL;
64     }    
65     if (tmp){
66         priv->theme = tmp;
67     }else
68         priv->theme = g_strdup("Modern");
69     /* get Rich animation default TRUE */
70     str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id);
71     value = gconf_client_get(gconf_client, str, NULL);
72     if (str){ 
73         g_free(str);
74         str = NULL;
75     } 
76     if (value) {
77         priv->rich_animation = gconf_value_get_bool(value);
78         gconf_value_free(value);
79     } else
80         priv->rich_animation = TRUE;
81     
82
83     return 0;
84 }
85
86 /*******************************************************************************/
87 void
88 save_config(Animation_WallpaperPrivate *priv) {
89
90     GConfClient *gconf_client;
91     gchar * str = NULL;
92     gint id = priv->view;
93
94     gconf_client = gconf_client_get_default();
95     if (!gconf_client) {
96         fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
97         return;
98     }
99     
100     if (priv->theme){
101         str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id);
102         gconf_client_set_string(gconf_client,
103                   str,
104                   priv->theme, NULL);
105         if (str){
106             g_free(str);
107             str = NULL;
108         }
109     }
110
111     str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id);
112     if (priv->rich_animation)
113         gconf_client_set_bool(gconf_client,
114                               str, TRUE, NULL);
115     else
116         gconf_client_set_bool(gconf_client,
117                               str, FALSE, NULL);
118     if (str){
119         g_free(str);
120         str = NULL;
121     }
122     
123 }