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 (!strcmp(desktop_plugin->priv->theme,"Flash")){
92 kill (desktop_plugin->priv->podpid, SIGKILL);
95 if (wait(&status) == desktop_plugin->priv->podpid)
98 desktop_plugin->priv->podpid = -1;
99 desktop_plugin->priv->running = FALSE;
102 /*******************************************************************************/
104 reload_scene(AWallpaperPlugin *desktop_plugin)
106 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
107 destroy_scene(desktop_plugin);
108 fill_priv(desktop_plugin->priv);
109 gtk_widget_destroy(desktop_plugin->priv->window);
110 if (desktop_plugin->priv->one_in_all_view && desktop_plugin->priv->view >1)
112 create_xwindow(desktop_plugin->priv);
113 init_scene_theme(desktop_plugin);
115 /*******************************************************************************/
117 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
122 gint now = time(NULL);
124 gchar *bgfile = NULL;
125 gint sizes1[4] = {57, 76, 43, 50},
128 /* fprintf(stderr, "init scene accel\n"); */
129 scene = g_new0(Scene, 1);
130 scene->actors = NULL;
131 desktop_plugin->priv->scene = scene;
133 bgfile = g_strdup_printf("/home/user/.backgrounds/background-%i.png", desktop_plugin->priv->view);
134 actor = init_object(desktop_plugin, "original", bgfile,
136 TRUE, TRUE, 100, 255,
138 scene->actors = g_slist_append(scene->actors, actor);
140 child = g_ptr_array_sized_new(16);
142 for (j= 0; j<4; j++){
144 str = g_strdup_printf("tape%i.png", n+1);
145 actor = init_object(desktop_plugin, "tape", str,
146 fast_rnd(800), fast_rnd(480), 2+fast_rnd(6), 800, sizes1[n],
147 TRUE, TRUE, 100, 255,
149 scene->actors = g_slist_append(scene->actors, actor);
150 g_ptr_array_add(child, actor);
154 actor = init_object(desktop_plugin, "tape", "",
156 FALSE, FALSE, 100, 255,
157 (gpointer)&change_tape, NULL, child);
158 actor->time_start_animation = now;
159 actor->duration_animation = G_MAXINT;
160 scene->actors = g_slist_append(scene->actors, actor);
162 run_long_timeout(desktop_plugin);
164 /*******************************************************************************/
166 parsestring(char *line, char **argv)
168 while (*line != '\0') {
169 while (*line == ' ' || *line == '\n')
170 *line++ = '\0'; /* replace white spaces with 0 */
171 *argv++ = line; /* save the argument position */
172 while (*line != '\0' && *line != ' ' &&
174 line++; /* skip the argument until ... */
176 *argv = '\0'; /* mark the end of argument list */
181 sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){
183 if (!desktop_plugin->priv->visible)
184 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
185 if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT){
186 return (GST_BUS_PASS);
188 if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")){
189 return (GST_BUS_PASS);
191 return (GST_BUS_DROP);
195 /*******************************************************************************/
197 bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin)
199 switch (GST_MESSAGE_TYPE (msg))
201 case GST_MESSAGE_EOS:
202 if (desktop_plugin->priv->rich_animation){
204 GstClockTime nach = (GstClockTime)(0 * GST_MSECOND);
205 if (!gst_element_seek(desktop_plugin->priv->pipeline, 1.0, GST_FORMAT_TIME,
206 (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET,
207 nach, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
208 fprintf(stderr,"ERROR in seek\n");
210 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
213 if (desktop_plugin->priv->pipeline){
214 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
215 gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
219 case GST_MESSAGE_ERROR: break;
225 /*******************************************************************************/
227 init_scene_External(AWallpaperPlugin *desktop_plugin){
229 char* child_argv[2048];
230 char *run_string = NULL;
231 gchar *exec_path = NULL,
235 *gtk_socket_id = NULL,
239 *theme_string_parametr1 = NULL,
240 *straddedstring = NULL,
244 if (!desktop_plugin->priv->visible)
247 exec_path = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "exec_path"));
248 window_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_id"));
249 view = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "view"));
250 window_name = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_name"));
251 gtk_socket_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "gtk_socket_id"));
252 addedstring = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "added_string"));
256 strwin = g_strdup_printf(" %s %i", window_id, (gint)GDK_WINDOW_XID(desktop_plugin->priv->window->window));
260 strsocket = g_strdup_printf(" %s %i", gtk_socket_id, (int)gtk_socket_get_id (GTK_SOCKET (desktop_plugin->priv->video_socket)));
265 strview = g_strdup_printf(" %s %i", view, desktop_plugin->priv->view);
270 straddedstring = g_strdup_printf(" %s", addedstring);
274 if (desktop_plugin->priv->theme_string_parametr1){
275 theme_string_parametr1 = g_strdup_printf(" %s", desktop_plugin->priv->theme_string_parametr1);
277 theme_string_parametr1 = "";
279 run_string = g_strdup_printf("%s%s%s%s%s%s", exec_path, strwin, strview, strsocket, straddedstring, theme_string_parametr1);
280 fprintf(stderr, "runs string = %s\n", run_string);
281 parsestring(run_string, child_argv);
283 desktop_plugin->priv->running = TRUE;
284 desktop_plugin->priv->podpid = fork();
285 if (desktop_plugin->priv->podpid == 0){
286 execvp(child_argv[0], child_argv);
287 fprintf(stderr,"Problem with new podprocess");
291 fprintf(stderr, "window name = %s\n", window_name);
293 /* Do 10 trying to search of window */
294 for (i=0; i<10; i++){
296 id_xwindow = Window_With_Name(GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
297 RootWindow( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window), XDefaultScreen( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window))),
299 fprintf(stderr,"name %s %i %i\n", window_name, id_xwindow, i);
301 if (desktop_plugin->priv->one_in_all_view)
302 set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
305 set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
306 id_xwindow, desktop_plugin->priv->view);
307 /* gtk_widget_destroy(desktop_plugin->priv->window); */
313 /*******************************************************************************/
315 cb_timeout0(AWallpaperPlugin *desktop_plugin) {
317 if (!desktop_plugin || !desktop_plugin->priv->pipeline)
319 if (desktop_plugin->priv->theme_int_parametr1 == 0){
320 if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
321 GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
322 desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
323 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
324 fprintf(stderr,"Error in seek:\n");
328 if (gst_element_get_state (desktop_plugin->priv->pipeline, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE)
331 if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
332 GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
333 desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
334 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
335 fprintf(stderr,"Error in seek:\n");
339 /*******************************************************************************/
341 init_scene_Video(AWallpaperPlugin *desktop_plugin)
344 GstElement *videosink;
345 gchar *file_plus_uri;
348 /* fprintf(stderr, "init scene Video \n"); */
349 desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
350 bin = gst_element_factory_make ("playbin2", "bin");
351 videosink = gst_element_factory_make ("ximagesink", "videosink");
352 g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
353 gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
357 bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
358 gst_bus_add_watch(bus, (GstBusFunc)bus_call, desktop_plugin);
359 gst_object_unref (bus);
361 file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
362 g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
364 /* Doesn't work in real device. Hardware volume buttons can to change volume for mutted track */
366 if (!desktop_plugin->priv->theme_bool_parametr1)
367 g_object_set (G_OBJECT (bin), "mute", TRUE, NULL );
369 g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
371 if (GST_IS_X_OVERLAY (videosink))
372 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
374 if (desktop_plugin->priv->visible){
375 g_timeout_add(50, (GSourceFunc)cb_timeout0, desktop_plugin);
376 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
379 //gst_element_get_state(deskddtop_plugin->priv->pipeline, NULL, NULL, 100 * GST_MSECOND);
382 /*******************************************************************************/
384 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
389 gint now = time(NULL);
392 if (desktop_plugin->priv->rich_animation){
400 /* fprintf(stderr, "init scene2 \n"); */
401 scene = g_new0(Scene, 1);
402 //scene.daytime = get_daytime();
403 scene->actors = NULL;
404 desktop_plugin->priv->scene = scene;
406 actor = init_object(desktop_plugin, "background", "bg.png",
408 TRUE, TRUE, 100, 255,
410 scene->actors = g_slist_append(scene->actors, actor);
412 actor = init_object(desktop_plugin, "symbols", "symbols.png",
414 TRUE, TRUE, 100, 255,
416 scene->actors = g_slist_append(scene->actors, actor);
418 child = g_ptr_array_sized_new(4);
419 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
421 TRUE, TRUE, 100, 255,
423 //actor->time_start_animation = now;
424 //actor->duration_animation = G_MAXINT;
425 scene->actors = g_slist_append(scene->actors, actor);
426 g_ptr_array_add(child, actor);
428 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
430 TRUE, TRUE, 100, 255,
432 //actor->time_start_animation = now;
433 //actor->duration_animation = G_MAXINT;
434 scene->actors = g_slist_append(scene->actors, actor);
435 g_ptr_array_add(child, actor);
437 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
439 TRUE, TRUE, 100, 255,
441 //actor->time_start_animation = now;
442 //actor->duration_animation = G_MAXINT;
443 scene->actors = g_slist_append(scene->actors, actor);
444 g_ptr_array_add(child, actor);
446 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
448 TRUE, TRUE, 100, 255,
450 //actor->time_start_animation = now;
451 //actor->duration_animation = G_MAXINT;
452 scene->actors = g_slist_append(scene->actors, actor);
453 g_ptr_array_add(child, actor);
455 actor = init_object(desktop_plugin, "layers", "",
457 FALSE, FALSE, 100, 255,
458 (gpointer)&change_layer, NULL, child);
459 actor->time_start_animation = now;
460 actor->duration_animation = G_MAXINT;
461 scene->actors = g_slist_append(scene->actors, actor);
463 run_long_timeout(desktop_plugin);
466 /*******************************************************************************/
467 /* Init Modern Scene */
469 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
473 gint now = time(NULL);
478 /* fprintf(stderr, "init scene \n"); */
479 scene = g_new0(Scene, 1);
480 scene->daytime = get_daytime();
481 scene->actors = NULL;
482 scene->wind_orientation = -1;
483 scene->wind_angle = 0.3;
484 /* init value for random */
485 scene->seed = time(NULL);
486 scene->notification = TRUE;
487 desktop_plugin->priv->scene = scene;
488 actor = init_object(desktop_plugin, "sky", "sky0.png",
490 TRUE , TRUE, 100, 255,
491 (gpointer)&change_static_actor, NULL, NULL);
492 scene->actors = g_slist_append(scene->actors, actor);
493 change_static_actor(actor, desktop_plugin);
495 actor = init_object(desktop_plugin, "sun", "sun.png",
497 FALSE, FALSE, 100, 255,
498 (gpointer)&change_sun, NULL, NULL);
499 actor->time_start_animation = now;
500 actor->duration_animation = G_MAXINT;
501 change_sun(actor, desktop_plugin);
502 scene->actors = g_slist_append(scene->actors, actor);
504 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
505 // TRUE, 100, 255, NULL, NULL);
506 //scene.actors = g_slist_append(scene.actors, actor);
508 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
509 0, fast_rnd(300)-97, 7, 150, 97,
510 FALSE, FALSE, 100, 255,
511 (gpointer)&change_cloud, NULL, NULL);
512 actor->time_start_animation = now + fast_rnd(20);
513 actor->duration_animation = 3*60;
514 scene->actors = g_slist_append(scene->actors, actor);
516 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
517 0, fast_rnd(300)-75, 7, 188, 75,
518 FALSE, FALSE, 100, 255,
519 (gpointer)&change_cloud, NULL, NULL);
520 actor->time_start_animation = now + fast_rnd(40)+10;
521 actor->duration_animation = 3*60;
522 scene->actors = g_slist_append(scene->actors, actor);
524 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
525 0, fast_rnd(300)-75, 7, 150, 75,
526 FALSE, FALSE, 100, 255,
527 (gpointer)&change_cloud, NULL, NULL);
528 actor->time_start_animation = now + fast_rnd(60) + 20;
529 actor->duration_animation = 5*60;
530 scene->actors = g_slist_append(scene->actors, actor);
533 actor = init_object(desktop_plugin, "town", "town0.png",
535 TRUE, TRUE, 100, 255,
536 (gpointer)&change_static_actor, NULL, NULL);
537 change_static_actor(actor, desktop_plugin);
538 scene->actors = g_slist_append(scene->actors, actor);
540 actor = init_object(desktop_plugin, "stend", "stend0.png",
541 452, 166, 9, 300, 305,
542 TRUE, TRUE, 100, 255,
543 (gpointer)&change_static_actor, NULL, NULL);
544 change_static_actor(actor, desktop_plugin);
545 scene->actors = g_slist_append(scene->actors, actor);
548 child = g_ptr_array_sized_new(4);
549 actor = init_object(desktop_plugin, "call", "call.png",
551 FALSE, TRUE, 100, 255,
553 scene->actors = g_slist_append(scene->actors, actor);
554 g_ptr_array_add(child, actor);
556 actor = init_object(desktop_plugin, "chat", "chat.png",
558 FALSE, TRUE, 100, 255,
560 scene->actors = g_slist_append(scene->actors, actor);
561 g_ptr_array_add(child, actor);
563 actor = init_object(desktop_plugin, "mail", "mail.png",
565 FALSE, TRUE, 100, 255,
567 scene->actors = g_slist_append(scene->actors, actor);
568 g_ptr_array_add(child, actor);
570 actor = init_object(desktop_plugin, "sms", "sms.png",
572 FALSE, TRUE, 100, 255,
574 scene->actors = g_slist_append(scene->actors, actor);
575 g_ptr_array_add(child, actor);
577 actor = init_object(desktop_plugin, "billboard_text", "",
578 470, 174, 9, 300, 108,
579 FALSE, FALSE, 100, 255,
580 (gpointer)&change_billboard, NULL, child);
581 create_hildon_actor_text(actor, desktop_plugin);
582 //actor->time_start_animation = time(NULL) + 20;
583 change_billboard(actor, desktop_plugin);
584 scene->actors = g_slist_append(scene->actors, actor);
586 actor = init_object(desktop_plugin, "tram", "tram.png",
587 -300, 225, 10, 350, 210,
588 FALSE, FALSE, 100, 255,
589 (gpointer)&change_tram, NULL, NULL);
590 actor->time_start_animation = time(NULL) + fast_rnd(10);
591 actor->duration_animation = 60;
592 scene->actors = g_slist_append(scene->actors, actor);
594 actor = init_object(desktop_plugin, "border", "border0.png",
595 0, 480-79, 11, 800, 79,
596 TRUE, TRUE, 100, 255,
597 (gpointer)&change_static_actor_with_corner, NULL, NULL);
598 change_static_actor_with_corner(actor, desktop_plugin);
599 scene->actors = g_slist_append(scene->actors, actor);
601 actor = init_object(desktop_plugin, "moon", "moon1.png",
603 FALSE, FALSE, 100, 255,
604 (gpointer)&change_moon, NULL, NULL);
605 change_moon(actor, desktop_plugin);
606 scene->actors = g_slist_append(scene->actors, actor);
608 actor = init_object(desktop_plugin, "wind", "",
610 FALSE, FALSE, 100, 255,
611 (gpointer)&change_wind, NULL, NULL);
612 change_wind(actor, desktop_plugin);
613 scene->actors = g_slist_append(scene->actors, actor);
615 /* windows in 4-th house */
655 for (i=0; i<13; i++){
656 actor = init_object(desktop_plugin, "window1", "window1.png",
657 winds[i][0], winds[i][1], 8, 8, 10,
658 FALSE, FALSE, 100, 255,
659 (gpointer)&change_window1, NULL, NULL);
660 //change_window1(actor, desktop_plugin);
661 actor->time_start_animation = now + fast_rnd(30);
662 scene->actors = g_slist_append(scene->actors, actor);
666 /* windows in 1-th house */
692 actor = init_object(desktop_plugin, "window2", "window2.png",
693 winds[i][0], winds[i][1], 8, 8, 10,
694 FALSE, FALSE, 100, 255,
695 (gpointer)&change_window1, NULL, NULL);
696 //change_window1(actor, desktop_plugin);
697 actor->time_start_animation = now + fast_rnd(30);
698 scene->actors = g_slist_append(scene->actors, actor);
702 /* windows in 3-th house */
734 for (i=0; i<10; i++){
735 actor = init_object(desktop_plugin, "window3", "window3.png",
736 winds[i][0], winds[i][1], 8, 8, 10,
737 FALSE, FALSE, 100, 255,
738 (gpointer)&change_window1, NULL, NULL);
739 //change_window1(actor, desktop_plugin);
740 actor->time_start_animation = now + fast_rnd(30);
741 scene->actors = g_slist_append(scene->actors, actor);
745 /* windows in 5-th house */
769 actor = init_object(desktop_plugin, "window4", "window4.png",
770 winds[i][0], winds[i][1], 8, 8, 10,
771 FALSE, FALSE, 100, 255,
772 (gpointer)&change_window1, NULL, NULL);
773 //change_window1(actor, desktop_plugin);
774 actor->time_start_animation = now + fast_rnd(30);
775 scene->actors = g_slist_append(scene->actors, actor);
779 /* windows in 6-th house */
800 actor = init_object(desktop_plugin, "window5", "window5.png",
801 winds[i][0], winds[i][1], 8, 8, 10,
802 FALSE, FALSE, 100, 255,
803 (gpointer)&change_window1, NULL, NULL);
804 //change_window1(actor, desktop_plugin);
805 actor->time_start_animation = now + fast_rnd(30);
806 scene->actors = g_slist_append(scene->actors, actor);
809 run_long_timeout(desktop_plugin);
812 anim = g_new0(Animation, 1);
815 anim->func_change = &change_tram;
816 anim->func_time = NULL;
817 anim->timestart = time(NULL);
820 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
823 /*******************************************************************************/
824 /* Init Berlin Scene */
826 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
828 Actor *actor, *actor1, *actor2;
830 gint now = time(NULL);
833 GPtrArray *child = NULL;
835 scene = g_new0(Scene, 1);
836 scene->daytime = get_daytime();
837 scene->actors = NULL;
838 scene->wind_orientation = -1;
839 scene->wind_angle = 0.3;
840 /* init value for random */
841 scene->seed = time(NULL);
842 desktop_plugin->priv->scene = scene;
844 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
845 TRUE, TRUE, 100, 255,
846 (gpointer)&change_static_actor, NULL, NULL);
847 change_static_actor(actor, desktop_plugin);
848 scene->actors = g_slist_append(scene->actors, actor);
851 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
852 FALSE, FALSE, 100, 255,
853 (gpointer)&change_sun, NULL, NULL);
854 actor->time_start_animation = time(NULL);
855 actor->duration_animation = G_MAXINT;
856 change_sun(actor, desktop_plugin);
857 scene->actors = g_slist_append(scene->actors, actor);
860 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
861 TRUE, 100, 255, NULL, NULL);
862 scene.actors = g_slist_append(scene.actors, actor);
865 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
866 FALSE, FALSE, 100, 255,
867 (gpointer)&change_moon, NULL, NULL);
868 change_moon(actor, desktop_plugin);
869 scene->actors = g_slist_append(scene->actors, actor);
871 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
872 FALSE, FALSE, 100, 255,
873 (gpointer)&change_cloud, NULL, NULL);
874 actor->time_start_animation = now + fast_rnd(30) + 10;
875 actor->duration_animation = 3*60;
876 scene->actors = g_slist_append(scene->actors, actor);
878 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
879 FALSE, FALSE, 100, 255,
880 (gpointer)&change_cloud, NULL, NULL);
881 actor->time_start_animation = now + fast_rnd(10);
882 actor->duration_animation = 3*60;
883 scene->actors = g_slist_append(scene->actors, actor);
885 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
886 FALSE, FALSE, 100, 255,
887 (gpointer)&change_cloud, NULL, NULL);
888 actor->time_start_animation = now + fast_rnd(60) + 20;
889 actor->duration_animation = 5*60;
890 scene->actors = g_slist_append(scene->actors, actor);
893 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
894 FALSE, FALSE, 100, 255,
895 (gpointer)&change_plane2, NULL, NULL);
896 actor->time_start_animation = now + fast_rnd(40) + 20;
897 actor->duration_animation = 60;
898 scene->actors = g_slist_append(scene->actors, actor);
900 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
901 FALSE, FALSE, 100, 255,
902 (gpointer)&change_plane1, NULL, NULL);
903 actor->time_start_animation = now + fast_rnd(20);
904 actor->duration_animation = 30;
905 scene->actors = g_slist_append(scene->actors, actor);
907 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
908 TRUE, TRUE, 100, 255,
909 (gpointer)&change_static_actor_with_corner, NULL, NULL);
910 change_static_actor_with_corner(actor, desktop_plugin);
911 scene->actors = g_slist_append(scene->actors, actor);
913 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
914 FALSE, FALSE, 100, 255,
915 (gpointer)&change_wind, NULL, NULL);
916 change_wind(actor, desktop_plugin);
917 scene->actors = g_slist_append(scene->actors, actor);
919 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
920 486, 425, 10, 18, 38,
921 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
922 //actor->time_start_animation = now + fast_rnd(30) + 10;
923 scene->actors = g_slist_append(scene->actors, actor1);
925 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
926 486, 425, 10, 18, 38,
927 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
928 //actor->time_start_animation = now + fast_rnd(30) + 10;
929 scene->actors = g_slist_append(scene->actors, actor2);
930 child = g_ptr_array_sized_new(2);
931 g_ptr_array_add(child, actor1);
932 g_ptr_array_add(child, actor2);
933 actor = init_object(desktop_plugin, "signal", "",
934 486, 425, 10, 18, 38,
935 FALSE, FALSE, 100, 255,
936 (gpointer)&change_signal, NULL, child);
937 actor->time_start_animation = now + fast_rnd(30) + 10;
938 scene->actors = g_slist_append(scene->actors, actor);
979 for (i=0; i<13; i++){
980 actor = init_object(desktop_plugin, "window", "window.png",
981 winds[i][0], winds[i][1], 10, 8, 9,
982 FALSE, TRUE, 100, 255,
983 (gpointer)&change_window1, NULL, NULL);
984 //change_window1(actor, desktop_plugin);
985 actor->time_start_animation = now + fast_rnd(30);
986 scene->actors = g_slist_append(scene->actors, actor);
990 run_long_timeout(desktop_plugin);
993 /*******************************************************************************/
995 init_scene_theme(AWallpaperPlugin *desktop_plugin)
998 void (*func)(gpointer);
999 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
1001 (*func)(desktop_plugin);
1004 fprintf(stderr, "Init_scene_theme\n");
1005 void (*func)(gpointer);
1006 func = desktop_plugin->priv->scene_func;
1008 fprintf(stderr, "Success init_scene_theme\n");
1009 (*func)(desktop_plugin);