Merge branch 'master' of https://vcs.maemo.org/git/livewp
authorVlad Vasiliev <vlad@toshiba2.oblgaz>
Sun, 11 Apr 2010 19:23:54 +0000 (22:23 +0300)
committerVlad Vasiliev <vlad@toshiba2.oblgaz>
Sun, 11 Apr 2010 19:23:54 +0000 (22:23 +0300)
Conflicts:

applet/src/livewp-home-widget.c

1  2 
applet/src/livewp-home-widget.c

@@@ -226,18 -226,15 +226,17 @@@ init_object(AWallpaperPlugin *desktop_p
  void 
  change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
  {
-     gint daytime, phase;
+     gint phase;
      char *newfile;
  
      if (actor){
-         daytime = get_daytime();
-         if (daytime == TIME_NIGHT){
+         if (scene.daytime == TIME_NIGHT){
              if (!actor->visible){
                  actor->visible = TRUE;
                  phase = get_moon_phase();
                  newfile = g_strdup_printf( "%s%d.png", actor->name, phase);
 +                if (actor->filename)
 +                    g_free(actor->filename);
                  actor->filename = newfile;
                  create_hildon_actor(actor, desktop_plugin);
  
@@@ -262,11 -259,10 +261,10 @@@ voi
  change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
  {
      double alt, azm;
-     gint x, y, daytime;
+     gint x, y;
  
      if (actor){
-         daytime = get_daytime();
-         if (daytime != TIME_NIGHT){
+         if (scene.daytime != TIME_NIGHT){
              if (!actor->visible){
                  actor->visible = TRUE;
  
      }
      
  }
  static void 
  change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
  {
      suseconds_t ms;
      long sec;
      double t;
-     gint daytime = get_daytime();
  
      gettimeofday(&tvb, NULL);
      
     
      if (!actor->visible){
          actor->visible = TRUE;
-         if (daytime == TIME_NIGHT){
 -        if (scene.daytime == TIME_NIGHT)
++        if (scene.daytime == TIME_NIGHT){
 +            if (actor->filename)
 +                g_free(actor->filename);
              actor->filename = g_strdup("tram_dark.png");
 -        else
 +        } else{
 +            if (actor->filename)
 +                g_free(actor->filename);
              actor->filename = g_strdup("tram.png");
 +        }
          create_hildon_actor(actor, desktop_plugin);
      }
      t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
@@@ -342,7 -333,6 +340,6 @@@ change_plane1(Actor *actor, AWallpaperP
      suseconds_t ms;
      long sec;
      double t;
-     gint daytime = get_daytime();
  
      gettimeofday(&tvb, NULL);
      
     
      if (!actor->visible){
          actor->visible = TRUE;
-         if (daytime == TIME_NIGHT){
 -        if (scene.daytime == TIME_NIGHT)
++        if (scene.daytime == TIME_NIGHT){
 +            if (actor->filename)
 +                g_free(actor->filename);
              actor->filename = g_strdup("tu154.png");
 -        else
 +        }else{
 +            if (actor->filename)
 +                g_free(actor->filename);
              actor->filename = g_strdup("tu154.png");
 +        }
          create_hildon_actor(actor, desktop_plugin);
      }
      t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
@@@ -389,7 -374,6 +386,6 @@@ change_plane2(Actor *actor, AWallpaperP
      suseconds_t ms;
      long sec;
      double t;
-     gint daytime = get_daytime();
  
      gettimeofday(&tvb, NULL);
      
     
      if (!actor->visible){
          actor->visible = TRUE;
-         if (daytime == TIME_NIGHT){
++        if (scene.daytime == TIME_NIGHT){
 +            if (actor->filename)
 +                g_free(actor->filename);
+         if (scene.daytime == TIME_NIGHT)
              actor->filename = g_strdup("plane3.png");
 -        else
 +        }else{
 +            if (actor->filename)
 +                g_free(actor->filename);
              actor->filename = g_strdup("plane3.png");
 +        }
          create_hildon_actor(actor, desktop_plugin);
      }
      t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
  }
  
  void
+ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
+ {
+     gint x0, y0 = 300, scale0 = 100,
+          x1, y1 = -actor->height, scale1 = 150, 
+          x, y, scale;
+     struct timeval tvb;     
+     suseconds_t ms;
+     long sec;
+     double t;
+     gettimeofday(&tvb, NULL);
+     
+     ms = tvb.tv_usec;
+     sec = tvb.tv_sec;
+ //    fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
+    
+     if (!actor->visible){
+         actor->visible = TRUE;
+         if (scene.daytime == TIME_NIGHT)
+             actor->filename = actor->filename;
+         else
+             actor->filename = actor->filename;
+         create_hildon_actor(actor, desktop_plugin);
+     }
+     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
+     
+     if (scene.wind_orientation == 1){
+         x0 = -actor->width;
+         x1 = 800;
+     }
+     else {
+         x0 = 800;
+         x1 = -actor->width;
+     }
+     x = path_line(x0, x1, t);    
+     y = -scene.wind_angle * (x - x0) + actor->y;
+     scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0));
+     //fprintf(stderr, "change cloud 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);
+     if ((y < y1 || y > y0) || t >= 1){
+         /* stop animation */
+         actor->visible = FALSE;
+         destroy_hildon_actor(actor);
+         actor->time_start_animation = sec + 5*60;
+     }
+ }
+ void
  create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) 
  {
    GtkWidget *ha = NULL;
    GdkPixbuf *pixbuf = NULL;
    GtkWidget *image = NULL;
 -  gchar *str;
 +  gchar     *str = NULL;
  
    /* fprintf(stderr, "create_hildon_actor %s\n", actor->name);*/
    ha = hildon_animation_actor_new();
                                               actor->width, 
                                               actor->height, 
                                               NULL);
 +  if (str)
 +      g_free(str);
    if (pixbuf){
        image = gtk_image_new_from_pixbuf (pixbuf);
        g_object_unref(G_OBJECT(pixbuf));
@@@ -483,7 -512,7 +532,7 @@@ change_hildon_actor(Actor *actor, AWall
  {
      GtkWidget *image = NULL;
      GdkPixbuf *pixbuf = NULL;
 -    gchar *str;
 +    gchar     *str = NULL;
  
      str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
                              desktop_plugin->priv->theme, actor->filename);
                                                 actor->width, 
                                                 actor->height, 
                                                 NULL);
 +    if(str)
 +        g_free(str);
      if (pixbuf){
          image = gtk_image_new_from_pixbuf (pixbuf);
          g_object_unref(G_OBJECT(pixbuf));
@@@ -521,8 -548,6 +570,8 @@@ change_static_actor(Actor * actor, AWal
      if (!actor) return;
      daytime = get_daytime();
      newfile = g_strdup_printf("%s%d.png", actor->name, daytime); 
 +    if (actor->filename)
 +            g_free(actor->filename);
      actor->filename = newfile;
      change_hildon_actor(actor, desktop_plugin);
  }
@@@ -543,10 -568,6 +592,10 @@@ destroy_scene(void)
      while (tmp != NULL){
          actor = tmp->data;
          if (actor){
 +            if (actor->filename)
 +                g_free(actor->filename);
 +            if (actor->name)
 +                g_free(actor->name);
              gtk_widget_destroy(actor->widget);
              //actor->widget = NULL;
              g_free(actor);
@@@ -645,6 -666,8 +694,8 @@@ init_scene1(AWallpaperPlugin *desktop_p
  
    scene.daytime = get_daytime();
    scene.actors = NULL;
+   scene.wind_orientation = -1;
+   scene.wind_angle = 0.3;
    
    actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
                        TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
    scene.actors = g_slist_append(scene.actors, actor);
  
  
-   actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 10, 50, 50, 
+   actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
                        TRUE, 100, 255, NULL, NULL);
    scene.actors = g_slist_append(scene.actors, actor);
  
  
-   actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 9, 800, 480, 
+   actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 
                        TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
    change_static_actor(actor, desktop_plugin);
    scene.actors = g_slist_append(scene.actors, actor);
    change_moon(actor, desktop_plugin);
    scene.actors = g_slist_append(scene.actors, actor);
    
-   actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 7, 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 = time(NULL) + 5;
    actor->duration_animation = 60;
    scene.actors = g_slist_append(scene.actors, actor);
    
-   actor = init_object(desktop_plugin, "plane1", "tu154_small.png", 620, 233, 8, 300, 116, 
+   actor = init_object(desktop_plugin, "plane1", "tu154_small.png", 620, 233, 9, 300, 116, 
                        FALSE, 100, 255, (gpointer)&change_plane1, NULL);
    actor->time_start_animation = time(NULL) + 60;
    actor->duration_animation = 30;
    scene.actors = g_slist_append(scene.actors, actor);
  
+   actor = init_object(desktop_plugin, "cloud1", "cloud2.png", 0, 50, 7, 188, 75, 
+                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+   actor->time_start_animation = time(NULL) + 5;
+   actor->duration_animation = 5*60;
+   scene.actors = g_slist_append(scene.actors, actor);
  }