started theme with tape
[livewp] / applet / src / livewp-actor.c
1 /*vim: set sw=4 ts=4 et: */
2 /*
3  * This file is part of Live Wallpaper (livewp)
4  * 
5  * Copyright (C) 2010 Vlad Vasiliev
6  * Copyright (C) 2010 Tanya Makova
7  *       for the code
8  * 
9  * This software is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1 of
12  * the License, or (at your option) any later version.
13  * 
14  * This software is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this software; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23 */
24 /*******************************************************************************/
25 #include "livewp-actor.h"
26
27 Actor* 
28 init_object(AWallpaperPlugin *desktop_plugin, 
29             gchar * name, 
30             gchar * filename, 
31             gint x, 
32             gint y, 
33             gint z, 
34             gint width, 
35             gint height, 
36             gboolean visible, 
37             gboolean load_image,
38             gint scale, 
39             gint opacity, 
40             void (*pfunc_change)(Actor*),
41             void (*pfunc_probability)(Actor*),
42             GPtrArray *child
43            )
44 {
45     Actor *actor = NULL;
46     actor = g_new0(Actor, 1);
47     actor->x = x;
48     actor->y = y;
49     actor->z = z;
50     actor->width = width;
51     actor->height = height;
52     actor->visible = visible;
53     actor->scale = scale;
54     actor->opacity = opacity;
55     actor->filename = g_strdup(filename);
56     actor->name = g_strdup(name);
57     actor->func_change = (gpointer)pfunc_change; 
58     actor->func_probability = (gpointer)pfunc_probability;
59     actor->child = child;
60     if (load_image)
61         create_hildon_actor(actor, desktop_plugin);
62     else 
63          actor->widget = NULL;
64     actor->time_start_animation = 0;
65     actor->duration_animation = 0;
66     return actor;
67 }
68
69 void 
70 destroy_actor(Actor *actor)
71 {
72     if (actor){
73         if (actor->child){
74             g_ptr_array_free(actor->child, TRUE);
75         }
76         if (actor->filename)
77             g_free(actor->filename);
78         if (actor->name)
79             g_free(actor->name);
80         gtk_widget_destroy(actor->widget);
81         //actor->widget = NULL;
82         g_free(actor);
83     }
84 }
85 static gint 
86 path_line(gint x0, gint x1, double t)
87 {
88     // уравниение прямой
89     return ((x1 - x0) * t + x0);
90 }
91 void
92 set_actor_scale(Actor *actor, double scalex, double scaley)
93 {
94     hildon_animation_actor_set_scale(
95             HILDON_ANIMATION_ACTOR(actor->widget), 
96             scalex, 
97             scaley
98     );
99
100 }
101
102 void 
103 set_actor_visible(Actor *actor, gboolean visible)
104 {
105     hildon_animation_actor_set_show(HILDON_ANIMATION_ACTOR(actor->widget), visible);
106 }
107
108 void
109 set_actor_position(Actor *actor, gint x, gint y, gint z, AWallpaperPlugin *desktop_plugin)
110 {
111     hildon_animation_actor_set_position_full(HILDON_ANIMATION_ACTOR (actor->widget), 
112                                              x-desktop_plugin->priv->xapplet, 
113                                              y-desktop_plugin->priv->yapplet, 
114                                              z);
115 }
116
117 int get_notify_count(gchar *notify_type)
118 {
119     sqlite3 *db = NULL;
120     sqlite3_stmt *res = NULL;
121     gint rc = 0, result = 0;
122     gchar sql[1024];
123
124     rc = sqlite3_open("/home/user/.config/hildon-desktop/notifications.db", &db);
125     if (rc){
126         fprintf(stderr, "error open db %d %s\n", rc, sqlite3_errmsg(db));
127     }else {
128         snprintf(sql, sizeof(sql)-1, "select count(id) from notifications where icon_name='%s'", notify_type);
129         rc = sqlite3_prepare(db, sql, sizeof(sql)-1, &res, NULL);
130         if (rc != SQLITE_OK){
131             fprintf(stderr, "error prepare %d %s\n", rc, sql);
132         }
133         if (sqlite3_step(res) != SQLITE_ROW){
134             fprintf(stderr, "not sqlite_row\n");
135         }
136         result = sqlite3_column_int(res, 0);
137         //fprintf(stderr, "count missing calls = %d\n", call_count);
138         sqlite3_finalize(res);
139
140         sqlite3_close(db);
141     }
142     return result;
143 }
144 gchar * read_notification()
145 {
146     gchar *message = "";
147     gint count = 0;
148     
149     fprintf(stderr, "read notification \n");
150     count = get_notify_count("general_missed");
151     if (count > 0){
152         message = g_strdup_printf("%s: %d", _("Missed calls"), count);
153     }
154     count = get_notify_count("general_sms");
155     if (count > 0){
156         if (message){
157             message = g_strdup_printf("%s \n%s: %d", message, _("Missed sms"), count);
158         }else {
159             message = g_strdup_printf("%s: %d", _("Missed sms"), count);
160         }
161     }
162     count = get_notify_count("general_chat");
163     if (count > 0){
164         if (message){
165             message = g_strdup_printf("%s \n%s: %d", message, _("Missed chat"), count);
166         }else {
167             message = g_strdup_printf("%s: %d", _("Missed chat"), count);
168         }
169     }
170     count = get_notify_count("qgn_list_messagin");
171     if (count > 0){
172         if (message){
173             message = g_strdup_printf("%s \n%s: %d", message, _("Missed mail"), count);
174         }else {
175             message = g_strdup_printf("%s: %d", _("Missed mail"), count);
176         }
177     }
178     fprintf(stderr, "notify=%s\n", message);
179     return message;
180 }
181
182 void
183 change_obj(Actor *actor, AWallpaperPlugin *desktop_plugin)
184 {
185     char * accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord";
186     //char * accel_filename = "/home/tanya/coord";
187
188     FILE *fd = NULL;
189     int rs, ax, ay, az, dx, dy;
190     fd = fopen(accel_filename, "r");
191     if (fd == NULL){
192         fprintf(stderr, "cannot open file\n");
193         return;
194     }
195     rs = fscanf((FILE*)fd, "%i %i %i", &ax, &ay, &az);
196     fclose(fd);
197     if (rs != 3){
198         fprintf(stderr, "cannot read information from file\n");
199         return;
200     }
201
202     fprintf(stderr, "change obj %i %i %i\n", ax, ay, az);
203     dx = -ax / 100;
204     dy = -ay / 100;
205
206     actor->x = actor->x + dx;
207     actor->y = actor->y + dy;
208
209     if (actor->x > 800) actor->x = 0;
210     if (actor->x < 0) actor->x = 800;
211
212     if (actor->y > 480) actor->y = 0;
213     if (actor->y < 0) actor->y = 480;
214
215     set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
216
217
218 }
219
220 void 
221 change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin)
222 {
223     gint count = 0;
224     Actor *a = NULL;
225      
226     //fprintf(stderr, "change_billboard\n");   
227     
228     if (desktop_plugin->priv->scene->notification < time(NULL)){
229         count = get_notify_count("general_missed");
230         a = g_ptr_array_index(actor->child, 0);
231         if (count > 0){
232             set_actor_visible(a, TRUE);            
233         }else {
234             set_actor_visible(a, FALSE);
235         }
236         count = get_notify_count("general_sms");
237         a = g_ptr_array_index(actor->child, 3);
238         if (count > 0){
239             set_actor_visible(a, TRUE);            
240         }else {
241             set_actor_visible(a, FALSE);
242         }
243         count = get_notify_count("general_chat");
244         a = g_ptr_array_index(actor->child, 1);
245         if (count > 0){
246             set_actor_visible(a, TRUE);            
247         }else {
248             set_actor_visible(a, FALSE);
249         }
250         count = get_notify_count("qgn_list_messagin");
251         a = g_ptr_array_index(actor->child, 2);
252         if (count > 0){
253             set_actor_visible(a, TRUE);            
254         }else {
255             set_actor_visible(a, FALSE);
256         }
257
258         desktop_plugin->priv->scene->notification = FALSE;
259     }
260     actor->time_start_animation = time(NULL) + 20;    
261 }
262
263 #if 0
264 void 
265 change_billboard1(Actor * actor, AWallpaperPlugin *desktop_plugin)
266 {
267     GtkWidget *label;
268     sqlite3 *db = NULL;
269     sqlite3_stmt *res = NULL;
270     gchar *errMsg = NULL, *message;
271     gchar sql[1024];
272     gint call_count=0, sms_count=0, rc=0;
273     GtkListStore *list = NULL;
274     PangoFontDescription *pfd = NULL;
275     
276     rc = sqlite3_open("/home/user/.rtcom-eventlogger/el.db", &db);
277     if (rc){
278         fprintf(stderr, "error open db %d %s\n", rc, sqlite3_errmsg(db));
279     }else {
280         snprintf(sql, sizeof(sql)-1, "select count(id) from Events where event_type_id=%d", 3);
281
282         rc = sqlite3_prepare(db, sql, sizeof(sql)-1, &res, NULL);
283         if (rc != SQLITE_OK){
284             fprintf(stderr, "error prepare %d %s\n", rc, sql);
285         }
286         if (sqlite3_step(res) != SQLITE_ROW){
287             fprintf(stderr, "not sqlite_row\n");
288         }
289         call_count = sqlite3_column_int(res, 0);
290         //fprintf(stderr, "count missing calls = %d\n", call_count);
291         sqlite3_finalize(res);
292
293         snprintf(sql, sizeof(sql)-1, "select count(id) from Events where event_type_id=%d and is_read=%d", 7, 0);
294         rc = sqlite3_prepare(db, sql, sizeof(sql)-1, &res, NULL);
295         if (rc != SQLITE_OK){
296             fprintf(stderr, "error prepare %d %s\n", rc, sql);
297         }
298         if (sqlite3_step(res) != SQLITE_ROW){
299             fprintf(stderr, "not sqlite_row\n");
300         }
301         sms_count = sqlite3_column_int(res, 0);
302         //fprintf(stderr, "count sms = %d\n", sms_count);
303         sqlite3_finalize(res);
304
305
306         sqlite3_close(db);
307     }
308     label = actor->image;
309     message = g_markup_printf_escaped("<span bgcolor=\"%s\" foreground=\"%s\">Missed calls: %d Unread sms: %d</span>", "#FFFFFF", "#000000", call_count, sms_count);
310     gtk_label_set_markup(GTK_LABEL(label), message);
311     g_free(message);
312     pfd = pango_font_description_from_string("Sans 14");
313     gtk_widget_modify_font(GTK_WIDGET(label), NULL);
314     gtk_widget_modify_font(GTK_WIDGET(label), pfd);
315     pango_font_description_free(pfd);
316     actor->time_start_animation = time(NULL) + 20;    
317 }
318 #endif
319
320 void 
321 change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
322 {
323     gint phase;
324     char *newfile;
325     gint x0 = 150,
326          x1 = 650, 
327          x, y;
328     struct timeval tvb;     
329     suseconds_t ms;
330     long sec;
331     double t;
332 #if 0
333     gint y0, y1, x2, y2;
334     double a, b, c;
335     a = (double)(y2 - (double)(x2*(y1-y0) + x1*y0 - x0*y1)/(x1-x0))/(x2*(x2-x0-x1)+x0*x1);
336     b = (double)(y1-y0)/(x1-x0) - (double)a*(x0+x1);
337     c = (double)(x1*y0 - x0*y1)/(x1-x0) + (double)a*x0*x1;
338     fprintf(stderr, "a=%f, b=%f, c=%f\n", a, b, c);
339 #endif
340     gettimeofday(&tvb, NULL);
341     
342     ms = tvb.tv_usec;
343     sec = tvb.tv_sec;
344
345     if (actor){
346         if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){
347             if (!actor->visible){
348                 actor->visible = TRUE;
349                 phase = get_moon_phase();
350                 newfile = g_strdup_printf( "%s%d.png", actor->name, phase);
351                 if (actor->filename)
352                     g_free(actor->filename);
353                 actor->filename = newfile;
354                 actor->time_start_animation = sec - fast_rnd(60 * 60);
355                 actor->duration_animation = 1 * 60 * 60;
356                 create_hildon_actor(actor, desktop_plugin);
357
358             }
359             t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
360             if (t <= 1)
361                 x = path_line(x0, x1, t);
362             else 
363                 x = path_line(x1, x0, t-1);
364             y = 0.001920*x*x - 1.536*x + 337.2;
365             //y = a*x*x + b*x + c;
366
367             set_actor_position(actor, x, y, actor->z, desktop_plugin);
368
369             if (t>=2){
370                 actor->time_start_animation = sec;
371             }
372
373          }else if (actor->visible){
374             actor->visible = FALSE;
375             fprintf(stderr, "destroy moon \n");
376             destroy_hildon_actor(actor);
377             actor->time_start_animation = 0;
378         } 
379     }
380     
381 }
382
383 void 
384 change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
385 {
386     double alt, azm;
387     gint x, y;
388
389     //fprintf(stderr, "change sun\n");
390     if (actor){
391         if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){
392             if (!actor->visible){
393                 actor->visible = TRUE;
394                 create_hildon_actor(actor, desktop_plugin);
395             }
396             get_sun_pos(&alt, &azm);
397             get_sun_screen_pos(alt, azm, &x, &y);
398             actor->x = x;
399             actor->y = y;
400             set_actor_position(actor, x, y, actor->z, desktop_plugin);
401             actor->time_start_animation = time(NULL) + 60;
402          }else if (actor->visible){
403             actor->visible = FALSE;
404             destroy_hildon_actor(actor);
405             actor->time_start_animation = 0;
406         } 
407     }
408     
409 }
410
411 void 
412 change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
413 {
414     gint x0 = -300, y0 = 225, scale0 = 100,
415          x1 = 800, y1 = 162, scale1 = 130, 
416          x, y, scale;
417     struct timeval tvb;     
418     suseconds_t ms;
419     long sec;
420     double t;
421
422     //fprintf(stderr, "change tram\n");
423     gettimeofday(&tvb, NULL);
424     
425     ms = tvb.tv_usec;
426     sec = tvb.tv_sec;
427     
428     if (!actor->visible){
429         actor->visible = TRUE;
430         if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){
431             if (actor->filename)
432                 g_free(actor->filename);
433             actor->filename = g_strdup("tram_dark.png");
434         } else{
435             if (actor->filename)
436                 g_free(actor->filename);
437             actor->filename = g_strdup("tram.png");
438         }
439         create_hildon_actor(actor, desktop_plugin);
440     }
441     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
442     x = path_line(x0, x1, t);
443     y = path_line(y0, y1, t);
444     scale = path_line(scale0, scale1, t);
445     set_actor_position(actor, x, y, actor->z, desktop_plugin);
446     set_actor_scale(actor, (double)scale/100, (double)scale/100);
447     if (t >= 1){
448         /* stop animation */
449         actor->visible = FALSE;
450         destroy_hildon_actor(actor);
451         actor->time_start_animation = sec + fast_rnd(60);
452     }
453 }
454
455 void
456 change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
457 {
458     gint x0 = 620, y0 = 233,
459          x1 = 79, y1 = -146, 
460          x, y;
461     struct timeval tvb;     
462     suseconds_t ms;
463     long sec;
464     double t;
465
466     gettimeofday(&tvb, NULL);
467     
468     ms = tvb.tv_usec;
469     sec = tvb.tv_sec;
470 //    fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
471    
472     if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){
473         if (actor->time_start_animation == 0){
474             actor->time_start_animation = sec + fast_rnd(180);
475             return;
476         }
477     }
478     if (!actor->visible){
479         actor->visible = TRUE;
480         create_hildon_actor(actor, desktop_plugin);
481     }
482     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
483     x = path_line(x0, x1, t);
484     y = path_line(y0, y1, t);
485     //scale = path_line(scale0, scale1, t);
486     set_actor_position(actor, x, y, actor->z, desktop_plugin);
487     if (t >= 1){
488         /* stop animation */
489         actor->visible = FALSE;
490         destroy_hildon_actor(actor);
491         if (desktop_plugin->priv->scene->daytime == TIME_NIGHT) 
492             actor->time_start_animation = 0;
493         else 
494             actor->time_start_animation = sec + fast_rnd(180);
495     }
496
497 }
498
499 void
500 change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
501 {
502     gint x0 = -actor->width, y0 = 45,
503          x1 = 800, y1 = 20, 
504          x, y;
505     struct timeval tvb;     
506     suseconds_t ms;
507     long sec;
508     double t;
509
510     gettimeofday(&tvb, NULL);
511     
512     ms = tvb.tv_usec;
513     sec = tvb.tv_sec;
514 //    fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
515     if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){
516         if (actor->time_start_animation == 0){
517             actor->time_start_animation = sec + fast_rnd(180);
518             return;
519         }
520     }
521     if (!actor->visible){
522         actor->visible = TRUE;
523         create_hildon_actor(actor, desktop_plugin);
524     }
525
526     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
527     x = path_line(x0, x1, t);
528     y = path_line(y0, y1, t);
529     //scale = path_line(scale0, scale1, t);
530     set_actor_position(actor, x, y, actor->z, desktop_plugin);
531     if (t >= 1){
532         /* stop animation */
533         actor->visible = FALSE;
534         destroy_hildon_actor(actor);
535         if (desktop_plugin->priv->scene->daytime == TIME_NIGHT) 
536             actor->time_start_animation = 0;
537         else 
538             actor->time_start_animation = sec + fast_rnd(180);
539     }
540
541 }
542
543 void
544 change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
545 {
546     gint x0, y0 = 300, scale0 = 100,
547          x1, y1 = -actor->height, scale1 = 150, 
548          x, y, scale;
549     struct timeval tvb;     
550     suseconds_t ms;
551     long sec;
552     double t;
553     gchar *newfile;
554
555     //fprintf(stderr, "change cloud\n");
556     gettimeofday(&tvb, NULL);
557     
558     ms = tvb.tv_usec;
559     sec = tvb.tv_sec;
560    
561     if (!actor->visible){
562         actor->visible = TRUE;
563         if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){
564             newfile = g_strdup_printf("%s_dark.png", actor->name);
565         }else{
566             newfile = g_strdup_printf("%s.png", actor->name);
567         } 
568         if (actor->filename)
569             g_free(actor->filename);
570         actor->filename = newfile;
571          
572         create_hildon_actor(actor, desktop_plugin);
573     }
574     t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
575     
576     if (desktop_plugin->priv->scene->wind_orientation == 1){
577         x0 = -actor->width;
578         x1 = 800;
579     }
580     else {
581         x0 = 800;
582         x1 = -actor->width;
583     }
584
585     x = path_line(x0, x1, t);    
586     y = -desktop_plugin->priv->scene->wind_angle * (x - x0) + actor->y;
587     scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0));
588
589     set_actor_position(actor, x, y, actor->z, desktop_plugin);
590     set_actor_scale(actor, (double)scale/100, (double)scale/100);
591     if ((y < y1 || y > y0) || t >= 1){
592         /* stop animation */
593         actor->visible = FALSE;
594         destroy_hildon_actor(actor);
595         actor->time_start_animation = sec + fast_rnd(300);
596         actor->y = fast_rnd(300);
597     }
598
599 }
600
601 void
602 change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin)
603 {
604     desktop_plugin->priv->scene->wind_orientation = fast_rnd(2);
605     if (desktop_plugin->priv->scene->wind_orientation == 0) desktop_plugin->priv->scene->wind_orientation = -1;
606     desktop_plugin->priv->scene->wind_angle = (double)(fast_rnd(200) - 100) / 100;
607     actor->time_start_animation = time(NULL) + (fast_rnd(10) + 10) * 60;
608     //fprintf(stderr, "change wind orient = %d angle = %f after = %d\n", scene.wind_orientation, scene.wind_angle, actor->time_start_animation-time(NULL));
609 }
610
611 void 
612 change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin)
613 {
614     gint now = time(NULL);
615     if (desktop_plugin->priv->scene->daytime == TIME_DAY){
616         if (actor->widget){
617             actor->visible = FALSE;
618             destroy_hildon_actor(actor);
619         }
620         actor->time_start_animation = 0;
621         return;
622     }else {
623         if (!actor->widget)
624             create_hildon_actor(actor, desktop_plugin);
625         if (actor->time_start_animation == 0){
626             actor->time_start_animation = now + fast_rnd(30);
627             return;
628         }
629     }
630
631     if (!actor->visible)
632         actor->visible = TRUE;
633     else 
634         actor->visible = FALSE;
635     set_actor_visible(actor, actor->visible);
636     actor->time_start_animation = now + fast_rnd(60) + 10;
637
638 }
639
640 void 
641 change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin)
642 {
643     gint now = time(NULL);
644     Actor *a;
645     a = g_ptr_array_index(actor->child, 0);
646     if (a->visible)
647         a->visible = FALSE;
648     else 
649         a->visible = TRUE;
650     set_actor_visible(a, a->visible);
651     
652     a = g_ptr_array_index(actor->child, 1);
653     if (a->visible)
654         a->visible = FALSE;
655     else 
656         a->visible = TRUE;
657     set_actor_visible(a, a->visible);
658
659     actor->time_start_animation = now + fast_rnd(30) + 10;
660 }
661
662 void
663 change_tape(Actor *actor, AWallpaperPlugin *desktop_plugin)
664 {
665     gint x, speed = 8;
666     Actor *a;
667     
668     if (!desktop_plugin->priv->rich_animation) return;
669
670     a = g_ptr_array_index(actor->child, 0);
671     x = a->x - speed;
672     if (x < -800) 
673         x = 2400;
674     set_actor_position(a, x, a->y, a->z, desktop_plugin);
675     a->x = x;
676     
677     a = g_ptr_array_index(actor->child, 1);
678     x = a->x - speed;
679     if (x < -800) 
680         x = 2400;
681     set_actor_position(a, x, a->y, a->z, desktop_plugin);
682     a->x = x;
683
684 }
685
686 void
687 change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin)
688 {
689     gint y, speed1 = 8, speed2 = 16;
690     Actor *a;
691
692     if (!desktop_plugin->priv->rich_animation) return;
693
694     a = g_ptr_array_index(actor->child, 0);
695     y = a->y + speed1;
696     if (y > 480) y = -480;
697     set_actor_position(a, a->x, y, a->z, desktop_plugin);
698     a->y = y;
699     
700     a = g_ptr_array_index(actor->child, 1);
701     y = a->y + speed1;
702     if (y > 480) y = -480;
703     set_actor_position(a, a->x, y, a->z, desktop_plugin);
704     a->y = y;
705
706     a = g_ptr_array_index(actor->child, 2);
707     y = a->y + speed2;
708     if (y > 480) y = -480;
709     set_actor_position(a, a->x, y, a->z, desktop_plugin);
710     a->y = y;
711
712     a = g_ptr_array_index(actor->child, 3);
713     y = a->y + speed2;
714     if (y > 480) y = -480;
715     set_actor_position(a, a->x, y, a->z, desktop_plugin);
716     a->y = y;
717 }
718
719 void 
720 change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
721 {
722     gchar *newfile;
723     newfile = g_strdup_printf("%s%d.png", actor->name, desktop_plugin->priv->scene->daytime); 
724     if (actor->filename)
725             g_free(actor->filename);
726     actor->filename = newfile;
727     change_hildon_actor(actor, desktop_plugin);
728 }
729
730 void 
731 change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin)
732 {
733     gchar buffer[2048];
734
735     if (desktop_plugin->priv->right_corner)
736         gtk_widget_destroy(desktop_plugin->priv->right_corner);
737     snprintf(buffer, sizeof(buffer) - 1, "%s/%s/town%i_right_corner.png", \
738                                   THEME_PATH, desktop_plugin->priv->theme, desktop_plugin->priv->scene->daytime);
739     desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
740     if (desktop_plugin->priv->right_corner){
741         gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
742         gtk_widget_show (desktop_plugin->priv->right_corner);
743     }
744     change_static_actor(actor, desktop_plugin);
745
746 }