reverted changes for demo
authorvlad <vlad@vlalin.(none)>
Fri, 16 Apr 2010 11:58:02 +0000 (14:58 +0300)
committervlad <vlad@vlalin.(none)>
Fri, 16 Apr 2010 11:58:02 +0000 (14:58 +0300)
applet/src/livewp-common.h
applet/src/livewp-home-widget.c
applet/src/livewp-rules.c
applet/src/livewp-rules.h

index 837d9d1..4757fdd 100644 (file)
@@ -33,7 +33,7 @@
 #define THEME_PATH "/usr/share/livewp/theme"
 #define SHORT_TIMER 50 /* 100 milisecond */
 //#define LONG_TIMER 5*60*1000 /* 10 minutes */
-#define LONG_TIMER  5*1000 /* 10 minutes */
+#define LONG_TIMER  10*1000 /* 10 minutes */
 enum { SHORT_TIMER_TYPE, LONG_TIMER_TYPE };
 #define SKY_LEVEL 0 
 #define SUN_LEVEL 0 
index 8ad44f5..f309794 100644 (file)
@@ -45,9 +45,6 @@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_H
 
 gint xapplet = 0, yapplet = 0;
 Scene scene;
-gint hour=8;
-gint min=0;
-gint ttt = 0;
 
 static void
 lw_applet_realize (GtkWidget *widget)
@@ -252,7 +249,7 @@ probability_sun()
 gint 
 probability_plane()
 {
-    return (fast_rnd(60));
+    return (fast_rnd(10) + 1) * 60;
 //    return 0;
 }
 
@@ -303,13 +300,13 @@ change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
                 actor->visible = TRUE;
                 create_hildon_actor(actor, desktop_plugin);
             }
-            get_sun_pos(hour, min, &alt, &azm);
+            get_sun_pos(&alt, &azm);
             get_sun_screen_pos(alt, azm, &x, &y);
             actor->x = x;
             actor->y = y;
             actor_set_position_full(actor->widget, x, y, actor->z);
             //probability_sun(actor);
-            actor->time_start_animation = time(NULL);
+            actor->time_start_animation = time(NULL) + probability_sun();
          }else if (actor->visible){
             actor->visible = FALSE;
             destroy_hildon_actor(actor);
@@ -329,7 +326,6 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
     suseconds_t ms;
     long sec;
     double t;
-    gchar *newfile;
 
     //fprintf(stderr, "change tram\n");
     gettimeofday(&tvb, NULL);
@@ -339,7 +335,7 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
     
     if (!actor->visible){
         actor->visible = TRUE;
-        if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
+        if (scene.daytime == TIME_NIGHT){
             if (actor->filename)
                 g_free(actor->filename);
             actor->filename = g_strdup("tram_dark.png");
@@ -350,20 +346,6 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
         }
         create_hildon_actor(actor, desktop_plugin);
     }
-    if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
-            newfile = g_strdup("tram_dark.png");
-        }else{
-            newfile = g_strdup("tram.png");
-        } 
-        if (strcmp(actor->filename, newfile)){
-        if (actor->filename)
-            g_free(actor->filename);
-        actor->filename = newfile;
-         
-
-        change_hildon_actor(actor, desktop_plugin);
-        }
-
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
     x = path_line(x0, x1, t);
     y = path_line(y0, y1, t);
@@ -375,7 +357,7 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
         /* stop animation */
         actor->visible = FALSE;
         destroy_hildon_actor(actor);
-        actor->time_start_animation = sec + 20;
+        actor->time_start_animation = sec + fast_rnd(300);
     }
 }
 
@@ -389,7 +371,6 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
     suseconds_t ms;
     long sec;
     double t;
-    gchar *newfile;
 
     gettimeofday(&tvb, NULL);
     
@@ -407,24 +388,10 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
         actor->visible = TRUE;
         create_hildon_actor(actor, desktop_plugin);
     }
-if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
-            newfile = g_strdup("dot1.png");
-        }else{
-            newfile = g_strdup("tu154.png");
-        } 
-        if (strcmp(actor->filename, newfile)){
-        if (actor->filename)
-            g_free(actor->filename);
-        actor->filename = newfile;
-         
-
-        change_hildon_actor(actor, desktop_plugin);
-        }
-
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
     x = path_line(x0, x1, t);
     y = path_line(y0, y1, t);
-    //scale line(scale0, scale1, t);
+    //scale = path_line(scale0, scale1, t);
     //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(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
