1 /* vim: set sw=4 ts=4 et: */
3 * This file is part of Live Wallpaper (livewp)
5 * Copyright (C) 2010 Vlad Vasiliev
6 * Copyright (C) 2010 Tanya Makova
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
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.
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
24 /*******************************************************************************/
25 #include "livewp-config.h"
26 /*******************************************************************************/
28 current_active_view(void){
29 GConfClient *gconf_client = NULL;
32 gconf_client = gconf_client_get_default();
34 fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
37 result = gconf_client_get_int(gconf_client, "/apps/osso/hildon-desktop/views/current", NULL);
42 /*******************************************************************************/
45 fill_priv(Animation_WallpaperPrivate *priv)
48 priv->hash_theme = NULL;
52 if (!strcmp(priv->theme, "Accel"))
53 priv->scene_func = (gpointer)&init_scene_Accel;
54 if (!strcmp(priv->theme, "Berlin"))
55 priv->scene_func = (gpointer)&init_scene_Berlin;
56 if (!strcmp(priv->theme, "Modern"))
57 priv->scene_func = (gpointer)&init_scene_Modern;
58 if (!strcmp(priv->theme, "Matrix"))
59 priv->scene_func = (gpointer)&init_scene_Matrix;
60 if (!strcmp(priv->theme, "Video"))
61 priv->scene_func = (gpointer)&init_scene_Video;
63 priv->extheme_list = get_list_exthemes();
64 GSList *store = priv->extheme_list;
66 if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
67 /* Default function for external themes init_scene_External */
69 priv->scene_func = (gpointer)&init_scene_External;
70 if (!strcmp(priv->theme, "Conky"))
71 priv->scene_func = (gpointer)&init_scene_Conky;
72 priv->hash_theme = store->data;
75 store = g_slist_next(store);
80 /*******************************************************************************/
82 read_config(Animation_WallpaperPrivate *priv) {
84 GConfClient *gconf_client = NULL;
86 GConfValue *value = NULL;
90 gconf_client = gconf_client_get_default();
92 fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
95 /* get Theme default Modern */
96 str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id);
97 tmp = gconf_client_get_string(gconf_client,
106 priv->theme = g_strdup("Modern");
107 /* get Rich animation default TRUE */
108 str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id);
109 value = gconf_client_get(gconf_client, str, NULL);
115 priv->rich_animation = gconf_value_get_bool(value);
116 gconf_value_free(value);
118 priv->rich_animation = TRUE;
119 /* get theme additional bool aparametr 1 default TRUE */
120 str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_BOOL_1, id);
121 value = gconf_client_get(gconf_client, str, NULL);
127 priv->theme_bool_parametr1 = gconf_value_get_bool(value);
128 gconf_value_free(value);
130 priv->theme_bool_parametr1= TRUE;
132 /* get theme additional parameter 1 */
133 str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_STRING_1 , id);
134 value = gconf_client_get(gconf_client, str, NULL);
140 priv->theme_string_parametr1 = g_strdup(gconf_value_get_string(value));
141 gconf_value_free(value);
143 /* get parameter one theme in all view */
144 priv->one_in_all_view = get_one_in_all_views_from_config();
147 /*******************************************************************************/
149 get_one_in_all_views_from_config(void){
150 GConfClient *gconf_client;
151 GConfValue *value = NULL;
154 gconf_client = gconf_client_get_default();
156 fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
159 /* get parameter one theme in all view */
160 value = gconf_client_get(gconf_client, GCONF_KEY_ONE_IN_ALL_VIEW, NULL);
162 result = gconf_value_get_bool(value);
163 gconf_value_free(value);
168 /*******************************************************************************/
170 save_one_in_all_views_to_config(gboolean one_in_all_views){
171 GConfClient *gconf_client;
173 gconf_client = gconf_client_get_default();
175 fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
179 if (one_in_all_views)
180 gconf_client_set_bool(gconf_client,
181 GCONF_KEY_ONE_IN_ALL_VIEW, TRUE, NULL);
183 gconf_client_set_bool(gconf_client,
184 GCONF_KEY_ONE_IN_ALL_VIEW, FALSE, NULL);
187 /*******************************************************************************/
189 save_config(Animation_WallpaperPrivate *priv) {
191 GConfClient *gconf_client;
193 gint id = priv->view;
195 gconf_client = gconf_client_get_default();
197 fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
202 str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id);
203 gconf_client_set_string(gconf_client,
212 str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id);
213 if (priv->rich_animation)
214 gconf_client_set_bool(gconf_client,
217 gconf_client_set_bool(gconf_client,
223 str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_BOOL_1, id);
224 if (priv->theme_bool_parametr1)
225 gconf_client_set_bool(gconf_client,
228 gconf_client_set_bool(gconf_client,
235 if (priv->theme_string_parametr1){
236 str = g_strdup_printf("%s%i",GCONF_KEY_ADDITIONAL_STRING_1, id);
237 gconf_client_set_string(gconf_client,
239 priv->theme_string_parametr1, NULL);