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