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 //*seed = *seed * multiplier + offset;
241 //return (gint)(*seed % max);
242 guint seed = time(NULL);
243 return (gint)(seed % max);
249 /* update sun position after ... second */
257 //return (fast_rnd(10) + 1) * 60;
258 return fast_rnd(180);
262 change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
269 y0=150, y1 = 150, x2=400, y2=30;
276 a = (double)(y2 - (double)(x2*(y1-y0) + x1*y0 - x0*y1)/(x1-x0))/(x2*(x2-x0-x1)+x0*x1);
277 b = (double)(y1-y0)/(x1-x0) - (double)a*(x0+x1);
278 c = (double)(x1*y0 - x0*y1)/(x1-x0) + (double)a*x0*x1;
279 fprintf(stderr, "a=%f, b=%f, c=%f\n", a, b, c);
281 gettimeofday(&tvb, NULL);
287 if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){
288 if (!actor->visible){
289 actor->visible = TRUE;
290 phase = get_moon_phase();
291 newfile = g_strdup_printf( "%s%d.png", actor->name, phase);
293 g_free(actor->filename);
294 actor->filename = newfile;
295 actor->time_start_animation = sec - fast_rnd(60 * 60);
296 actor->duration_animation = 1 * 60 * 60;
297 create_hildon_actor(actor, desktop_plugin);
300 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
302 x = path_line(x0, x1, t);
304 x = path_line(x1, x0, t-1);
305 //y = path_line(y0, y1, t);
306 y = 0.001920*x*x - 1.536*x + 337.2;
307 //y = a*x*x + b*x + c;
309 actor_set_position_full(actor->widget, x, y, actor->z);
312 actor->time_start_animation = sec;
315 }else if (actor->visible){
316 actor->visible = FALSE;
317 fprintf(stderr, "destroy moon \n");
318 destroy_hildon_actor(actor);
319 /* TO DO make moonrise*/
320 actor->time_start_animation = 0;
327 change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
332 //fprintf(stderr, "change sun\n");
334 if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){
335 if (!actor->visible){
336 actor->visible = TRUE;
337 create_hildon_actor(actor, desktop_plugin);
339 get_sun_pos(&alt, &azm);
340 get_sun_screen_pos(alt, azm, &x, &y);
343 actor_set_position_full(actor->widget, x, y, actor->z);
344 //probability_sun(actor);
345 actor->time_start_animation = time(NULL) + probability_sun();
346 }else if (actor->visible){
347 actor->visible = FALSE;
348 destroy_hildon_actor(actor);
349 actor->time_start_animation = 0;
356 change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
358 gint x0 = -300, y0 = 225, scale0 = 100,
359 x1 = 800, y1 = 162, scale1 = 130,
366 //fprintf(stderr, "change tram\n");
367 gettimeofday(&tvb, NULL);
372 if (!actor->visible){
373 actor->visible = TRUE;
374 if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){
376 g_free(actor->filename);
377 actor->filename = g_strdup("tram_dark.png");
380 g_free(actor->filename);
381 actor->filename = g_strdup("tram.png");
383 create_hildon_actor(actor, desktop_plugin);
385 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
386 x = path_line(x0, x1, t);
387 y = path_line(y0, y1, t);
388 scale = path_line(scale0, scale1, t);
389 //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
390 actor_set_position_full(actor->widget, x, y, actor->z);
391 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
392 set_actor_scale(actor, (double)scale/100, (double)scale/100);
395 actor->visible = FALSE;
396 destroy_hildon_actor(actor);
397 actor->time_start_animation = sec + fast_rnd(60);
402 change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
404 gint x0 = 620, y0 = 233,
412 gettimeofday(&tvb, NULL);
416 // fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
418 if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){
419 if (actor->time_start_animation == 0){
420 actor->time_start_animation = sec + probability_plane();
424 if (!actor->visible){
425 actor->visible = TRUE;
426 create_hildon_actor(actor, desktop_plugin);
428 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
429 x = path_line(x0, x1, t);
430 y = path_line(y0, y1, t);
431 //scale = path_line(scale0, scale1, t);
432 //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
433 actor_set_position_full(actor->widget, x, y, actor->z);
434 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
437 actor->visible = FALSE;
438 destroy_hildon_actor(actor);
439 if (desktop_plugin->priv->scene->daytime == TIME_NIGHT)
440 actor->time_start_animation = 0;
442 actor->time_start_animation = sec + probability_plane();
448 change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
450 gint x0 = -actor->width, y0 = 45,
458 gettimeofday(&tvb, NULL);
462 // fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
463 if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){
464 if (actor->time_start_animation == 0){
465 actor->time_start_animation = sec + probability_plane();
469 if (!actor->visible){
470 actor->visible = TRUE;
471 create_hildon_actor(actor, desktop_plugin);
474 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
475 x = path_line(x0, x1, t);
476 y = path_line(y0, y1, t);
477 //scale = path_line(scale0, scale1, t);
478 //fprintf(stderr, "change tram t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
479 actor_set_position_full(actor->widget, x, y, actor->z);
480 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
483 actor->visible = FALSE;
484 destroy_hildon_actor(actor);
485 if (desktop_plugin->priv->scene->daytime == TIME_NIGHT)
486 actor->time_start_animation = 0;
488 actor->time_start_animation = sec + probability_plane();
494 change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
496 gint x0, y0 = 300, scale0 = 100,
497 x1, y1 = -actor->height, scale1 = 150,
505 //fprintf(stderr, "change cloud\n");
506 gettimeofday(&tvb, NULL);
510 //fprintf(stderr, "c1oud %s - y0=%d\n", actor->name, actor->y);
512 if (!actor->visible){
513 actor->visible = TRUE;
514 if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){
515 newfile = g_strdup_printf("%s_dark.png", actor->name);
517 newfile = g_strdup_printf("%s.png", actor->name);
520 g_free(actor->filename);
521 actor->filename = newfile;
523 create_hildon_actor(actor, desktop_plugin);
525 t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
527 if (desktop_plugin->priv->scene->wind_orientation == 1){
536 x = path_line(x0, x1, t);
537 y = -desktop_plugin->priv->scene->wind_angle * (x - x0) + actor->y;
538 scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0));
540 //fprintf(stderr, "change cloud t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
541 actor_set_position_full(actor->widget, x, y, actor->z);
542 //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
543 set_actor_scale(actor, (double)scale/100, (double)scale/100);
544 if ((y < y1 || y > y0) || t >= 1){
546 actor->visible = FALSE;
547 destroy_hildon_actor(actor);
548 actor->time_start_animation = sec + fast_rnd(300);
549 actor->y = fast_rnd(300);
555 change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin)
557 desktop_plugin->priv->scene->wind_orientation = fast_rnd(2);
558 if (desktop_plugin->priv->scene->wind_orientation == 0) desktop_plugin->priv->scene->wind_orientation = -1;
559 desktop_plugin->priv->scene->wind_angle = (double)(fast_rnd(200) - 100) / 100;
560 actor->time_start_animation = time(NULL) + (fast_rnd(10) + 10) * 60;
561 //fprintf(stderr, "change wind orient = %d angle = %f after = %d\n", scene.wind_orientation, scene.wind_angle, actor->time_start_animation-time(NULL));
565 change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin)
567 gint now = time(NULL);
568 if (desktop_plugin->priv->scene->daytime == TIME_DAY){
570 actor->visible = FALSE;
571 destroy_hildon_actor(actor);
573 actor->time_start_animation = 0;
577 create_hildon_actor(actor, desktop_plugin);
578 if (actor->time_start_animation == 0){
579 actor->time_start_animation = now + fast_rnd(30);
585 actor->visible = TRUE;
587 actor->visible = FALSE;
588 //hildon_animation_actor_set_show(
589 // HILDON_ANIMATION_ACTOR(actor->widget),
592 set_actor_visible(actor, actor->visible);
593 actor->time_start_animation = now + fast_rnd(60) + 10;
598 change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin)
600 gint now = time(NULL);
604 gint now = time(NULL);
605 newfile = g_strdup_printf("%s%d.png", actor->name, scene.daytime);
606 if (!strcmp(actor->filename, "red.png"))
607 newfile = g_strdup_printf("%s", "green.png");
609 newfile = g_strdup_printf("%s", "red.png");
610 g_free(actor->filename);
611 actor->filename = newfile;
612 change_hildon_actor(actor, desktop_plugin);
613 actor->time_start_animation = now + fast_rnd(30) + 10;
615 a = g_ptr_array_index(actor->child, 0);
616 //fprintf(stderr, "actor name= %p \n", child->widget);
621 //hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(a->widget), a->visible);
622 set_actor_visible(a, a->visible);
624 a = g_ptr_array_index(actor->child, 1);
625 //fprintf(stderr, "actor name= %s \n", child->name);
630 //hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(a->widget), a->visible);
631 set_actor_visible(a, a->visible);
633 actor->time_start_animation = now + fast_rnd(30) + 10;
637 set_actor_scale(Actor *actor, double scalex, double scaley)
639 hildon_animation_actor_set_scale(
640 HILDON_ANIMATION_ACTOR(actor->widget),
648 set_actor_visible(Actor *actor, gboolean visible)
650 hildon_animation_actor_set_show(HILDON_ANIMATION_ACTOR(actor->widget), visible);
653 create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
655 GtkWidget *ha = NULL;
656 GdkPixbuf *pixbuf = NULL;
657 GtkWidget *image = NULL;
660 ha = hildon_animation_actor_new();
661 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
662 desktop_plugin->priv->theme, actor->filename);
663 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
667 /*fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str);*/
671 image = gtk_image_new_from_pixbuf (pixbuf);
672 g_object_unref(G_OBJECT(pixbuf));
675 g_signal_connect(G_OBJECT(image), "expose_event",
676 G_CALLBACK(expose_event), pixbuf);
677 gtk_container_add (GTK_CONTAINER (ha), image);
679 actor_set_position_full(ha, actor->x, actor->y, actor->z);
680 hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(ha), (double)actor->scale/100, (double)actor->scale/100);
682 gtk_widget_show_all(ha);
683 hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(ha), actor->visible);
688 //g_object_set_data(G_OBJECT(ha), "name", name);
689 //g_object_set_data(G_OBJECT(ha), "filename", filename);
690 g_object_set_data(G_OBJECT(ha), "image", image);
692 g_object_set_data(G_OBJECT(ha), "x", x);
693 g_object_set_data(G_OBJECT(ha), "y", y);
694 g_object_set_data(G_OBJECT(ha), "z", z);
695 g_object_set_data(G_OBJECT(ha), "width", width);
696 g_object_set_data(G_OBJECT(ha), "height", height);
697 g_object_set_data(G_OBJECT(ha), "scale", scale);
698 g_object_set_data(G_OBJECT(ha), "visible", visible);
699 g_object_set_data(G_OBJECT(ha), "opacity", opacity);
700 g_object_set_data(G_OBJECT(ha), "func", pfunc);
702 hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin));
708 change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
710 GtkWidget *image = NULL;
711 GdkPixbuf *pixbuf = NULL;
714 str = g_strdup_printf( "%s/%s/%s", THEME_PATH,
715 desktop_plugin->priv->theme, actor->filename);
717 pixbuf = gdk_pixbuf_new_from_file_at_size (str,
724 image = gtk_image_new_from_pixbuf (pixbuf);
725 g_object_unref(G_OBJECT(pixbuf));
728 g_signal_connect(G_OBJECT(image), "expose_event",
729 G_CALLBACK(expose_event), pixbuf);
730 if (g_object_get_data(G_OBJECT(actor->widget), "image")){
731 gtk_container_remove(GTK_CONTAINER(actor->widget), g_object_get_data(G_OBJECT(actor->widget), "image"));
733 g_object_set_data(G_OBJECT(actor->widget), "image", image);
734 gtk_container_add (GTK_CONTAINER (actor->widget), image);
735 realize(actor->widget);
736 gtk_widget_show_all(actor->widget);
747 change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
750 newfile = g_strdup_printf("%s%d.png", actor->name, desktop_plugin->priv->scene->daytime);
752 g_free(actor->filename);
753 actor->filename = newfile;
754 change_hildon_actor(actor, desktop_plugin);
758 change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin)
762 if (desktop_plugin->priv->right_corner)
763 gtk_widget_destroy(desktop_plugin->priv->right_corner);
764 snprintf(buffer, sizeof(buffer) - 1, "%s/%s/town%i_right_corner.png", \
765 THEME_PATH, desktop_plugin->priv->theme, desktop_plugin->priv->scene->daytime);
766 desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
767 if (desktop_plugin->priv->right_corner){
768 gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
769 gtk_widget_show (desktop_plugin->priv->right_corner);
771 change_static_actor(actor, desktop_plugin);
776 change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin)
781 if (!desktop_plugin->priv->rich_animation) return;
783 a = g_ptr_array_index(actor->child, 0);
785 if (y > 480) y = -480;
786 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
787 actor_set_position_full(a->widget, a->x, y, a->z);
790 a = g_ptr_array_index(actor->child, 1);
792 if (y > 480) y = -480;
793 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
794 actor_set_position_full(a->widget, a->x, y, a->z);
797 a = g_ptr_array_index(actor->child, 2);
799 if (y > 480) y = -480;
800 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
801 actor_set_position_full(a->widget, a->x, y, a->z);
804 a = g_ptr_array_index(actor->child, 3);
806 if (y > 480) y = -480;
807 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
808 actor_set_position_full(a->widget, a->x, y, a->z);
814 change_layer1(Actor * actor, AWallpaperPlugin *desktop_plugin)
818 if (y > 480) y = -480;
819 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
820 actor_set_position_full(actor->widget, actor->x, y, actor->z);
825 change_layer2(Actor * actor, AWallpaperPlugin *desktop_plugin)
829 if (y >= 480) y = -480;
830 //fprintf(stderr, "!! %s - %d\n", actor->name, y);
831 actor_set_position_full(actor->widget, actor->x, y, actor->z);
838 // уравнение изменения времени
843 destroy_scene(AWallpaperPlugin *desktop_plugin)
845 GSList * tmp = desktop_plugin->priv->scene->actors;
851 g_ptr_array_free(actor->child, TRUE);
854 g_free(actor->filename);
857 gtk_widget_destroy(actor->widget);
858 //actor->widget = NULL;
861 tmp = g_slist_next(tmp);
868 reload_scene(AWallpaperPlugin *desktop_plugin)
870 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
871 destroy_scene(desktop_plugin);
872 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
873 init_scene(desktop_plugin);
874 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
875 init_scene1(desktop_plugin);
876 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
877 init_scene2(desktop_plugin);
881 init_scene2(AWallpaperPlugin *desktop_plugin)
886 gint now = time(NULL);
889 if (desktop_plugin->priv->rich_animation){
897 fprintf(stderr, "init scene2 \n");
898 scene = g_new0(Scene, 1);
899 //scene.daytime = get_daytime();
900 scene->actors = NULL;
901 desktop_plugin->priv->scene = scene;
903 actor = init_object(desktop_plugin, "background", "bg.png",
905 TRUE, TRUE, 100, 255,
907 scene->actors = g_slist_append(scene->actors, actor);
909 actor = init_object(desktop_plugin, "symbols", "symbols.png",
911 TRUE, TRUE, 100, 255,
913 scene->actors = g_slist_append(scene->actors, actor);
915 child = g_ptr_array_sized_new(4);
916 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
918 TRUE, TRUE, 100, 255,
920 //actor->time_start_animation = now;
921 //actor->duration_animation = G_MAXINT;
922 scene->actors = g_slist_append(scene->actors, actor);
923 g_ptr_array_add(child, actor);
925 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
927 TRUE, TRUE, 100, 255,
929 //actor->time_start_animation = now;
930 //actor->duration_animation = G_MAXINT;
931 scene->actors = g_slist_append(scene->actors, actor);
932 g_ptr_array_add(child, actor);
934 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
936 TRUE, TRUE, 100, 255,
938 //actor->time_start_animation = now;
939 //actor->duration_animation = G_MAXINT;
940 scene->actors = g_slist_append(scene->actors, actor);
941 g_ptr_array_add(child, actor);
943 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
945 TRUE, TRUE, 100, 255,
947 //actor->time_start_animation = now;
948 //actor->duration_animation = G_MAXINT;
949 scene->actors = g_slist_append(scene->actors, actor);
950 g_ptr_array_add(child, actor);
952 actor = init_object(desktop_plugin, "layers", "",
954 FALSE, FALSE, 100, 255,
955 (gpointer)&change_layer, NULL, child);
956 actor->time_start_animation = now;
957 actor->duration_animation = G_MAXINT;
958 scene->actors = g_slist_append(scene->actors, actor);
960 run_long_timeout(desktop_plugin);
964 /* Init Modern Scene */
966 init_scene(AWallpaperPlugin *desktop_plugin)
970 gint now = time(NULL);
974 //fprintf(stderr, "init scene \n");
975 scene = g_new0(Scene, 1);
976 scene->daytime = get_daytime();
977 scene->actors = NULL;
978 scene->wind_orientation = -1;
979 scene->wind_angle = 0.3;
980 /* init value for random */
981 scene->seed = time(NULL);
982 desktop_plugin->priv->scene = scene;
984 actor = init_object(desktop_plugin, "sky", "sky0.png",
986 TRUE , TRUE, 100, 255,
987 (gpointer)&change_static_actor, NULL, NULL);
988 change_static_actor(actor, desktop_plugin);
989 scene->actors = g_slist_append(scene->actors, actor);
991 actor = init_object(desktop_plugin, "sun", "sun.png",
993 FALSE, FALSE, 100, 255,
994 (gpointer)&change_sun, (gpointer)&probability_sun, NULL);
995 actor->time_start_animation = now;
996 actor->duration_animation = G_MAXINT;
997 change_sun(actor, desktop_plugin);
998 scene->actors = g_slist_append(scene->actors, actor);
1000 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
1001 // TRUE, 100, 255, NULL, NULL);
1002 //scene.actors = g_slist_append(scene.actors, actor);
1004 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
1005 0, fast_rnd(300)-97, 7, 150, 97,
1006 FALSE, FALSE, 100, 255,
1007 (gpointer)&change_cloud, NULL, NULL);
1008 actor->time_start_animation = now + fast_rnd(20);
1009 actor->duration_animation = 3*60;
1010 scene->actors = g_slist_append(scene->actors, actor);
1012 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
1013 0, fast_rnd(300)-75, 7, 188, 75,
1014 FALSE, FALSE, 100, 255,
1015 (gpointer)&change_cloud, NULL, NULL);
1016 actor->time_start_animation = now + fast_rnd(40)+10;
1017 actor->duration_animation = 3*60;
1018 scene->actors = g_slist_append(scene->actors, actor);
1020 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
1021 0, fast_rnd(300)-75, 7, 150, 75,
1022 FALSE, FALSE, 100, 255,
1023 (gpointer)&change_cloud, NULL, NULL);
1024 actor->time_start_animation = now + fast_rnd(60) + 20;
1025 actor->duration_animation = 5*60;
1026 scene->actors = g_slist_append(scene->actors, actor);
1029 actor = init_object(desktop_plugin, "town", "town0.png",
1031 TRUE, TRUE, 100, 255,
1032 (gpointer)&change_static_actor, NULL, NULL);
1033 change_static_actor(actor, desktop_plugin);
1034 scene->actors = g_slist_append(scene->actors, actor);
1036 actor = init_object(desktop_plugin, "tram", "tram.png",
1037 -300, 225, 9, 350, 210,
1038 FALSE, FALSE, 100, 255,
1039 (gpointer)&change_tram, NULL, NULL);
1040 actor->time_start_animation = time(NULL) + fast_rnd(10);
1041 actor->duration_animation = 60;
1042 scene->actors = g_slist_append(scene->actors, actor);
1044 actor = init_object(desktop_plugin, "border", "border0.png",
1045 0, 480-79, 10, 800, 79,
1046 TRUE, TRUE, 100, 255,
1047 (gpointer)&change_static_actor_with_corner, NULL, NULL);
1048 change_static_actor_with_corner(actor, desktop_plugin);
1049 scene->actors = g_slist_append(scene->actors, actor);
1051 actor = init_object(desktop_plugin, "moon", "moon1.png",
1053 FALSE, FALSE, 100, 255,
1054 (gpointer)&change_moon, NULL, NULL);
1055 change_moon(actor, desktop_plugin);
1056 scene->actors = g_slist_append(scene->actors, actor);
1058 actor = init_object(desktop_plugin, "wind", "",
1060 FALSE, FALSE, 100, 255,
1061 (gpointer)&change_wind, NULL, NULL);
1062 change_wind(actor, desktop_plugin);
1063 scene->actors = g_slist_append(scene->actors, actor);
1065 /* windows in 4-th house */
1105 for (i=0; i<13; i++){
1106 actor = init_object(desktop_plugin, "window1", "window1.png",
1107 winds[i][0], winds[i][1], 8, 8, 10,
1108 FALSE, FALSE, 100, 255,
1109 (gpointer)&change_window1, NULL, NULL);
1110 //change_window1(actor, desktop_plugin);
1111 actor->time_start_animation = now + fast_rnd(30);
1112 scene->actors = g_slist_append(scene->actors, actor);
1116 /* windows in 1-th house */
1141 for (i=0; i<8; i++){
1142 actor = init_object(desktop_plugin, "window2", "window2.png",
1143 winds[i][0], winds[i][1], 8, 8, 10,
1144 FALSE, FALSE, 100, 255,
1145 (gpointer)&change_window1, NULL, NULL);
1146 //change_window1(actor, desktop_plugin);
1147 actor->time_start_animation = now + fast_rnd(30);
1148 scene->actors = g_slist_append(scene->actors, actor);
1152 /* windows in 3-th house */
1184 for (i=0; i<10; i++){
1185 actor = init_object(desktop_plugin, "window3", "window3.png",
1186 winds[i][0], winds[i][1], 8, 8, 10,
1187 FALSE, FALSE, 100, 255,
1188 (gpointer)&change_window1, NULL, NULL);
1189 //change_window1(actor, desktop_plugin);
1190 actor->time_start_animation = now + fast_rnd(30);
1191 scene->actors = g_slist_append(scene->actors, actor);
1195 /* windows in 5-th house */
1218 for (i=0; i<7; i++){
1219 actor = init_object(desktop_plugin, "window4", "window4.png",
1220 winds[i][0], winds[i][1], 8, 8, 10,
1221 FALSE, FALSE, 100, 255,
1222 (gpointer)&change_window1, NULL, NULL);
1223 //change_window1(actor, desktop_plugin);
1224 actor->time_start_animation = now + fast_rnd(30);
1225 scene->actors = g_slist_append(scene->actors, actor);
1229 /* windows in 6-th house */
1249 for (i=0; i<6; i++){
1250 actor = init_object(desktop_plugin, "window5", "window5.png",
1251 winds[i][0], winds[i][1], 8, 8, 10,
1252 FALSE, FALSE, 100, 255,
1253 (gpointer)&change_window1, NULL, NULL);
1254 //change_window1(actor, desktop_plugin);
1255 actor->time_start_animation = now + fast_rnd(30);
1256 scene->actors = g_slist_append(scene->actors, actor);
1259 run_long_timeout(desktop_plugin);
1262 anim = g_new0(Animation, 1);
1264 anim->actor = actor;
1265 anim->func_change = &change_tram;
1266 anim->func_time = NULL;
1267 anim->timestart = time(NULL);
1270 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
1274 /* Init Berlin Scene */
1276 init_scene1(AWallpaperPlugin *desktop_plugin)
1278 Actor *actor, *actor1, *actor2;
1280 gint now = time(NULL);
1283 GPtrArray *child = NULL;
1285 scene = g_new0(Scene, 1);
1286 scene->daytime = get_daytime();
1287 scene->actors = NULL;
1288 scene->wind_orientation = -1;
1289 scene->wind_angle = 0.3;
1290 /* init value for random */
1291 scene->seed = time(NULL);
1292 desktop_plugin->priv->scene = scene;
1294 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
1295 TRUE, TRUE, 100, 255,
1296 (gpointer)&change_static_actor, NULL, NULL);
1297 change_static_actor(actor, desktop_plugin);
1298 scene->actors = g_slist_append(scene->actors, actor);
1301 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
1302 FALSE, FALSE, 100, 255,
1303 (gpointer)&change_sun, (gpointer)&probability_sun, NULL);
1304 actor->time_start_animation = time(NULL);
1305 actor->duration_animation = G_MAXINT;
1306 change_sun(actor, desktop_plugin);
1307 scene->actors = g_slist_append(scene->actors, actor);
1310 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
1311 TRUE, 100, 255, NULL, NULL);
1312 scene.actors = g_slist_append(scene.actors, actor);
1315 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
1316 FALSE, FALSE, 100, 255,
1317 (gpointer)&change_moon, NULL, NULL);
1318 change_moon(actor, desktop_plugin);
1319 scene->actors = g_slist_append(scene->actors, actor);
1321 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
1322 FALSE, FALSE, 100, 255,
1323 (gpointer)&change_cloud, NULL, NULL);
1324 actor->time_start_animation = now + fast_rnd(30) + 10;
1325 actor->duration_animation = 3*60;
1326 scene->actors = g_slist_append(scene->actors, actor);
1328 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
1329 FALSE, FALSE, 100, 255,
1330 (gpointer)&change_cloud, NULL, NULL);
1331 actor->time_start_animation = now + fast_rnd(10);
1332 actor->duration_animation = 3*60;
1333 scene->actors = g_slist_append(scene->actors, actor);
1335 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
1336 FALSE, FALSE, 100, 255,
1337 (gpointer)&change_cloud, NULL, NULL);
1338 actor->time_start_animation = now + fast_rnd(60) + 20;
1339 actor->duration_animation = 5*60;
1340 scene->actors = g_slist_append(scene->actors, actor);
1343 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
1344 FALSE, FALSE, 100, 255,
1345 (gpointer)&change_plane2, NULL, NULL);
1346 actor->time_start_animation = now + fast_rnd(40) + 20;
1347 actor->duration_animation = 60;
1348 scene->actors = g_slist_append(scene->actors, actor);
1350 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
1351 FALSE, FALSE, 100, 255,
1352 (gpointer)&change_plane1, NULL, NULL);
1353 actor->time_start_animation = now + fast_rnd(20);
1354 actor->duration_animation = 30;
1355 scene->actors = g_slist_append(scene->actors, actor);
1357 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
1358 TRUE, TRUE, 100, 255,
1359 (gpointer)&change_static_actor_with_corner, NULL, NULL);
1360 change_static_actor_with_corner(actor, desktop_plugin);
1361 scene->actors = g_slist_append(scene->actors, actor);
1363 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
1364 FALSE, FALSE, 100, 255,
1365 (gpointer)&change_wind, NULL, NULL);
1366 change_wind(actor, desktop_plugin);
1367 scene->actors = g_slist_append(scene->actors, actor);
1369 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
1370 486, 425, 10, 18, 38,
1371 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
1372 //actor->time_start_animation = now + fast_rnd(30) + 10;
1373 scene->actors = g_slist_append(scene->actors, actor1);
1375 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
1376 486, 425, 10, 18, 38,
1377 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
1378 //actor->time_start_animation = now + fast_rnd(30) + 10;
1379 scene->actors = g_slist_append(scene->actors, actor2);
1380 child = g_ptr_array_sized_new(2);
1381 g_ptr_array_add(child, actor1);
1382 g_ptr_array_add(child, actor2);
1383 actor = init_object(desktop_plugin, "signal", "",
1384 486, 425, 10, 18, 38,
1385 FALSE, FALSE, 100, 255,
1386 (gpointer)&change_signal, NULL, child);
1387 actor->time_start_animation = now + fast_rnd(30) + 10;
1388 scene->actors = g_slist_append(scene->actors, actor);
1429 for (i=0; i<13; i++){
1430 actor = init_object(desktop_plugin, "window", "window.png",
1431 winds[i][0], winds[i][1], 10, 8, 9,
1432 FALSE, TRUE, 100, 255,
1433 (gpointer)&change_window1, NULL, NULL);
1434 //change_window1(actor, desktop_plugin);
1435 actor->time_start_animation = now + fast_rnd(30);
1436 scene->actors = g_slist_append(scene->actors, actor);
1440 run_long_timeout(desktop_plugin);
1445 get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
1447 gint y0 = 365;// - уровень горизонта
1448 *x = (int)(azm * 800) - 64;
1449 *y = (int)((1 - alt) * y0) - 64;
1450 //fprintf(stderr, "sun pos alt=%f azm=%f x=%d y=%d\n", alt, azm, *x, *y);
1454 change_actor(GtkWidget * actor)
1457 gint x, y, daytime, scale;
1464 void (*pfunc)(gpointer, gpointer);
1466 name = g_object_get_data(G_OBJECT(actor), "name");
1467 fprintf(stderr, "change actor %s\n", name);
1469 pfunc = g_object_get_data(G_OBJECT(actor), "func");
1471 (*pfunc)(actor, g_strdup(name));
1472 daytime = get_daytime();
1473 if (daytime != TIME_NIGHT){
1474 hildon_animation_actor_set_show(actor, 1);
1475 get_sun_pos(&alt, &azm);
1476 get_sun_screen_pos(alt, azm, &x, &y);
1477 actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
1481 if (name == "cloud1"){
1482 x = g_object_get_data(G_OBJECT(actor), "x");
1483 y = g_object_get_data(G_OBJECT(actor), "y");
1484 scale = g_object_get_data(G_OBJECT(actor), "scale");
1487 image = g_object_get_data(G_OBJECT(actor), "image");
1489 gtk_container_remove(actor, image);
1490 pixbuf = gdk_pixbuf_new_from_file_at_size ("/usr/share/livewp/theme/Modern/sun.png",
1495 image = gtk_image_new_from_pixbuf (pixbuf);
1496 g_object_unref(G_OBJECT(pixbuf));
1498 g_signal_connect(G_OBJECT(image), "expose_event",
1499 G_CALLBACK(expose_event), pixbuf);
1500 gtk_container_add (GTK_CONTAINER (actor), image);
1502 gtk_widget_show_all(actor);
1514 sc = (double)scale / 100;
1515 hildon_animation_actor_set_scale(actor, sc, sc);
1516 fprintf(stderr, "cloud x=%d y=%d scale=%f", x, y, sc);
1517 actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
1518 g_object_set_data(G_OBJECT(actor), "x", x);
1519 g_object_set_data(G_OBJECT(actor), "y", y);
1520 g_object_set_data(G_OBJECT(actor), "scale", scale);
1526 short_timeout (AWallpaperPlugin *desktop_plugin)
1528 //gint daytime = get_daytime();
1530 void (*pfunc)(gpointer, gpointer);
1533 gboolean stop_flag = TRUE;
1535 if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
1536 desktop_plugin->priv->short_timer = 0;
1541 //scene.daytime = daytime;
1542 /* fprintf(stderr, "Short timer %d\n", now); */
1543 tmp = desktop_plugin->priv->scene->actors;
1544 while (tmp != NULL){
1546 if (now >= actor->time_start_animation
1547 && actor->time_start_animation > 0
1548 /* && now - actor->time_start_animation <= actor->duration_animation*/){
1549 pfunc = actor->func_change;
1551 (*pfunc)(actor, desktop_plugin);
1555 tmp = g_slist_next(tmp);
1558 desktop_plugin->priv->short_timer = 0;
1561 return TRUE; /* keep running this event */
1565 run_long_timeout(AWallpaperPlugin *desktop_plugin)
1568 gint daytime = get_daytime();
1570 void (*pfunc)(gpointer, gpointer);
1575 //fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer);
1576 if (desktop_plugin->priv->scene->daytime != daytime){
1577 desktop_plugin->priv->scene->daytime = daytime;
1578 tmp = desktop_plugin->priv->scene->actors;
1579 while (tmp != NULL){
1580 //change_actor(tmp->data);
1581 pfunc =((Actor*)tmp->data)->func_change;
1583 (*pfunc)(tmp->data, desktop_plugin);
1585 tmp = g_slist_next(tmp);
1590 //fprintf(stderr, "Now %d\n", now);
1591 tmp = desktop_plugin->priv->scene->actors;
1592 while (tmp != NULL){
1594 if (now >= actor->time_start_animation
1595 && actor->time_start_animation > 0
1596 && desktop_plugin->priv->short_timer == 0){
1597 /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
1598 if (desktop_plugin->priv->rich_animation){
1599 actor->time_start_animation = now;
1600 desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
1603 (*actor->func_change)(actor, desktop_plugin);
1606 tmp = g_slist_next(tmp);
1612 long_timeout (AWallpaperPlugin *desktop_plugin)
1614 /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
1615 if (desktop_plugin->priv->long_timer == 0 )
1617 if (!desktop_plugin->priv->visible){
1618 if(desktop_plugin->priv->short_timer != 0){
1619 g_source_remove(desktop_plugin->priv->short_timer);
1620 desktop_plugin->priv->short_timer = 0;
1622 desktop_plugin->priv->long_timer = 0;
1627 run_long_timeout(desktop_plugin);
1628 return TRUE; /* keep running this event */
1632 desktop_plugin_visible_notify (GObject *object,
1634 AWallpaperPlugin *desktop_plugin)
1637 g_object_get (object, "is-on-current-desktop", &visible, NULL);
1638 /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
1640 desktop_plugin->priv->visible = TRUE;
1641 if (desktop_plugin->priv->long_timer == 0 ){
1642 desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
1643 run_long_timeout(desktop_plugin);
1646 desktop_plugin->priv->visible = FALSE;
1647 if (desktop_plugin->priv->long_timer != 0 ){
1648 g_source_remove(desktop_plugin->priv->long_timer);
1649 desktop_plugin->priv->long_timer = 0;
1655 rich_animation_press(GtkWidget *widget, GdkEvent *event,
1656 gpointer user_data){
1657 fprintf(stderr,"gggggggggggggggggggg2222\n");
1661 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
1663 GtkWidget *rich_animation;
1667 //fprintf(stderr, "!!!!!!!plugin init \n");
1668 Animation_WallpaperPrivate *priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
1669 desktop_plugin->priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
1670 priv->osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
1674 /* Initialize DBUS */
1675 livewp_initialize_dbus(priv);
1677 priv->desktop_plugin = desktop_plugin;
1678 priv->visible = TRUE;
1679 priv->short_timer = 0;
1680 //priv->theme = g_strdup("Modern");
1681 desktop_plugin->priv->main_widget = gtk_fixed_new();
1683 gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 100, 32);
1684 desktop_plugin->priv->right_corner = NULL;
1685 snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town0_right_corner.png");
1686 desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
1687 if (desktop_plugin->priv->right_corner){
1688 gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
1689 gtk_widget_show (desktop_plugin->priv->right_corner);
1691 /* Create rich animation event */
1692 rich_animation = gtk_event_box_new();
1694 gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
1695 gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
1696 gtk_widget_set_size_request(rich_animation, 100, 32);
1697 gtk_widget_show (rich_animation);
1698 g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
1699 gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), rich_animation, 0, 0);
1702 GtkWidget *label = gtk_label_new ("ddddddddddddd");
1703 gtk_widget_set_size_request(label, 95, 30);
1704 gtk_widget_show (label);
1705 // gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
1706 gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
1708 hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
1709 g_signal_connect (desktop_plugin, "show-settings",
1710 G_CALLBACK (show_settings), priv);
1711 gtk_widget_show (desktop_plugin->priv->main_widget);
1712 gtk_container_add (GTK_CONTAINER (desktop_plugin), desktop_plugin->priv->main_widget);
1713 init_applet_position();
1716 fprintf(stderr, "!!!theme = %s\n", priv->theme);
1718 if (!strcmp(priv->theme,"Modern"))
1719 init_scene(desktop_plugin);
1720 else if (!strcmp(priv->theme,"Berlin"))
1721 init_scene1(desktop_plugin);
1722 else if (!strcmp(priv->theme, "Matrix"))
1723 init_scene2(desktop_plugin);
1724 priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
1725 /* TODO Move scene to priv */
1726 //scene.timer_type = LONG_TIMER_TYPE;
1727 g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
1728 G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
1735 lw_applet_finalize (GObject *object)
1737 AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
1738 Animation_WallpaperPrivate *priv = desktop_plugin->priv;
1740 fprintf(stderr,"finalaze %i\n", priv->long_timer);
1741 if (priv->long_timer){
1742 g_source_remove(priv->long_timer);
1743 priv->long_timer = 0;
1745 if (priv->short_timer){
1746 g_source_remove(priv->short_timer);
1747 priv->short_timer = 0;
1750 destroy_scene(desktop_plugin);
1754 animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
1756 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
1757 GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
1760 gobject_class->destroy = (gpointer)lw_applet_finalize;
1761 widget_class->realize = lw_applet_realize;
1762 widget_class->expose_event = lw_applet_expose_event;
1764 g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));
1769 animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {