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-common.h"
26 #include "livewp-home-widget.h"
27 #include <gconf/gconf-client.h>
28 #include "livewp-rules.h"
32 #define PLUGIN_NAME "livewp-home-widget.desktop-0"
33 #define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/%s/position"
34 #define GCONF_KEY_MODIFIED "/apps/osso/hildon-desktop/applets/%s/modified"
35 #define GCONF_KEY_VIEW "/apps/osso/hildon-desktop/applets/%s/view"
37 HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_HOME_PLUGIN_ITEM)
38 #define Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj,\
39 Animation_Wallpaper_TYPE_HOME_PLUGIN,\
40 Animation_WallpaperPrivate))
42 /* Position of plugin on desktop */
43 #define Xstartposition 700
44 #define Ystartposition 448
46 gint xapplet = 0, yapplet = 0;
50 lw_applet_realize (GtkWidget *widget)
54 screen = gtk_widget_get_screen (widget);
55 gtk_widget_set_colormap (widget,
56 gdk_screen_get_rgba_colormap (screen));
57 gtk_widget_set_app_paintable (widget,
59 GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
64 lw_applet_expose_event(GtkWidget *widget,
65 GdkEventExpose *event)
69 /* Create cairo context */
70 cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
71 gdk_cairo_region (cr, event->region);
74 /* Draw alpha background */
75 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
76 cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
82 return GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->expose_event (widget,
87 expose_event (GtkWidget *widget,GdkEventExpose *event,
91 GdkPixbuf *pixbuf = (GdkPixbuf *) data;
93 cr = gdk_cairo_create(widget->window);
95 gdk_cairo_region(cr, event->region);
96 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
97 gdk_cairo_set_source_pixbuf(cr, pixbuf, 0.0, 0.0);
105 realize (GtkWidget *widget)
108 screen = gtk_widget_get_screen (widget);
109 gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));
112 /* Set position of widget on desktop */
114 init_applet_position(void)
116 GSList *position = NULL;
120 GError *error = NULL;
121 GConfClient *gconf_client = gconf_client_get_default ();
122 position_key = g_strdup_printf (GCONF_KEY_POSITION, PLUGIN_NAME);
123 position = gconf_client_get_list (gconf_client,
127 if (position && position->data && position->next->data){
128 xapplet = GPOINTER_TO_INT (position->data);
129 yapplet = GPOINTER_TO_INT (position->next->data);
131 position = g_slist_prepend (g_slist_prepend (NULL,
132 GINT_TO_POINTER (Ystartposition)),
133 GINT_TO_POINTER (Xstartposition));
134 gconf_client_set_list (gconf_client,
139 xapplet = Xstartposition;
140 yapplet = Ystartposition;
142 g_free (position_key);
143 modified = g_strdup_printf ("%i", 0);
144 modified_key = g_strdup_printf (GCONF_KEY_MODIFIED, PLUGIN_NAME);
145 gconf_client_set_string (gconf_client,
150 g_free(modified_key);
151 gconf_client_clear_cache(gconf_client);
152 g_object_unref(gconf_client);
156 actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
158 /* fprintf(stderr, "actor_set_position_full z=%d\n", z); */
159 hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-xapplet, y-yapplet, z);
163 path_line(gint x0, gint x1, double t)
166 return ((x1 - x0) * t + x0);
171 destroy_hildon_actor(Actor *actor)
173 //fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
174 gtk_widget_destroy(actor->widget);
175 actor->widget = NULL;
179 init_object(AWallpaperPlugin *desktop_plugin,
191 void (*pfunc_change)(Actor*),
192 void (*pfunc_probability)(Actor*),
197 actor = g_new0(Actor, 1);
201 actor->width = width;
202 actor->height = height;
203 actor->visible = visible;
204 actor->scale = scale;
205 actor->opacity = opacity;
206 actor->filename = g_strdup(filename);
207 actor->name = g_strdup(name);
208 actor->func_change = (gpointer)pfunc_change;
209 actor->func_probability = (gpointer)pfunc_probability;
210 actor->child = child;
212 create_hildon_actor(actor, desktop_plugin);
214 actor->widget = NULL;
215 actor->time_start_animation = 0;
216 actor->duration_animation = 0;
224 //objects_list = g_slist_append(objects_list, G_OBJECT(actor));
225 //objects_list = g_slist_append(objects_list, G_OBJECT(a));
235 gint fast_rnd(gint max)
237 guint offset = 12923;
238 guint multiplier = 4079;
240 scene.seed = scene.seed * multiplier + offset;
241 return (gint)(scene.seed % max);
247 /* update sun position after ... second */
255 //return (fast_rnd(10) + 1) * 60;
256 return fast_rnd(180);
260 change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
267 y0=150, y1 = 150, x2=400, y2=30;
274 a = (double)(y2 - (double)(x2*(y1-y0) + x1*y0 - x0*y1)/(x1-x0))/(x2*(x2-x0-x1)+x0*x1);
275 b = (double)(y1-y0)/(x1-x0) - (double)a*(x0+x1);
276 c = (double)(x1*y0 - x0*y1)/(x1-x0) + (double)a*x0*x1;
277 fprintf(stderr, "a=%f, b=%f, c=%f\n", a, b, c);
279 gettimeofday(&tvb, NULL);
285 if (scene.daytime == TIME_NIGHT){
286 if (!actor->visible){
287 actor->visible = TRUE;
288 phase = get_moon_phase();
289 newfile = g_strdup_printf( "%s%d.png", actor->name, phase);
291 g_free(actor->filename);
292 actor->filename = newfile;
293 actor->time_start_animation = sec - fast_rnd(60 * 60);
294 actor->duration_animation = 1 * 60 * 60;
295 create_hildon_actor(actor, desktop_plugin);
298 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
300 x = path_line(x0, x1, t);
302 x = path_line(x1, x0, t-1);
303 //y = path_line(y0, y1, t);
304 y = 0.001920*x*x - 1.536*x + 337.2;
305 //y = a*x*x + b*x + c;
307 actor_set_position_full(actor->widget, x, y, actor->z);
310 actor->time_start_animation = sec;
313 }else if (actor->visible){
314 actor->visible = FALSE;
315 fprintf(stderr, "destroy moon \n");
316 destroy_hildon_actor(actor);
317 /* TO DO make moonrise*/
318 actor->time_start_animation = 0;
325 change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
330 //fprintf(stderr, "change sun\n");
332 if (scene.daytime != TIME_NIGHT){
333 if (!actor->visible){
334 actor->visible = TRUE;
335 create_hildon_actor(actor, desktop_plugin);
337 get_sun_pos(&alt, &azm);
338 get_sun_screen_pos(alt, azm, &x, &y);
341 actor_set_position_full(actor->widget, x, y, actor->z);
342 //probability_sun(actor);
343 actor->time_start_animation = time(NULL) + probability_sun();
344 }else if (actor->visible){
345 actor->visible = FALSE;
346 destroy_hildon_actor(actor);
347 actor->time_start_animation = 0;
354 change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
356 gint x0 = -300, y0 = 225, scale0 = 100,
357 x1 = 800, y1 = 162, scale1 = 130,
364 //fprintf(stderr, "change tram\n");
365 gettimeofday(&tvb, NULL);
370 if (!actor->visible){
371 actor->visible = TRUE;
372 if (scene.daytime == TIME_NIGHT){
374 g_free(actor->filename);
375 actor->filename = g_strdup("tram_dark.png");
378 g_free(actor->filename);
379 actor->filename = g_strdup("tram.png");
381 create_hildon_actor(actor, desktop_plugin);
383 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
384 x = path_line(x0, x1, t);
385 y = path_line(y0, y1, t);
386 scale = path_line(scale0, scale1, t);
387 //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
388 actor_set_position_full(actor->widget, x, y, actor->z);
389 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
390 set_actor_scale(actor, (double)scale/100, (double)scale/100);
393 actor->visible = FALSE;
394 destroy_hildon_actor(actor);
395 actor->time_start_animation = sec + fast_rnd(60);
400 change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
402 gint x0 = 620, y0 = 233,
410 gettimeofday(&tvb, NULL);
414 // fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
416 if (scene.daytime != TIME_NIGHT){
417 if (actor->time_start_animation == 0){
418 actor->time_start_animation = sec + probability_plane();
422 if (!actor->visible){
423 actor->visible = TRUE;
424 create_hildon_actor(actor, desktop_plugin);
426 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
427 x = path_line(x0, x1, t);
428 y = path_line(y0, y1, t);
429 //scale = path_line(scale0, scale1, t);
430 //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
431 actor_set_position_full(actor->widget, x, y, actor->z);
432 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
435 actor->visible = FALSE;
436 destroy_hildon_actor(actor);
437 if (scene.daytime == TIME_NIGHT)
438 actor->time_start_animation = 0;
440 actor->time_start_animation = sec + probability_plane();
446 change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
448 gint x0 = -actor->width, y0 = 45,
456 gettimeofday(&tvb, NULL);
460 // fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
461 if (scene.daytime != TIME_NIGHT){
462 if (actor->time_start_animation == 0){
463 actor->time_start_animation = sec + probability_plane();
467 if (!actor->visible){
468 actor->visible = TRUE;
469 create_hildon_actor(actor, desktop_plugin);
472 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
473 x = path_line(x0, x1, t);
474 y = path_line(y0, y1, t);
475 //scale = path_line(scale0, scale1, t);
476 //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
477 actor_set_position_full(actor->widget, x, y, actor->z);
478 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
481 actor->visible = FALSE;
482 destroy_hildon_actor(actor);
483 if (scene.daytime == TIME_NIGHT)
484 actor->time_start_animation = 0;
486 actor->time_start_animation = sec + probability_plane();
492 change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
494 gint x0, y0 = 300, scale0 = 100,
495 x1, y1 = -actor->height, scale1 = 150,
503 //fprintf(stderr, "change cloud\n");
504 gettimeofday(&tvb, NULL);
508 //fprintf(stderr, "c1oud %s - y0=%d\n", actor->name, actor->y);
510 if (!actor->visible){
511 actor->visible = TRUE;
512 if (scene.daytime == TIME_NIGHT){
513 newfile = g_strdup_printf("%s_dark.png", actor->name);
515 newfile = g_strdup_printf("%s.png", actor->name);
518 g_free(actor->filename);
519 actor->filename = newfile;
521 create_hildon_actor(actor, desktop_plugin);
523 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
525 if (scene.wind_orientation == 1){
534 x = path_line(x0, x1, t);
535 y = -scene.wind_angle * (x - x0) + actor->y;
536 scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0));
538 //fprintf(stderr, "change cloud t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
539 actor_set_position_full(actor->widget, x, y, actor->z);
540 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
541 set_actor_scale(actor, (double)scale/100, (double)scale/100);
542 if ((y < y1 || y > y0) || t >= 1){
544 actor->visible = FALSE;
545 destroy_hildon_actor(actor);
546 actor->time_start_animation = sec + fast_rnd(300);
547 actor->y = fast_rnd(300);
553 change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin)
555 scene.wind_orientation = fast_rnd(2);
556 if (scene.wind_orientation == 0) scene.wind_orientation = -1;
557 scene.wind_angle = (double)(fast_rnd(200) - 100) / 100;
558 actor->time_start_animation = time(NULL) + (fast_rnd(10) + 10) * 60;
559 //fprintf(stderr, "change wind orient = %d angle = %f after = %d\n", scene.wind_orientation, scene.wind_angle, actor->time_start_animation-time(NULL));
563 change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin)
565 gint now = time(NULL);
566 if (scene.daytime == TIME_DAY){
568 actor->visible = FALSE;
569 destroy_hildon_actor(actor);
571 actor->time_start_animation = 0;
575 create_hildon_actor(actor, desktop_plugin);
576 if (actor->time_start_animation == 0){
577 actor->time_start_animation = now + fast_rnd(30);
583 actor->visible = TRUE;
585 actor->visible = FALSE;
586 //hildon_animation_actor_set_show(
587 // HILDON_ANIMATION_ACTOR(actor->widget),
590 set_actor_visible(actor, actor->visible);
591 actor->time_start_animation = now + fast_rnd(60) + 10;
596 change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin)
598 gint now = time(NULL);
602 gint now = time(NULL);
603 newfile = g_strdup_printf("%s%d.png", actor->name, scene.daytime);
604 if (!strcmp(actor->filename, "red.png"))
605 newfile = g_strdup_printf("%s", "green.png");
607 newfile = g_strdup_printf("%s", "red.png");
608 g_free(actor->filename);
609 actor->filename = newfile;
610 change_hildon_actor(actor, desktop_plugin);
611 actor->time_start_animation = now + fast_rnd(30) + 10;
613 a = g_ptr_array_index(actor->child, 0);
614 //fprintf(stderr, "actor name= %p \n", child->widget);
619 //hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(a->widget), a->visible);
620 set_actor_visible(a, a->visible);
622 a = g_ptr_array_index(actor->child, 1);
623 //fprintf(stderr, "actor name= %s \n", child->name);
628 //hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(a->widget), a->visible);
629 set_actor_visible(a, a->visible);
631 actor->time_start_animation = now + fast_rnd(30) + 10;
635 set_actor_scale(Actor *actor, double scalex, double scaley)
637 hildon_animation_actor_set_scale(
638 HILDON_ANIMATION_ACTOR(actor->widget),
646 set_actor_visible(Actor *actor, gboolean visible)
648 hildon_animation_actor_set_show(HILDON_ANIMATION_ACTOR(actor->widget), visible);
651 create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
653 GtkWidget *ha = NULL;
654 GdkPixbuf *pixbuf = NULL;
655 GtkWidget *image = NULL;
658 ha = hildon_animation_actor_new();
659 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
660 desktop_plugin->priv->theme, actor->filename);
661 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
665 /*fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str);*/
669 image = gtk_image_new_from_pixbuf (pixbuf);
670 g_object_unref(G_OBJECT(pixbuf));
673 g_signal_connect(G_OBJECT(image), "expose_event",
674 G_CALLBACK(expose_event), pixbuf);
675 gtk_container_add (GTK_CONTAINER (ha), image);
677 actor_set_position_full(ha, actor->x, actor->y, actor->z);
678 hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(ha), (double)actor->scale/100, (double)actor->scale/100);
680 gtk_widget_show_all(ha);
681 hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(ha), actor->visible);
686 //g_object_set_data(G_OBJECT(ha), "name", name);
687 //g_object_set_data(G_OBJECT(ha), "filename", filename);
688 g_object_set_data(G_OBJECT(ha), "image", image);
690 g_object_set_data(G_OBJECT(ha), "x", x);
691 g_object_set_data(G_OBJECT(ha), "y", y);
692 g_object_set_data(G_OBJECT(ha), "z", z);
693 g_object_set_data(G_OBJECT(ha), "width", width);
694 g_object_set_data(G_OBJECT(ha), "height", height);
695 g_object_set_data(G_OBJECT(ha), "scale", scale);
696 g_object_set_data(G_OBJECT(ha), "visible", visible);
697 g_object_set_data(G_OBJECT(ha), "opacity", opacity);
698 g_object_set_data(G_OBJECT(ha), "func", pfunc);
700 hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin));
706 change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
708 GtkWidget *image = NULL;
709 GdkPixbuf *pixbuf = NULL;
712 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
713 desktop_plugin->priv->theme, actor->filename);
715 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
722 image = gtk_image_new_from_pixbuf (pixbuf);
723 g_object_unref(G_OBJECT(pixbuf));
726 g_signal_connect(G_OBJECT(image), "expose_event",
727 G_CALLBACK(expose_event), pixbuf);
728 if (g_object_get_data(G_OBJECT(actor->widget), "image")){
729 gtk_container_remove(GTK_CONTAINER(actor->widget), g_object_get_data(G_OBJECT(actor->widget), "image"));
731 g_object_set_data(G_OBJECT(actor->widget), "image", image);
732 gtk_container_add (GTK_CONTAINER (actor->widget), image);
733 realize(actor->widget);
734 gtk_widget_show_all(actor->widget);
745 change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
748 newfile = g_strdup_printf("%s%d.png", actor->name, scene.daytime);
750 g_free(actor->filename);
751 actor->filename = newfile;
752 change_hildon_actor(actor, desktop_plugin);
756 change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin)
760 if (desktop_plugin->priv->right_corner)
761 gtk_widget_destroy(desktop_plugin->priv->right_corner);
762 snprintf(buffer, sizeof(buffer) - 1, "%s/%s/town%i_right_corner.png", \
763 THEME_PATH, desktop_plugin->priv->theme, scene.daytime);
764 desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
765 if (desktop_plugin->priv->right_corner){
766 gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
767 gtk_widget_show (desktop_plugin->priv->right_corner);
769 change_static_actor(actor, desktop_plugin);
774 change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin)
779 if (!desktop_plugin->priv->rich_animation) return;
781 a = g_ptr_array_index(actor->child, 0);
783 if (y > 480) y = -480;
784 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
785 actor_set_position_full(a->widget, a->x, y, a->z);
788 a = g_ptr_array_index(actor->child, 1);
790 if (y > 480) y = -480;
791 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
792 actor_set_position_full(a->widget, a->x, y, a->z);
795 a = g_ptr_array_index(actor->child, 2);
797 if (y > 480) y = -480;
798 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
799 actor_set_position_full(a->widget, a->x, y, a->z);
802 a = g_ptr_array_index(actor->child, 3);
804 if (y > 480) y = -480;
805 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
806 actor_set_position_full(a->widget, a->x, y, a->z);
812 change_layer1(Actor * actor, AWallpaperPlugin *desktop_plugin)
816 if (y > 480) y = -480;
817 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
818 actor_set_position_full(actor->widget, actor->x, y, actor->z);
823 change_layer2(Actor * actor, AWallpaperPlugin *desktop_plugin)
827 if (y >= 480) y = -480;
828 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
829 actor_set_position_full(actor->widget, actor->x, y, actor->z);
836 // уравнение изменения времени
842 GSList * tmp = scene.actors;
848 g_ptr_array_free(actor->child, TRUE);
851 g_free(actor->filename);
854 gtk_widget_destroy(actor->widget);
855 //actor->widget = NULL;
858 tmp = g_slist_next(tmp);
865 reload_scene(AWallpaperPlugin *desktop_plugin)
867 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
869 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
870 init_scene(desktop_plugin);
871 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
872 init_scene1(desktop_plugin);
873 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
874 init_scene2(desktop_plugin);
879 init_scene2(AWallpaperPlugin *desktop_plugin)
883 gint now = time(NULL);
886 if (desktop_plugin->priv->rich_animation){
894 fprintf(stderr, "init scene2 \n");
895 //scene.daytime = get_daytime();
899 actor = init_object(desktop_plugin, "background", "bg.png",
901 TRUE, TRUE, 100, 255,
903 scene.actors = g_slist_append(scene.actors, actor);
905 actor = init_object(desktop_plugin, "symbols", "symbols.png",
907 TRUE, TRUE, 100, 255,
909 scene.actors = g_slist_append(scene.actors, actor);
911 child = g_ptr_array_sized_new(4);
912 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
914 TRUE, TRUE, 100, 255,
916 //actor->time_start_animation = now;
917 //actor->duration_animation = G_MAXINT;
918 scene.actors = g_slist_append(scene.actors, actor);
919 g_ptr_array_add(child, actor);
921 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
923 TRUE, TRUE, 100, 255,
925 //actor->time_start_animation = now;
926 //actor->duration_animation = G_MAXINT;
927 scene.actors = g_slist_append(scene.actors, actor);
928 g_ptr_array_add(child, actor);
930 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
932 TRUE, TRUE, 100, 255,
934 //actor->time_start_animation = now;
935 //actor->duration_animation = G_MAXINT;
936 scene.actors = g_slist_append(scene.actors, actor);
937 g_ptr_array_add(child, actor);
939 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
941 TRUE, TRUE, 100, 255,
943 //actor->time_start_animation = now;
944 //actor->duration_animation = G_MAXINT;
945 scene.actors = g_slist_append(scene.actors, actor);
946 g_ptr_array_add(child, actor);
948 actor = init_object(desktop_plugin, "layers", "",
950 FALSE, FALSE, 100, 255,
951 (gpointer)&change_layer, NULL, child);
952 actor->time_start_animation = now;
953 actor->duration_animation = G_MAXINT;
954 scene.actors = g_slist_append(scene.actors, actor);
956 run_long_timeout(desktop_plugin);
959 /* Init Modern Scene */
961 init_scene(AWallpaperPlugin *desktop_plugin)
964 gint now = time(NULL);
968 /* fprintf(stderr, "init scene \n");*/
969 scene.daytime = get_daytime();
971 scene.wind_orientation = -1;
972 scene.wind_angle = 0.3;
973 /* init value for random */
974 scene.seed = time(NULL);
976 actor = init_object(desktop_plugin, "sky", "sky0.png",
978 TRUE , TRUE, 100, 255,
979 (gpointer)&change_static_actor, NULL, NULL);
980 change_static_actor(actor, desktop_plugin);
981 scene.actors = g_slist_append(scene.actors, actor);
983 actor = init_object(desktop_plugin, "sun", "sun.png",
985 FALSE, FALSE, 100, 255,
986 (gpointer)&change_sun, (gpointer)&probability_sun, NULL);
987 actor->time_start_animation = now;
988 actor->duration_animation = G_MAXINT;
989 change_sun(actor, desktop_plugin);
990 scene.actors = g_slist_append(scene.actors, actor);
992 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
993 // TRUE, 100, 255, NULL, NULL);
994 //scene.actors = g_slist_append(scene.actors, actor);
996 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
997 0, fast_rnd(300)-97, 7, 150, 97,
998 FALSE, FALSE, 100, 255,
999 (gpointer)&change_cloud, NULL, NULL);
1000 actor->time_start_animation = now + fast_rnd(20);
1001 actor->duration_animation = 3*60;
1002 scene.actors = g_slist_append(scene.actors, actor);
1004 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
1005 0, fast_rnd(300)-75, 7, 188, 75,
1006 FALSE, FALSE, 100, 255,
1007 (gpointer)&change_cloud, NULL, NULL);
1008 actor->time_start_animation = now + fast_rnd(40)+10;
1009 actor->duration_animation = 3*60;
1010 scene.actors = g_slist_append(scene.actors, actor);
1012 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
1013 0, fast_rnd(300)-75, 7, 150, 75,
1014 FALSE, FALSE, 100, 255,
1015 (gpointer)&change_cloud, NULL, NULL);
1016 actor->time_start_animation = now + fast_rnd(60) + 20;
1017 actor->duration_animation = 5*60;
1018 scene.actors = g_slist_append(scene.actors, actor);
1021 actor = init_object(desktop_plugin, "town", "town0.png",
1023 TRUE, TRUE, 100, 255,
1024 (gpointer)&change_static_actor, NULL, NULL);
1025 change_static_actor(actor, desktop_plugin);
1026 scene.actors = g_slist_append(scene.actors, actor);
1028 actor = init_object(desktop_plugin, "tram", "tram.png",
1029 -300, 225, 9, 350, 210,
1030 FALSE, FALSE, 100, 255,
1031 (gpointer)&change_tram, NULL, NULL);
1032 actor->time_start_animation = time(NULL) + fast_rnd(10);
1033 actor->duration_animation = 60;
1034 scene.actors = g_slist_append(scene.actors, actor);
1036 actor = init_object(desktop_plugin, "border", "border0.png",
1037 0, 480-79, 10, 800, 79,
1038 TRUE, TRUE, 100, 255,
1039 (gpointer)&change_static_actor_with_corner, NULL, NULL);
1040 change_static_actor_with_corner(actor, desktop_plugin);
1041 scene.actors = g_slist_append(scene.actors, actor);
1043 actor = init_object(desktop_plugin, "moon", "moon1.png",
1045 FALSE, FALSE, 100, 255,
1046 (gpointer)&change_moon, NULL, NULL);
1047 change_moon(actor, desktop_plugin);
1048 scene.actors = g_slist_append(scene.actors, actor);
1050 actor = init_object(desktop_plugin, "wind", "",
1052 FALSE, FALSE, 100, 255,
1053 (gpointer)&change_wind, NULL, NULL);
1054 change_wind(actor, desktop_plugin);
1055 scene.actors = g_slist_append(scene.actors, actor);
1057 /* windows in 4-th house */
1097 for (i=0; i<13; i++){
1098 actor = init_object(desktop_plugin, "window1", "window1.png",
1099 winds[i][0], winds[i][1], 8, 8, 10,
1100 FALSE, FALSE, 100, 255,
1101 (gpointer)&change_window1, NULL, NULL);
1102 //change_window1(actor, desktop_plugin);
1103 actor->time_start_animation = now + fast_rnd(30);
1104 scene.actors = g_slist_append(scene.actors, actor);
1108 /* windows in 1-th house */
1133 for (i=0; i<8; i++){
1134 actor = init_object(desktop_plugin, "window2", "window2.png",
1135 winds[i][0], winds[i][1], 8, 8, 10,
1136 FALSE, FALSE, 100, 255,
1137 (gpointer)&change_window1, NULL, NULL);
1138 //change_window1(actor, desktop_plugin);
1139 actor->time_start_animation = now + fast_rnd(30);
1140 scene.actors = g_slist_append(scene.actors, actor);
1144 /* windows in 3-th house */
1176 for (i=0; i<10; i++){
1177 actor = init_object(desktop_plugin, "window3", "window3.png",
1178 winds[i][0], winds[i][1], 8, 8, 10,
1179 FALSE, FALSE, 100, 255,
1180 (gpointer)&change_window1, NULL, NULL);
1181 //change_window1(actor, desktop_plugin);
1182 actor->time_start_animation = now + fast_rnd(30);
1183 scene.actors = g_slist_append(scene.actors, actor);
1187 /* windows in 5-th house */
1210 for (i=0; i<7; i++){
1211 actor = init_object(desktop_plugin, "window4", "window4.png",
1212 winds[i][0], winds[i][1], 8, 8, 10,
1213 FALSE, FALSE, 100, 255,
1214 (gpointer)&change_window1, NULL, NULL);
1215 //change_window1(actor, desktop_plugin);
1216 actor->time_start_animation = now + fast_rnd(30);
1217 scene.actors = g_slist_append(scene.actors, actor);
1221 /* windows in 6-th house */
1241 for (i=0; i<6; i++){
1242 actor = init_object(desktop_plugin, "window5", "window5.png",
1243 winds[i][0], winds[i][1], 8, 8, 10,
1244 FALSE, FALSE, 100, 255,
1245 (gpointer)&change_window1, NULL, NULL);
1246 //change_window1(actor, desktop_plugin);
1247 actor->time_start_animation = now + fast_rnd(30);
1248 scene.actors = g_slist_append(scene.actors, actor);
1252 run_long_timeout(desktop_plugin);
1255 anim = g_new0(Animation, 1);
1257 anim->actor = actor;
1258 anim->func_change = &change_tram;
1259 anim->func_time = NULL;
1260 anim->timestart = time(NULL);
1263 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
1267 /* Init Berlin Scene */
1269 init_scene1(AWallpaperPlugin *desktop_plugin)
1271 Actor *actor, *actor1, *actor2;
1272 gint now = time(NULL);
1275 GPtrArray *child = NULL;
1277 scene.daytime = get_daytime();
1278 scene.actors = NULL;
1279 scene.wind_orientation = -1;
1280 scene.wind_angle = 0.3;
1281 /* init value for random */
1282 scene.seed = time(NULL);
1285 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
1286 TRUE, TRUE, 100, 255,
1287 (gpointer)&change_static_actor, NULL, NULL);
1288 change_static_actor(actor, desktop_plugin);
1289 scene.actors = g_slist_append(scene.actors, actor);
1292 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
1293 FALSE, FALSE, 100, 255,
1294 (gpointer)&change_sun, (gpointer)&probability_sun, NULL);
1295 actor->time_start_animation = time(NULL);
1296 actor->duration_animation = G_MAXINT;
1297 change_sun(actor, desktop_plugin);
1298 scene.actors = g_slist_append(scene.actors, actor);
1301 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
1302 TRUE, 100, 255, NULL, NULL);
1303 scene.actors = g_slist_append(scene.actors, actor);
1306 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
1307 FALSE, FALSE, 100, 255,
1308 (gpointer)&change_moon, NULL, NULL);
1309 change_moon(actor, desktop_plugin);
1310 scene.actors = g_slist_append(scene.actors, actor);
1312 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
1313 FALSE, FALSE, 100, 255,
1314 (gpointer)&change_cloud, NULL, NULL);
1315 actor->time_start_animation = now + fast_rnd(30) + 10;
1316 actor->duration_animation = 3*60;
1317 scene.actors = g_slist_append(scene.actors, actor);
1319 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
1320 FALSE, FALSE, 100, 255,
1321 (gpointer)&change_cloud, NULL, NULL);
1322 actor->time_start_animation = now + fast_rnd(10);
1323 actor->duration_animation = 3*60;
1324 scene.actors = g_slist_append(scene.actors, actor);
1326 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
1327 FALSE, FALSE, 100, 255,
1328 (gpointer)&change_cloud, NULL, NULL);
1329 actor->time_start_animation = now + fast_rnd(60) + 20;
1330 actor->duration_animation = 5*60;
1331 scene.actors = g_slist_append(scene.actors, actor);
1334 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
1335 FALSE, FALSE, 100, 255,
1336 (gpointer)&change_plane2, NULL, NULL);
1337 actor->time_start_animation = now + fast_rnd(40) + 20;
1338 actor->duration_animation = 60;
1339 scene.actors = g_slist_append(scene.actors, actor);
1341 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
1342 FALSE, FALSE, 100, 255,
1343 (gpointer)&change_plane1, NULL, NULL);
1344 actor->time_start_animation = now + fast_rnd(20);
1345 actor->duration_animation = 30;
1346 scene.actors = g_slist_append(scene.actors, actor);
1348 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
1349 TRUE, TRUE, 100, 255,
1350 (gpointer)&change_static_actor_with_corner, NULL, NULL);
1351 change_static_actor_with_corner(actor, desktop_plugin);
1352 scene.actors = g_slist_append(scene.actors, actor);
1354 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
1355 FALSE, FALSE, 100, 255,
1356 (gpointer)&change_wind, NULL, NULL);
1357 change_wind(actor, desktop_plugin);
1358 scene.actors = g_slist_append(scene.actors, actor);
1360 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
1361 486, 425, 10, 18, 38,
1362 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
1363 //actor->time_start_animation = now + fast_rnd(30) + 10;
1364 scene.actors = g_slist_append(scene.actors, actor1);
1366 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
1367 486, 425, 10, 18, 38,
1368 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
1369 //actor->time_start_animation = now + fast_rnd(30) + 10;
1370 scene.actors = g_slist_append(scene.actors, actor2);
1371 child = g_ptr_array_sized_new(2);
1372 g_ptr_array_add(child, actor1);
1373 g_ptr_array_add(child, actor2);
1374 actor = init_object(desktop_plugin, "signal", "",
1375 486, 425, 10, 18, 38,
1376 FALSE, FALSE, 100, 255,
1377 (gpointer)&change_signal, NULL, child);
1378 actor->time_start_animation = now + fast_rnd(30) + 10;
1379 scene.actors = g_slist_append(scene.actors, actor);
1420 for (i=0; i<13; i++){
1421 actor = init_object(desktop_plugin, "window", "window.png",
1422 winds[i][0], winds[i][1], 10, 8, 9,
1423 FALSE, TRUE, 100, 255,
1424 (gpointer)&change_window1, NULL, NULL);
1425 //change_window1(actor, desktop_plugin);
1426 actor->time_start_animation = now + fast_rnd(30);
1427 scene.actors = g_slist_append(scene.actors, actor);
1431 run_long_timeout(desktop_plugin);
1437 get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
1439 gint y0 = 365;// - уровень горизонта
1440 *x = (int)(azm * 800) - 64;
1441 *y = (int)((1 - alt) * y0) - 64;
1442 //fprintf(stderr, "sun pos alt=%f azm=%f x=%d y=%d\n", alt, azm, *x, *y);
1446 change_actor(GtkWidget * actor)
1449 gint x, y, daytime, scale;
1456 void (*pfunc)(gpointer, gpointer);
1458 name = g_object_get_data(G_OBJECT(actor), "name");
1459 fprintf(stderr, "change actor %s\n", name);
1461 pfunc = g_object_get_data(G_OBJECT(actor), "func");
1463 (*pfunc)(actor, g_strdup(name));
1464 daytime = get_daytime();
1465 if (daytime != TIME_NIGHT){
1466 hildon_animation_actor_set_show(actor, 1);
1467 get_sun_pos(&alt, &azm);
1468 get_sun_screen_pos(alt, azm, &x, &y);
1469 actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
1473 if (name == "cloud1"){
1474 x = g_object_get_data(G_OBJECT(actor), "x");
1475 y = g_object_get_data(G_OBJECT(actor), "y");
1476 scale = g_object_get_data(G_OBJECT(actor), "scale");
1479 image = g_object_get_data(G_OBJECT(actor), "image");
1481 gtk_container_remove(actor, image);
1482 pixbuf = gdk_pixbuf_new_from_file_at_size ("/usr/share/livewp/theme/Modern/sun.png",
1487 image = gtk_image_new_from_pixbuf (pixbuf);
1488 g_object_unref(G_OBJECT(pixbuf));
1490 g_signal_connect(G_OBJECT(image), "expose_event",
1491 G_CALLBACK(expose_event), pixbuf);
1492 gtk_container_add (GTK_CONTAINER (actor), image);
1494 gtk_widget_show_all(actor);
1506 sc = (double)scale / 100;
1507 hildon_animation_actor_set_scale(actor, sc, sc);
1508 fprintf(stderr, "cloud x=%d y=%d scale=%f", x, y, sc);
1509 actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
1510 g_object_set_data(G_OBJECT(actor), "x", x);
1511 g_object_set_data(G_OBJECT(actor), "y", y);
1512 g_object_set_data(G_OBJECT(actor), "scale", scale);
1518 short_timeout (AWallpaperPlugin *desktop_plugin)
1520 //gint daytime = get_daytime();
1522 void (*pfunc)(gpointer, gpointer);
1525 gboolean stop_flag = TRUE;
1527 if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
1528 desktop_plugin->priv->short_timer = 0;
1533 //scene.daytime = daytime;
1534 /* fprintf(stderr, "Short timer %d\n", now); */
1536 while (tmp != NULL){
1538 if (now >= actor->time_start_animation
1539 && actor->time_start_animation > 0
1540 /* && now - actor->time_start_animation <= actor->duration_animation*/){
1541 pfunc = actor->func_change;
1543 (*pfunc)(actor, desktop_plugin);
1547 tmp = g_slist_next(tmp);
1550 desktop_plugin->priv->short_timer = 0;
1553 return TRUE; /* keep running this event */
1557 run_long_timeout(AWallpaperPlugin *desktop_plugin)
1560 gint daytime = get_daytime();
1562 void (*pfunc)(gpointer, gpointer);
1567 //fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer);
1568 if (scene.daytime != daytime){
1569 scene.daytime = daytime;
1571 while (tmp != NULL){
1572 //change_actor(tmp->data);
1573 pfunc =((Actor*)tmp->data)->func_change;
1575 (*pfunc)(tmp->data, desktop_plugin);
1577 tmp = g_slist_next(tmp);
1582 //fprintf(stderr, "Now %d\n", now);
1584 while (tmp != NULL){
1586 if (now >= actor->time_start_animation
1587 && actor->time_start_animation > 0
1588 && desktop_plugin->priv->short_timer == 0){
1589 /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
1590 if (desktop_plugin->priv->rich_animation){
1591 actor->time_start_animation = now;
1592 desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
1595 (*actor->func_change)(actor, desktop_plugin);
1598 tmp = g_slist_next(tmp);
1604 long_timeout (AWallpaperPlugin *desktop_plugin)
1606 /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
1607 if (desktop_plugin->priv->long_timer == 0 )
1609 if (!desktop_plugin->priv->visible){
1610 if(desktop_plugin->priv->short_timer != 0){
1611 g_source_remove(desktop_plugin->priv->short_timer);
1612 desktop_plugin->priv->short_timer = 0;
1614 desktop_plugin->priv->long_timer = 0;
1619 run_long_timeout(desktop_plugin);
1620 return TRUE; /* keep running this event */
1624 desktop_plugin_visible_notify (GObject *object,
1626 AWallpaperPlugin *desktop_plugin)
1629 g_object_get (object, "is-on-current-desktop", &visible, NULL);
1630 /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
1632 desktop_plugin->priv->visible = TRUE;
1633 if (desktop_plugin->priv->long_timer == 0 ){
1634 desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
1635 run_long_timeout(desktop_plugin);
1638 desktop_plugin->priv->visible = FALSE;
1639 if (desktop_plugin->priv->long_timer != 0 ){
1640 g_source_remove(desktop_plugin->priv->long_timer);
1641 desktop_plugin->priv->long_timer = 0;
1647 rich_animation_press(GtkWidget *widget, GdkEvent *event,
1648 gpointer user_data){
1649 fprintf(stderr,"gggggggggggggggggggg2222\n");
1653 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
1655 GtkWidget *rich_animation;
1659 fprintf(stderr, "!!!!!!!plugin init \n");
1660 Animation_WallpaperPrivate *priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
1661 desktop_plugin->priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
1662 priv->osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
1666 /* Initialize DBUS */
1667 livewp_initialize_dbus(priv);
1669 priv->desktop_plugin = desktop_plugin;
1670 priv->visible = TRUE;
1671 priv->short_timer = 0;
1672 //priv->theme = g_strdup("Modern");
1673 desktop_plugin->priv->main_widget = gtk_fixed_new();
1675 gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 100, 32);
1676 desktop_plugin->priv->right_corner = NULL;
1677 snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town0_right_corner.png");
1678 desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
1679 if (desktop_plugin->priv->right_corner){
1680 gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
1681 gtk_widget_show (desktop_plugin->priv->right_corner);
1683 /* Create rich animation event */
1684 rich_animation = gtk_event_box_new();
1686 gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
1687 gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
1688 gtk_widget_set_size_request(rich_animation, 100, 32);
1689 gtk_widget_show (rich_animation);
1690 g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
1691 gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), rich_animation, 0, 0);
1694 GtkWidget *label = gtk_label_new ("ddddddddddddd");
1695 gtk_widget_set_size_request(label, 95, 30);
1696 gtk_widget_show (label);
1697 // gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
1698 gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
1700 hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
1701 g_signal_connect (desktop_plugin, "show-settings",
1702 G_CALLBACK (show_settings), priv);
1703 gtk_widget_show (desktop_plugin->priv->main_widget);
1704 gtk_container_add (GTK_CONTAINER (desktop_plugin), desktop_plugin->priv->main_widget);
1705 init_applet_position();
1708 fprintf(stderr, "!!!theme = %s\n", priv->theme);
1709 if (!strcmp(priv->theme,"Modern"))
1710 init_scene(desktop_plugin);
1711 else if (!strcmp(priv->theme,"Berlin"))
1712 init_scene1(desktop_plugin);
1713 else if (!strcmp(priv->theme, "Matrix"))
1714 init_scene2(desktop_plugin);
1715 priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
1716 /* TODO Move scene to priv */
1717 scene.timer_type = LONG_TIMER_TYPE;
1718 g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
1719 G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
1726 lw_applet_finalize (GObject *object)
1728 AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
1729 Animation_WallpaperPrivate *priv = desktop_plugin->priv;
1731 fprintf(stderr,"finalaze %i\n", priv->long_timer);
1732 if (priv->long_timer){
1733 g_source_remove(priv->long_timer);
1734 priv->long_timer = 0;
1736 if (priv->short_timer){
1737 g_source_remove(priv->short_timer);
1738 priv->short_timer = 0;
1745 animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
1747 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
1748 GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
1751 gobject_class->destroy = (gpointer)lw_applet_finalize;
1752 widget_class->realize = lw_applet_realize;
1753 widget_class->expose_event = lw_applet_expose_event;
1755 g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));
1760 animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {