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