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