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