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