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