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