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