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