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