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