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 */
70 init_scene_Video(AWallpaperPlugin *desktop_plugin)
74 GstElement *videosink;
79 fprintf(stderr,"dddddddddddddddddddd\n");
80 pipeline= gst_pipeline_new("gst-player");
81 bin = gst_element_factory_make ("playbin2", "bin");
82 videosink = gst_element_factory_make ("ximagesink", "videosink");
83 g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
84 gst_bin_add (GST_BIN (pipeline), bin);
88 bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
89 // gst_bus_add_watch(bus, bus_call, NULL);
90 // gst_bus_set_sync_handler(bus, (GstBusSyncHandler)SetVideoAreaXID, desktop_plugin);
91 gst_object_unref (bus);
93 g_object_set (G_OBJECT (bin), "uri", "file:///home/user/MyDocs/.videos/9.mp4", NULL );
94 g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
95 if (GST_IS_X_OVERLAY (videosink)){
96 printf("Is Overlay (Win ID: %i)!!\n",GPOINTER_TO_INT(GDK_WINDOW_XWINDOW(desktop_plugin->priv->window->window)));
97 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
99 gst_element_set_state (pipeline, GST_STATE_PLAYING);
103 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
108 gint now = time(NULL);
111 if (desktop_plugin->priv->rich_animation){
119 /* fprintf(stderr, "init scene2 \n"); */
120 scene = g_new0(Scene, 1);
121 //scene.daytime = get_daytime();
122 scene->actors = NULL;
123 desktop_plugin->priv->scene = scene;
125 actor = init_object(desktop_plugin, "background", "bg.png",
127 TRUE, TRUE, 100, 255,
129 scene->actors = g_slist_append(scene->actors, actor);
131 actor = init_object(desktop_plugin, "symbols", "symbols.png",
133 TRUE, TRUE, 100, 255,
135 scene->actors = g_slist_append(scene->actors, actor);
137 child = g_ptr_array_sized_new(4);
138 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
140 TRUE, TRUE, 100, 255,
142 //actor->time_start_animation = now;
143 //actor->duration_animation = G_MAXINT;
144 scene->actors = g_slist_append(scene->actors, actor);
145 g_ptr_array_add(child, actor);
147 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
149 TRUE, TRUE, 100, 255,
151 //actor->time_start_animation = now;
152 //actor->duration_animation = G_MAXINT;
153 scene->actors = g_slist_append(scene->actors, actor);
154 g_ptr_array_add(child, actor);
156 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
158 TRUE, TRUE, 100, 255,
160 //actor->time_start_animation = now;
161 //actor->duration_animation = G_MAXINT;
162 scene->actors = g_slist_append(scene->actors, actor);
163 g_ptr_array_add(child, actor);
165 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
167 TRUE, TRUE, 100, 255,
169 //actor->time_start_animation = now;
170 //actor->duration_animation = G_MAXINT;
171 scene->actors = g_slist_append(scene->actors, actor);
172 g_ptr_array_add(child, actor);
174 actor = init_object(desktop_plugin, "layers", "",
176 FALSE, FALSE, 100, 255,
177 (gpointer)&change_layer, NULL, child);
178 actor->time_start_animation = now;
179 actor->duration_animation = G_MAXINT;
180 scene->actors = g_slist_append(scene->actors, actor);
182 run_long_timeout(desktop_plugin);
186 /* Init Modern Scene */
188 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
192 gint now = time(NULL);
197 /* fprintf(stderr, "init scene \n"); */
198 scene = g_new0(Scene, 1);
199 scene->daytime = get_daytime();
200 scene->actors = NULL;
201 scene->wind_orientation = -1;
202 scene->wind_angle = 0.3;
203 /* init value for random */
204 scene->seed = time(NULL);
205 scene->notification = TRUE;
206 desktop_plugin->priv->scene = scene;
207 actor = init_object(desktop_plugin, "sky", "sky0.png",
209 TRUE , TRUE, 100, 255,
210 (gpointer)&change_static_actor, NULL, NULL);
211 scene->actors = g_slist_append(scene->actors, actor);
212 change_static_actor(actor, desktop_plugin);
214 actor = init_object(desktop_plugin, "sun", "sun.png",
216 FALSE, FALSE, 100, 255,
217 (gpointer)&change_sun, NULL, NULL);
218 actor->time_start_animation = now;
219 actor->duration_animation = G_MAXINT;
220 change_sun(actor, desktop_plugin);
221 scene->actors = g_slist_append(scene->actors, actor);
223 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
224 // TRUE, 100, 255, NULL, NULL);
225 //scene.actors = g_slist_append(scene.actors, actor);
227 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
228 0, fast_rnd(300)-97, 7, 150, 97,
229 FALSE, FALSE, 100, 255,
230 (gpointer)&change_cloud, NULL, NULL);
231 actor->time_start_animation = now + fast_rnd(20);
232 actor->duration_animation = 3*60;
233 scene->actors = g_slist_append(scene->actors, actor);
235 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
236 0, fast_rnd(300)-75, 7, 188, 75,
237 FALSE, FALSE, 100, 255,
238 (gpointer)&change_cloud, NULL, NULL);
239 actor->time_start_animation = now + fast_rnd(40)+10;
240 actor->duration_animation = 3*60;
241 scene->actors = g_slist_append(scene->actors, actor);
243 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
244 0, fast_rnd(300)-75, 7, 150, 75,
245 FALSE, FALSE, 100, 255,
246 (gpointer)&change_cloud, NULL, NULL);
247 actor->time_start_animation = now + fast_rnd(60) + 20;
248 actor->duration_animation = 5*60;
249 scene->actors = g_slist_append(scene->actors, actor);
252 actor = init_object(desktop_plugin, "town", "town0.png",
254 TRUE, TRUE, 100, 255,
255 (gpointer)&change_static_actor, NULL, NULL);
256 change_static_actor(actor, desktop_plugin);
257 scene->actors = g_slist_append(scene->actors, actor);
259 actor = init_object(desktop_plugin, "stend", "stend0.png",
260 452, 166, 9, 300, 305,
261 TRUE, TRUE, 100, 255,
262 (gpointer)&change_static_actor, NULL, NULL);
263 change_static_actor(actor, desktop_plugin);
264 scene->actors = g_slist_append(scene->actors, actor);
267 child = g_ptr_array_sized_new(4);
268 actor = init_object(desktop_plugin, "call", "call.png",
270 FALSE, TRUE, 100, 255,
272 scene->actors = g_slist_append(scene->actors, actor);
273 g_ptr_array_add(child, actor);
275 actor = init_object(desktop_plugin, "chat", "chat.png",
277 FALSE, TRUE, 100, 255,
279 scene->actors = g_slist_append(scene->actors, actor);
280 g_ptr_array_add(child, actor);
282 actor = init_object(desktop_plugin, "mail", "mail.png",
284 FALSE, TRUE, 100, 255,
286 scene->actors = g_slist_append(scene->actors, actor);
287 g_ptr_array_add(child, actor);
289 actor = init_object(desktop_plugin, "sms", "sms.png",
291 FALSE, TRUE, 100, 255,
293 scene->actors = g_slist_append(scene->actors, actor);
294 g_ptr_array_add(child, actor);
296 actor = init_object(desktop_plugin, "billboard_text", "",
297 470, 174, 9, 300, 108,
298 FALSE, FALSE, 100, 255,
299 (gpointer)&change_billboard, NULL, child);
300 create_hildon_actor_text(actor, desktop_plugin);
301 //actor->time_start_animation = time(NULL) + 20;
302 change_billboard(actor, desktop_plugin);
303 scene->actors = g_slist_append(scene->actors, actor);
305 actor = init_object(desktop_plugin, "tram", "tram.png",
306 -300, 225, 10, 350, 210,
307 FALSE, FALSE, 100, 255,
308 (gpointer)&change_tram, NULL, NULL);
309 actor->time_start_animation = time(NULL) + fast_rnd(10);
310 actor->duration_animation = 60;
311 scene->actors = g_slist_append(scene->actors, actor);
313 actor = init_object(desktop_plugin, "border", "border0.png",
314 0, 480-79, 11, 800, 79,
315 TRUE, TRUE, 100, 255,
316 (gpointer)&change_static_actor_with_corner, NULL, NULL);
317 change_static_actor_with_corner(actor, desktop_plugin);
318 scene->actors = g_slist_append(scene->actors, actor);
320 actor = init_object(desktop_plugin, "moon", "moon1.png",
322 FALSE, FALSE, 100, 255,
323 (gpointer)&change_moon, NULL, NULL);
324 change_moon(actor, desktop_plugin);
325 scene->actors = g_slist_append(scene->actors, actor);
327 actor = init_object(desktop_plugin, "wind", "",
329 FALSE, FALSE, 100, 255,
330 (gpointer)&change_wind, NULL, NULL);
331 change_wind(actor, desktop_plugin);
332 scene->actors = g_slist_append(scene->actors, actor);
334 /* windows in 4-th house */
374 for (i=0; i<13; i++){
375 actor = init_object(desktop_plugin, "window1", "window1.png",
376 winds[i][0], winds[i][1], 8, 8, 10,
377 FALSE, FALSE, 100, 255,
378 (gpointer)&change_window1, NULL, NULL);
379 //change_window1(actor, desktop_plugin);
380 actor->time_start_animation = now + fast_rnd(30);
381 scene->actors = g_slist_append(scene->actors, actor);
385 /* windows in 1-th house */
411 actor = init_object(desktop_plugin, "window2", "window2.png",
412 winds[i][0], winds[i][1], 8, 8, 10,
413 FALSE, FALSE, 100, 255,
414 (gpointer)&change_window1, NULL, NULL);
415 //change_window1(actor, desktop_plugin);
416 actor->time_start_animation = now + fast_rnd(30);
417 scene->actors = g_slist_append(scene->actors, actor);
421 /* windows in 3-th house */
453 for (i=0; i<10; i++){
454 actor = init_object(desktop_plugin, "window3", "window3.png",
455 winds[i][0], winds[i][1], 8, 8, 10,
456 FALSE, FALSE, 100, 255,
457 (gpointer)&change_window1, NULL, NULL);
458 //change_window1(actor, desktop_plugin);
459 actor->time_start_animation = now + fast_rnd(30);
460 scene->actors = g_slist_append(scene->actors, actor);
464 /* windows in 5-th house */
488 actor = init_object(desktop_plugin, "window4", "window4.png",
489 winds[i][0], winds[i][1], 8, 8, 10,
490 FALSE, FALSE, 100, 255,
491 (gpointer)&change_window1, NULL, NULL);
492 //change_window1(actor, desktop_plugin);
493 actor->time_start_animation = now + fast_rnd(30);
494 scene->actors = g_slist_append(scene->actors, actor);
498 /* windows in 6-th house */
519 actor = init_object(desktop_plugin, "window5", "window5.png",
520 winds[i][0], winds[i][1], 8, 8, 10,
521 FALSE, FALSE, 100, 255,
522 (gpointer)&change_window1, NULL, NULL);
523 //change_window1(actor, desktop_plugin);
524 actor->time_start_animation = now + fast_rnd(30);
525 scene->actors = g_slist_append(scene->actors, actor);
528 run_long_timeout(desktop_plugin);
531 anim = g_new0(Animation, 1);
534 anim->func_change = &change_tram;
535 anim->func_time = NULL;
536 anim->timestart = time(NULL);
539 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
543 /* Init Berlin Scene */
545 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
547 Actor *actor, *actor1, *actor2;
549 gint now = time(NULL);
552 GPtrArray *child = NULL;
554 scene = g_new0(Scene, 1);
555 scene->daytime = get_daytime();
556 scene->actors = NULL;
557 scene->wind_orientation = -1;
558 scene->wind_angle = 0.3;
559 /* init value for random */
560 scene->seed = time(NULL);
561 desktop_plugin->priv->scene = scene;
563 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
564 TRUE, TRUE, 100, 255,
565 (gpointer)&change_static_actor, NULL, NULL);
566 change_static_actor(actor, desktop_plugin);
567 scene->actors = g_slist_append(scene->actors, actor);
570 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
571 FALSE, FALSE, 100, 255,
572 (gpointer)&change_sun, NULL, NULL);
573 actor->time_start_animation = time(NULL);
574 actor->duration_animation = G_MAXINT;
575 change_sun(actor, desktop_plugin);
576 scene->actors = g_slist_append(scene->actors, actor);
579 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
580 TRUE, 100, 255, NULL, NULL);
581 scene.actors = g_slist_append(scene.actors, actor);
584 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
585 FALSE, FALSE, 100, 255,
586 (gpointer)&change_moon, NULL, NULL);
587 change_moon(actor, desktop_plugin);
588 scene->actors = g_slist_append(scene->actors, actor);
590 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
591 FALSE, FALSE, 100, 255,
592 (gpointer)&change_cloud, NULL, NULL);
593 actor->time_start_animation = now + fast_rnd(30) + 10;
594 actor->duration_animation = 3*60;
595 scene->actors = g_slist_append(scene->actors, actor);
597 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
598 FALSE, FALSE, 100, 255,
599 (gpointer)&change_cloud, NULL, NULL);
600 actor->time_start_animation = now + fast_rnd(10);
601 actor->duration_animation = 3*60;
602 scene->actors = g_slist_append(scene->actors, actor);
604 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
605 FALSE, FALSE, 100, 255,
606 (gpointer)&change_cloud, NULL, NULL);
607 actor->time_start_animation = now + fast_rnd(60) + 20;
608 actor->duration_animation = 5*60;
609 scene->actors = g_slist_append(scene->actors, actor);
612 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
613 FALSE, FALSE, 100, 255,
614 (gpointer)&change_plane2, NULL, NULL);
615 actor->time_start_animation = now + fast_rnd(40) + 20;
616 actor->duration_animation = 60;
617 scene->actors = g_slist_append(scene->actors, actor);
619 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
620 FALSE, FALSE, 100, 255,
621 (gpointer)&change_plane1, NULL, NULL);
622 actor->time_start_animation = now + fast_rnd(20);
623 actor->duration_animation = 30;
624 scene->actors = g_slist_append(scene->actors, actor);
626 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
627 TRUE, TRUE, 100, 255,
628 (gpointer)&change_static_actor_with_corner, NULL, NULL);
629 change_static_actor_with_corner(actor, desktop_plugin);
630 scene->actors = g_slist_append(scene->actors, actor);
632 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
633 FALSE, FALSE, 100, 255,
634 (gpointer)&change_wind, NULL, NULL);
635 change_wind(actor, desktop_plugin);
636 scene->actors = g_slist_append(scene->actors, actor);
638 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
639 486, 425, 10, 18, 38,
640 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
641 //actor->time_start_animation = now + fast_rnd(30) + 10;
642 scene->actors = g_slist_append(scene->actors, actor1);
644 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
645 486, 425, 10, 18, 38,
646 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
647 //actor->time_start_animation = now + fast_rnd(30) + 10;
648 scene->actors = g_slist_append(scene->actors, actor2);
649 child = g_ptr_array_sized_new(2);
650 g_ptr_array_add(child, actor1);
651 g_ptr_array_add(child, actor2);
652 actor = init_object(desktop_plugin, "signal", "",
653 486, 425, 10, 18, 38,
654 FALSE, FALSE, 100, 255,
655 (gpointer)&change_signal, NULL, child);
656 actor->time_start_animation = now + fast_rnd(30) + 10;
657 scene->actors = g_slist_append(scene->actors, actor);
698 for (i=0; i<13; i++){
699 actor = init_object(desktop_plugin, "window", "window.png",
700 winds[i][0], winds[i][1], 10, 8, 9,
701 FALSE, TRUE, 100, 255,
702 (gpointer)&change_window1, NULL, NULL);
703 //change_window1(actor, desktop_plugin);
704 actor->time_start_animation = now + fast_rnd(30);
705 scene->actors = g_slist_append(scene->actors, actor);
709 run_long_timeout(desktop_plugin);
714 init_scene_theme(AWallpaperPlugin *desktop_plugin)
716 void (*func)(gpointer);
717 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
719 (*func)(desktop_plugin);