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