change theme
authorTanya <tanya@bookdmitri.oblgaz>
Fri, 9 Apr 2010 19:01:40 +0000 (22:01 +0300)
committerTanya <tanya@bookdmitri.oblgaz>
Fri, 9 Apr 2010 19:01:40 +0000 (22:01 +0300)
applet/src/livewp-common.h
applet/src/livewp-home-widget.c
applet/src/livewp-rules.c

index 66b1fee..2da389b 100644 (file)
@@ -32,8 +32,8 @@
 
 #define THEME_PATH "/usr/share/livewp/theme"
 #define SHORT_TIMER 100 /* 100 milisecond */
-//#define LONG_TIMER 10*60*1000 /* 10 minutes */
-#define LONG_TIMER  5*1000 /* 10 minutes */
+#define LONG_TIMER 10*60*1000 /* 10 minutes */
+//#define LONG_TIMER  10*1000 /* 10 minutes */
 enum { SHORT_TIMER_TYPE, LONG_TIMER_TYPE };
 
 
index acdb602..093cf2a 100644 (file)
@@ -316,14 +316,14 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
     x = path_line(x0, x1, t);
     y = path_line(y0, y1, t);
     scale = path_line(scale0, scale1, t);
-    fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
+    //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
     actor_set_position_full(actor->widget, x, y, actor->z);
     hildon_animation_actor_set_scale(actor->widget, (double)scale/100, (double)scale/100);
     if (t >= 1){
         /* stop animation */
         actor->visible = FALSE;
         destroy_hildon_actor(actor);
-        actor->time_start_animation = now + 20;
+        actor->time_start_animation = now + 5*60;
     }
 }
 void
@@ -467,10 +467,13 @@ get_time(gint t){
 static void 
 destroy_scene(void){
     GSList * tmp = scene.actors;
+    Actor *actor;
     while (tmp != NULL){
-        if (tmp->data){
-            gtk_widget_destroy(tmp->data);
-            tmp->data = NULL;
+        actor = tmp->data;
+        if (actor){
+            gtk_widget_destroy(actor->widget);
+            //actor->widget = NULL;
+            g_free(actor);
         }
         tmp = g_slist_next(tmp);
     }
@@ -486,7 +489,7 @@ reload_scene(AWallpaperPlugin *desktop_plugin)
     if (!strcmp(desktop_plugin->priv->theme,"Modern"))
         init_scene(desktop_plugin);
     else if (!strcmp(desktop_plugin->priv->theme,"Berlin")) 
-        init_scene(desktop_plugin);
+        init_scene1(desktop_plugin);
 }
 
 void 
@@ -509,7 +512,7 @@ fprintf(stderr, "init scene \n");
   //get_sun_pos(&alt, &azm);
   //get_sun_screen_pos(alt, azm, &x, &y);
   
-  actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 11, 88, 88, 
+  actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, -4, 88, 88, 
                       TRUE, 100, 255, &change_sun, &probability_sun);
   actor->time_start_animation = time(NULL);
   actor->duration_animation = G_MAXINT;
@@ -517,23 +520,23 @@ fprintf(stderr, "init scene \n");
   scene.actors = g_slist_append(scene.actors, actor);
   //scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
  
-  actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, 5, 800, 480, 
+  actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, -5, 800, 480, 
                       TRUE, 100, 255, &change_static_actor, NULL);
   change_static_actor(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
 
 
-  actor = init_object(desktop_plugin, "town", "town0.png", 0, 480-374, 10, 800, 374, 
+  actor = init_object(desktop_plugin, "town", "town0.png", 0, 480-374, -3, 800, 374, 
                       TRUE, 100, 255, &change_static_actor, NULL);
   change_static_actor(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "border", "border0.png", 0, 480-79, 30, 800, 79, 
+  actor = init_object(desktop_plugin, "border", "border0.png", 0, 480-79, -1, 800, 79, 
                       TRUE, 100, 255, &change_static_actor, NULL);
   change_static_actor(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
 
-  actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 20, 7, 70, 70, 
+  actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 20, -5, 70, 70, 
                       FALSE, 100, 255, &change_moon, NULL);
   change_moon(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
@@ -543,11 +546,12 @@ fprintf(stderr, "init scene \n");
   //else snprintf(str, 255, "tram_dark.png");
   //actor = init_object("tram", "tram.png", -300, 191, 25, 350, 210, 1, 100, 255, NULL);
   
-  actor = init_object(desktop_plugin, "tram", "tram_dark.png", -300, 225, 25, 350, 210, 
+  actor = init_object(desktop_plugin, "tram", "tram.png", -300, 225, -2, 350, 210, 
                       FALSE, 100, 255, &change_tram, NULL);
   actor->time_start_animation = time(NULL) + 10;
   actor->duration_animation = 60;
   scene.actors = g_slist_append(scene.actors, actor);
+
 #if 0    
   anim = g_new0(Animation, 1);
   anim->count = 1;
@@ -560,38 +564,45 @@ fprintf(stderr, "init scene \n");
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
 #endif  
  }
-#if 0
+
 static void
 init_scene1(AWallpaperPlugin *desktop_plugin)
 {
-  GtkWidget *actor;
+  Actor *actor;
   GdkPixbuf *pixbuf;
   GtkWidget *image;
   double alt, azm;
   gint x, y;
-  GSList * list = NULL;
 
   scene.daytime = get_daytime();
-  scene.dynamic_actors = NULL;
-  scene.static_actors = NULL;
+  scene.actors = NULL;
+  
+  actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, -4, 88, 88, 
+                      TRUE, 100, 255, &change_sun, &probability_sun);
+  actor->time_start_animation = time(NULL);
+  actor->duration_animation = G_MAXINT;
+  change_sun(actor, desktop_plugin);
+  scene.actors = g_slist_append(scene.actors, actor);
+  
+  actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, -5, 800, 480, 
+                      TRUE, 100, 255, &change_static_actor, NULL);
+  change_static_actor(actor, desktop_plugin);
+  scene.actors = g_slist_append(scene.actors, actor);
 
-  actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 20, 88, 88, 1, 100, 255, &change_sun);
-  change_sun(actor, NULL);
-  //scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
-  scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
-/*
-  actor = init_object(desktop_plugin, "background", "sky_dark.png", 0, 0, 4, 800, 480, 1, 100, 255, NULL);
-  scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
-*/
-  actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 1, 100, 255, &change_static_actor);
-  change_static_actor(actor, NULL);
-  scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
 
-  actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 1, 100, 255, &change_static_actor);
-  change_static_actor(actor, NULL);
-  scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
-  
-/*
+  actor = init_object(desktop_plugin, "town", "town.png", 0, 0, -3, 800, 480, 
+                      TRUE, 100, 255, &change_static_actor, NULL);
+  change_static_actor(actor, desktop_plugin);
+  scene.actors = g_slist_append(scene.actors, actor);
+
+  actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 20, -5, 70, 70, 
+                      FALSE, 100, 255, &change_moon, NULL);
+  change_moon(actor, desktop_plugin);
+  scene.actors = g_slist_append(scene.actors, actor);
+
+  //scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
+   /*
   actor = init_object("cloud1", 400, 150, 2, 200, 150, NULL);
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
 
@@ -605,7 +616,7 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
   */
 
 }
