fork is done
[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
39     result = gconf_client_get_int(gconf_client, "/apps/osso/hildon-desktop/views/current", NULL);
40
41     fprintf(stderr,"uuuu@@@@@@@@@@@@!!!!!!!!!!!1 %i\n", result);
42     return result;
43
44 }
45 /*******************************************************************************/
46 gint 
47 read_config(Animation_WallpaperPrivate *priv) {
48
49     GConfClient *gconf_client = NULL;
50     gchar *tmp = NULL;
51     GConfValue *value = NULL;
52     gint id = priv->view;
53     gchar * str = NULL;
54
55     gconf_client = gconf_client_get_default();
56     if (!gconf_client) {
57         fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
58         return -1;
59     }
60     /* get Theme default Modern */
61     str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id);
62     tmp = gconf_client_get_string(gconf_client,
63                                   str, NULL);
64     if (str){ 
65         g_free(str);
66         str = NULL;
67     }    
68     if (tmp){
69         priv->theme = tmp;
70     }else
71         priv->theme = g_strdup("Modern");
72     /* get Rich animation default TRUE */
73     str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id);
74     value = gconf_client_get(gconf_client, str, NULL);
75     if (str){ 
76         g_free(str);
77         str = NULL;
78     } 
79     if (value) {
80         priv->rich_animation = gconf_value_get_bool(value);
81         gconf_value_free(value);
82     } else
83         priv->rich_animation = TRUE;
84     
85
86     return 0;
87 }
88
89 /*******************************************************************************/
90 void
91 save_config(Animation_WallpaperPrivate *priv) {
92
93     GConfClient *gconf_client;
94     gchar * str = NULL;
95     gint id = priv->view;
96
97     gconf_client = gconf_client_get_default();
98     if (!gconf_client) {
99         fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
100         return;
101     }
102     
103     if (priv->theme){
104         str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id);
105         gconf_client_set_string(gconf_client,
106                   str,
107                   priv->theme, NULL);
108         if (str){
109             g_free(str);
110             str = NULL;
111         }
112     }
113
114     str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id);
115     if (priv->rich_animation)
116         gconf_client_set_bool(gconf_client,
117                               str, TRUE, NULL);
118     else
119         gconf_client_set_bool(gconf_client,
120                               str, FALSE, NULL);
121     if (str){
122         g_free(str);
123         str = NULL;
124     }
125     
126 }