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

applet/src/livewp-home-widget.c

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

@@@ -44,7 -44,6 +44,6 @@@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlug
  #define Ystartposition 425 
  
  gint xapplet = 0, yapplet = 0;
- GSList * objects_list = NULL;
  Scene scene;
  
  static void
@@@ -171,7 -170,7 +170,7 @@@ path_line(gint x0, gint x1, double t
  void
  destroy_hildon_actor(Actor *actor)
  {
-     fprintf(stderr, "estroy_hildon_actor %p\n",actor->widget);
+     fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
      gtk_widget_destroy(actor->widget);
      actor->widget = NULL;
  }
@@@ -230,14 -229,13 +229,13 @@@ rnd(gint max
      srand(time(NULL));
      return rand() % max;
  }
- guint seed;
  gint fast_rnd(gint max)
  {
      guint offset = 12923;
      guint multiplier = 4079;
      
-     seed = seed * multiplier + offset;
-     return (gint)(seed % max);
+     scene.seed = scene.seed * multiplier + offset;
+     return (gint)(scene.seed % max);
  }
  
  gint 
@@@ -261,7 -259,7 +259,7 @@@ change_moon(Actor * actor, AWallpaperPl
      char *newfile;
  
      if (actor){
-         if (get_daytime() == TIME_NIGHT){
+         if (scene.daytime == TIME_NIGHT){
              if (!actor->visible){
                  actor->visible = TRUE;
                  phase = get_moon_phase();
@@@ -378,17 -376,14 +376,14 @@@ change_plane1(Actor *actor, AWallpaperP
      sec = tvb.tv_sec;
  //    fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
     
+     if (scene.daytime != TIME_NIGHT){
+         if (actor->time_start_animation == 0){
+             actor->time_start_animation = sec + probability_plane();
+             return;
+         }
+     }
      if (!actor->visible){
          actor->visible = TRUE;
-         if (scene.daytime == TIME_NIGHT){
-             if (actor->filename)
-                 g_free(actor->filename);
-             actor->filename = g_strdup("tu154.png");
-         }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;
          /* stop animation */
          actor->visible = FALSE;
          destroy_hildon_actor(actor);
-         actor->time_start_animation = sec + probability_plane();
+         if (scene.daytime == TIME_NIGHT) 
+             actor->time_start_animation = 0;
+         else 
+             actor->time_start_animation = sec + probability_plane();
      }
  
  }
@@@ -423,21 -421,17 +421,17 @@@ change_plane2(Actor *actor, AWallpaperP
      ms = tvb.tv_usec;
      sec = tvb.tv_sec;
  //    fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
-    
+     if (scene.daytime != TIME_NIGHT){
+         if (actor->time_start_animation == 0){
+             actor->time_start_animation = sec + probability_plane();
+             return;
+         }
+     }
      if (!actor->visible){
          actor->visible = TRUE;
-         if (scene.daytime == TIME_NIGHT){
-             if (actor->filename)
-                 g_free(actor->filename);
-         if (scene.daytime == TIME_NIGHT)
-             actor->filename = g_strdup("plane3.png");
-         }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;
      x = path_line(x0, x1, t);
      y = path_line(y0, y1, t);
          /* stop animation */
          actor->visible = FALSE;
          destroy_hildon_actor(actor);
-         actor->time_start_animation = sec + probability_plane();
+         if (scene.daytime == TIME_NIGHT) 
+             actor->time_start_animation = 0;
+         else 
+             actor->time_start_animation = sec + probability_plane();
      }
  
  }
@@@ -510,9 -507,10 +507,10 @@@ change_cloud(Actor *actor, AWallpaperPl
  void
  change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin)
  {
-     scene.wind_orientation = fast_rnd(2) - 1;
-     scene.wind_angle = (double)(fast_rnd(400) - 200) / 100;
-     actor->time_start_animation = time(NULL) + (fast_rnd(20) + 10) * 60;
+     scene.wind_orientation = fast_rnd(2);
+     if (scene.wind_orientation == 0) scene.wind_orientation = -1;
+     scene.wind_angle = (double)(fast_rnd(200) - 100) / 100;
+     actor->time_start_animation = time(NULL) + (fast_rnd(10) + 10) * 60;
      fprintf(stderr, "change wind orient = %d angle = %f after = %d\n", scene.wind_orientation, scene.wind_angle, actor->time_start_animation-time(NULL));
  }
  
@@@ -613,11 -611,8 +611,8 @@@ change_hildon_actor(Actor *actor, AWall
  void 
  change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
  {
-     gint daytime;
      gchar *newfile;
-     if (!actor) return;
-     daytime = get_daytime();
-     newfile = g_strdup_printf("%s%d.png", actor->name, daytime); 
+     newfile = g_strdup_printf("%s%d.png", actor->name, scene.daytime); 
      if (actor->filename)
              g_free(actor->filename);
      actor->filename = newfile;
@@@ -678,6 -673,9 +673,9 @@@ init_scene(AWallpaperPlugin *desktop_pl
    scene.actors = NULL;
    scene.wind_orientation = -1;
    scene.wind_angle = 0.3;
+   /* init value for random */
+   scene.seed = time(NULL);
    
  
    actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, 5, 800, 480, 
@@@ -766,6 -764,9 +764,9 @@@ init_scene1(AWallpaperPlugin *desktop_p
    scene.actors = NULL;
    scene.wind_orientation = -1;
    scene.wind_angle = 0.3;
+   /* init value for random */
+   scene.seed = time(NULL);
    
    actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
                        TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
    change_moon(actor, desktop_plugin);
    scene.actors = g_slist_append(scene.actors, actor);
    
-   actor = init_object(desktop_plugin, "cloud1", "cloud2.png", 0, fast_rnd(300), 7, 188, 75, 
+   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 + fast_rnd(3) * 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, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, 
+                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+   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, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, 
+                       FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+   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, "plane2", "plane3.png", 0, 45, 8, 160, 50, 
                        FALSE, 100, 255, (gpointer)&change_plane2, NULL);
    actor->time_start_animation = now + probability_plane();
    change_static_actor(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);
  
  }
  
@@@ -902,12 -920,12 +920,12 @@@ change_actor(GtkWidget * actor
  static gboolean
  short_timeout (AWallpaperPlugin *desktop_plugin)
  {
-       gint daytime = get_daytime();
-       GSList * tmp;
-       void (*pfunc)(gpointer, gpointer);
-       time_t now;
-       Actor *actor;
-       gboolean stop_flag = TRUE;
+     gint daytime = get_daytime();
+     GSList * tmp;
+     void (*pfunc)(gpointer, gpointer);
+     time_t now;
+     Actor *actor;
+     gboolean stop_flag = TRUE;
  
      if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
          desktop_plugin->priv->short_timer = 0;
@@@ -948,16 -966,16 +966,19 @@@ long_timeout (AWallpaperPlugin *desktop
      time_t now;
      Actor *actor;
  
 +    fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer);
 +    if (desktop_plugin->priv->long_timer == 0 )
 +        return FALSE;
-     /* TODO  remove timeout */
      if (!desktop_plugin->priv->visible){
-         desktop_plugin->priv->short_timer = 0;
+         if(desktop_plugin->priv->short_timer != 0){
+             g_source_remove(desktop_plugin->priv->short_timer);
+             desktop_plugin->priv->short_timer = 0;
+         }
          return FALSE;
      }
      //fprintf(stderr, "timer daytime=%d\n", daytime);
      if (scene.daytime != daytime){
+         scene.daytime = daytime;
          tmp = scene.actors;
          while (tmp != NULL){
              //change_actor(tmp->data);
          tmp = g_slist_next(tmp);
      }
     
-     scene.daytime = daytime;
  
      return TRUE; /* keep running this event */
  }
@@@ -997,76 -1014,58 +1017,75 @@@ desktop_plugin_visible_notify (GObjec
  {
      gboolean visible;
      g_object_get (object, "is-on-current-desktop", &visible, NULL);
 +    /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
      if (visible){
          desktop_plugin->priv->visible = TRUE;
-         if ( desktop_plugin->priv->long_timer == 0){
+         if (desktop_plugin->priv->long_timer == 0 )
              desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
-         }
      }else{
          desktop_plugin->priv->visible = FALSE;
-         g_source_remove(desktop_plugin->priv->long_timer);
-         desktop_plugin->priv->long_timer = 0;
+         if (desktop_plugin->priv->long_timer != 0 ){
+             g_source_remove(desktop_plugin->priv->long_timer);
+             desktop_plugin->priv->long_timer = 0;
+         }
      }
 -   /*   fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
  }
  
  gboolean
  rich_animation_press(GtkWidget *widget, GdkEvent *event,
                                              gpointer user_data){
-     fprintf(stderr,"gggggggggggggggggggg\n");
+     fprintf(stderr,"gggggggggggggggggggg2222\n");
  }    
  static void
  animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
  {
 -    GtkWidget *label;
 +    GtkWidget *widget;
      GtkWidget *rich_animation;
 +    gchar           buffer[2048];
 +
 +    GtkWidget  *background_town = NULL;
 +
      fprintf(stderr, "!!!!!!!plugin init \n");
      Animation_WallpaperPrivate *priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
      desktop_plugin->priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
 +
      /* Load config */
      read_config(priv);
      priv->desktop_plugin = desktop_plugin;
 +    widget = gtk_fixed_new();
 +
-     gtk_widget_set_size_request(widget, 95, 68);
++    gtk_widget_set_size_request(widget, 95, 50);
 +    snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town_right_corner.png");
 +    background_town = gtk_image_new_from_file (buffer);
 +    if (background_town){
 +        gtk_fixed_put(GTK_FIXED(widget), background_town, 0, 0);
 +        gtk_widget_show (background_town);
 +    }
      /* Create rich animation event */
      rich_animation = gtk_event_box_new();
      if(rich_animation){
          gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
          gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
-         gtk_widget_set_size_request(rich_animation, 95, 60);
 -        gtk_widget_set_size_request(rich_animation, 95, 30);
++        gtk_widget_set_size_request(rich_animation, 95, 50);
          gtk_widget_show (rich_animation);
          g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
 +        gtk_fixed_put(GTK_FIXED(widget), rich_animation, 0, 0);
      }
  /*
 -    label = gtk_label_new (""); 
 +    GtkWidget *label = gtk_label_new ("ddddddddddddd"); 
      gtk_widget_set_size_request(label, 95, 30);
      gtk_widget_show (label);
 -    gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
 +//    gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
 +    gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
  */
      hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
      g_signal_connect (desktop_plugin, "show-settings",
                             G_CALLBACK (lw_settings), priv);
 -    gtk_container_add (GTK_CONTAINER (desktop_plugin), rich_animation);
 +    gtk_widget_show (widget);
 +    gtk_container_add (GTK_CONTAINER (desktop_plugin), widget);
      init_applet_position();
  
-     /* start value for random */
-     seed = time(NULL);
+     
      fprintf(stderr, "!!!theme = %s\n", priv->theme);
      if (!strcmp(priv->theme,"Modern"))
          init_scene(desktop_plugin);
@@@ -1088,8 -1087,7 +1107,8 @@@ lw_applet_finalize (GObject *object
  {
       AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
       Animation_WallpaperPrivate *priv = desktop_plugin->priv;
 -
 +     
 +     fprintf(stderr,"finalaze %i\n", priv->long_timer);
       if (priv->long_timer){
          g_source_remove(priv->long_timer);
          priv->long_timer = 0;
@@@ -1118,4 -1116,5 +1137,5 @@@ animation_wallpaper_plugin_class_init (
  }
  
  static void
- animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {}
+ animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
+ }