1 /*vim: set sw=4 ts=4 et: */
3 * This file is part of Live Wallpaper (livewp)
5 * Copyright (C) 2010 Vlad Vasiliev
6 * Copyright (C) 2010 Tanya Makova
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.
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.
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
24 /*******************************************************************************/
25 #include "livewp-scene.h"
28 destroy_scene(AWallpaperPlugin *desktop_plugin)
30 if (desktop_plugin->priv->scene){
31 GSList * tmp = desktop_plugin->priv->scene->actors;
33 destroy_actor(tmp->data);
34 tmp = g_slist_next(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;
47 reload_scene(AWallpaperPlugin *desktop_plugin)
49 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
50 destroy_scene(desktop_plugin);
51 init_scene_theme(desktop_plugin);
55 parsestring(char *line, char **argv)
57 while (*line != '\0') {
58 while (*line == ' ' || *line == '\n')
59 *line++ = '\0'; /* replace white spaces with 0 */
60 *argv++ = line; /* save the argument position */
61 while (*line != '\0' && *line != ' ' &&
63 line++; /* skip the argument until ... */
65 *argv = '\0'; /* mark the end of argument list */
69 init_scene_Mplayer(AWallpaperPlugin *desktop_plugin)
71 fprintf(stderr,"init_scene_Mplayer\n");
72 char* child_argv[128];
73 char *run_string = NULL;
75 fprintf(stderr, "PARAMETR %s\n", desktop_plugin->priv->theme_string_parametr1);
76 run_string = g_strdup_printf("/usr/bin/mplayer -vo x11 -wid %d %s\n", \
77 GDK_WINDOW_XID(desktop_plugin->priv->window->window), desktop_plugin->priv->theme_string_parametr1);
78 parsestring(run_string, child_argv);
80 desktop_plugin->priv->podpid = fork();
81 if (desktop_plugin->priv->podpid == 0){
82 execvp("/usr/bin/mplayer", child_argv);
83 fprintf(stderr,"Problem with new podprocess");
90 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
95 gint now = time(NULL);
98 if (desktop_plugin->priv->rich_animation){
106 /* fprintf(stderr, "init scene2 \n"); */
107 scene = g_new0(Scene, 1);
108 //scene.daytime = get_daytime();
109 scene->actors = NULL;
110 desktop_plugin->priv->scene = scene;
112 actor = init_object(desktop_plugin, "background", "bg.png",
114 TRUE, TRUE, 100, 255,
116 scene->actors = g_slist_append(scene->actors, actor);
118 actor = init_object(desktop_plugin, "symbols", "symbols.png",
120 TRUE, TRUE, 100, 255,
122 scene->actors = g_slist_append(scene->actors, actor);
124 child = g_ptr_array_sized_new(4);
125 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
127 TRUE, TRUE, 100, 255,
129 //actor->time_start_animation = now;
130 //actor->duration_animation = G_MAXINT;
131 scene->actors = g_slist_append(scene->actors, actor);
132 g_ptr_array_add(child, actor);
134 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
136 TRUE, TRUE, 100, 255,
138 //actor->time_start_animation = now;
139 //actor->duration_animation = G_MAXINT;
140 scene->actors = g_slist_append(scene->actors, actor);
141 g_ptr_array_add(child, actor);
143 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
145 TRUE, TRUE, 100, 255,
147 //actor->time_start_animation = now;
148 //actor->duration_animation = G_MAXINT;
149 scene->actors = g_slist_append(scene->actors, actor);
150 g_ptr_array_add(child, actor);
152 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
154 TRUE, TRUE, 100, 255,
156 //actor->time_start_animation = now;
157 //actor->duration_animation = G_MAXINT;
158 scene->actors = g_slist_append(scene->actors, actor);
159 g_ptr_array_add(child, actor);
161 actor = init_object(desktop_plugin, "layers", "",
163 FALSE, FALSE, 100, 255,
164 (gpointer)&change_layer, NULL, child);
165 actor->time_start_animation = now;
166 actor->duration_animation = G_MAXINT;
167 scene->actors = g_slist_append(scene->actors, actor);
169 run_long_timeout(desktop_plugin);
173 /* Init Modern Scene */
175 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
179 gint now = time(NULL);
184 /* fprintf(stderr, "init scene \n"); */
185 scene = g_new0(Scene, 1);
186 scene->daytime = get_daytime();
187 scene->actors = NULL;
188 scene->wind_orientation = -1;
189 scene->wind_angle = 0.3;
190 /* init value for random */
191 scene->seed = time(NULL);
192 scene->notification = TRUE;
193 desktop_plugin->priv->scene = scene;
194 actor = init_object(desktop_plugin, "sky", "sky0.png",
196 TRUE , TRUE, 100, 255,
197 (gpointer)&change_static_actor, NULL, NULL);
198 scene->actors = g_slist_append(scene->actors, actor);
199 change_static_actor(actor, desktop_plugin);
201 actor = init_object(desktop_plugin, "sun", "sun.png",
203 FALSE, FALSE, 100, 255,
204 (gpointer)&change_sun, NULL, NULL);
205 actor->time_start_animation = now;
206 actor->duration_animation = G_MAXINT;
207 change_sun(actor, desktop_plugin);
208 scene->actors = g_slist_append(scene->actors, actor);
210 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
211 // TRUE, 100, 255, NULL, NULL);
212 //scene.actors = g_slist_append(scene.actors, actor);
214 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
215 0, fast_rnd(300)-97, 7, 150, 97,
216 FALSE, FALSE, 100, 255,
217 (gpointer)&change_cloud, NULL, NULL);
218 actor->time_start_animation = now + fast_rnd(20);
219 actor->duration_animation = 3*60;
220 scene->actors = g_slist_append(scene->actors, actor);
222 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
223 0, fast_rnd(300)-75, 7, 188, 75,
224 FALSE, FALSE, 100, 255,
225 (gpointer)&change_cloud, NULL, NULL);
226 actor->time_start_animation = now + fast_rnd(40)+10;
227 actor->duration_animation = 3*60;
228 scene->actors = g_slist_append(scene->actors, actor);
230 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
231 0, fast_rnd(300)-75, 7, 150, 75,
232 FALSE, FALSE, 100, 255,
233 (gpointer)&change_cloud, NULL, NULL);
234 actor->time_start_animation = now + fast_rnd(60) + 20;
235 actor->duration_animation = 5*60;
236 scene->actors = g_slist_append(scene->actors, actor);
239 actor = init_object(desktop_plugin, "town", "town0.png",
241 TRUE, TRUE, 100, 255,
242 (gpointer)&change_static_actor, NULL, NULL);
243 change_static_actor(actor, desktop_plugin);
244 scene->actors = g_slist_append(scene->actors, actor);
246 actor = init_object(desktop_plugin, "stend", "stend0.png",
247 452, 166, 9, 300, 305,
248 TRUE, TRUE, 100, 255,
249 (gpointer)&change_static_actor, NULL, NULL);
250 change_static_actor(actor, desktop_plugin);
251 scene->actors = g_slist_append(scene->actors, actor);
254 child = g_ptr_array_sized_new(4);
255 actor = init_object(desktop_plugin, "call", "call.png",
257 FALSE, TRUE, 100, 255,
259 scene->actors = g_slist_append(scene->actors, actor);
260 g_ptr_array_add(child, actor);
262 actor = init_object(desktop_plugin, "chat", "chat.png",
264 FALSE, TRUE, 100, 255,
266 scene->actors = g_slist_append(scene->actors, actor);
267 g_ptr_array_add(child, actor);
269 actor = init_object(desktop_plugin, "mail", "mail.png",
271 FALSE, TRUE, 100, 255,
273 scene->actors = g_slist_append(scene->actors, actor);
274 g_ptr_array_add(child, actor);
276 actor = init_object(desktop_plugin, "sms", "sms.png",
278 FALSE, TRUE, 100, 255,
280 scene->actors = g_slist_append(scene->actors, actor);
281 g_ptr_array_add(child, actor);
283 actor = init_object(desktop_plugin, "billboard_text", "",
284 470, 174, 9, 300, 108,
285 FALSE, FALSE, 100, 255,
286 (gpointer)&change_billboard, NULL, child);
287 create_hildon_actor_text(actor, desktop_plugin);
288 //actor->time_start_animation = time(NULL) + 20;
289 change_billboard(actor, desktop_plugin);
290 scene->actors = g_slist_append(scene->actors, actor);
292 actor = init_object(desktop_plugin, "tram", "tram.png",
293 -300, 225, 10, 350, 210,
294 FALSE, FALSE, 100, 255,
295 (gpointer)&change_tram, NULL, NULL);
296 actor->time_start_animation = time(NULL) + fast_rnd(10);
297 actor->duration_animation = 60;
298 scene->actors = g_slist_append(scene->actors, actor);
300 actor = init_object(desktop_plugin, "border", "border0.png",
301 0, 480-79, 11, 800, 79,
302 TRUE, TRUE, 100, 255,
303 (gpointer)&change_static_actor_with_corner, NULL, NULL);
304 change_static_actor_with_corner(actor, desktop_plugin);
305 scene->actors = g_slist_append(scene->actors, actor);
307 actor = init_object(desktop_plugin, "moon", "moon1.png",
309 FALSE, FALSE, 100, 255,
310 (gpointer)&change_moon, NULL, NULL);
311 change_moon(actor, desktop_plugin);
312 scene->actors = g_slist_append(scene->actors, actor);
314 actor = init_object(desktop_plugin, "wind", "",
316 FALSE, FALSE, 100, 255,
317 (gpointer)&change_wind, NULL, NULL);
318 change_wind(actor, desktop_plugin);
319 scene->actors = g_slist_append(scene->actors, actor);
321 /* windows in 4-th house */
361 for (i=0; i<13; i++){
362 actor = init_object(desktop_plugin, "window1", "window1.png",
363 winds[i][0], winds[i][1], 8, 8, 10,
364 FALSE, FALSE, 100, 255,
365 (gpointer)&change_window1, NULL, NULL);
366 //change_window1(actor, desktop_plugin);
367 actor->time_start_animation = now + fast_rnd(30);
368 scene->actors = g_slist_append(scene->actors, actor);
372 /* windows in 1-th house */
398 actor = init_object(desktop_plugin, "window2", "window2.png",
399 winds[i][0], winds[i][1], 8, 8, 10,
400 FALSE, FALSE, 100, 255,
401 (gpointer)&change_window1, NULL, NULL);
402 //change_window1(actor, desktop_plugin);
403 actor->time_start_animation = now + fast_rnd(30);
404 scene->actors = g_slist_append(scene->actors, actor);
408 /* windows in 3-th house */
440 for (i=0; i<10; i++){
441 actor = init_object(desktop_plugin, "window3", "window3.png",
442 winds[i][0], winds[i][1], 8, 8, 10,
443 FALSE, FALSE, 100, 255,
444 (gpointer)&change_window1, NULL, NULL);
445 //change_window1(actor, desktop_plugin);
446 actor->time_start_animation = now + fast_rnd(30);
447 scene->actors = g_slist_append(scene->actors, actor);
451 /* windows in 5-th house */
475 actor = init_object(desktop_plugin, "window4", "window4.png",
476 winds[i][0], winds[i][1], 8, 8, 10,
477 FALSE, FALSE, 100, 255,
478 (gpointer)&change_window1, NULL, NULL);
479 //change_window1(actor, desktop_plugin);
480 actor->time_start_animation = now + fast_rnd(30);
481 scene->actors = g_slist_append(scene->actors, actor);
485 /* windows in 6-th house */
506 actor = init_object(desktop_plugin, "window5", "window5.png",
507 winds[i][0], winds[i][1], 8, 8, 10,
508 FALSE, FALSE, 100, 255,
509 (gpointer)&change_window1, NULL, NULL);
510 //change_window1(actor, desktop_plugin);
511 actor->time_start_animation = now + fast_rnd(30);
512 scene->actors = g_slist_append(scene->actors, actor);
515 run_long_timeout(desktop_plugin);
518 anim = g_new0(Animation, 1);
521 anim->func_change = &change_tram;
522 anim->func_time = NULL;
523 anim->timestart = time(NULL);
526 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
530 /* Init Berlin Scene */
532 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
534 Actor *actor, *actor1, *actor2;
536 gint now = time(NULL);
539 GPtrArray *child = NULL;
541 scene = g_new0(Scene, 1);
542 scene->daytime = get_daytime();
543 scene->actors = NULL;
544 scene->wind_orientation = -1;
545 scene->wind_angle = 0.3;
546 /* init value for random */
547 scene->seed = time(NULL);
548 desktop_plugin->priv->scene = scene;
550 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
551 TRUE, TRUE, 100, 255,
552 (gpointer)&change_static_actor, NULL, NULL);
553 change_static_actor(actor, desktop_plugin);
554 scene->actors = g_slist_append(scene->actors, actor);
557 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
558 FALSE, FALSE, 100, 255,
559 (gpointer)&change_sun, NULL, NULL);
560 actor->time_start_animation = time(NULL);
561 actor->duration_animation = G_MAXINT;
562 change_sun(actor, desktop_plugin);
563 scene->actors = g_slist_append(scene->actors, actor);
566 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
567 TRUE, 100, 255, NULL, NULL);
568 scene.actors = g_slist_append(scene.actors, actor);
571 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
572 FALSE, FALSE, 100, 255,
573 (gpointer)&change_moon, NULL, NULL);
574 change_moon(actor, desktop_plugin);
575 scene->actors = g_slist_append(scene->actors, actor);
577 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
578 FALSE, FALSE, 100, 255,
579 (gpointer)&change_cloud, NULL, NULL);
580 actor->time_start_animation = now + fast_rnd(30) + 10;
581 actor->duration_animation = 3*60;
582 scene->actors = g_slist_append(scene->actors, actor);
584 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
585 FALSE, FALSE, 100, 255,
586 (gpointer)&change_cloud, NULL, NULL);
587 actor->time_start_animation = now + fast_rnd(10);
588 actor->duration_animation = 3*60;
589 scene->actors = g_slist_append(scene->actors, actor);
591 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
592 FALSE, FALSE, 100, 255,
593 (gpointer)&change_cloud, NULL, NULL);
594 actor->time_start_animation = now + fast_rnd(60) + 20;
595 actor->duration_animation = 5*60;
596 scene->actors = g_slist_append(scene->actors, actor);
599 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
600 FALSE, FALSE, 100, 255,
601 (gpointer)&change_plane2, NULL, NULL);
602 actor->time_start_animation = now + fast_rnd(40) + 20;
603 actor->duration_animation = 60;
604 scene->actors = g_slist_append(scene->actors, actor);
606 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
607 FALSE, FALSE, 100, 255,
608 (gpointer)&change_plane1, NULL, NULL);
609 actor->time_start_animation = now + fast_rnd(20);
610 actor->duration_animation = 30;
611 scene->actors = g_slist_append(scene->actors, actor);
613 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
614 TRUE, TRUE, 100, 255,
615 (gpointer)&change_static_actor_with_corner, NULL, NULL);
616 change_static_actor_with_corner(actor, desktop_plugin);
617 scene->actors = g_slist_append(scene->actors, actor);
619 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
620 FALSE, FALSE, 100, 255,
621 (gpointer)&change_wind, NULL, NULL);
622 change_wind(actor, desktop_plugin);
623 scene->actors = g_slist_append(scene->actors, actor);
625 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
626 486, 425, 10, 18, 38,
627 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
628 //actor->time_start_animation = now + fast_rnd(30) + 10;
629 scene->actors = g_slist_append(scene->actors, actor1);
631 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
632 486, 425, 10, 18, 38,
633 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
634 //actor->time_start_animation = now + fast_rnd(30) + 10;
635 scene->actors = g_slist_append(scene->actors, actor2);
636 child = g_ptr_array_sized_new(2);
637 g_ptr_array_add(child, actor1);
638 g_ptr_array_add(child, actor2);
639 actor = init_object(desktop_plugin, "signal", "",
640 486, 425, 10, 18, 38,
641 FALSE, FALSE, 100, 255,
642 (gpointer)&change_signal, NULL, child);
643 actor->time_start_animation = now + fast_rnd(30) + 10;
644 scene->actors = g_slist_append(scene->actors, actor);
685 for (i=0; i<13; i++){
686 actor = init_object(desktop_plugin, "window", "window.png",
687 winds[i][0], winds[i][1], 10, 8, 9,
688 FALSE, TRUE, 100, 255,
689 (gpointer)&change_window1, NULL, NULL);
690 //change_window1(actor, desktop_plugin);
691 actor->time_start_animation = now + fast_rnd(30);
692 scene->actors = g_slist_append(scene->actors, actor);
696 run_long_timeout(desktop_plugin);
701 init_scene_theme(AWallpaperPlugin *desktop_plugin)
703 void (*func)(gpointer);
704 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
706 (*func)(desktop_plugin);