@@ -435,7 +402,7 @@ if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
         if (scene.daytime == TIME_NIGHT) 
             actor->time_start_animation = 0;
         else 
-            actor->time_start_animation = sec + 10;
+            actor->time_start_animation = sec + probability_plane();
     }
 
 }
@@ -450,7 +417,6 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
     suseconds_t ms;
     long sec;
     double t;
-    gchar * newfile;
 
     gettimeofday(&tvb, NULL);
     
@@ -467,19 +433,6 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
         actor->visible = TRUE;
         create_hildon_actor(actor, desktop_plugin);
     }
-if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
-            newfile = g_strdup("dot1.png");
-        }else{
-            newfile = g_strdup("plane3.png");
-        } 
-        if (strcmp(actor->filename, newfile)){
-        if (actor->filename)
-            g_free(actor->filename);
-        actor->filename = newfile;
-         
-
-        change_hildon_actor(actor, desktop_plugin);
-        }
 
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
     x = path_line(x0, x1, t);
@@ -495,7 +448,7 @@ if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
         if (scene.daytime == TIME_NIGHT) 
             actor->time_start_animation = 0;
         else 
-            actor->time_start_animation = sec + 15;
+            actor->time_start_animation = sec + probability_plane();
     }
 
 }
@@ -521,7 +474,7 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
+        if (scene.daytime == TIME_NIGHT){
             newfile = g_strdup_printf("%s_dark.png", actor->name);
         }else{
             newfile = g_strdup_printf("%s.png", actor->name);
@@ -533,20 +486,6 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
 
         create_hildon_actor(actor, desktop_plugin);
     }
-    if (scene.daytime == TIME_NIGHT || (hour > 20 || hour < 6)){
-            newfile = g_strdup_printf("%s_dark.png", actor->name);
-        }else{
-            newfile = g_strdup_printf("%s.png", actor->name);
-        } 
-        if (strcmp(actor->filename, newfile)){
-        if (actor->filename)
-            g_free(actor->filename);
-        actor->filename = newfile;
-         
-
-        change_hildon_actor(actor, desktop_plugin);
-        }
-
     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
     
     if (scene.wind_orientation == 1){
@@ -569,7 +508,7 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
         /* stop animation */
         actor->visible = FALSE;
         destroy_hildon_actor(actor);
-        actor->time_start_animation = sec + 10;
+        actor->time_start_animation = sec + fast_rnd(300);
         actor->y = fast_rnd(300);
     }
 
@@ -605,11 +544,11 @@ change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin)
     if (!actor->visible){
         actor->visible = TRUE;
         create_hildon_actor(actor, desktop_plugin);
-        actor->time_start_animation = now + 10;
+        actor->time_start_animation = now + fast_rnd(60) + 10;
     }else {
         actor->visible = FALSE;
         destroy_hildon_actor(actor);
-        actor->time_start_animation = now + 10;
+        actor->time_start_animation = now + fast_rnd(60) + 10;
     }
    
 }
@@ -627,7 +566,7 @@ change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin)
     g_free(actor->filename);
     actor->filename = newfile;
     change_hildon_actor(actor, desktop_plugin);
-    actor->time_start_animation = now + 5;
+    actor->time_start_animation = now + fast_rnd(30) + 10;
 }
 
 void
@@ -805,7 +744,7 @@ init_scene(AWallpaperPlugin *desktop_plugin)
   gint winds[13][2];
 
   /* fprintf(stderr, "init scene \n");*/
-  scene.daytime = get_daytime(hour, min);
+  scene.daytime = get_daytime();
   scene.actors = NULL;
   scene.wind_orientation = -1;
   scene.wind_angle = 0.3;
@@ -830,22 +769,22 @@ init_scene(AWallpaperPlugin *desktop_plugin)
     //                  TRUE, 100, 255, NULL, NULL);
   //scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, 0, 7, 150, 97, 
+  actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, 
                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
-  actor->time_start_animation = now;
-  actor->duration_animation = 1*60;
+  actor->time_start_animation = now + fast_rnd(180);
+  actor->duration_animation = 3*60;
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, 80, 7, 188, 75, 
+  actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, 
                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
-  actor->time_start_animation = now + 20;
-  actor->duration_animation = 1*60;
+  actor->time_start_animation = now + fast_rnd(180);
+  actor->duration_animation = 3*60;
   scene.actors = g_slist_append(scene.actors, actor);
 
-  actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, 30, 7, 150, 75, 
+  actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, 
                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
-  actor->time_start_animation = now + 40;
-  actor->duration_animation = 1*60;
+  actor->time_start_animation = now + fast_rnd(180);
+  actor->duration_animation = 5*60;
   scene.actors = g_slist_append(scene.actors, actor);
 
 
@@ -856,8 +795,8 @@ init_scene(AWallpaperPlugin *desktop_plugin)
 
   actor = init_object(desktop_plugin, "tram", "tram.png", -300, 225, 9, 350, 210, 
                       FALSE, 100, 255, (gpointer)&change_tram, NULL);
-  actor->time_start_animation = now; 
-  actor->duration_animation = 40;
+  actor->time_start_animation = time(NULL) + fast_rnd(10); 
+  actor->duration_animation = 60;
   scene.actors = g_slist_append(scene.actors, actor);
 
   actor = init_object(desktop_plugin, "border", "border0.png", 0, 480-79, 10, 800, 79,
@@ -869,12 +808,12 @@ init_scene(AWallpaperPlugin *desktop_plugin)
                       FALSE, 100, 255, (gpointer)&change_moon, NULL);
   change_moon(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
-/*
+
   actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, 
                       FALSE, 100, 255, (gpointer)&change_wind, NULL);
   change_wind(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
-*/
+
     /* windows in 4-th house  */
 
     winds[0][0] = 482;
@@ -1088,9 +1027,9 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
   gint i; 
   gint winds[13][2];
 
-  scene.daytime = get_daytime(hour, min);
+  scene.daytime = get_daytime();
   scene.actors = NULL;
-  scene.wind_orientation = 1;
+  scene.wind_orientation = -1;
   scene.wind_angle = 0.3;
   /* init value for random */
   scene.seed = time(NULL);
@@ -1120,50 +1059,50 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
   change_moon(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, 300, 7, 150, 97, 
+  actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, 
                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
-  actor->time_start_animation = now + 20;
-  actor->duration_animation = 1*60;
+  actor->time_start_animation = now + fast_rnd(180);
+  actor->duration_animation = 3*60;
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, 100, 7, 188, 75, 
+  actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, 
                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
-  actor->time_start_animation = now;
-  actor->duration_animation = 1*60;
+  actor->time_start_animation = now + fast_rnd(180);
+  actor->duration_animation = 3*60;
   scene.actors = g_slist_append(scene.actors, actor);
 
-  actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, 200, 7, 150, 75, 
+  actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, 
                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
-  actor->time_start_animation = now + 40;
-  actor->duration_animation = 1*60;
+  actor->time_start_animation = now + fast_rnd(180);
+  actor->duration_animation = 5*60;
   scene.actors = g_slist_append(scene.actors, actor);
 
  
-  actor = init_object(desktop_plugin, "plane3", "plane3.png", 0, 45, 8, 160, 50, 
+  actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, 
                       FALSE, 100, 255, (gpointer)&change_plane2, NULL);
-  actor->time_start_animation = now + 20;
-  actor->duration_animation = 40;
+  actor->time_start_animation = now + probability_plane();
+  actor->duration_animation = 60;
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "tu154", "tu154.png", 620, 233, 9, 300, 116, 
+  actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, 
                       FALSE, 100, 255, (gpointer)&change_plane1, NULL);
-  actor->time_start_animation = now;
-  actor->duration_animation = 20;
+  actor->time_start_animation = now + probability_plane();
+  actor->duration_animation = 30;
   scene.actors = g_slist_append(scene.actors, actor);
 
   actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 
                       TRUE, 100, 255, (gpointer)&change_static_actor_with_corner, NULL);
   change_static_actor_with_corner(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
-/*
+
   actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, 
                       FALSE, 100, 255, (gpointer)&change_wind, NULL);
   change_wind(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
-*/
+
   actor = init_object(desktop_plugin, "signal", "red.png", 486, 425, 10, 18, 38, 
                       TRUE, 100, 255, (gpointer)&change_signal, NULL);
-  actor->time_start_animation = now;  
+  actor->time_start_animation = now + fast_rnd(30) + 10;  
   scene.actors = g_slist_append(scene.actors, actor);winds[0][0] = 717;
     
     winds[0][0] = 389;
@@ -1304,22 +1243,13 @@ change_actor(GtkWidget * actor)
 static gboolean
 short_timeout (AWallpaperPlugin *desktop_plugin)
 {
-    //gint daytime = get_daytime();
+    gint daytime = get_daytime();
     GSList * tmp;
     void (*pfunc)(gpointer, gpointer);
     time_t now;
     Actor *actor;
     gboolean stop_flag = TRUE;
-    
-    if (ttt == 1){
-        min ++;
-        if (min == 60){
-            hour ++;
-            min = 0;
-            if (hour == 23) hour = 0;
-        }
-        ttt = 0;
-    }else ttt ++;
+
     if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
         desktop_plugin->priv->short_timer = 0;
         return FALSE;
@@ -1352,17 +1282,12 @@ short_timeout (AWallpaperPlugin *desktop_plugin)
 void
 run_long_timeout(AWallpaperPlugin *desktop_plugin){
 
-    gint daytime = get_daytime(hour, min);
+    gint daytime = get_daytime();
     GSList * tmp;
     void (*pfunc)(gpointer, gpointer);
     time_t now;
     Actor *actor;
 
-    //hour = hour + 1;
-    //min = 0;
-    //if (hour == 24) hour = 0;
-    fprintf(stderr, "---- %d:%d\n", hour, min);
-
 
     //fprintf(stderr, "timer daytime=%d\n", daytime);
     if (scene.daytime != daytime){
index cd264f0..545147a 100644 (file)
@@ -84,36 +84,8 @@ get_max_sun_alt(double lon, double lat, int year, int month, int day, int zone)
     //printf("alt = %f \n", alt);
     return alt;
 }
-void get_sun_pos(int h, int m, double * alt, double * azm)
-{
-    int year, month, day, hour, min, zone;
-    double lat, lon, alt_max;
-    //get_localtime(&year, &month, &day, &hour, &min, &zone);
-    year = 2010;
-    month = 4;
-    day = 14;
-    hour = h;
-    min = m;
-    zone = 3;
-    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 + 10); // 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) / 210; // sun azimuth in percent
-    //printf("azm1 = %f \n", *azm);
-}
 
-void get_sun_pos1(double * alt, double * azm)
+void get_sun_pos(double * alt, double * azm)
 {
     int year, month, day, hour, min, zone;
     double lat, lon, alt_max;
@@ -144,23 +116,10 @@ time_t get_next_sunset()
         return time(NULL) + 60*60*12;
 }
 
-int get_daytime(int h, int m)
-{
-    double alt, azm;
-    get_sun_pos(h, m, &alt, &azm);
-    alt = alt * 100;
-    azm = azm * 100;
-    //printf("alt = %f azm=%f\n", alt, azm);
-    if (alt <= -7) return TIME_NIGHT;
-    if (alt > -7 && alt < 7 && azm < 50) return TIME_SUNRISE;
-    if (alt > -7 && alt < 7 && azm > 50) return TIME_SUNSET;
-    if (alt >= 7) return TIME_DAY;
-    return TIME_DAY;
-}
-int get_daytime1()
+int get_daytime()
 {
     double alt, azm;
-    get_sun_pos1(&alt, &azm);
+    get_sun_pos(&alt, &azm);
     alt = alt * 100;
     azm = azm * 100;
     //printf("alt = %f azm=%f\n", alt, azm);
@@ -170,6 +129,7 @@ int get_daytime1()
     if (alt >= 7) return TIME_DAY;
     return TIME_DAY;
 }
+
 int get_moon_phase()
 { 
     int year, month, day, hour, min, zone;
@@ -183,7 +143,6 @@ int get_moon_phase()
     if (phase > 45 && phase <= 55) return MOON_FULL;
     if (phase > 55 && phase <= 75) return MOON_DECREASHALF;
     if (phase > 75 && phase < 97) return MOON_DECREAS;
-    //return MOON_NONE;
-    return MOON_GROWSHALF;
+    return MOON_NONE;
 
 }
index 66678d6..38b8d46 100644 (file)
@@ -42,8 +42,8 @@
 /*******************************************************************************/
 void get_localtime(int * year, int * month, int * day, int * hour, int * min, int * zone);
 void get_coord(double * lat, double * lon);
-void get_sun_pos(int h, int m, double * alt, double * azm);
-int get_daytime(int h, int m);
+void get_sun_pos(double * alt, double * azm);
+int get_daytime();
 int get_moon_phase();
 time_t get_next_sunrise();
 time_t get_next_sunset();