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