-#endif
+
 
 void 
 get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
@@ -615,7 +626,7 @@ get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
          o_height = 128; 
     *x = (int)(azm * 800) - 64;
     *y = (int)((1 - alt) * y0) - 64;
-    //fprintf(stderr, "sun pos x=%d y=%d\n", *x, *y);
+    fprintf(stderr, "sun pos alt=%f azm=%f x=%d y=%d\n", alt, azm, *x, *y);
 }
 #if 0
 static void 
@@ -706,7 +717,7 @@ short_timeout (AWallpaperPlugin *desktop_plugin)
         return TRUE;
   
     now = time(NULL);
-    fprintf(stderr, "Short timer %d\n", now);
+    //fprintf(stderr, "Short timer %d\n", now);
     tmp = scene.actors;
     while (tmp != NULL){
            actor = tmp->data;
@@ -818,7 +829,7 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
     if (!strcmp(priv->theme,"Modern"))
         init_scene(desktop_plugin);
     else if (!strcmp(priv->theme,"Berlin")) 
-        init_scene(desktop_plugin);
+        init_scene1(desktop_plugin);
     priv->long_timer = g_timeout_add(LONG_TIMER, long_timeout, desktop_plugin);
     priv->short_timer = 0;
     /* TODO Move scene to priv */
index 43cd24b..473721c 100644 (file)
@@ -88,15 +88,19 @@ void get_sun_pos(double * alt, double * azm)
     get_coord(&lat, &lon);
     alt_max = get_max_sun_alt(lon, lat, year, month, day, zone);
     *alt = altitude(lon, lat, year, month, day, hour, min, zone);
+    //printf("max = %f alt = %f ",alt_max, *alt);
     *alt = *alt / (alt_max + 5); // sun height in percent
+    //printf("alt1 = %f \n", *alt);
 
     *azm = azimuth(lon, lat, year, month, day, hour, min, zone);
+    //printf("azm = %f ", *azm);
     //if south latitude
     if (lat < 0){
         *azm = 75 + (75 - *azm);
         *azm = fmod(*azm, 380);
     }
-    *azm = (*azm - 75) / 190; // sun azimuth in percent
+    *azm = (*azm - 75) / 210; // sun azimuth in percent
+    //printf("azm1 = %f \n", *azm);
 }
 time_t get_next_sunrise()
 {