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"
27 /* This code form X11-utils */
28 Window Window_With_Name( Display *dpy, Window top, char *name)
30 Window *children, dummy;
31 unsigned int nchildren;
36 XClassHint *class_hint;
37 class_hint = XAllocClassHint();
38 XGetClassHint(dpy, top, class_hint);
39 if (class_hint->res_name && name && !strcmp(class_hint->res_name, name)){
40 XFree(class_hint->res_class);
41 XFree(class_hint->res_name);
44 XFree(class_hint->res_class);
45 XFree(class_hint->res_name);
47 if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
50 if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
53 for (i=0; i<nchildren; i++) {
54 w = Window_With_Name(dpy, children[i], name);
58 if (children) XFree ((char *)children);
62 /*******************************************************************************/
65 destroy_scene(AWallpaperPlugin *desktop_plugin)
69 if (desktop_plugin->priv->scene){
70 GSList * tmp = desktop_plugin->priv->scene->actors;
72 destroy_actor(tmp->data);
73 tmp = g_slist_next(tmp);
77 desktop_plugin->priv->scene->actors = NULL;
78 if (desktop_plugin->priv->scene){
79 g_free(desktop_plugin->priv->scene);
80 desktop_plugin->priv->scene = NULL;
83 if (desktop_plugin->priv->pipeline){
84 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
85 gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
86 desktop_plugin->priv->pipeline = NULL;
88 if (desktop_plugin->priv->podpid > 1){
89 kill (desktop_plugin->priv->podpid, SIGTERM);
91 if (!strcmp(desktop_plugin->priv->theme,"Flash")){
93 kill (desktop_plugin->priv->podpid, SIGKILL);
96 if (wait(&status) == desktop_plugin->priv->podpid)
99 desktop_plugin->priv->podpid = -1;
100 desktop_plugin->priv->running = FALSE;
103 /*******************************************************************************/
105 reload_scene(AWallpaperPlugin *desktop_plugin)
107 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
108 destroy_scene(desktop_plugin);
109 fill_priv(desktop_plugin->priv);
110 gtk_widget_destroy(desktop_plugin->priv->window);
111 if (desktop_plugin->priv->one_in_all_view && desktop_plugin->priv->view >1)
113 create_xwindow(desktop_plugin->priv);
114 init_scene_theme(desktop_plugin);
116 /*******************************************************************************/
118 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
123 gint now = time(NULL);
125 gchar *bgfile = NULL;
126 gint sizes1[4] = {57, 76, 43, 50},
129 /* fprintf(stderr, "init scene accel\n"); */
130 scene = g_new0(Scene, 1);
131 scene->actors = NULL;
132 desktop_plugin->priv->scene = scene;
134 bgfile = g_strdup_printf("/home/user/.backgrounds/background-%i.png", desktop_plugin->priv->view);
135 actor = init_object(desktop_plugin, "original", bgfile,
137 TRUE, TRUE, 100, 255,
139 scene->actors = g_slist_append(scene->actors, actor);
141 child = g_ptr_array_sized_new(16);
143 for (j= 0; j<4; j++){
145 str = g_strdup_printf("tape%i.png", n+1);
146 actor = init_object(desktop_plugin, "tape", str,
147 fast_rnd(800), fast_rnd(480), 2+fast_rnd(6), 800, sizes1[n],
148 TRUE, TRUE, 100, 255,
150 scene->actors = g_slist_append(scene->actors, actor);
151 g_ptr_array_add(child, actor);
155 actor = init_object(desktop_plugin, "tape", "",
157 FALSE, FALSE, 100, 255,
158 (gpointer)&change_tape, NULL, child);
159 actor->time_start_animation = now;
160 actor->duration_animation = G_MAXINT;
161 scene->actors = g_slist_append(scene->actors, actor);
163 run_long_timeout(desktop_plugin);
165 /*******************************************************************************/
167 parsestring(char *line, char **argv)
169 while (*line != '\0') {
170 while (*line == ' ' || *line == '\n')
171 *line++ = '\0'; /* replace white spaces with 0 */
172 *argv++ = line; /* save the argument position */
173 while (*line != '\0' && *line != ' ' &&
175 line++; /* skip the argument until ... */
177 *argv = '\0'; /* mark the end of argument list */
182 sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){
184 if (!desktop_plugin->priv->visible)
185 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
186 if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT){
187 return (GST_BUS_PASS);
189 if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")){
190 return (GST_BUS_PASS);
192 return (GST_BUS_DROP);
196 /*******************************************************************************/
198 bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin)
200 switch (GST_MESSAGE_TYPE (msg))
202 case GST_MESSAGE_EOS:
203 if (desktop_plugin->priv->rich_animation){
205 GstClockTime nach = (GstClockTime)(0 * GST_MSECOND);
206 if (!gst_element_seek(desktop_plugin->priv->pipeline, 1.0, GST_FORMAT_TIME,
207 (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET,
208 nach, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
209 fprintf(stderr,"ERROR in seek\n");
211 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
214 if (desktop_plugin->priv->pipeline){
215 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
216 gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
220 case GST_MESSAGE_ERROR: break;
226 /*******************************************************************************/
228 init_scene_External(AWallpaperPlugin *desktop_plugin){
230 char* child_argv[2048];
231 char *run_string = NULL;
232 gchar *exec_path = NULL,
236 *gtk_socket_id = NULL,
240 *theme_string_parametr1 = NULL,
241 *straddedstring = NULL,
245 if (!desktop_plugin->priv->visible)
248 exec_path = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "exec_path"));
249 window_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_id"));
250 view = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "view"));
251 window_name = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_name"));
252 gtk_socket_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "gtk_socket_id"));
253 addedstring = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "added_string"));
257 strwin = g_strdup_printf(" %s %i", window_id, (gint)GDK_WINDOW_XID(desktop_plugin->priv->window->window));
261 strsocket = g_strdup_printf(" %s %i", gtk_socket_id, (int)gtk_socket_get_id (GTK_SOCKET (desktop_plugin->priv->video_socket)));
266 strview = g_strdup_printf(" %s %i", view, desktop_plugin->priv->view);
271 straddedstring = g_strdup_printf(" %s", addedstring);
275 if (desktop_plugin->priv->theme_string_parametr1){
276 theme_string_parametr1 = g_strdup_printf(" %s", desktop_plugin->priv->theme_string_parametr1);
278 theme_string_parametr1 = "";
280 run_string = g_strdup_printf("%s%s%s%s%s%s", exec_path, strwin, strview, strsocket, straddedstring, theme_string_parametr1);
281 fprintf(stderr, "runs string = %s\n", run_string);
282 parsestring(run_string, child_argv);
284 desktop_plugin->priv->running = TRUE;
285 desktop_plugin->priv->podpid = fork();
286 if (desktop_plugin->priv->podpid == 0){
287 execvp(child_argv[0], child_argv);
288 fprintf(stderr,"Problem with new podprocess");
292 fprintf(stderr, "window name = %s\n", window_name);
294 /* Do 10 trying to search of window */
295 for (i=0; i<10; i++){
297 id_xwindow = Window_With_Name(GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
298 RootWindow( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window), XDefaultScreen( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window))),
300 fprintf(stderr,"name %s %i %i\n", window_name, id_xwindow, i);
302 if (desktop_plugin->priv->one_in_all_view)
303 set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
306 set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
307 id_xwindow, desktop_plugin->priv->view);
308 /* gtk_widget_destroy(desktop_plugin->priv->window); */
314 /*******************************************************************************/
316 cb_timeout0(AWallpaperPlugin *desktop_plugin) {
318 if (!desktop_plugin || !desktop_plugin->priv->pipeline)
320 if (desktop_plugin->priv->theme_int_parametr1 == 0){
321 if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
322 GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
323 desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
324 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
325 fprintf(stderr,"Error in seek:\n");
329 if (gst_element_get_state (desktop_plugin->priv->pipeline, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE)
332 if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
333 GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
334 desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
335 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
336 fprintf(stderr,"Error in seek:\n");
340 /*******************************************************************************/
342 init_scene_Video(AWallpaperPlugin *desktop_plugin)
345 GstElement *videosink;
346 gchar *file_plus_uri;
349 /* fprintf(stderr, "init scene Video \n"); */
350 desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
351 bin = gst_element_factory_make ("playbin2", "bin");
352 videosink = gst_element_factory_make ("ximagesink", "videosink");
353 g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
354 gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
358 bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
359 gst_bus_add_watch(bus, (GstBusFunc)bus_call, desktop_plugin);
360 gst_object_unref (bus);
362 file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
363 g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
365 /* Doesn't work in real device. Hardware volume buttons can to change volume for mutted track */
367 if (!desktop_plugin->priv->theme_bool_parametr1)
368 g_object_set (G_OBJECT (bin), "mute", TRUE, NULL );
370 g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
372 if (GST_IS_X_OVERLAY (videosink))
373 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
375 if (desktop_plugin->priv->visible){
376 g_timeout_add(50, (GSourceFunc)cb_timeout0, desktop_plugin);
377 gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
380 //gst_element_get_state(deskddtop_plugin->priv->pipeline, NULL, NULL, 100 * GST_MSECOND);
383 /*******************************************************************************/
385 init_scene_Slideshow(AWallpaperPlugin *desktop_plugin)
387 gchar *ext, *file, *str, *bgfile;
394 gint now = time(NULL);
395 GSList *store = NULL;
398 fprintf(stderr, "init scene Slideshow %d %s\n", desktop_plugin->priv->theme_int_parametr1,
399 desktop_plugin->priv->theme_string_parametr1);
401 scene = g_new0(Scene, 1);
402 scene->actors = NULL;
403 desktop_plugin->priv->scene = scene;
405 dir_fd = opendir(desktop_plugin->priv->theme_string_parametr1);
407 while((dp = readdir(dir_fd))){
408 if(!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
411 ext = strrchr(dp->d_name, '.') + 1; /* get file extension */
413 /* lowercase string */
414 for(i=0; ext[i]; i++)
415 ext[i] = tolower(ext[i]);
416 if (strcmp(ext, "jpg") && strcmp(ext, "png"))
418 if(dp->d_type == DT_REG || dp->d_type == DT_LNK){
419 str = g_strdup_printf("%s/%s", desktop_plugin->priv->theme_string_parametr1, dp->d_name);
420 store = g_slist_append(store, str);
427 bgfile = g_strdup_printf("/home/user/.backgrounds/background-%i.png", desktop_plugin->priv->view);
428 actor = init_object(desktop_plugin, "original", bgfile,
430 TRUE, TRUE, 100, 255,
432 scene->actors = g_slist_append(scene->actors, actor);
434 child = g_ptr_array_sized_new(num);
436 actor = init_object(desktop_plugin, "original", store->data,
438 FALSE, FALSE, 100, 0,
440 scene->actors = g_slist_append(scene->actors, actor);
441 g_ptr_array_add(child, actor);
442 store = g_slist_next(store);
444 actor = init_object(desktop_plugin, "images", "",
446 FALSE, FALSE, num, -1,
447 (gpointer)&change_slideshow, NULL, child);
448 actor->time_start_animation = now;
449 actor->duration_animation = 5;
450 scene->actors = g_slist_append(scene->actors, actor);
451 desktop_plugin->priv->rich_animation = TRUE;
452 run_long_timeout(desktop_plugin);
455 /*******************************************************************************/
457 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
462 gint now = time(NULL);
465 if (desktop_plugin->priv->rich_animation){
473 /* fprintf(stderr, "init scene matrix \n"); */
474 scene = g_new0(Scene, 1);
475 //scene.daytime = get_daytime();
476 scene->actors = NULL;
477 desktop_plugin->priv->scene = scene;
479 actor = init_object(desktop_plugin, "background", "bg.png",
481 TRUE, TRUE, 100, 255,
483 scene->actors = g_slist_append(scene->actors, actor);
485 actor = init_object(desktop_plugin, "symbols", "symbols.png",
487 TRUE, TRUE, 100, 255,
489 scene->actors = g_slist_append(scene->actors, actor);
491 child = g_ptr_array_sized_new(4);
492 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
494 TRUE, TRUE, 100, 255,
496 //actor->time_start_animation = now;
497 //actor->duration_animation = G_MAXINT;
498 scene->actors = g_slist_append(scene->actors, actor);
499 g_ptr_array_add(child, actor);
501 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
503 TRUE, TRUE, 100, 255,
505 //actor->time_start_animation = now;
506 //actor->duration_animation = G_MAXINT;
507 scene->actors = g_slist_append(scene->actors, actor);
508 g_ptr_array_add(child, actor);
510 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
512 TRUE, TRUE, 100, 255,
514 //actor->time_start_animation = now;
515 //actor->duration_animation = G_MAXINT;
516 scene->actors = g_slist_append(scene->actors, actor);
517 g_ptr_array_add(child, actor);
519 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
521 TRUE, TRUE, 100, 255,
523 //actor->time_start_animation = now;
524 //actor->duration_animation = G_MAXINT;
525 scene->actors = g_slist_append(scene->actors, actor);
526 g_ptr_array_add(child, actor);
528 actor = init_object(desktop_plugin, "layers", "",
530 FALSE, FALSE, 100, 255,
531 (gpointer)&change_layer, NULL, child);
532 actor->time_start_animation = now;
533 actor->duration_animation = G_MAXINT;
534 scene->actors = g_slist_append(scene->actors, actor);
536 run_long_timeout(desktop_plugin);
539 /*******************************************************************************/
540 /* Init Modern Scene */
542 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
546 gint now = time(NULL);
551 /* fprintf(stderr, "init scene \n"); */
552 scene = g_new0(Scene, 1);
553 scene->daytime = get_daytime();
554 scene->actors = NULL;
555 scene->wind_orientation = -1;
556 scene->wind_angle = 0.3;
557 /* init value for random */
558 scene->seed = time(NULL);
559 scene->notification = TRUE;
560 desktop_plugin->priv->scene = scene;
561 actor = init_object(desktop_plugin, "sky", "sky0.png",
563 TRUE , TRUE, 100, 255,
564 (gpointer)&change_static_actor, NULL, NULL);
565 scene->actors = g_slist_append(scene->actors, actor);
566 change_static_actor(actor, desktop_plugin);
568 actor = init_object(desktop_plugin, "sun", "sun.png",
570 FALSE, FALSE, 100, 255,
571 (gpointer)&change_sun, NULL, NULL);
572 actor->time_start_animation = now;
573 actor->duration_animation = G_MAXINT;
574 change_sun(actor, desktop_plugin);
575 scene->actors = g_slist_append(scene->actors, actor);
577 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
578 // TRUE, 100, 255, NULL, NULL);
579 //scene.actors = g_slist_append(scene.actors, actor);
581 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
582 0, fast_rnd(300)-97, 7, 150, 97,
583 FALSE, FALSE, 100, 255,
584 (gpointer)&change_cloud, NULL, NULL);
585 actor->time_start_animation = now + fast_rnd(20);
586 actor->duration_animation = 3*60;
587 scene->actors = g_slist_append(scene->actors, actor);
589 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
590 0, fast_rnd(300)-75, 7, 188, 75,
591 FALSE, FALSE, 100, 255,
592 (gpointer)&change_cloud, NULL, NULL);
593 actor->time_start_animation = now + fast_rnd(40)+10;
594 actor->duration_animation = 3*60;
595 scene->actors = g_slist_append(scene->actors, actor);
597 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
598 0, fast_rnd(300)-75, 7, 150, 75,
599 FALSE, FALSE, 100, 255,
600 (gpointer)&change_cloud, NULL, NULL);
601 actor->time_start_animation = now + fast_rnd(60) + 20;
602 actor->duration_animation = 5*60;
603 scene->actors = g_slist_append(scene->actors, actor);
606 actor = init_object(desktop_plugin, "town", "town0.png",
608 TRUE, TRUE, 100, 255,
609 (gpointer)&change_static_actor, NULL, NULL);
610 change_static_actor(actor, desktop_plugin);
611 scene->actors = g_slist_append(scene->actors, actor);
613 actor = init_object(desktop_plugin, "stend", "stend0.png",
614 452, 166, 9, 300, 305,
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 child = g_ptr_array_sized_new(4);
622 actor = init_object(desktop_plugin, "call", "call.png",
624 FALSE, TRUE, 100, 255,
626 scene->actors = g_slist_append(scene->actors, actor);
627 g_ptr_array_add(child, actor);
629 actor = init_object(desktop_plugin, "chat", "chat.png",
631 FALSE, TRUE, 100, 255,
633 scene->actors = g_slist_append(scene->actors, actor);
634 g_ptr_array_add(child, actor);
636 actor = init_object(desktop_plugin, "mail", "mail.png",
638 FALSE, TRUE, 100, 255,
640 scene->actors = g_slist_append(scene->actors, actor);
641 g_ptr_array_add(child, actor);
643 actor = init_object(desktop_plugin, "sms", "sms.png",
645 FALSE, TRUE, 100, 255,
647 scene->actors = g_slist_append(scene->actors, actor);
648 g_ptr_array_add(child, actor);
650 actor = init_object(desktop_plugin, "billboard_text", "",
651 470, 174, 9, 300, 108,
652 FALSE, FALSE, 100, 255,
653 (gpointer)&change_billboard, NULL, child);
654 create_hildon_actor_text(actor, desktop_plugin);
655 //actor->time_start_animation = time(NULL) + 20;
656 change_billboard(actor, desktop_plugin);
657 scene->actors = g_slist_append(scene->actors, actor);
659 actor = init_object(desktop_plugin, "tram", "tram.png",
660 -300, 225, 10, 350, 210,
661 FALSE, FALSE, 100, 255,
662 (gpointer)&change_tram, NULL, NULL);
663 actor->time_start_animation = time(NULL) + fast_rnd(10);
664 actor->duration_animation = 60;
665 scene->actors = g_slist_append(scene->actors, actor);
667 actor = init_object(desktop_plugin, "border", "border0.png",
668 0, 480-79, 11, 800, 79,
669 TRUE, TRUE, 100, 255,
670 (gpointer)&change_static_actor_with_corner, NULL, NULL);
671 change_static_actor_with_corner(actor, desktop_plugin);
672 scene->actors = g_slist_append(scene->actors, actor);
674 actor = init_object(desktop_plugin, "moon", "moon1.png",
676 FALSE, FALSE, 100, 255,
677 (gpointer)&change_moon, NULL, NULL);
678 change_moon(actor, desktop_plugin);
679 scene->actors = g_slist_append(scene->actors, actor);
681 actor = init_object(desktop_plugin, "wind", "",
683 FALSE, FALSE, 100, 255,
684 (gpointer)&change_wind, NULL, NULL);
685 change_wind(actor, desktop_plugin);
686 scene->actors = g_slist_append(scene->actors, actor);
688 /* windows in 4-th house */
728 for (i=0; i<13; i++){
729 actor = init_object(desktop_plugin, "window1", "window1.png",
730 winds[i][0], winds[i][1], 8, 8, 10,
731 FALSE, FALSE, 100, 255,
732 (gpointer)&change_window1, NULL, NULL);
733 //change_window1(actor, desktop_plugin);
734 actor->time_start_animation = now + fast_rnd(30);
735 scene->actors = g_slist_append(scene->actors, actor);
739 /* windows in 1-th house */
765 actor = init_object(desktop_plugin, "window2", "window2.png",
766 winds[i][0], winds[i][1], 8, 8, 10,
767 FALSE, FALSE, 100, 255,
768 (gpointer)&change_window1, NULL, NULL);
769 //change_window1(actor, desktop_plugin);
770 actor->time_start_animation = now + fast_rnd(30);
771 scene->actors = g_slist_append(scene->actors, actor);
775 /* windows in 3-th house */
807 for (i=0; i<10; i++){
808 actor = init_object(desktop_plugin, "window3", "window3.png",
809 winds[i][0], winds[i][1], 8, 8, 10,
810 FALSE, FALSE, 100, 255,
811 (gpointer)&change_window1, NULL, NULL);
812 //change_window1(actor, desktop_plugin);
813 actor->time_start_animation = now + fast_rnd(30);
814 scene->actors = g_slist_append(scene->actors, actor);
818 /* windows in 5-th house */
842 actor = init_object(desktop_plugin, "window4", "window4.png",
843 winds[i][0], winds[i][1], 8, 8, 10,
844 FALSE, FALSE, 100, 255,
845 (gpointer)&change_window1, NULL, NULL);
846 //change_window1(actor, desktop_plugin);
847 actor->time_start_animation = now + fast_rnd(30);
848 scene->actors = g_slist_append(scene->actors, actor);
852 /* windows in 6-th house */
873 actor = init_object(desktop_plugin, "window5", "window5.png",
874 winds[i][0], winds[i][1], 8, 8, 10,
875 FALSE, FALSE, 100, 255,
876 (gpointer)&change_window1, NULL, NULL);
877 //change_window1(actor, desktop_plugin);
878 actor->time_start_animation = now + fast_rnd(30);
879 scene->actors = g_slist_append(scene->actors, actor);
882 run_long_timeout(desktop_plugin);
885 anim = g_new0(Animation, 1);
888 anim->func_change = &change_tram;
889 anim->func_time = NULL;
890 anim->timestart = time(NULL);
893 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
896 /*******************************************************************************/
897 /* Init Berlin Scene */
899 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
901 Actor *actor, *actor1, *actor2;
903 gint now = time(NULL);
906 GPtrArray *child = NULL;
908 scene = g_new0(Scene, 1);
909 scene->daytime = get_daytime();
910 scene->actors = NULL;
911 scene->wind_orientation = -1;
912 scene->wind_angle = 0.3;
913 /* init value for random */
914 scene->seed = time(NULL);
915 desktop_plugin->priv->scene = scene;
917 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
918 TRUE, TRUE, 100, 255,
919 (gpointer)&change_static_actor, NULL, NULL);
920 change_static_actor(actor, desktop_plugin);
921 scene->actors = g_slist_append(scene->actors, actor);
924 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
925 FALSE, FALSE, 100, 255,
926 (gpointer)&change_sun, NULL, NULL);
927 actor->time_start_animation = time(NULL);
928 actor->duration_animation = G_MAXINT;
929 change_sun(actor, desktop_plugin);
930 scene->actors = g_slist_append(scene->actors, actor);
933 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
934 TRUE, 100, 255, NULL, NULL);
935 scene.actors = g_slist_append(scene.actors, actor);
938 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
939 FALSE, FALSE, 100, 255,
940 (gpointer)&change_moon, NULL, NULL);
941 change_moon(actor, desktop_plugin);
942 scene->actors = g_slist_append(scene->actors, actor);
944 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
945 FALSE, FALSE, 100, 255,
946 (gpointer)&change_cloud, NULL, NULL);
947 actor->time_start_animation = now + fast_rnd(30) + 10;
948 actor->duration_animation = 3*60;
949 scene->actors = g_slist_append(scene->actors, actor);
951 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
952 FALSE, FALSE, 100, 255,
953 (gpointer)&change_cloud, NULL, NULL);
954 actor->time_start_animation = now + fast_rnd(10);
955 actor->duration_animation = 3*60;
956 scene->actors = g_slist_append(scene->actors, actor);
958 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
959 FALSE, FALSE, 100, 255,
960 (gpointer)&change_cloud, NULL, NULL);
961 actor->time_start_animation = now + fast_rnd(60) + 20;
962 actor->duration_animation = 5*60;
963 scene->actors = g_slist_append(scene->actors, actor);
966 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
967 FALSE, FALSE, 100, 255,
968 (gpointer)&change_plane2, NULL, NULL);
969 actor->time_start_animation = now + fast_rnd(40) + 20;
970 actor->duration_animation = 60;
971 scene->actors = g_slist_append(scene->actors, actor);
973 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
974 FALSE, FALSE, 100, 255,
975 (gpointer)&change_plane1, NULL, NULL);
976 actor->time_start_animation = now + fast_rnd(20);
977 actor->duration_animation = 30;
978 scene->actors = g_slist_append(scene->actors, actor);
980 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
981 TRUE, TRUE, 100, 255,
982 (gpointer)&change_static_actor_with_corner, NULL, NULL);
983 change_static_actor_with_corner(actor, desktop_plugin);
984 scene->actors = g_slist_append(scene->actors, actor);
986 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
987 FALSE, FALSE, 100, 255,
988 (gpointer)&change_wind, NULL, NULL);
989 change_wind(actor, desktop_plugin);
990 scene->actors = g_slist_append(scene->actors, actor);
992 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
993 486, 425, 10, 18, 38,
994 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
995 //actor->time_start_animation = now + fast_rnd(30) + 10;
996 scene->actors = g_slist_append(scene->actors, actor1);
998 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
999 486, 425, 10, 18, 38,
1000 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
1001 //actor->time_start_animation = now + fast_rnd(30) + 10;
1002 scene->actors = g_slist_append(scene->actors, actor2);
1003 child = g_ptr_array_sized_new(2);
1004 g_ptr_array_add(child, actor1);
1005 g_ptr_array_add(child, actor2);
1006 actor = init_object(desktop_plugin, "signal", "",
1007 486, 425, 10, 18, 38,
1008 FALSE, FALSE, 100, 255,
1009 (gpointer)&change_signal, NULL, child);
1010 actor->time_start_animation = now + fast_rnd(30) + 10;
1011 scene->actors = g_slist_append(scene->actors, actor);
1052 for (i=0; i<13; i++){
1053 actor = init_object(desktop_plugin, "window", "window.png",
1054 winds[i][0], winds[i][1], 10, 8, 9,
1055 FALSE, TRUE, 100, 255,
1056 (gpointer)&change_window1, NULL, NULL);
1057 //change_window1(actor, desktop_plugin);
1058 actor->time_start_animation = now + fast_rnd(30);
1059 scene->actors = g_slist_append(scene->actors, actor);
1063 run_long_timeout(desktop_plugin);
1066 /*******************************************************************************/
1068 init_scene_theme(AWallpaperPlugin *desktop_plugin)
1071 void (*func)(gpointer);
1072 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
1074 (*func)(desktop_plugin);
1077 fprintf(stderr, "Init_scene_theme\n");
1078 void (*func)(gpointer);
1079 func = desktop_plugin->priv->scene_func;
1081 fprintf(stderr, "Success init_scene_theme %s\n", desktop_plugin->priv->theme);
1082 (*func)(desktop_plugin);