moving tram depend on time
authorTanya <tanya@bookdmitri.oblgaz>
Sun, 4 Apr 2010 18:03:02 +0000 (21:03 +0300)
committerTanya <tanya@bookdmitri.oblgaz>
Sun, 4 Apr 2010 18:03:02 +0000 (21:03 +0300)
applet/src/livewp-home-widget.c

index c23f2ea..ebf002b 100644 (file)
@@ -180,6 +180,7 @@ init_object(gchar * name, gchar * filename, gint x, gint y, gint z, gint width,
 
   actor_set_position_full(actor, x, y, z);
   hildon_animation_actor_set_show (actor, visible);
+  hildon_animation_actor_set_scale(actor, (double)scale/100, (double)scale/100);
   realize(actor);
   gtk_widget_show_all(actor);
   g_object_set_data(G_OBJECT(actor), "name", name);
@@ -230,10 +231,10 @@ void change_sun(GtkWidget * actor, gpointer data)
     }
 }
 void change_tram(GtkWidget * actor, gpointer data)
-{
+{    
     double alt, azm;
     gint x, y, z, scale, width, height, daytime;
-    //fprintf(stderr, "change sun \n");
+    fprintf(stderr, "change tram %i \n", data);
     if (actor){
         x = g_object_get_data(G_OBJECT(actor), "x");
         y = g_object_get_data(G_OBJECT(actor), "y");
@@ -287,6 +288,30 @@ void change_background(GtkWidget * actor, gpointer data)
     }
 }
 
+static void path_tram(GtkWidget * actor, gint* t)
+{
+    gint x0 = -300, y0 = 191, scale0 = 100, t0 = 0,
+         x1 = 800, y1 = 119, scale1 = 130, t1 = 100, 
+         x, y, scale;
+    x = 12 * *t - 300;
+    y = -0.72 * *t + 191;
+    scale = 0.3 * *t + 100;
+    if (x >= x1){
+        x = x0;
+        y = y0;
+        scale = scale0;
+        *t = 0;
+    }
+    fprintf(stderr, "path tram:  t=%i, x=%i, y=%i, scale=%i\n", *t, x, y, scale);
+    actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
+    hildon_animation_actor_set_scale(actor, (double)scale/100, (double)scale/100);
+}
+static gint get_time(gint t)
+{
+    return t*1.2;
+    
+}
+
 static void
 init_scene(GtkWidget *window)
 {
@@ -320,8 +345,7 @@ init_scene(GtkWidget *window)
   
   actor = init_object("tram", "tram.png", -300, 191, 25, 350, 240, 1, 100, 255, NULL);
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
-  
-}
+ }
 static void
 init_scene1(GtkWidget *window)
 {
@@ -470,12 +494,13 @@ change_actor(GtkWidget * actor)
     }
 
 }
-
+gint ttt = 0;
 static gboolean
 plugin_on_timeout (AWallpaperPlugin *desktop_plugin)
 {
   gint daytime = get_daytime();
   GSList * tmp;
+  gchar * name;
   void (*pfunc)(gpointer, gpointer);
   //fprintf(stderr, "on timeout\n");
 
@@ -489,6 +514,11 @@ plugin_on_timeout (AWallpaperPlugin *desktop_plugin)
   while (tmp != NULL){
       //change_actor(tmp->data);
       pfunc = g_object_get_data(G_OBJECT(tmp->data), "func");
+      name = g_object_get_data(G_OBJECT(tmp->data), "name");
+      if (name == "tram"){
+          path_tram(tmp->data, &ttt);
+          ttt = get_time(ttt+1);
+        }else
       if (pfunc){
           (*pfunc)(tmp->data, NULL);
       }
@@ -549,25 +579,23 @@ desktop_plugin_visible_notify (GObject    *object,
 static void
 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
 {
-    GtkWidget *label;
-
-    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);
-    label = gtk_label_new (""); 
-    gtk_widget_set_size_request(label, 95, 30);
-    gtk_widget_show (label);
-    hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
-    g_signal_connect (desktop_plugin, "show-settings",
+  GtkWidget *label;
+  Animation_WallpaperPrivate *priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
+  desktop_plugin->priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
+  label = gtk_label_new (""); 
+  //desktop_plugin->priv->main_widget = label;
+  gtk_widget_set_size_request(label, 95, 30);
+  gtk_widget_show (label);
+  hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
+  g_signal_connect (desktop_plugin, "show-settings",
                             G_CALLBACK (lw_settings), NULL);
-    g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
+  g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
                      G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
 
-    gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
-    init_applet_position();
-    init_scene(desktop_plugin);
-    priv->timer = g_timeout_add(50, plugin_on_timeout, desktop_plugin);
+  gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
+  init_applet_position();
+  init_scene(desktop_plugin);
+  priv->timer = g_timeout_add(1000, plugin_on_timeout, desktop_plugin);
 }
 
 static void
@@ -580,8 +608,6 @@ lw_applet_finalize (GObject *object)
         g_source_remove(priv->timer);
         priv->timer = NULL;
      }
-     /* Save config */
-     save_config(priv);
 }
 
 static void