Merge branch 'master' of https://vcs.maemo.org/git/livewp
[livewp] / applet / src / livewp-scene.c
1 /* vim: set sw=4 ts=4 et: */
2 /*
3  * This file is part of Live Wallpaper (livewp)
4  * 
5  * Copyright (C) 2010 Vlad Vasiliev
6  * Copyright (C) 2010 Tanya Makova
7  *       for the code
8  * 
9  * This software is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1 of
12  * the License, or (at your option) any later version.
13  * 
14  * This software is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this software; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23 */
24 /*******************************************************************************/
25 #include "livewp-scene.h" 
26
27 void 
28 destroy_scene(AWallpaperPlugin *desktop_plugin)
29 {
30     if (desktop_plugin->priv->scene){
31             GSList * tmp = desktop_plugin->priv->scene->actors;
32             while (tmp != NULL){
33                     destroy_actor(tmp->data);
34                     tmp = g_slist_next(tmp);
35             }
36             if (tmp)
37                     g_slist_free(tmp);
38             desktop_plugin->priv->scene->actors = NULL;
39             if (desktop_plugin->priv->scene){
40                     g_free(desktop_plugin->priv->scene);
41                     desktop_plugin->priv->scene = NULL;
42             }
43     }
44     if (desktop_plugin->priv->pipeline){
45         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
46         gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
47         desktop_plugin->priv->pipeline = NULL;
48     }
49     if (desktop_plugin->priv->podpid > 1){
50         kill (desktop_plugin->priv->podpid, SIGTERM);
51         desktop_plugin->priv->podpid = -1;
52     }
53 }
54 /*******************************************************************************/
55 void
56 reload_scene(AWallpaperPlugin *desktop_plugin)
57 {
58     fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);  
59     destroy_scene(desktop_plugin);
60     init_scene_theme(desktop_plugin);
61 }
62 /*******************************************************************************/
63 void 
64 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
65 {
66     Actor *actor;
67     Scene *scene;
68     GPtrArray *child;
69     gint now = time(NULL);
70     gchar *str;
71     gint sizes1[4] = {57, 76, 43, 50},
72          n, j;
73     
74     fprintf(stderr, "init scene accel\n");
75     scene = g_new0(Scene, 1);
76     scene->actors = NULL;
77     desktop_plugin->priv->scene = scene;
78     
79     actor = init_object(desktop_plugin, "background", "bg.png", 
80                       0, 0, 0, 800, 480, 
81                       TRUE, TRUE, 100, 255, 
82                       NULL, NULL, NULL);
83     scene->actors = g_slist_append(scene->actors, actor);
84
85     child = g_ptr_array_sized_new(16);
86     
87     for (j= 0; j<4; j++){
88     for (n=0; n<4; n++){
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     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 /*******************************************************************************/
171 void
172 init_scene_Xsnow(AWallpaperPlugin *desktop_plugin){
173     fprintf(stderr,"init_scene_Xsnow\n");
174     char* child_argv[128];
175     char *run_string = NULL;
176 #if 0
177     fprintf(stderr, "PARAMETR %s\n",  desktop_plugin->priv->theme_string_parametr1);
178     run_string = g_strdup_printf("/usr/bin/mplayer -vo x11 -wid %d %s\n", \
179                                  GDK_WINDOW_XID(desktop_plugin->priv->window->window), desktop_plugin->priv->theme_string_parametr1);
180 #endif
181     if (!desktop_plugin->priv->visible)
182         return;
183     run_string= g_strdup_printf("/usr/bin/xsnow");
184     parsestring(run_string, child_argv);
185
186     desktop_plugin->priv->running = TRUE;
187     desktop_plugin->priv->podpid = fork();
188     if (desktop_plugin->priv->podpid == 0){
189         execvp("/usr/bin/xsnow", child_argv);
190         fprintf(stderr,"Problem with new podprocess");
191     }
192     g_free(run_string);
193 }
194 /*******************************************************************************/
195 gboolean cb_timeout0(AWallpaperPlugin *desktop_plugin) {
196     GstFormat fmt = GST_FORMAT_TIME;
197     gboolean test;
198     gint64 len;
199     gint len_seconds = 0;
200
201     if (!desktop_plugin || !desktop_plugin->priv->pipeline)
202         return FALSE;
203     if (desktop_plugin->priv->theme_int_parametr1 == 0){
204         if (!gst_element_seek(GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
205                                           GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 
206                                           desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
207                                           GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
208             fprintf(stderr,"Error in seek:\n");
209         return FALSE;
210     }
211        
212     gst_element_query_position(desktop_plugin->priv->pipeline, &fmt, &len);
213     len_seconds = len / GST_SECOND;
214     if (len <0)
215         return TRUE;
216     if (len_seconds <  desktop_plugin->priv->theme_int_parametr1){
217         if (!gst_element_seek(GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
218                                           GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 
219                                           desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
220                                           GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
221             fprintf(stderr,"Error in seek:\n");
222         return TRUE;
223     }else
224         return FALSE;
225
226 /*******************************************************************************/
227 void
228 init_scene_Video(AWallpaperPlugin *desktop_plugin)
229 {
230     GstElement *bin;                                                                                                                                                           
231     GstElement *videosink;                                                                                                
232     GstFormat format; 
233     gchar *file_plus_uri;
234
235
236     /* fprintf(stderr, "init scene Video \n"); */
237     desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
238     bin = gst_element_factory_make ("playbin2", "bin");
239     videosink = gst_element_factory_make ("ximagesink", "videosink");
240     g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
241     gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
242
243     {
244         GstBus *bus;
245         bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
246         gst_bus_add_watch(bus, bus_call, desktop_plugin);
247         gst_object_unref (bus);
248     }
249     file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
250     g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
251     g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL  );
252
253     if (GST_IS_X_OVERLAY (videosink))
254             gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
255
256     if (desktop_plugin->priv->visible){
257         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
258         g_timeout_add(100, cb_timeout0, desktop_plugin); 
259     }
260    
261     //gst_element_get_state(deskddtop_plugin->priv->pipeline, NULL, NULL, 100 * GST_MSECOND);
262
263 }
264 /*******************************************************************************/
265 void
266 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
267 {
268   Actor *actor;
269   Scene *scene;
270   GPtrArray *child;
271   gint now = time(NULL);
272   gint y1, y2;
273
274   if (desktop_plugin->priv->rich_animation){
275       y1 = -480;
276       y2 = -480-480;
277   }else {
278       y1 = 0;
279       y2 = -480;
280   }
281
282   /* fprintf(stderr, "init scene2 \n"); */
283   scene = g_new0(Scene, 1);
284   //scene.daytime = get_daytime();
285   scene->actors = NULL;
286   desktop_plugin->priv->scene = scene;
287   
288   actor = init_object(desktop_plugin, "background", "bg.png", 
289                       0, 0, 5, 800, 480, 
290                       TRUE, TRUE, 100, 255, 
291                       NULL, NULL, NULL);
292   scene->actors = g_slist_append(scene->actors, actor);
293
294   actor = init_object(desktop_plugin, "symbols", "symbols.png", 
295                       0, 0, 10, 800, 480, 
296                       TRUE, TRUE, 100, 255, 
297                       NULL, NULL, NULL);
298   scene->actors = g_slist_append(scene->actors, actor);
299
300   child = g_ptr_array_sized_new(4);
301   actor = init_object(desktop_plugin, "layer1", "layer1_2.png", 
302                       0, y1, 6, 800, 960, 
303                       TRUE, TRUE, 100, 255, 
304                       NULL, NULL, NULL);
305   //actor->time_start_animation = now;
306   //actor->duration_animation = G_MAXINT;
307   scene->actors = g_slist_append(scene->actors, actor);
308   g_ptr_array_add(child, actor);
309
310   actor = init_object(desktop_plugin, "layer1", "layer1_1.png", 
311                       0, y2, 7, 800, 960, 
312                       TRUE, TRUE, 100, 255, 
313                       NULL, NULL, NULL);
314   //actor->time_start_animation = now;
315   //actor->duration_animation = G_MAXINT;
316   scene->actors = g_slist_append(scene->actors, actor);
317   g_ptr_array_add(child, actor);
318
319   actor = init_object(desktop_plugin, "layer2", "layer2_2.png", 
320                       0, y1, 8, 800, 960, 
321                       TRUE, TRUE, 100, 255, 
322                       NULL, NULL, NULL);
323   //actor->time_start_animation = now;
324   //actor->duration_animation = G_MAXINT;
325   scene->actors = g_slist_append(scene->actors, actor);
326   g_ptr_array_add(child, actor);
327
328   actor = init_object(desktop_plugin, "layer2", "layer2_1.png", 
329                       0, y2, 9, 800, 960, 
330                       TRUE, TRUE, 100, 255, 
331                       NULL, NULL, NULL);
332   //actor->time_start_animation = now;
333   //actor->duration_animation = G_MAXINT;
334   scene->actors = g_slist_append(scene->actors, actor);
335   g_ptr_array_add(child, actor);
336
337   actor = init_object(desktop_plugin, "layers", "", 
338                       0, y2, 9, 800, 960, 
339                       FALSE, FALSE, 100, 255, 
340                       (gpointer)&change_layer, NULL, child);
341   actor->time_start_animation = now;
342   actor->duration_animation = G_MAXINT;
343   scene->actors = g_slist_append(scene->actors, actor);
344
345   run_long_timeout(desktop_plugin);
346
347 }
348 /*******************************************************************************/
349 /* Init Modern Scene */
350 void
351 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
352 {
353   Actor *actor;
354   Scene *scene;
355   gint now = time(NULL);
356   gint i;
357   gint winds[13][2];
358   GPtrArray *child; 
359
360   /* fprintf(stderr, "init scene \n"); */
361   scene = g_new0(Scene, 1);
362   scene->daytime = get_daytime();
363   scene->actors = NULL;
364   scene->wind_orientation = -1;
365   scene->wind_angle = 0.3;
366   /* init value for random */
367   scene->seed = time(NULL);
368   scene->notification = TRUE;
369   desktop_plugin->priv->scene = scene;
370   actor = init_object(desktop_plugin, "sky", "sky0.png", 
371                       0, 0, 5, 800, 480, 
372                       TRUE , TRUE, 100, 255, 
373                       (gpointer)&change_static_actor, NULL, NULL);
374   scene->actors = g_slist_append(scene->actors, actor);
375   change_static_actor(actor, desktop_plugin);
376   
377   actor = init_object(desktop_plugin, "sun", "sun.png", 
378                       0, 0, 6, 88, 88, 
379                       FALSE, FALSE, 100, 255, 
380                       (gpointer)&change_sun, NULL, NULL);
381   actor->time_start_animation = now;
382   actor->duration_animation = G_MAXINT;
383   change_sun(actor, desktop_plugin);
384   scene->actors = g_slist_append(scene->actors, actor);
385
386   //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
387     //                  TRUE, 100, 255, NULL, NULL);
388   //scene.actors = g_slist_append(scene.actors, actor);
389   
390   actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 
391                       0, fast_rnd(300)-97, 7, 150, 97, 
392                       FALSE, FALSE, 100, 255, 
393                       (gpointer)&change_cloud, NULL, NULL);
394   actor->time_start_animation = now + fast_rnd(20);
395   actor->duration_animation = 3*60;
396   scene->actors = g_slist_append(scene->actors, actor);
397   
398   actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 
399                       0, fast_rnd(300)-75, 7, 188, 75, 
400                       FALSE, FALSE, 100, 255, 
401                       (gpointer)&change_cloud, NULL, NULL);
402   actor->time_start_animation = now + fast_rnd(40)+10;
403   actor->duration_animation = 3*60;
404   scene->actors = g_slist_append(scene->actors, actor);
405
406   actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 
407                       0, fast_rnd(300)-75, 7, 150, 75, 
408                       FALSE, FALSE, 100, 255, 
409                       (gpointer)&change_cloud, NULL, NULL);
410   actor->time_start_animation = now + fast_rnd(60) + 20;
411   actor->duration_animation = 5*60;
412   scene->actors = g_slist_append(scene->actors, actor);
413
414
415   actor = init_object(desktop_plugin, "town", "town0.png", 
416                       0, 0, 8, 800, 480, 
417                       TRUE, TRUE, 100, 255, 
418                       (gpointer)&change_static_actor, NULL, NULL);
419   change_static_actor(actor, desktop_plugin);
420   scene->actors = g_slist_append(scene->actors, actor);
421
422   actor = init_object(desktop_plugin, "stend", "stend0.png", 
423                       452, 166, 9, 300, 305, 
424                       TRUE, TRUE, 100, 255, 
425                       (gpointer)&change_static_actor, NULL, NULL);
426   change_static_actor(actor, desktop_plugin);
427   scene->actors = g_slist_append(scene->actors, actor);
428
429
430   child = g_ptr_array_sized_new(4);
431   actor = init_object(desktop_plugin, "call", "call.png", 
432                       480, 190, 9, 50, 58, 
433                       FALSE, TRUE, 100, 255, 
434                       NULL, NULL, NULL);
435   scene->actors = g_slist_append(scene->actors, actor);
436   g_ptr_array_add(child, actor);
437
438   actor = init_object(desktop_plugin, "chat", "chat.png", 
439                       540, 190, 9, 50, 58, 
440                       FALSE, TRUE, 100, 255, 
441                       NULL, NULL, NULL);
442   scene->actors = g_slist_append(scene->actors, actor);
443   g_ptr_array_add(child, actor);
444
445   actor = init_object(desktop_plugin, "mail", "mail.png", 
446                       600, 190, 9, 50, 58, 
447                       FALSE, TRUE, 100, 255, 
448                       NULL, NULL, NULL);
449   scene->actors = g_slist_append(scene->actors, actor);
450   g_ptr_array_add(child, actor);
451   
452   actor = init_object(desktop_plugin, "sms", "sms.png", 
453                       660, 190, 9, 50, 58, 
454                       FALSE, TRUE, 100, 255, 
455                       NULL, NULL, NULL);
456   scene->actors = g_slist_append(scene->actors, actor);
457   g_ptr_array_add(child, actor);
458
459   actor = init_object(desktop_plugin, "billboard_text", "",
460                       470, 174, 9, 300, 108,
461                       FALSE, FALSE, 100, 255,
462                       (gpointer)&change_billboard, NULL, child);
463   create_hildon_actor_text(actor, desktop_plugin);
464   //actor->time_start_animation = time(NULL) + 20;
465   change_billboard(actor, desktop_plugin);
466   scene->actors = g_slist_append(scene->actors, actor);
467
468   actor = init_object(desktop_plugin, "tram", "tram.png", 
469                       -300, 225, 10, 350, 210, 
470                       FALSE, FALSE, 100, 255, 
471                       (gpointer)&change_tram, NULL, NULL);
472   actor->time_start_animation = time(NULL) + fast_rnd(10); 
473   actor->duration_animation = 60;
474   scene->actors = g_slist_append(scene->actors, actor);
475
476   actor = init_object(desktop_plugin, "border", "border0.png", 
477                       0, 480-79, 11, 800, 79,
478                       TRUE, TRUE, 100, 255, 
479                       (gpointer)&change_static_actor_with_corner, NULL, NULL);
480   change_static_actor_with_corner(actor, desktop_plugin);
481   scene->actors = g_slist_append(scene->actors, actor);
482   
483   actor = init_object(desktop_plugin, "moon", "moon1.png", 
484                       400, 20, 6, 60, 60, 
485                       FALSE, FALSE, 100, 255, 
486                       (gpointer)&change_moon, NULL, NULL);
487   change_moon(actor, desktop_plugin);
488   scene->actors = g_slist_append(scene->actors, actor);
489
490   actor = init_object(desktop_plugin, "wind", "", 
491                       0, 0, 5, 0, 0, 
492                       FALSE, FALSE, 100, 255, 
493                       (gpointer)&change_wind, NULL, NULL);
494   change_wind(actor, desktop_plugin);
495   scene->actors = g_slist_append(scene->actors, actor);
496
497     /* windows in 4-th house  */
498
499     winds[0][0] = 482;
500     winds[0][1] = 180;
501
502     winds[1][0] = 495;
503     winds[1][1] = 179;
504
505     winds[2][0] = 482;
506     winds[2][1] = 191;
507
508     winds[3][0] = 495;
509     winds[3][1] = 190;
510     
511     winds[4][0] = 482;
512     winds[4][1] = 201;
513     
514     winds[5][0] = 495;
515     winds[5][1] = 210;
516     
517     winds[6][0] = 482;
518     winds[6][1] = 222;
519     
520     winds[7][0] = 495;
521     winds[7][1] = 221;
522     
523     winds[8][0] = 459;
524     winds[8][1] = 203;
525     
526     winds[9][0] = 495;
527     winds[9][1] = 241;
528     
529     winds[10][0] = 495;
530     winds[10][1] = 252;
531     
532     winds[11][0] = 482;
533     winds[11][1] = 273;
534     
535     winds[12][0] = 495;
536     winds[12][1] = 303;
537     for (i=0; i<13; i++){
538         actor = init_object(desktop_plugin, "window1", "window1.png", 
539                             winds[i][0], winds[i][1], 8, 8, 10, 
540                             FALSE, FALSE, 100, 255, 
541                             (gpointer)&change_window1, NULL, NULL);
542         //change_window1(actor, desktop_plugin);
543         actor->time_start_animation = now + fast_rnd(30);
544         scene->actors = g_slist_append(scene->actors, actor);
545
546     }
547     
548     /* windows in 1-th house  */
549     
550     winds[0][0] = 86;
551     winds[0][1] = 321;
552
553     winds[1][0] = 86;
554     winds[1][1] = 363;
555
556     winds[2][0] = 86;
557     winds[2][1] = 385;
558
559     winds[3][0] = 86;
560     winds[3][1] = 286;
561     
562     winds[4][0] = 94;
563     winds[4][1] = 232;
564     
565     winds[5][0] = 94;
566     winds[5][1] = 243;
567     
568     winds[6][0] = 94;
569     winds[6][1] = 265;
570     
571     winds[7][0] = 94;
572     winds[7][1] = 331;
573     for (i=0; i<8; i++){
574         actor = init_object(desktop_plugin, "window2", "window2.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 3-th house  */
585     
586     winds[0][0] = 251;
587     winds[0][1] = 162;
588
589     winds[1][0] = 251;
590     winds[1][1] = 196;
591
592     winds[2][0] = 251;
593     winds[2][1] = 278;
594
595     winds[3][0] = 251;
596     winds[3][1] = 289;
597     
598     winds[4][0] = 313;
599     winds[4][1] = 173;
600     
601     winds[5][0] = 322;
602     winds[5][1] = 160;
603     
604     winds[6][0] = 303;
605     winds[6][1] = 217;
606     
607     winds[7][0] = 322;
608     winds[7][1] = 224;
609     
610     winds[8][0] = 323;
611     winds[8][1] = 217;
612     
613     winds[9][0] = 322;
614     winds[9][1] = 288;
615     
616     for (i=0; i<10; i++){
617         actor = init_object(desktop_plugin, "window3", "window3.png", 
618                             winds[i][0], winds[i][1], 8, 8, 10, 
619                             FALSE, FALSE, 100, 255, 
620                             (gpointer)&change_window1, NULL, NULL);
621         //change_window1(actor, desktop_plugin);
622         actor->time_start_animation = now + fast_rnd(30);
623         scene->actors = g_slist_append(scene->actors, actor);
624
625     }
626
627     /* windows in 5-th house  */
628     
629     winds[0][0] = 610;
630     winds[0][1] = 224;
631
632     winds[1][0] = 602;
633     winds[1][1] = 245;
634
635     winds[2][0] = 602;
636     winds[2][1] = 264;
637
638     winds[3][0] = 610;
639     winds[3][1] = 301;
640     
641     winds[4][0] = 610;
642     winds[4][1] = 320;
643     
644     winds[5][0] = 593;
645     winds[5][1] = 352;
646     
647     winds[6][0] = 610;
648     winds[6][1] = 368;
649     
650     for (i=0; i<7; i++){
651         actor = init_object(desktop_plugin, "window4", "window4.png", 
652                             winds[i][0], winds[i][1], 8, 8, 10, 
653                             FALSE, FALSE, 100, 255, 
654                             (gpointer)&change_window1, NULL, NULL);
655         //change_window1(actor, desktop_plugin);
656         actor->time_start_animation = now + fast_rnd(30);
657         scene->actors = g_slist_append(scene->actors, actor);
658
659     }
660
661     /* windows in 6-th house  */
662     
663     winds[0][0] = 717;
664     winds[0][1] = 283;
665
666     winds[1][0] = 698;
667     winds[1][1] = 293;
668
669     winds[2][0] = 717;
670     winds[2][1] = 315;
671
672     winds[3][0] = 717;
673     winds[3][1] = 323;
674     
675     winds[4][0] = 698;
676     winds[4][1] = 362;
677     
678     winds[5][0] = 698;
679     winds[5][1] = 400;
680     
681     for (i=0; i<6; i++){
682         actor = init_object(desktop_plugin, "window5", "window5.png", 
683                             winds[i][0], winds[i][1], 8, 8, 10, 
684                             FALSE, FALSE, 100, 255, 
685                             (gpointer)&change_window1, NULL, NULL);
686         //change_window1(actor, desktop_plugin);
687         actor->time_start_animation = now + fast_rnd(30);
688         scene->actors = g_slist_append(scene->actors, actor);
689
690     }
691     run_long_timeout(desktop_plugin);
692
693 #if 0    
694   anim = g_new0(Animation, 1);
695   anim->count = 1;
696   anim->actor = actor;
697   anim->func_change = &change_tram;
698   anim->func_time = NULL;
699   anim->timestart = time(NULL); 
700   anim->timeall = 10;
701   
702   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
703 #endif  
704 }
705 /*******************************************************************************/
706 /* Init Berlin Scene */
707 void
708 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
709 {
710   Actor *actor, *actor1, *actor2;
711   Scene *scene;
712   gint now = time(NULL);
713   gint i; 
714   gint winds[13][2];
715   GPtrArray *child = NULL;
716
717   scene = g_new0(Scene, 1);
718   scene->daytime = get_daytime();
719   scene->actors = NULL;
720   scene->wind_orientation = -1;
721   scene->wind_angle = 0.3;
722   /* init value for random */
723   scene->seed = time(NULL);
724   desktop_plugin->priv->scene = scene;
725   
726   actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
727                       TRUE, TRUE, 100, 255, 
728                       (gpointer)&change_static_actor, NULL, NULL);
729   change_static_actor(actor, desktop_plugin);
730   scene->actors = g_slist_append(scene->actors, actor);
731
732   
733   actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, 
734                       FALSE, FALSE, 100, 255, 
735                       (gpointer)&change_sun, NULL, NULL);
736   actor->time_start_animation = time(NULL);
737   actor->duration_animation = G_MAXINT;
738   change_sun(actor, desktop_plugin);
739   scene->actors = g_slist_append(scene->actors, actor);
740
741 #if 0
742   actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
743                       TRUE, 100, 255, NULL, NULL);
744   scene.actors = g_slist_append(scene.actors, actor);
745 #endif
746
747   actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60, 
748                       FALSE, FALSE, 100, 255, 
749                       (gpointer)&change_moon, NULL, NULL);
750   change_moon(actor, desktop_plugin);
751   scene->actors = g_slist_append(scene->actors, actor);
752   
753   actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, 
754                       FALSE, FALSE, 100, 255, 
755                       (gpointer)&change_cloud, NULL, NULL);
756   actor->time_start_animation = now + fast_rnd(30) + 10;
757   actor->duration_animation = 3*60;
758   scene->actors = g_slist_append(scene->actors, actor);
759   
760   actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, 
761                       FALSE, FALSE, 100, 255, 
762                       (gpointer)&change_cloud, NULL, NULL);
763   actor->time_start_animation = now + fast_rnd(10);
764   actor->duration_animation = 3*60;
765   scene->actors = g_slist_append(scene->actors, actor);
766
767   actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, 
768                       FALSE, FALSE, 100, 255, 
769                       (gpointer)&change_cloud, NULL, NULL);
770   actor->time_start_animation = now + fast_rnd(60) + 20;
771   actor->duration_animation = 5*60;
772   scene->actors = g_slist_append(scene->actors, actor);
773
774  
775   actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, 
776                       FALSE, FALSE, 100, 255, 
777                       (gpointer)&change_plane2, NULL, NULL);
778   actor->time_start_animation = now + fast_rnd(40) + 20;
779   actor->duration_animation = 60;
780   scene->actors = g_slist_append(scene->actors, actor);
781   
782   actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, 
783                       FALSE, FALSE, 100, 255, 
784                       (gpointer)&change_plane1, NULL, NULL);
785   actor->time_start_animation = now + fast_rnd(20);
786   actor->duration_animation = 30;
787   scene->actors = g_slist_append(scene->actors, actor);
788
789   actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 
790                       TRUE, TRUE, 100, 255, 
791                       (gpointer)&change_static_actor_with_corner, NULL, NULL);
792   change_static_actor_with_corner(actor, desktop_plugin);
793   scene->actors = g_slist_append(scene->actors, actor);
794
795   actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, 
796                       FALSE, FALSE, 100, 255, 
797                       (gpointer)&change_wind, NULL, NULL);
798   change_wind(actor, desktop_plugin);
799   scene->actors = g_slist_append(scene->actors, actor);
800
801   actor1 = init_object(desktop_plugin, "signal_red", "red.png", 
802                       486, 425, 10, 18, 38, 
803                       FALSE, TRUE, 100, 255, NULL, NULL, NULL);
804   //actor->time_start_animation = now + fast_rnd(30) + 10;  
805   scene->actors = g_slist_append(scene->actors, actor1);
806    
807   actor2 = init_object(desktop_plugin, "signal_green", "green.png", 
808                       486, 425, 10, 18, 38, 
809                       TRUE, TRUE, 100, 255, NULL, NULL, NULL);
810   //actor->time_start_animation = now + fast_rnd(30) + 10;  
811   scene->actors = g_slist_append(scene->actors, actor2);
812   child = g_ptr_array_sized_new(2);
813   g_ptr_array_add(child, actor1);
814   g_ptr_array_add(child, actor2);
815   actor = init_object(desktop_plugin, "signal", "",
816                       486, 425, 10, 18, 38,
817                       FALSE, FALSE, 100, 255, 
818                       (gpointer)&change_signal, NULL, child);
819   actor->time_start_animation = now + fast_rnd(30) + 10;
820   scene->actors = g_slist_append(scene->actors, actor);
821     
822     winds[0][0] = 389;
823     winds[0][1] = 305;
824
825     winds[1][0] = 373;
826     winds[1][1] = 306;
827
828     winds[2][0] = 355;
829     winds[2][1] = 306;
830
831     winds[3][0] = 356;
832     winds[3][1] = 288;
833     
834     winds[4][0] = 337;
835     winds[4][1] = 269;
836     
837     winds[5][0] = 372;
838     winds[5][1] = 268;
839   
840     winds[6][0] = 372;
841     winds[6][1] = 249;
842     
843     winds[7][0] = 388;
844     winds[7][1] = 249;
845     
846     winds[8][0] = 387;
847     winds[8][1] = 230;
848     
849     winds[9][0] = 372;
850     winds[9][1] = 211;
851     
852     winds[10][0] = 355;
853     winds[10][1] = 159;
854     
855     winds[11][0] = 335;
856     winds[11][1] = 158;
857     
858     winds[12][0] = 386;
859     winds[12][1] = 119;
860   
861     for (i=0; i<13; i++){
862         actor = init_object(desktop_plugin, "window", "window.png", 
863                             winds[i][0], winds[i][1], 10, 8, 9, 
864                             FALSE, TRUE, 100, 255, 
865                             (gpointer)&change_window1, NULL, NULL);
866         //change_window1(actor, desktop_plugin);
867         actor->time_start_animation = now + fast_rnd(30);
868         scene->actors = g_slist_append(scene->actors, actor);
869
870     }
871     
872     run_long_timeout(desktop_plugin);
873
874 }
875 /*******************************************************************************/
876 void 
877 init_scene_theme(AWallpaperPlugin *desktop_plugin)
878 {
879     void (*func)(gpointer);
880     func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
881     if (func){
882         (*func)(desktop_plugin);
883     }
884 }