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