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 General Public License
11 * as published by the Free Software Foundation; either version 2 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"
26 /* This code form X11-utils */
27 Window Window_With_Name( Display *dpy, Window top, char *name)
29 Window *children, dummy;
30 unsigned int nchildren;
35 XClassHint *class_hint;
36 class_hint = XAllocClassHint();
37 XGetClassHint(dpy, top, class_hint);
38 if (class_hint->res_name && name && !strcmp(class_hint->res_name, name)){
39 XFree(class_hint->res_class);
40 XFree(class_hint->res_name);
43 XFree(class_hint->res_class);
44 XFree(class_hint->res_name);
46 if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
49 if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
52 for (i=0; i<nchildren; i++) {
53 w = Window_With_Name(dpy, children[i], name);
57 if (children) XFree ((char *)children);
61 /*******************************************************************************/
64 destroy_scene(AWallpaperPlugin *desktop_plugin)
68 if (desktop_plugin->priv->scene){
69 GSList * tmp = desktop_plugin->priv->scene->actors;
71 destroy_actor(tmp->data);
72 tmp = g_slist_next(tmp);
76 desktop_plugin->priv->scene->actors = NULL;
77 if (desktop_plugin->priv->scene){
78 g_free(desktop_plugin->priv->scene);
79 desktop_plugin->priv->scene = NULL;
82 if (desktop_plugin->priv->pipeline){
83 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
84 gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
85 desktop_plugin->priv->pipeline = NULL;
87 if (desktop_plugin->priv->podpid > 1){
88 kill (desktop_plugin->priv->podpid, SIGTERM);
90 if (wait(&status) == desktop_plugin->priv->podpid)
93 desktop_plugin->priv->podpid = -1;
94 desktop_plugin->priv->running = FALSE;
97 /*******************************************************************************/
99 reload_scene(AWallpaperPlugin *desktop_plugin)
101 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
102 destroy_scene(desktop_plugin);
103 fill_priv(desktop_plugin->priv);
104 gtk_widget_destroy(desktop_plugin->priv->window);
105 if (desktop_plugin->priv->one_in_all_view && desktop_plugin->priv->view >1)
107 create_xwindow(desktop_plugin->priv);
108 init_scene_theme(desktop_plugin);
110 /*******************************************************************************/
112 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
117 gint now = time(NULL);
119 gchar *bgfile = NULL;
120 gint sizes1[4] = {57, 76, 43, 50},
123 /* fprintf(stderr, "init scene accel\n"); */
124 scene = g_new0(Scene, 1);
125 scene->actors = NULL;
126 desktop_plugin->priv->scene = scene;
128 bgfile = g_strdup_printf("/home/user/.backgrounds/background-%i.png", desktop_plugin->priv->view);
129 actor = init_object(desktop_plugin, "original", bgfile,
131 TRUE, TRUE, 100, 255,
133 scene->actors = g_slist_append(scene->actors, actor);
135 child = g_ptr_array_sized_new(16);
137 for (j= 0; j<4; j++){
139 str = g_strdup_printf("tape%i.png", n+1);
140 actor = init_object(desktop_plugin, "tape", str,
141 fast_rnd(800), fast_rnd(480), 2+fast_rnd(6), 800, sizes1[n],
142 TRUE, TRUE, 100, 255,
144 scene->actors = g_slist_append(scene->actors, actor);
145 g_ptr_array_add(child, actor);
149 actor = init_object(desktop_plugin, "tape", "",
151 FALSE, FALSE, 100, 255,
152 (gpointer)&change_tape, NULL, child);
153 actor->time_start_animation = now;
154 actor->duration_animation = G_MAXINT;
155 scene->actors = g_slist_append(scene->actors, actor);
157 run_long_timeout(desktop_plugin);
159 /*******************************************************************************/
161 parsestring(char *line, char **argv)
163 while (*line != '\0') {
164 while (*line == ' ' || *line == '\n')
165 *line++ = '\0'; /* replace white spaces with 0 */
166 *argv++ = line; /* save the argument position */
167 while (*line != '\0' && *line != ' ' &&
169 line++; /* skip the argument until ... */
171 *argv = '\0'; /* mark the end of argument list */
176 sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){
178 if (!desktop_plugin->priv->visible)
179 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
180 if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT){
181 return (GST_BUS_PASS);
183 if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")){
184 return (GST_BUS_PASS);
186 return (GST_BUS_DROP);
190 /*******************************************************************************/
192 bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin)
194 switch (GST_MESSAGE_TYPE (msg))
196 case GST_MESSAGE_EOS:
197 if (desktop_plugin->priv->rich_animation){
199 GstClockTime nach = (GstClockTime)(0 * GST_MSECOND);
200 if (!gst_element_seek(desktop_plugin->priv->pipeline, 1.0, GST_FORMAT_TIME,
201 (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET,
202 nach, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
203 fprintf(stderr,"ERROR in seek\n");
205 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
208 if (desktop_plugin->priv->pipeline){
209 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
210 gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
214 case GST_MESSAGE_ERROR: break;
220 /*******************************************************************************/
222 init_scene_External(AWallpaperPlugin *desktop_plugin){
224 char* child_argv[2048];
225 char *run_string = NULL;
226 gchar *exec_path = NULL,
230 *gtk_socket_id = NULL,
234 *theme_string_parametr1 = NULL,
235 *straddedstring = NULL,
239 if (!desktop_plugin->priv->visible)
242 exec_path = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "exec_path"));
243 window_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_id"));
244 view = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "view"));
245 window_name = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_name"));
246 gtk_socket_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "gtk_socket_id"));
247 addedstring = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "added_string"));
251 strwin = g_strdup_printf(" %s %i", window_id, (gint)GDK_WINDOW_XID(desktop_plugin->priv->window->window));
255 strsocket = g_strdup_printf(" %s %i", gtk_socket_id, (int)gtk_socket_get_id (GTK_SOCKET (desktop_plugin->priv->video_socket)));
260 strview = g_strdup_printf(" %s %i", view, desktop_plugin->priv->view);
265 straddedstring = g_strdup_printf(" %s", addedstring);
269 if (desktop_plugin->priv->theme_string_parametr1){
270 theme_string_parametr1 = g_strdup_printf(" %s", desktop_plugin->priv->theme_string_parametr1);
272 theme_string_parametr1 = "";
274 run_string = g_strdup_printf("%s%s%s%s%s%s", exec_path, strwin, strview, strsocket, straddedstring, theme_string_parametr1);
275 fprintf(stderr, "runs string = %s\n", run_string);
276 parsestring(run_string, child_argv);
278 desktop_plugin->priv->running = TRUE;
279 desktop_plugin->priv->podpid = fork();
280 if (desktop_plugin->priv->podpid == 0){
281 execvp(child_argv[0], child_argv);
282 fprintf(stderr,"Problem with new podprocess");
286 fprintf(stderr, "window name = %s\n", window_name);
288 /* Do 10 trying to search of window */
289 for (i=0; i<10; i++){
291 id_xwindow = Window_With_Name(GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
292 RootWindow( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window), XDefaultScreen( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window))),
294 fprintf(stderr,"name %s %i %i\n", window_name, id_xwindow, i);
296 if (desktop_plugin->priv->one_in_all_view)
297 set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
300 set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
301 id_xwindow, desktop_plugin->priv->view);
302 /* gtk_widget_destroy(desktop_plugin->priv->window); */
308 /*******************************************************************************/
310 cb_timeout0(AWallpaperPlugin *desktop_plugin) {
312 if (!desktop_plugin || !desktop_plugin->priv->pipeline)
314 if (desktop_plugin->priv->theme_int_parametr1 == 0){
315 if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
316 GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
317 desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
318 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
319 fprintf(stderr,"Error in seek:\n");
323 if (gst_element_get_state (desktop_plugin->priv->pipeline, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE)
326 if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
327 GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
328 desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
329 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
330 fprintf(stderr,"Error in seek:\n");
334 /*******************************************************************************/
336 init_scene_Video(AWallpaperPlugin *desktop_plugin)
339 GstElement *videosink;
340 gchar *file_plus_uri;
343 /* fprintf(stderr, "init scene Video \n"); */
344 desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
345 bin = gst_element_factory_make ("playbin2", "bin");
346 videosink = gst_element_factory_make ("ximagesink", "videosink");
347 g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
348 gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
352 bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
353 gst_bus_add_watch(bus, (GstBusFunc)bus_call, desktop_plugin);
354 gst_object_unref (bus);
356 file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
357 g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
359 /* Doesn't work in real device. Hardware volume buttons can to change volume for mutted track */
361 if (!desktop_plugin->priv->theme_bool_parametr1)
362 g_object_set (G_OBJECT (bin), "mute", TRUE, NULL );
364 g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
366 if (GST_IS_X_OVERLAY (videosink))
367 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
369 if (desktop_plugin->priv->visible){
370 g_timeout_add(50, (GSourceFunc)cb_timeout0, desktop_plugin);
371 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
374 //gst_element_get_state(deskddtop_plugin->priv->pipeline, NULL, NULL, 100 * GST_MSECOND);
377 /*******************************************************************************/
379 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
384 gint now = time(NULL);
387 if (desktop_plugin->priv->rich_animation){
395 /* fprintf(stderr, "init scene2 \n"); */
396 scene = g_new0(Scene, 1);
397 //scene.daytime = get_daytime();
398 scene->actors = NULL;
399 desktop_plugin->priv->scene = scene;
401 actor = init_object(desktop_plugin, "background", "bg.png",
403 TRUE, TRUE, 100, 255,
405 scene->actors = g_slist_append(scene->actors, actor);
407 actor = init_object(desktop_plugin, "symbols", "symbols.png",
409 TRUE, TRUE, 100, 255,
411 scene->actors = g_slist_append(scene->actors, actor);
413 child = g_ptr_array_sized_new(4);
414 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
416 TRUE, TRUE, 100, 255,
418 //actor->time_start_animation = now;
419 //actor->duration_animation = G_MAXINT;
420 scene->actors = g_slist_append(scene->actors, actor);
421 g_ptr_array_add(child, actor);
423 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
425 TRUE, TRUE, 100, 255,
427 //actor->time_start_animation = now;
428 //actor->duration_animation = G_MAXINT;
429 scene->actors = g_slist_append(scene->actors, actor);
430 g_ptr_array_add(child, actor);
432 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
434 TRUE, TRUE, 100, 255,
436 //actor->time_start_animation = now;
437 //actor->duration_animation = G_MAXINT;
438 scene->actors = g_slist_append(scene->actors, actor);
439 g_ptr_array_add(child, actor);
441 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
443 TRUE, TRUE, 100, 255,
445 //actor->time_start_animation = now;
446 //actor->duration_animation = G_MAXINT;
447 scene->actors = g_slist_append(scene->actors, actor);
448 g_ptr_array_add(child, actor);
450 actor = init_object(desktop_plugin, "layers", "",
452 FALSE, FALSE, 100, 255,
453 (gpointer)&change_layer, NULL, child);
454 actor->time_start_animation = now;
455 actor->duration_animation = G_MAXINT;
456 scene->actors = g_slist_append(scene->actors, actor);
458 run_long_timeout(desktop_plugin);
461 /*******************************************************************************/
462 /* Init Modern Scene */
464 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
468 gint now = time(NULL);
473 /* fprintf(stderr, "init scene \n"); */
474 scene = g_new0(Scene, 1);
475 scene->daytime = get_daytime();
476 scene->actors = NULL;
477 scene->wind_orientation = -1;
478 scene->wind_angle = 0.3;
479 /* init value for random */
480 scene->seed = time(NULL);
481 scene->notification = TRUE;
482 desktop_plugin->priv->scene = scene;
483 actor = init_object(desktop_plugin, "sky", "sky0.png",
485 TRUE , TRUE, 100, 255,
486 (gpointer)&change_static_actor, NULL, NULL);
487 scene->actors = g_slist_append(scene->actors, actor);
488 change_static_actor(actor, desktop_plugin);
490 actor = init_object(desktop_plugin, "sun", "sun.png",
492 FALSE, FALSE, 100, 255,
493 (gpointer)&change_sun, NULL, NULL);
494 actor->time_start_animation = now;
495 actor->duration_animation = G_MAXINT;
496 change_sun(actor, desktop_plugin);
497 scene->actors = g_slist_append(scene->actors, actor);
499 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
500 // TRUE, 100, 255, NULL, NULL);
501 //scene.actors = g_slist_append(scene.actors, actor);
503 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
504 0, fast_rnd(300)-97, 7, 150, 97,
505 FALSE, FALSE, 100, 255,
506 (gpointer)&change_cloud, NULL, NULL);
507 actor->time_start_animation = now + fast_rnd(20);
508 actor->duration_animation = 3*60;
509 scene->actors = g_slist_append(scene->actors, actor);
511 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
512 0, fast_rnd(300)-75, 7, 188, 75,
513 FALSE, FALSE, 100, 255,
514 (gpointer)&change_cloud, NULL, NULL);
515 actor->time_start_animation = now + fast_rnd(40)+10;
516 actor->duration_animation = 3*60;
517 scene->actors = g_slist_append(scene->actors, actor);
519 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
520 0, fast_rnd(300)-75, 7, 150, 75,
521 FALSE, FALSE, 100, 255,
522 (gpointer)&change_cloud, NULL, NULL);
523 actor->time_start_animation = now + fast_rnd(60) + 20;
524 actor->duration_animation = 5*60;
525 scene->actors = g_slist_append(scene->actors, actor);
528 actor = init_object(desktop_plugin, "town", "town0.png",
530 TRUE, TRUE, 100, 255,
531 (gpointer)&change_static_actor, NULL, NULL);
532 change_static_actor(actor, desktop_plugin);
533 scene->actors = g_slist_append(scene->actors, actor);
535 actor = init_object(desktop_plugin, "stend", "stend0.png",
536 452, 166, 9, 300, 305,
537 TRUE, TRUE, 100, 255,
538 (gpointer)&change_static_actor, NULL, NULL);
539 change_static_actor(actor, desktop_plugin);
540 scene->actors = g_slist_append(scene->actors, actor);
543 child = g_ptr_array_sized_new(4);
544 actor = init_object(desktop_plugin, "call", "call.png",
546 FALSE, TRUE, 100, 255,
548 scene->actors = g_slist_append(scene->actors, actor);
549 g_ptr_array_add(child, actor);
551 actor = init_object(desktop_plugin, "chat", "chat.png",
553 FALSE, TRUE, 100, 255,
555 scene->actors = g_slist_append(scene->actors, actor);
556 g_ptr_array_add(child, actor);
558 actor = init_object(desktop_plugin, "mail", "mail.png",
560 FALSE, TRUE, 100, 255,
562 scene->actors = g_slist_append(scene->actors, actor);
563 g_ptr_array_add(child, actor);
565 actor = init_object(desktop_plugin, "sms", "sms.png",
567 FALSE, TRUE, 100, 255,
569 scene->actors = g_slist_append(scene->actors, actor);
570 g_ptr_array_add(child, actor);
572 actor = init_object(desktop_plugin, "billboard_text", "",
573 470, 174, 9, 300, 108,
574 FALSE, FALSE, 100, 255,
575 (gpointer)&change_billboard, NULL, child);
576 create_hildon_actor_text(actor, desktop_plugin);
577 //actor->time_start_animation = time(NULL) + 20;
578 change_billboard(actor, desktop_plugin);
579 scene->actors = g_slist_append(scene->actors, actor);
581 actor = init_object(desktop_plugin, "tram", "tram.png",
582 -300, 225, 10, 350, 210,
583 FALSE, FALSE, 100, 255,
584 (gpointer)&change_tram, NULL, NULL);
585 actor->time_start_animation = time(NULL) + fast_rnd(10);
586 actor->duration_animation = 60;
587 scene->actors = g_slist_append(scene->actors, actor);
589 actor = init_object(desktop_plugin, "border", "border0.png",
590 0, 480-79, 11, 800, 79,
591 TRUE, TRUE, 100, 255,
592 (gpointer)&change_static_actor_with_corner, NULL, NULL);
593 change_static_actor_with_corner(actor, desktop_plugin);
594 scene->actors = g_slist_append(scene->actors, actor);
596 actor = init_object(desktop_plugin, "moon", "moon1.png",
598 FALSE, FALSE, 100, 255,
599 (gpointer)&change_moon, NULL, NULL);
600 change_moon(actor, desktop_plugin);
601 scene->actors = g_slist_append(scene->actors, actor);
603 actor = init_object(desktop_plugin, "wind", "",
605 FALSE, FALSE, 100, 255,
606 (gpointer)&change_wind, NULL, NULL);
607 change_wind(actor, desktop_plugin);
608 scene->actors = g_slist_append(scene->actors, actor);
610 /* windows in 4-th house */
650 for (i=0; i<13; i++){
651 actor = init_object(desktop_plugin, "window1", "window1.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);
661 /* windows in 1-th house */
687 actor = init_object(desktop_plugin, "window2", "window2.png",
688 winds[i][0], winds[i][1], 8, 8, 10,
689 FALSE, FALSE, 100, 255,
690 (gpointer)&change_window1, NULL, NULL);
691 //change_window1(actor, desktop_plugin);
692 actor->time_start_animation = now + fast_rnd(30);
693 scene->actors = g_slist_append(scene->actors, actor);
697 /* windows in 3-th house */
729 for (i=0; i<10; i++){
730 actor = init_object(desktop_plugin, "window3", "window3.png",
731 winds[i][0], winds[i][1], 8, 8, 10,
732 FALSE, FALSE, 100, 255,
733 (gpointer)&change_window1, NULL, NULL);
734 //change_window1(actor, desktop_plugin);
735 actor->time_start_animation = now + fast_rnd(30);
736 scene->actors = g_slist_append(scene->actors, actor);
740 /* windows in 5-th house */
764 actor = init_object(desktop_plugin, "window4", "window4.png",
765 winds[i][0], winds[i][1], 8, 8, 10,
766 FALSE, FALSE, 100, 255,
767 (gpointer)&change_window1, NULL, NULL);
768 //change_window1(actor, desktop_plugin);
769 actor->time_start_animation = now + fast_rnd(30);
770 scene->actors = g_slist_append(scene->actors, actor);
774 /* windows in 6-th house */
795 actor = init_object(desktop_plugin, "window5", "window5.png",
796 winds[i][0], winds[i][1], 8, 8, 10,
797 FALSE, FALSE, 100, 255,
798 (gpointer)&change_window1, NULL, NULL);
799 //change_window1(actor, desktop_plugin);
800 actor->time_start_animation = now + fast_rnd(30);
801 scene->actors = g_slist_append(scene->actors, actor);
804 run_long_timeout(desktop_plugin);
807 anim = g_new0(Animation, 1);
810 anim->func_change = &change_tram;
811 anim->func_time = NULL;
812 anim->timestart = time(NULL);
815 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
818 /*******************************************************************************/
819 /* Init Berlin Scene */
821 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
823 Actor *actor, *actor1, *actor2;
825 gint now = time(NULL);
828 GPtrArray *child = NULL;
830 scene = g_new0(Scene, 1);
831 scene->daytime = get_daytime();
832 scene->actors = NULL;
833 scene->wind_orientation = -1;
834 scene->wind_angle = 0.3;
835 /* init value for random */
836 scene->seed = time(NULL);
837 desktop_plugin->priv->scene = scene;
839 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
840 TRUE, TRUE, 100, 255,
841 (gpointer)&change_static_actor, NULL, NULL);
842 change_static_actor(actor, desktop_plugin);
843 scene->actors = g_slist_append(scene->actors, actor);
846 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
847 FALSE, FALSE, 100, 255,
848 (gpointer)&change_sun, NULL, NULL);
849 actor->time_start_animation = time(NULL);
850 actor->duration_animation = G_MAXINT;
851 change_sun(actor, desktop_plugin);
852 scene->actors = g_slist_append(scene->actors, actor);
855 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
856 TRUE, 100, 255, NULL, NULL);
857 scene.actors = g_slist_append(scene.actors, actor);
860 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
861 FALSE, FALSE, 100, 255,
862 (gpointer)&change_moon, NULL, NULL);
863 change_moon(actor, desktop_plugin);
864 scene->actors = g_slist_append(scene->actors, actor);
866 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
867 FALSE, FALSE, 100, 255,
868 (gpointer)&change_cloud, NULL, NULL);
869 actor->time_start_animation = now + fast_rnd(30) + 10;
870 actor->duration_animation = 3*60;
871 scene->actors = g_slist_append(scene->actors, actor);
873 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
874 FALSE, FALSE, 100, 255,
875 (gpointer)&change_cloud, NULL, NULL);
876 actor->time_start_animation = now + fast_rnd(10);
877 actor->duration_animation = 3*60;
878 scene->actors = g_slist_append(scene->actors, actor);
880 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
881 FALSE, FALSE, 100, 255,
882 (gpointer)&change_cloud, NULL, NULL);
883 actor->time_start_animation = now + fast_rnd(60) + 20;
884 actor->duration_animation = 5*60;
885 scene->actors = g_slist_append(scene->actors, actor);
888 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
889 FALSE, FALSE, 100, 255,
890 (gpointer)&change_plane2, NULL, NULL);
891 actor->time_start_animation = now + fast_rnd(40) + 20;
892 actor->duration_animation = 60;
893 scene->actors = g_slist_append(scene->actors, actor);
895 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
896 FALSE, FALSE, 100, 255,
897 (gpointer)&change_plane1, NULL, NULL);
898 actor->time_start_animation = now + fast_rnd(20);
899 actor->duration_animation = 30;
900 scene->actors = g_slist_append(scene->actors, actor);
902 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
903 TRUE, TRUE, 100, 255,
904 (gpointer)&change_static_actor_with_corner, NULL, NULL);
905 change_static_actor_with_corner(actor, desktop_plugin);
906 scene->actors = g_slist_append(scene->actors, actor);
908 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
909 FALSE, FALSE, 100, 255,
910 (gpointer)&change_wind, NULL, NULL);
911 change_wind(actor, desktop_plugin);
912 scene->actors = g_slist_append(scene->actors, actor);
914 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
915 486, 425, 10, 18, 38,
916 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
917 //actor->time_start_animation = now + fast_rnd(30) + 10;
918 scene->actors = g_slist_append(scene->actors, actor1);
920 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
921 486, 425, 10, 18, 38,
922 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
923 //actor->time_start_animation = now + fast_rnd(30) + 10;
924 scene->actors = g_slist_append(scene->actors, actor2);
925 child = g_ptr_array_sized_new(2);
926 g_ptr_array_add(child, actor1);
927 g_ptr_array_add(child, actor2);
928 actor = init_object(desktop_plugin, "signal", "",
929 486, 425, 10, 18, 38,
930 FALSE, FALSE, 100, 255,
931 (gpointer)&change_signal, NULL, child);
932 actor->time_start_animation = now + fast_rnd(30) + 10;
933 scene->actors = g_slist_append(scene->actors, actor);
974 for (i=0; i<13; i++){
975 actor = init_object(desktop_plugin, "window", "window.png",
976 winds[i][0], winds[i][1], 10, 8, 9,
977 FALSE, TRUE, 100, 255,
978 (gpointer)&change_window1, NULL, NULL);
979 //change_window1(actor, desktop_plugin);
980 actor->time_start_animation = now + fast_rnd(30);
981 scene->actors = g_slist_append(scene->actors, actor);
985 run_long_timeout(desktop_plugin);
988 /*******************************************************************************/
990 init_scene_theme(AWallpaperPlugin *desktop_plugin)
993 void (*func)(gpointer);
994 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
996 (*func)(desktop_plugin);
999 fprintf(stderr, "Init_scene_theme\n");
1000 void (*func)(gpointer);
1001 func = desktop_plugin->priv->scene_func;
1003 fprintf(stderr, "Success init_scene_theme\n");
1004 (*func)(desktop_plugin);