one theme in all views almost done
[livewp] / applet / src / livewp-config.c
index 96dda24..97ee239 100644 (file)
@@ -27,7 +27,6 @@
 gint 
 current_active_view(void){
     GConfClient *gconf_client = NULL;
-    GConfValue *value = NULL;
     gint result = -1;
 
     gconf_client = gconf_client_get_default();
@@ -39,6 +38,43 @@ current_active_view(void){
 
     return result;
 }
+
+/*******************************************************************************/
+#ifdef APPLICATION
+void 
+fill_priv(Animation_WallpaperPrivate *priv)
+{
+    /* Load config */
+    read_config(priv);
+    /* Set function */
+    if (!strcmp(priv->theme, "Accel"))
+        priv->scene_func = (gpointer)&init_scene_Accel;
+    if (!strcmp(priv->theme, "Berlin"))
+        priv->scene_func = (gpointer)&init_scene_Berlin;
+    if (!strcmp(priv->theme, "Modern"))
+        priv->scene_func = (gpointer)&init_scene_Modern;
+    if (!strcmp(priv->theme, "Matrix"))
+        priv->scene_func = (gpointer)&init_scene_Matrix;
+    if (!strcmp(priv->theme, "Video"))
+        priv->scene_func = (gpointer)&init_scene_Video;
+    
+    priv->extheme_list = get_list_exthemes();
+    GSList *store = priv->extheme_list;
+    while (store){
+        if (!strcmp(priv->theme, g_hash_table_lookup(store->data, "name"))){
+            /* Default function for external themes init_scene_External */
+            if (priv->scene_func)
+                priv->scene_func = (gpointer)&init_scene_External;
+            if (!strcmp(priv->theme, "Conky"))
+                priv->scene_func = (gpointer)&init_scene_Conky;
+            priv->hash_theme = store->data;
+            break;
+        }
+        store = g_slist_next(store);
+    }
+
+}
+#endif
 /*******************************************************************************/
 gint 
 read_config(Animation_WallpaperPrivate *priv) {
@@ -78,8 +114,21 @@ read_config(Animation_WallpaperPrivate *priv) {
         gconf_value_free(value);
     } else
         priv->rich_animation = TRUE;
+    /* get theme additional bool aparametr 1 default  TRUE */
+    str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_BOOL_1, id);
+    value = gconf_client_get(gconf_client, str, NULL);
+    if (str){ 
+        g_free(str);
+        str = NULL;
+    } 
+    if (value) {
+        priv->theme_bool_parametr1 = gconf_value_get_bool(value);
+        gconf_value_free(value);
+    } else
+       priv->theme_bool_parametr1= TRUE;
+
     /* get theme additional parameter 1  */
-    str = g_strdup_printf("%s%i", GCONF_KEY_ADDIONAL_STRING_1 , id);
+    str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_STRING_1 , id);
     value = gconf_client_get(gconf_client, str, NULL);
     if (str){ 
         g_free(str);
@@ -89,10 +138,50 @@ read_config(Animation_WallpaperPrivate *priv) {
         priv->theme_string_parametr1 = g_strdup(gconf_value_get_string(value));
         gconf_value_free(value);
     } 
-
+    /* get parameter one theme in all view */
+    priv->one_in_all_view = get_one_in_all_views_from_config();
     return 0;
 }
+/*******************************************************************************/
+gboolean
+get_one_in_all_views_from_config(void){
+    GConfClient *gconf_client;
+    GConfValue *value = NULL;
+    gboolean result;
 
+    gconf_client = gconf_client_get_default();
+    if (!gconf_client) {
+        fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
+        return FALSE;
+    }
+    /* get parameter one theme in all view */
+    value = gconf_client_get(gconf_client, GCONF_KEY_ONE_IN_ALL_VIEW, NULL);
+    if (value) {
+        result = gconf_value_get_bool(value);
+        gconf_value_free(value);
+    } else
+        result = FALSE;
+    return result;
+}
+/*******************************************************************************/
+void
+save_one_in_all_views_to_config(gboolean one_in_all_views){
+    GConfClient *gconf_client;
+
+    gconf_client = gconf_client_get_default();
+    if (!gconf_client) {
+        fprintf(stderr, _("Failed to initialize GConf. Quitting.\n"));
+        return;
+    }
+
+    if (one_in_all_views)
+        gconf_client_set_bool(gconf_client,
+                              GCONF_KEY_ONE_IN_ALL_VIEW, TRUE, NULL);
+    else
+        gconf_client_set_bool(gconf_client,
+                              GCONF_KEY_ONE_IN_ALL_VIEW, FALSE, NULL);
+
+}
 /*******************************************************************************/
 void
 save_config(Animation_WallpaperPrivate *priv) {
@@ -129,8 +218,20 @@ save_config(Animation_WallpaperPrivate *priv) {
         g_free(str);
         str = NULL;
     }
+    str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_BOOL_1, id);
+    if (priv->theme_bool_parametr1)
+        gconf_client_set_bool(gconf_client,
+                              str, TRUE, NULL);
+    else
+        gconf_client_set_bool(gconf_client,
+                              str, FALSE, NULL);
+    if (str){
+        g_free(str);
+        str = NULL;
+    }
+
     if (priv->theme_string_parametr1){
-        str = g_strdup_printf("%s%i",GCONF_KEY_ADDIONAL_STRING_1, id);
+        str = g_strdup_printf("%s%i",GCONF_KEY_ADDITIONAL_STRING_1, id);
         gconf_client_set_string(gconf_client,
                   str,
                   priv->theme_string_parametr1, NULL);
@@ -139,6 +240,4 @@ save_config(Animation_WallpaperPrivate *priv) {
             str = NULL;
         }
     }
-
-    
 }