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