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);
56 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
61 gint now = time(NULL);
63 gint sizes[4] = {170, 229, 130, 150},
64 heights[4] = {0, 100, 200, 300},
67 fprintf(stderr, "init scene accel\n");
68 scene = g_new0(Scene, 1);
70 desktop_plugin->priv->scene = scene;
72 actor = init_object(desktop_plugin, "background", "bg.png",
76 scene->actors = g_slist_append(scene->actors, actor);
78 child = g_ptr_array_sized_new(24);
83 str = g_strdup_printf("tape%i_%i.png", n+1, i);
84 actor = init_object(desktop_plugin, "tape", str,
85 fast_rnd(700), fast_rnd(430), 1+fast_rnd(10), 800, sizes[n],
88 scene->actors = g_slist_append(scene->actors, actor);
89 g_ptr_array_add(child, actor);
94 actor = init_object(desktop_plugin, "tape", "",
96 FALSE, FALSE, 100, 255,
97 (gpointer)&change_tape, NULL, child);
98 actor->time_start_animation = now;
99 actor->duration_animation = G_MAXINT;
100 scene->actors = g_slist_append(scene->actors, actor);
102 run_long_timeout(desktop_plugin);
106 parsestring(char *line, char **argv)
108 while (*line != '\0') {
109 while (*line == ' ' || *line == '\n')
110 *line++ = '\0'; /* replace white spaces with 0 */
111 *argv++ = line; /* save the argument position */
112 while (*line != '\0' && *line != ' ' &&
114 line++; /* skip the argument until ... */
116 *argv = '\0'; /* mark the end of argument list */
121 init_scene_Video(AWallpaperPlugin *desktop_plugin)
123 GstElement *pipeline;
125 GstElement *videosink;
130 fprintf(stderr,"dddddddddddddddddddd\n");
131 pipeline= gst_pipeline_new("gst-player");
132 bin = gst_element_factory_make ("playbin2", "bin");
133 videosink = gst_element_factory_make ("ximagesink", "videosink");
134 g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
135 gst_bin_add (GST_BIN (pipeline), bin);
139 bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
140 // gst_bus_add_watch(bus, bus_call, NULL);
141 // gst_bus_set_sync_handler(bus, (GstBusSyncHandler)SetVideoAreaXID, desktop_plugin);
142 gst_object_unref (bus);
144 g_object_set (G_OBJECT (bin), "uri", "file:///home/user/MyDocs/.videos/9.mp4", NULL );
145 g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
146 if (GST_IS_X_OVERLAY (videosink)){
147 printf("Is Overlay (Win ID: %i)!!\n",GPOINTER_TO_INT(GDK_WINDOW_XWINDOW(desktop_plugin->priv->window->window)));
148 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
150 gst_element_set_state (pipeline, GST_STATE_PLAYING);
154 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
159 gint now = time(NULL);
162 if (desktop_plugin->priv->rich_animation){
170 /* fprintf(stderr, "init scene2 \n"); */
171 scene = g_new0(Scene, 1);
172 //scene.daytime = get_daytime();
173 scene->actors = NULL;
174 desktop_plugin->priv->scene = scene;
176 actor = init_object(desktop_plugin, "background", "bg.png",
178 TRUE, TRUE, 100, 255,
180 scene->actors = g_slist_append(scene->actors, actor);
182 actor = init_object(desktop_plugin, "symbols", "symbols.png",
184 TRUE, TRUE, 100, 255,
186 scene->actors = g_slist_append(scene->actors, actor);
188 child = g_ptr_array_sized_new(4);
189 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
191 TRUE, TRUE, 100, 255,
193 //actor->time_start_animation = now;
194 //actor->duration_animation = G_MAXINT;
195 scene->actors = g_slist_append(scene->actors, actor);
196 g_ptr_array_add(child, actor);
198 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
200 TRUE, TRUE, 100, 255,
202 //actor->time_start_animation = now;
203 //actor->duration_animation = G_MAXINT;
204 scene->actors = g_slist_append(scene->actors, actor);
205 g_ptr_array_add(child, actor);
207 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
209 TRUE, TRUE, 100, 255,
211 //actor->time_start_animation = now;
212 //actor->duration_animation = G_MAXINT;
213 scene->actors = g_slist_append(scene->actors, actor);
214 g_ptr_array_add(child, actor);
216 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
218 TRUE, TRUE, 100, 255,
220 //actor->time_start_animation = now;
221 //actor->duration_animation = G_MAXINT;
222 scene->actors = g_slist_append(scene->actors, actor);
223 g_ptr_array_add(child, actor);
225 actor = init_object(desktop_plugin, "layers", "",
227 FALSE, FALSE, 100, 255,
228 (gpointer)&change_layer, NULL, child);
229 actor->time_start_animation = now;
230 actor->duration_animation = G_MAXINT;
231 scene->actors = g_slist_append(scene->actors, actor);
233 run_long_timeout(desktop_plugin);
237 /* Init Modern Scene */
239 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
243 gint now = time(NULL);
248 /* fprintf(stderr, "init scene \n"); */
249 scene = g_new0(Scene, 1);
250 scene->daytime = get_daytime();
251 scene->actors = NULL;
252 scene->wind_orientation = -1;
253 scene->wind_angle = 0.3;
254 /* init value for random */
255 scene->seed = time(NULL);
256 scene->notification = TRUE;
257 desktop_plugin->priv->scene = scene;
258 actor = init_object(desktop_plugin, "sky", "sky0.png",
260 TRUE , TRUE, 100, 255,
261 (gpointer)&change_static_actor, NULL, NULL);
262 scene->actors = g_slist_append(scene->actors, actor);
263 change_static_actor(actor, desktop_plugin);
265 actor = init_object(desktop_plugin, "sun", "sun.png",
267 FALSE, FALSE, 100, 255,
268 (gpointer)&change_sun, NULL, NULL);
269 actor->time_start_animation = now;
270 actor->duration_animation = G_MAXINT;
271 change_sun(actor, desktop_plugin);
272 scene->actors = g_slist_append(scene->actors, actor);
274 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
275 // TRUE, 100, 255, NULL, NULL);
276 //scene.actors = g_slist_append(scene.actors, actor);
278 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
279 0, fast_rnd(300)-97, 7, 150, 97,
280 FALSE, FALSE, 100, 255,
281 (gpointer)&change_cloud, NULL, NULL);
282 actor->time_start_animation = now + fast_rnd(20);
283 actor->duration_animation = 3*60;
284 scene->actors = g_slist_append(scene->actors, actor);
286 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
287 0, fast_rnd(300)-75, 7, 188, 75,
288 FALSE, FALSE, 100, 255,
289 (gpointer)&change_cloud, NULL, NULL);
290 actor->time_start_animation = now + fast_rnd(40)+10;
291 actor->duration_animation = 3*60;
292 scene->actors = g_slist_append(scene->actors, actor);
294 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
295 0, fast_rnd(300)-75, 7, 150, 75,
296 FALSE, FALSE, 100, 255,
297 (gpointer)&change_cloud, NULL, NULL);
298 actor->time_start_animation = now + fast_rnd(60) + 20;
299 actor->duration_animation = 5*60;
300 scene->actors = g_slist_append(scene->actors, actor);
303 actor = init_object(desktop_plugin, "town", "town0.png",
305 TRUE, TRUE, 100, 255,
306 (gpointer)&change_static_actor, NULL, NULL);
307 change_static_actor(actor, desktop_plugin);
308 scene->actors = g_slist_append(scene->actors, actor);
310 actor = init_object(desktop_plugin, "stend", "stend0.png",
311 452, 166, 9, 300, 305,
312 TRUE, TRUE, 100, 255,
313 (gpointer)&change_static_actor, NULL, NULL);
314 change_static_actor(actor, desktop_plugin);
315 scene->actors = g_slist_append(scene->actors, actor);
318 child = g_ptr_array_sized_new(4);
319 actor = init_object(desktop_plugin, "call", "call.png",
321 FALSE, TRUE, 100, 255,
323 scene->actors = g_slist_append(scene->actors, actor);
324 g_ptr_array_add(child, actor);
326 actor = init_object(desktop_plugin, "chat", "chat.png",
328 FALSE, TRUE, 100, 255,
330 scene->actors = g_slist_append(scene->actors, actor);
331 g_ptr_array_add(child, actor);
333 actor = init_object(desktop_plugin, "mail", "mail.png",
335 FALSE, TRUE, 100, 255,
337 scene->actors = g_slist_append(scene->actors, actor);
338 g_ptr_array_add(child, actor);
340 actor = init_object(desktop_plugin, "sms", "sms.png",
342 FALSE, TRUE, 100, 255,
344 scene->actors = g_slist_append(scene->actors, actor);
345 g_ptr_array_add(child, actor);
347 actor = init_object(desktop_plugin, "billboard_text", "",
348 470, 174, 9, 300, 108,
349 FALSE, FALSE, 100, 255,
350 (gpointer)&change_billboard, NULL, child);
351 create_hildon_actor_text(actor, desktop_plugin);
352 //actor->time_start_animation = time(NULL) + 20;
353 change_billboard(actor, desktop_plugin);
354 scene->actors = g_slist_append(scene->actors, actor);
356 actor = init_object(desktop_plugin, "tram", "tram.png",
357 -300, 225, 10, 350, 210,
358 FALSE, FALSE, 100, 255,
359 (gpointer)&change_tram, NULL, NULL);
360 actor->time_start_animation = time(NULL) + fast_rnd(10);
361 actor->duration_animation = 60;
362 scene->actors = g_slist_append(scene->actors, actor);
364 actor = init_object(desktop_plugin, "border", "border0.png",
365 0, 480-79, 11, 800, 79,
366 TRUE, TRUE, 100, 255,
367 (gpointer)&change_static_actor_with_corner, NULL, NULL);
368 change_static_actor_with_corner(actor, desktop_plugin);
369 scene->actors = g_slist_append(scene->actors, actor);
371 actor = init_object(desktop_plugin, "moon", "moon1.png",
373 FALSE, FALSE, 100, 255,
374 (gpointer)&change_moon, NULL, NULL);
375 change_moon(actor, desktop_plugin);
376 scene->actors = g_slist_append(scene->actors, actor);
378 actor = init_object(desktop_plugin, "wind", "",
380 FALSE, FALSE, 100, 255,
381 (gpointer)&change_wind, NULL, NULL);
382 change_wind(actor, desktop_plugin);
383 scene->actors = g_slist_append(scene->actors, actor);
385 /* windows in 4-th house */
425 for (i=0; i<13; i++){
426 actor = init_object(desktop_plugin, "window1", "window1.png",
427 winds[i][0], winds[i][1], 8, 8, 10,
428 FALSE, FALSE, 100, 255,
429 (gpointer)&change_window1, NULL, NULL);
430 //change_window1(actor, desktop_plugin);
431 actor->time_start_animation = now + fast_rnd(30);
432 scene->actors = g_slist_append(scene->actors, actor);
436 /* windows in 1-th house */
462 actor = init_object(desktop_plugin, "window2", "window2.png",
463 winds[i][0], winds[i][1], 8, 8, 10,
464 FALSE, FALSE, 100, 255,
465 (gpointer)&change_window1, NULL, NULL);
466 //change_window1(actor, desktop_plugin);
467 actor->time_start_animation = now + fast_rnd(30);
468 scene->actors = g_slist_append(scene->actors, actor);
472 /* windows in 3-th house */
504 for (i=0; i<10; i++){
505 actor = init_object(desktop_plugin, "window3", "window3.png",
506 winds[i][0], winds[i][1], 8, 8, 10,
507 FALSE, FALSE, 100, 255,
508 (gpointer)&change_window1, NULL, NULL);
509 //change_window1(actor, desktop_plugin);
510 actor->time_start_animation = now + fast_rnd(30);
511 scene->actors = g_slist_append(scene->actors, actor);
515 /* windows in 5-th house */
539 actor = init_object(desktop_plugin, "window4", "window4.png",
540 winds[i][0], winds[i][1], 8, 8, 10,
541 FALSE, FALSE, 100, 255,
542 (gpointer)&change_window1, NULL, NULL);
543 //change_window1(actor, desktop_plugin);
544 actor->time_start_animation = now + fast_rnd(30);
545 scene->actors = g_slist_append(scene->actors, actor);
549 /* windows in 6-th house */
570 actor = init_object(desktop_plugin, "window5", "window5.png",
571 winds[i][0], winds[i][1], 8, 8, 10,
572 FALSE, FALSE, 100, 255,
573 (gpointer)&change_window1, NULL, NULL);
574 //change_window1(actor, desktop_plugin);
575 actor->time_start_animation = now + fast_rnd(30);
576 scene->actors = g_slist_append(scene->actors, actor);
579 run_long_timeout(desktop_plugin);
582 anim = g_new0(Animation, 1);
585 anim->func_change = &change_tram;
586 anim->func_time = NULL;
587 anim->timestart = time(NULL);
590 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
594 /* Init Berlin Scene */
596 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
598 Actor *actor, *actor1, *actor2;
600 gint now = time(NULL);
603 GPtrArray *child = NULL;
605 scene = g_new0(Scene, 1);
606 scene->daytime = get_daytime();
607 scene->actors = NULL;
608 scene->wind_orientation = -1;
609 scene->wind_angle = 0.3;
610 /* init value for random */
611 scene->seed = time(NULL);
612 desktop_plugin->priv->scene = scene;
614 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
615 TRUE, TRUE, 100, 255,
616 (gpointer)&change_static_actor, NULL, NULL);
617 change_static_actor(actor, desktop_plugin);
618 scene->actors = g_slist_append(scene->actors, actor);
621 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
622 FALSE, FALSE, 100, 255,
623 (gpointer)&change_sun, NULL, NULL);
624 actor->time_start_animation = time(NULL);
625 actor->duration_animation = G_MAXINT;
626 change_sun(actor, desktop_plugin);
627 scene->actors = g_slist_append(scene->actors, actor);
630 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
631 TRUE, 100, 255, NULL, NULL);
632 scene.actors = g_slist_append(scene.actors, actor);
635 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
636 FALSE, FALSE, 100, 255,
637 (gpointer)&change_moon, NULL, NULL);
638 change_moon(actor, desktop_plugin);
639 scene->actors = g_slist_append(scene->actors, actor);
641 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
642 FALSE, FALSE, 100, 255,
643 (gpointer)&change_cloud, NULL, NULL);
644 actor->time_start_animation = now + fast_rnd(30) + 10;
645 actor->duration_animation = 3*60;
646 scene->actors = g_slist_append(scene->actors, actor);
648 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
649 FALSE, FALSE, 100, 255,
650 (gpointer)&change_cloud, NULL, NULL);
651 actor->time_start_animation = now + fast_rnd(10);
652 actor->duration_animation = 3*60;
653 scene->actors = g_slist_append(scene->actors, actor);
655 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
656 FALSE, FALSE, 100, 255,
657 (gpointer)&change_cloud, NULL, NULL);
658 actor->time_start_animation = now + fast_rnd(60) + 20;
659 actor->duration_animation = 5*60;
660 scene->actors = g_slist_append(scene->actors, actor);
663 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
664 FALSE, FALSE, 100, 255,
665 (gpointer)&change_plane2, NULL, NULL);
666 actor->time_start_animation = now + fast_rnd(40) + 20;
667 actor->duration_animation = 60;
668 scene->actors = g_slist_append(scene->actors, actor);
670 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
671 FALSE, FALSE, 100, 255,
672 (gpointer)&change_plane1, NULL, NULL);
673 actor->time_start_animation = now + fast_rnd(20);
674 actor->duration_animation = 30;
675 scene->actors = g_slist_append(scene->actors, actor);
677 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
678 TRUE, TRUE, 100, 255,
679 (gpointer)&change_static_actor_with_corner, NULL, NULL);
680 change_static_actor_with_corner(actor, desktop_plugin);
681 scene->actors = g_slist_append(scene->actors, actor);
683 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
684 FALSE, FALSE, 100, 255,
685 (gpointer)&change_wind, NULL, NULL);
686 change_wind(actor, desktop_plugin);
687 scene->actors = g_slist_append(scene->actors, actor);
689 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
690 486, 425, 10, 18, 38,
691 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
692 //actor->time_start_animation = now + fast_rnd(30) + 10;
693 scene->actors = g_slist_append(scene->actors, actor1);
695 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
696 486, 425, 10, 18, 38,
697 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
698 //actor->time_start_animation = now + fast_rnd(30) + 10;
699 scene->actors = g_slist_append(scene->actors, actor2);
700 child = g_ptr_array_sized_new(2);
701 g_ptr_array_add(child, actor1);
702 g_ptr_array_add(child, actor2);
703 actor = init_object(desktop_plugin, "signal", "",
704 486, 425, 10, 18, 38,
705 FALSE, FALSE, 100, 255,
706 (gpointer)&change_signal, NULL, child);
707 actor->time_start_animation = now + fast_rnd(30) + 10;
708 scene->actors = g_slist_append(scene->actors, actor);
749 for (i=0; i<13; i++){
750 actor = init_object(desktop_plugin, "window", "window.png",
751 winds[i][0], winds[i][1], 10, 8, 9,
752 FALSE, TRUE, 100, 255,
753 (gpointer)&change_window1, NULL, NULL);
754 //change_window1(actor, desktop_plugin);
755 actor->time_start_animation = now + fast_rnd(30);
756 scene->actors = g_slist_append(scene->actors, actor);
760 run_long_timeout(desktop_plugin);
765 init_scene_theme(AWallpaperPlugin *desktop_plugin)
767 void (*func)(gpointer);
768 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
770 (*func)(desktop_plugin);