added xsnow theme and cosmetic changes
[livewp] / applet / src / livewp-scene.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-scene.h" 
26
27 void 
28 destroy_scene(AWallpaperPlugin *desktop_plugin)
29 {
30     if (desktop_plugin->priv->scene){
31             GSList * tmp = desktop_plugin->priv->scene->actors;
32             while (tmp != NULL){
33                 destroy_actor(tmp->data);
34                 tmp = g_slist_next(tmp);
35             }
36             if (tmp)
37                 g_slist_free(tmp);
38             desktop_plugin->priv->scene->actors = NULL;
39             if (desktop_plugin->priv->scene){
40                 g_free(desktop_plugin->priv->scene);
41                 desktop_plugin->priv->scene = NULL;
42             }
43     }
44     if (desktop_plugin->priv->pipeline){
45         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
46         gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
47
48     }
49 }
50 /*******************************************************************************/
51 void
52 reload_scene(AWallpaperPlugin *desktop_plugin)
53 {
54     fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);  
55     destroy_scene(desktop_plugin);
56     init_scene_theme(desktop_plugin);
57 }
58 /*******************************************************************************/
59 void 
60 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
61 {
62     Actor *actor;
63     Scene *scene;
64     GPtrArray *child;
65     gint now = time(NULL);
66     gchar *str;
67     gint sizes[4] = {170, 229, 130, 150}, 
68         sizes1[4] = {57, 76, 43, 50},
69         heights[4] = {0, 100, 200, 300}, 
70         n, i, j;
71     
72     fprintf(stderr, "init scene accel\n");
73     scene = g_new0(Scene, 1);
74     scene->actors = NULL;
75     desktop_plugin->priv->scene = scene;
76     
77     actor = init_object(desktop_plugin, "background", "bg.png", 
78                       0, 0, 0, 800, 480, 
79                       TRUE, TRUE, 100, 255, 
80                       NULL, NULL, NULL);
81     scene->actors = g_slist_append(scene->actors, actor);
82
83     child = g_ptr_array_sized_new(16);
84     
85     for (j= 0; j<4; j++){
86     for (n=0; n<4; n++){
87         //for (i=0; i<3; i++){
88             str = g_strdup_printf("tape%i.png", n+1);
89             actor = init_object(desktop_plugin, "tape", str,
90                                 fast_rnd(800), fast_rnd(480), 2+fast_rnd(6), 800, sizes1[n],
91                                 TRUE, TRUE, 100, 255,
92                                 NULL, NULL, NULL);
93             scene->actors = g_slist_append(scene->actors, actor);
94             g_ptr_array_add(child, actor);
95             g_free(str);
96         //}
97     }
98     }
99     actor = init_object(desktop_plugin, "tape", "", 
100                       0, 800, 5, 800, 170, 
101                       FALSE, FALSE, 100, 255, 
102                       (gpointer)&change_tape, NULL, child);
103     actor->time_start_animation = now;
104     actor->duration_animation = G_MAXINT;
105     scene->actors = g_slist_append(scene->actors, actor);
106
107     run_long_timeout(desktop_plugin);
108 }
109 /*******************************************************************************/
110 void  
111 parsestring(char *line, char **argv)
112 {
113    while (*line != '\0') {  
114           while (*line == ' ' || *line == '\n')
115                 *line++ = '\0';     /* replace white spaces with 0    */
116                  *argv++ = line;          /* save the argument position     */
117                  while (*line != '\0' && *line != ' ' && 
118                         *line != '\n') 
119                      line++;             /* skip the argument until ...    */
120    }
121                   *argv = '\0';                 /* mark the end of argument list  */
122 }
123
124 #if 0
125 GstBusSyncReply 
126 sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){
127
128     if (!desktop_plugin->priv->visible)
129         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
130     if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT){
131                 return (GST_BUS_PASS);
132         }
133     if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")){
134         return (GST_BUS_PASS);
135     }
136     return (GST_BUS_DROP);
137
138 }
139 #endif
140 /*******************************************************************************/
141 static gboolean
142 bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin)
143 {
144     switch (GST_MESSAGE_TYPE (msg))
145     {
146        case GST_MESSAGE_EOS: 
147            if (desktop_plugin->priv->rich_animation){
148
149                 GstClockTime nach   = (GstClockTime)(0 * GST_MSECOND);
150                 if (!gst_element_seek(desktop_plugin->priv->pipeline, 1.0, GST_FORMAT_TIME,
151                    (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET, 
152                    nach, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
153                     fprintf(stderr,"ERROR in seek\n");
154
155                 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
156
157            }else{
158                 if (desktop_plugin->priv->pipeline){
159                     gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
160                     gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
161                 } 
162            }
163            break;
164        case GST_MESSAGE_ERROR: break;
165        default: break;
166      }
167        return TRUE;
168 }
169 /*******************************************************************************/
170 void
171 init_scene_Video(AWallpaperPlugin *desktop_plugin)
172 {
173     GstElement *bin;                                                                                                                                                           
174     GstElement *videosink;                                                                                                
175     GstFormat format; 
176     gchar *file_plus_uri;
177
178
179     desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
180     bin = gst_element_factory_make ("playbin2", "bin");
181     videosink = gst_element_factory_make ("ximagesink", "videosink");
182     g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
183     gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
184
185     {
186         GstBus *bus;
187         bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
188         gst_bus_add_watch(bus, bus_call, desktop_plugin);
189         gst_object_unref (bus);
190     }
191     file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
192     g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
193     g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL  );
194     if (GST_IS_X_OVERLAY (videosink))
195             gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
196     if (desktop_plugin->priv->visible)
197         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
198 }
199 /*******************************************************************************/
200 void
201 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
202 {
203   Actor *actor;
204   Scene *scene;
205   GPtrArray *child;
206   gint now = time(NULL);
207   gint y1, y2;
208
209   if (desktop_plugin->priv->rich_animation){
210       y1 = -480;
211       y2 = -480-480;
212   }else {
213       y1 = 0;
214       y2 = -480;
215   }
216
217   /* fprintf(stderr, "init scene2 \n"); */
218   scene = g_new0(Scene, 1);
219   //scene.daytime = get_daytime();
220   scene->actors = NULL;
221   desktop_plugin->priv->scene = scene;
222   
223   actor = init_object(desktop_plugin, "background", "bg.png", 
224                       0, 0, 5, 800, 480, 
225                       TRUE, TRUE, 100, 255, 
226                       NULL, NULL, NULL);
227   scene->actors = g_slist_append(scene->actors, actor);
228
229   actor = init_object(desktop_plugin, "symbols", "symbols.png", 
230                       0, 0, 10, 800, 480, 
231                       TRUE, TRUE, 100, 255, 
232                       NULL, NULL, NULL);
233   scene->actors = g_slist_append(scene->actors, actor);
234
235   child = g_ptr_array_sized_new(4);
236   actor = init_object(desktop_plugin, "layer1", "layer1_2.png", 
237                       0, y1, 6, 800, 960, 
238                       TRUE, TRUE, 100, 255, 
239                       NULL, NULL, NULL);
240   //actor->time_start_animation = now;
241   //actor->duration_animation = G_MAXINT;
242   scene->actors = g_slist_append(scene->actors, actor);
243   g_ptr_array_add(child, actor);
244
245   actor = init_object(desktop_plugin, "layer1", "layer1_1.png", 
246                       0, y2, 7, 800, 960, 
247                       TRUE, TRUE, 100, 255, 
248                       NULL, NULL, NULL);
249   //actor->time_start_animation = now;
250   //actor->duration_animation = G_MAXINT;
251   scene->actors = g_slist_append(scene->actors, actor);
252   g_ptr_array_add(child, actor);
253
254   actor = init_object(desktop_plugin, "layer2", "layer2_2.png", 
255                       0, y1, 8, 800, 960, 
256                       TRUE, TRUE, 100, 255, 
257                       NULL, NULL, NULL);
258   //actor->time_start_animation = now;
259   //actor->duration_animation = G_MAXINT;
260   scene->actors = g_slist_append(scene->actors, actor);
261   g_ptr_array_add(child, actor);
262
263   actor = init_object(desktop_plugin, "layer2", "layer2_1.png", 
264                       0, y2, 9, 800, 960, 
265                       TRUE, TRUE, 100, 255, 
266                       NULL, NULL, NULL);
267   //actor->time_start_animation = now;
268   //actor->duration_animation = G_MAXINT;
269   scene->actors = g_slist_append(scene->actors, actor);
270   g_ptr_array_add(child, actor);
271
272   actor = init_object(desktop_plugin, "layers", "", 
273                       0, y2, 9, 800, 960, 
274                       FALSE, FALSE, 100, 255, 
275                       (gpointer)&change_layer, NULL, child);
276   actor->time_start_animation = now;
277   actor->duration_animation = G_MAXINT;
278   scene->actors = g_slist_append(scene->actors, actor);
279
280   run_long_timeout(desktop_plugin);
281
282 }
283 /*******************************************************************************/
284 /* Init Modern Scene */
285 void
286 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
287 {
288   Actor *actor;
289   Scene *scene;
290   gint now = time(NULL);
291   gint i;
292   gint winds[13][2];
293   GPtrArray *child; 
294
295   /* fprintf(stderr, "init scene \n"); */
296   scene = g_new0(Scene, 1);
297   scene->daytime = get_daytime();
298   scene->actors = NULL;
299   scene->wind_orientation = -1;
300   scene->wind_angle = 0.3;
301   /* init value for random */
302   scene->seed = time(NULL);
303   scene->notification = TRUE;
304   desktop_plugin->priv->scene = scene;
305   actor = init_object(desktop_plugin, "sky", "sky0.png", 
306                       0, 0, 5, 800, 480, 
307                       TRUE , TRUE, 100, 255, 
308                       (gpointer)&change_static_actor, NULL, NULL);
309   scene->actors = g_slist_append(scene->actors, actor);
310   change_static_actor(actor, desktop_plugin);
311   
312   actor = init_object(desktop_plugin, "sun", "sun.png", 
313                       0, 0, 6, 88, 88, 
314                       FALSE, FALSE, 100, 255, 
315                       (gpointer)&change_sun, NULL, NULL);
316   actor->time_start_animation = now;
317   actor->duration_animation = G_MAXINT;
318   change_sun(actor, desktop_plugin);
319   scene->actors = g_slist_append(scene->actors, actor);
320
321   //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
322     //                  TRUE, 100, 255, NULL, NULL);
323   //scene.actors = g_slist_append(scene.actors, actor);
324   
325   actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 
326                       0, fast_rnd(300)-97, 7, 150, 97, 
327                       FALSE, FALSE, 100, 255, 
328                       (gpointer)&change_cloud, NULL, NULL);
329   actor->time_start_animation = now + fast_rnd(20);
330   actor->duration_animation = 3*60;
331   scene->actors = g_slist_append(scene->actors, actor);
332   
333   actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 
334                       0, fast_rnd(300)-75, 7, 188, 75, 
335                       FALSE, FALSE, 100, 255, 
336                       (gpointer)&change_cloud, NULL, NULL);
337   actor->time_start_animation = now + fast_rnd(40)+10;
338   actor->duration_animation = 3*60;
339   scene->actors = g_slist_append(scene->actors, actor);
340
341   actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 
342                       0, fast_rnd(300)-75, 7, 150, 75, 
343                       FALSE, FALSE, 100, 255, 
344                       (gpointer)&change_cloud, NULL, NULL);
345   actor->time_start_animation = now + fast_rnd(60) + 20;
346   actor->duration_animation = 5*60;
347   scene->actors = g_slist_append(scene->actors, actor);
348
349
350   actor = init_object(desktop_plugin, "town", "town0.png", 
351                       0, 0, 8, 800, 480, 
352                       TRUE, TRUE, 100, 255, 
353                       (gpointer)&change_static_actor, NULL, NULL);
354   change_static_actor(actor, desktop_plugin);
355   scene->actors = g_slist_append(scene->actors, actor);
356
357   actor = init_object(desktop_plugin, "stend", "stend0.png", 
358                       452, 166, 9, 300, 305, 
359                       TRUE, TRUE, 100, 255, 
360                       (gpointer)&change_static_actor, NULL, NULL);
361   change_static_actor(actor, desktop_plugin);
362   scene->actors = g_slist_append(scene->actors, actor);
363
364
365   child = g_ptr_array_sized_new(4);
366   actor = init_object(desktop_plugin, "call", "call.png", 
367                       480, 190, 9, 50, 58, 
368                       FALSE, TRUE, 100, 255, 
369                       NULL, NULL, NULL);
370   scene->actors = g_slist_append(scene->actors, actor);
371   g_ptr_array_add(child, actor);
372
373   actor = init_object(desktop_plugin, "chat", "chat.png", 
374                       540, 190, 9, 50, 58, 
375                       FALSE, TRUE, 100, 255, 
376                       NULL, NULL, NULL);
377   scene->actors = g_slist_append(scene->actors, actor);
378   g_ptr_array_add(child, actor);
379
380   actor = init_object(desktop_plugin, "mail", "mail.png", 
381                       600, 190, 9, 50, 58, 
382                       FALSE, TRUE, 100, 255, 
383                       NULL, NULL, NULL);
384   scene->actors = g_slist_append(scene->actors, actor);
385   g_ptr_array_add(child, actor);
386   
387   actor = init_object(desktop_plugin, "sms", "sms.png", 
388                       660, 190, 9, 50, 58, 
389                       FALSE, TRUE, 100, 255, 
390                       NULL, NULL, NULL);
391   scene->actors = g_slist_append(scene->actors, actor);
392   g_ptr_array_add(child, actor);
393
394   actor = init_object(desktop_plugin, "billboard_text", "",
395                       470, 174, 9, 300, 108,
396                       FALSE, FALSE, 100, 255,
397                       (gpointer)&change_billboard, NULL, child);
398   create_hildon_actor_text(actor, desktop_plugin);
399   //actor->time_start_animation = time(NULL) + 20;
400   change_billboard(actor, desktop_plugin);
401   scene->actors = g_slist_append(scene->actors, actor);
402
403   actor = init_object(desktop_plugin, "tram", "tram.png", 
404                       -300, 225, 10, 350, 210, 
405                       FALSE, FALSE, 100, 255, 
406                       (gpointer)&change_tram, NULL, NULL);
407   actor->time_start_animation = time(NULL) + fast_rnd(10); 
408   actor->duration_animation = 60;
409   scene->actors = g_slist_append(scene->actors, actor);
410
411   actor = init_object(desktop_plugin, "border", "border0.png", 
412                       0, 480-79, 11, 800, 79,
413                       TRUE, TRUE, 100, 255, 
414                       (gpointer)&change_static_actor_with_corner, NULL, NULL);
415   change_static_actor_with_corner(actor, desktop_plugin);
416   scene->actors = g_slist_append(scene->actors, actor);
417   
418   actor = init_object(desktop_plugin, "moon", "moon1.png", 
419                       400, 20, 6, 60, 60, 
420                       FALSE, FALSE, 100, 255, 
421                       (gpointer)&change_moon, NULL, NULL);
422   change_moon(actor, desktop_plugin);
423   scene->actors = g_slist_append(scene->actors, actor);
424
425   actor = init_object(desktop_plugin, "wind", "", 
426                       0, 0, 5, 0, 0, 
427                       FALSE, FALSE, 100, 255, 
428                       (gpointer)&change_wind, NULL, NULL);
429   change_wind(actor, desktop_plugin);
430   scene->actors = g_slist_append(scene->actors, actor);
431
432     /* windows in 4-th house  */
433
434     winds[0][0] = 482;
435     winds[0][1] = 180;
436
437     winds[1][0] = 495;
438     winds[1][1] = 179;
439
440     winds[2][0] = 482;
441     winds[2][1] = 191;
442
443     winds[3][0] = 495;
444     winds[3][1] = 190;
445     
446     winds[4][0] = 482;
447     winds[4][1] = 201;
448     
449     winds[5][0] = 495;
450     winds[5][1] = 210;
451     
452     winds[6][0] = 482;
453     winds[6][1] = 222;
454     
455     winds[7][0] = 495;
456     winds[7][1] = 221;
457     
458     winds[8][0] = 459;
459     winds[8][1] = 203;
460     
461     winds[9][0] = 495;
462     winds[9][1] = 241;
463     
464     winds[10][0] = 495;
465     winds[10][1] = 252;
466     
467     winds[11][0] = 482;
468     winds[11][1] = 273;
469     
470     winds[12][0] = 495;
471     winds[12][1] = 303;
472     for (i=0; i<13; i++){
473         actor = init_object(desktop_plugin, "window1", "window1.png", 
474                             winds[i][0], winds[i][1], 8, 8, 10, 
475                             FALSE, FALSE, 100, 255, 
476                             (gpointer)&change_window1, NULL, NULL);
477         //change_window1(actor, desktop_plugin);
478         actor->time_start_animation = now + fast_rnd(30);
479         scene->actors = g_slist_append(scene->actors, actor);
480
481     }
482     
483     /* windows in 1-th house  */
484     
485     winds[0][0] = 86;
486     winds[0][1] = 321;
487
488     winds[1][0] = 86;
489     winds[1][1] = 363;
490
491     winds[2][0] = 86;
492     winds[2][1] = 385;
493
494     winds[3][0] = 86;
495     winds[3][1] = 286;
496     
497     winds[4][0] = 94;
498     winds[4][1] = 232;
499     
500     winds[5][0] = 94;
501     winds[5][1] = 243;
502     
503     winds[6][0] = 94;
504     winds[6][1] = 265;
505     
506     winds[7][0] = 94;
507     winds[7][1] = 331;
508     for (i=0; i<8; i++){
509         actor = init_object(desktop_plugin, "window2", "window2.png", 
510                             winds[i][0], winds[i][1], 8, 8, 10, 
511                             FALSE, FALSE, 100, 255, 
512                             (gpointer)&change_window1, NULL, NULL);
513         //change_window1(actor, desktop_plugin);
514         actor->time_start_animation = now + fast_rnd(30);
515         scene->actors = g_slist_append(scene->actors, actor);
516
517     }
518     
519     /* windows in 3-th house  */
520     
521     winds[0][0] = 251;
522     winds[0][1] = 162;
523
524     winds[1][0] = 251;
525     winds[1][1] = 196;
526
527     winds[2][0] = 251;
528     winds[2][1] = 278;
529
530     winds[3][0] = 251;
531     winds[3][1] = 289;
532     
533     winds[4][0] = 313;
534     winds[4][1] = 173;
535     
536     winds[5][0] = 322;
537     winds[5][1] = 160;
538     
539     winds[6][0] = 303;
540     winds[6][1] = 217;
541     
542     winds[7][0] = 322;
543     winds[7][1] = 224;
544     
545     winds[8][0] = 323;
546     winds[8][1] = 217;
547     
548     winds[9][0] = 322;
549     winds[9][1] = 288;
550     
551     for (i=0; i<10; i++){
552         actor = init_object(desktop_plugin, "window3", "window3.png", 
553                             winds[i][0], winds[i][1], 8, 8, 10, 
554                             FALSE, FALSE, 100, 255, 
555                             (gpointer)&change_window1, NULL, NULL);
556         //change_window1(actor, desktop_plugin);
557         actor->time_start_animation = now + fast_rnd(30);
558         scene->actors = g_slist_append(scene->actors, actor);
559
560     }
561
562     /* windows in 5-th house  */
563     
564     winds[0][0] = 610;
565     winds[0][1] = 224;
566
567     winds[1][0] = 602;
568     winds[1][1] = 245;
569
570     winds[2][0] = 602;
571     winds[2][1] = 264;
572
573     winds[3][0] = 610;
574     winds[3][1] = 301;
575     
576     winds[4][0] = 610;
577     winds[4][1] = 320;
578     
579     winds[5][0] = 593;
580     winds[5][1] = 352;
581     
582     winds[6][0] = 610;
583     winds[6][1] = 368;
584     
585     for (i=0; i<7; i++){
586         actor = init_object(desktop_plugin, "window4", "window4.png", 
587                             winds[i][0], winds[i][1], 8, 8, 10, 
588                             FALSE, FALSE, 100, 255, 
589                             (gpointer)&change_window1, NULL, NULL);
590         //change_window1(actor, desktop_plugin);
591         actor->time_start_animation = now + fast_rnd(30);
592         scene->actors = g_slist_append(scene->actors, actor);
593
594     }
595
596     /* windows in 6-th house  */
597     
598     winds[0][0] = 717;
599     winds[0][1] = 283;
600
601     winds[1][0] = 698;
602     winds[1][1] = 293;
603
604     winds[2][0] = 717;
605     winds[2][1] = 315;
606
607     winds[3][0] = 717;
608     winds[3][1] = 323;
609     
610     winds[4][0] = 698;
611     winds[4][1] = 362;
612     
613     winds[5][0] = 698;
614     winds[5][1] = 400;
615     
616     for (i=0; i<6; i++){
617         actor = init_object(desktop_plugin, "window5", "window5.png", 
618                             winds[i][0], winds[i][1], 8, 8, 10, 
619                             FALSE, FALSE, 100, 255, 
620                             (gpointer)&change_window1, NULL, NULL);
621         //change_window1(actor, desktop_plugin);
622         actor->time_start_animation = now + fast_rnd(30);
623         scene->actors = g_slist_append(scene->actors, actor);
624
625     }
626     run_long_timeout(desktop_plugin);
627
628 #if 0    
629   anim = g_new0(Animation, 1);
630   anim->count = 1;
631   anim->actor = actor;
632   anim->func_change = &change_tram;
633   anim->func_time = NULL;
634   anim->timestart = time(NULL); 
635   anim->timeall = 10;
636   
637   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
638 #endif  
639 }
640 /*******************************************************************************/
641 /* Init Berlin Scene */
642 void
643 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
644 {
645   Actor *actor, *actor1, *actor2;
646   Scene *scene;
647   gint now = time(NULL);
648   gint i; 
649   gint winds[13][2];
650   GPtrArray *child = NULL;
651
652   scene = g_new0(Scene, 1);
653   scene->daytime = get_daytime();
654   scene->actors = NULL;
655   scene->wind_orientation = -1;
656   scene->wind_angle = 0.3;
657   /* init value for random */
658   scene->seed = time(NULL);
659   desktop_plugin->priv->scene = scene;
660   
661   actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
662                       TRUE, TRUE, 100, 255, 
663                       (gpointer)&change_static_actor, NULL, NULL);
664   change_static_actor(actor, desktop_plugin);
665   scene->actors = g_slist_append(scene->actors, actor);
666
667   
668   actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, 
669                       FALSE, FALSE, 100, 255, 
670                       (gpointer)&change_sun, NULL, NULL);
671   actor->time_start_animation = time(NULL);
672   actor->duration_animation = G_MAXINT;
673   change_sun(actor, desktop_plugin);
674   scene->actors = g_slist_append(scene->actors, actor);
675
676 #if 0
677   actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
678                       TRUE, 100, 255, NULL, NULL);
679   scene.actors = g_slist_append(scene.actors, actor);
680 #endif
681
682   actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60, 
683                       FALSE, FALSE, 100, 255, 
684                       (gpointer)&change_moon, NULL, NULL);
685   change_moon(actor, desktop_plugin);
686   scene->actors = g_slist_append(scene->actors, actor);
687   
688   actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, 
689                       FALSE, FALSE, 100, 255, 
690                       (gpointer)&change_cloud, NULL, NULL);
691   actor->time_start_animation = now + fast_rnd(30) + 10;
692   actor->duration_animation = 3*60;
693   scene->actors = g_slist_append(scene->actors, actor);
694   
695   actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, 
696                       FALSE, FALSE, 100, 255, 
697                       (gpointer)&change_cloud, NULL, NULL);
698   actor->time_start_animation = now + fast_rnd(10);
699   actor->duration_animation = 3*60;
700   scene->actors = g_slist_append(scene->actors, actor);
701
702   actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, 
703                       FALSE, FALSE, 100, 255, 
704                       (gpointer)&change_cloud, NULL, NULL);
705   actor->time_start_animation = now + fast_rnd(60) + 20;
706   actor->duration_animation = 5*60;
707   scene->actors = g_slist_append(scene->actors, actor);
708
709  
710   actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, 
711                       FALSE, FALSE, 100, 255, 
712                       (gpointer)&change_plane2, NULL, NULL);
713   actor->time_start_animation = now + fast_rnd(40) + 20;
714   actor->duration_animation = 60;
715   scene->actors = g_slist_append(scene->actors, actor);
716   
717   actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, 
718                       FALSE, FALSE, 100, 255, 
719                       (gpointer)&change_plane1, NULL, NULL);
720   actor->time_start_animation = now + fast_rnd(20);
721   actor->duration_animation = 30;
722   scene->actors = g_slist_append(scene->actors, actor);
723
724   actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 
725                       TRUE, TRUE, 100, 255, 
726                       (gpointer)&change_static_actor_with_corner, NULL, NULL);
727   change_static_actor_with_corner(actor, desktop_plugin);
728   scene->actors = g_slist_append(scene->actors, actor);
729
730   actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, 
731                       FALSE, FALSE, 100, 255, 
732                       (gpointer)&change_wind, NULL, NULL);
733   change_wind(actor, desktop_plugin);
734   scene->actors = g_slist_append(scene->actors, actor);
735
736   actor1 = init_object(desktop_plugin, "signal_red", "red.png", 
737                       486, 425, 10, 18, 38, 
738                       FALSE, TRUE, 100, 255, NULL, NULL, NULL);
739   //actor->time_start_animation = now + fast_rnd(30) + 10;  
740   scene->actors = g_slist_append(scene->actors, actor1);
741    
742   actor2 = init_object(desktop_plugin, "signal_green", "green.png", 
743                       486, 425, 10, 18, 38, 
744                       TRUE, TRUE, 100, 255, NULL, NULL, NULL);
745   //actor->time_start_animation = now + fast_rnd(30) + 10;  
746   scene->actors = g_slist_append(scene->actors, actor2);
747   child = g_ptr_array_sized_new(2);
748   g_ptr_array_add(child, actor1);
749   g_ptr_array_add(child, actor2);
750   actor = init_object(desktop_plugin, "signal", "",
751                       486, 425, 10, 18, 38,
752                       FALSE, FALSE, 100, 255, 
753                       (gpointer)&change_signal, NULL, child);
754   actor->time_start_animation = now + fast_rnd(30) + 10;
755   scene->actors = g_slist_append(scene->actors, actor);
756     
757     winds[0][0] = 389;
758     winds[0][1] = 305;
759
760     winds[1][0] = 373;
761     winds[1][1] = 306;
762
763     winds[2][0] = 355;
764     winds[2][1] = 306;
765
766     winds[3][0] = 356;
767     winds[3][1] = 288;
768     
769     winds[4][0] = 337;
770     winds[4][1] = 269;
771     
772     winds[5][0] = 372;
773     winds[5][1] = 268;
774   
775     winds[6][0] = 372;
776     winds[6][1] = 249;
777     
778     winds[7][0] = 388;
779     winds[7][1] = 249;
780     
781     winds[8][0] = 387;
782     winds[8][1] = 230;
783     
784     winds[9][0] = 372;
785     winds[9][1] = 211;
786     
787     winds[10][0] = 355;
788     winds[10][1] = 159;
789     
790     winds[11][0] = 335;
791     winds[11][1] = 158;
792     
793     winds[12][0] = 386;
794     winds[12][1] = 119;
795   
796     for (i=0; i<13; i++){
797         actor = init_object(desktop_plugin, "window", "window.png", 
798                             winds[i][0], winds[i][1], 10, 8, 9, 
799                             FALSE, TRUE, 100, 255, 
800                             (gpointer)&change_window1, NULL, NULL);
801         //change_window1(actor, desktop_plugin);
802         actor->time_start_animation = now + fast_rnd(30);
803         scene->actors = g_slist_append(scene->actors, actor);
804
805     }
806     
807     run_long_timeout(desktop_plugin);
808
809 }
810 /*******************************************************************************/
811 void 
812 init_scene_theme(AWallpaperPlugin *desktop_plugin)
813 {
814     void (*func)(gpointer);
815     func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
816     if (func){
817         (*func)(desktop_plugin);
818     }
819 }