a181dc5121144f5dbd6c8dac0ec0e4f3eea66921
[livewp] / applet / src / livewp-home-widget.c
1 /*vim: set sw=4 ts=4 et: */
2 /*
3  * This file is part of Live Wallpaper (livewp)
4  * 
5  * Copyright (C) 2010 Vlad Vasiliev
6  * Copyright (C) 2010 Tanya Makova
7  *       for the code
8  * 
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.
13  * 
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.
18  * 
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
22  * 02110-1301 USA
23 */
24 /*******************************************************************************/
25 #include "livewp-common.h" 
26 #include "livewp-home-widget.h"
27 #include "livewp-actor.h"
28 #include <gconf/gconf-client.h>
29 #include "livewp-rules.h"
30 #include <sys/time.h>
31 #include <stdlib.h>
32
33 #define PLUGIN_NAME "livewp-home-widget.desktop-0"
34 #define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/%s/position"
35 #define GCONF_KEY_MODIFIED "/apps/osso/hildon-desktop/applets/%s/modified"
36 #define GCONF_KEY_VIEW     "/apps/osso/hildon-desktop/applets/%s/view"
37
38 HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_HOME_PLUGIN_ITEM)
39 #define Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj,\
40                                                           Animation_Wallpaper_TYPE_HOME_PLUGIN,\
41                                                           Animation_WallpaperPrivate))
42
43 /* Position of plugin on desktop */
44 #define Xstartposition 700 
45 #define Ystartposition 448 
46
47 gint xapplet = 0, yapplet = 0;
48 //Scene scene;
49
50 static void
51 lw_applet_realize (GtkWidget *widget)
52 {
53       GdkScreen *screen;
54
55       screen = gtk_widget_get_screen (widget);
56       gtk_widget_set_colormap (widget,
57                                 gdk_screen_get_rgba_colormap (screen));
58       gtk_widget_set_app_paintable (widget,
59                                 TRUE);
60       GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
61 }
62
63
64 static gboolean
65 lw_applet_expose_event(GtkWidget      *widget,
66                                         GdkEventExpose *event)
67 {
68   cairo_t *cr;
69
70   /* Create cairo context */
71   cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
72   gdk_cairo_region (cr, event->region);
73   cairo_clip (cr);
74
75   /* Draw alpha background */
76   cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
77   cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
78   cairo_paint (cr);
79
80   /* Free context */
81   cairo_destroy (cr);
82
83   return GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->expose_event (widget,
84                                                                                   event);
85 }
86
87 static gboolean
88 expose_event (GtkWidget *widget,GdkEventExpose *event,
89      gpointer data)
90 {
91     cairo_t *cr;
92     GdkPixbuf *pixbuf = (GdkPixbuf *) data;
93         
94     cr = gdk_cairo_create(widget->window);
95     if (cr){
96         gdk_cairo_region(cr, event->region);
97         cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
98         gdk_cairo_set_source_pixbuf(cr, pixbuf, 0.0, 0.0);
99         cairo_paint(cr);
100         cairo_destroy(cr);
101     }
102     return TRUE;
103 }
104
105 static void
106 realize (GtkWidget *widget)
107 {
108     GdkScreen *screen;
109     screen = gtk_widget_get_screen (widget);
110     gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));
111 }
112
113 /* Set position of widget on desktop */
114 static void
115 init_applet_position(void)
116 {
117   GSList *position = NULL;
118   gchar *position_key;
119   gchar *modified_key;
120   gchar *modified;
121   GError *error = NULL;
122   GConfClient   *gconf_client = gconf_client_get_default ();
123   position_key = g_strdup_printf (GCONF_KEY_POSITION, PLUGIN_NAME);
124   position = gconf_client_get_list (gconf_client,
125                                     position_key,
126                                     GCONF_VALUE_INT,
127                                     NULL);
128   if (position && position->data && position->next->data){
129         xapplet = GPOINTER_TO_INT (position->data);
130         yapplet = GPOINTER_TO_INT (position->next->data);
131   }else{
132         position = g_slist_prepend (g_slist_prepend (NULL,
133                                       GINT_TO_POINTER (Ystartposition)),
134                                       GINT_TO_POINTER (Xstartposition));
135         gconf_client_set_list (gconf_client,
136                                position_key,
137                                GCONF_VALUE_INT,
138                                position,
139                                &error);
140         xapplet = Xstartposition;
141         yapplet = Ystartposition;
142   }
143   g_free (position_key);
144   modified = g_strdup_printf ("%i", 0);
145   modified_key = g_strdup_printf (GCONF_KEY_MODIFIED, PLUGIN_NAME);
146   gconf_client_set_string (gconf_client,
147                            modified_key,
148                            modified,
149                            &error);
150   g_free(modified);
151   g_free(modified_key);
152   gconf_client_clear_cache(gconf_client);
153   g_object_unref(gconf_client);
154 }
155
156 void
157 actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
158 {
159 /*  fprintf(stderr, "actor_set_position_full z=%d\n", z); */
160     hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-xapplet, y-yapplet, z);
161 }
162
163
164 void
165 destroy_hildon_actor(Actor *actor)
166 {
167     //fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
168     gtk_widget_destroy(actor->widget);
169     actor->widget = NULL;
170 }
171
172
173 gint 
174 rnd(gint max)
175 {
176     srand(time(NULL));
177     return rand() % max;
178 }
179 gint fast_rnd(gint max)
180 {
181     guint offset = 12923;
182     guint multiplier = 4079;
183     
184     //*seed = *seed * multiplier + offset;
185     //return (gint)(*seed % max);
186     guint seed = time(NULL);
187     return (gint)(seed % max);
188 }
189
190 void
191 create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) 
192 {
193   GtkWidget *ha = NULL;
194   GdkPixbuf *pixbuf = NULL;
195   GtkWidget *image = NULL;
196   gchar     *str = NULL;
197
198   ha = hildon_animation_actor_new();
199   str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
200                         desktop_plugin->priv->theme, actor->filename);
201   pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
202                                              actor->width, 
203                                              actor->height, 
204                                              NULL);
205   /*fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str);*/
206   if (str)
207       g_free(str);
208   if (pixbuf){
209       image = gtk_image_new_from_pixbuf (pixbuf);
210       g_object_unref(G_OBJECT(pixbuf));
211   }
212   if (image){
213     g_signal_connect(G_OBJECT(image), "expose_event",
214                            G_CALLBACK(expose_event), pixbuf);
215     gtk_container_add (GTK_CONTAINER (ha), image);
216   }  
217   actor_set_position_full(ha, actor->x, actor->y, actor->z);
218   hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(ha), (double)actor->scale/100, (double)actor->scale/100);
219   realize(ha);
220   gtk_widget_show_all(ha);
221   hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(ha), actor->visible);
222   
223   /* TO DO check it */
224   /*  gdk_flush (); */
225
226   g_object_set_data(G_OBJECT(ha), "image", image);
227   hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin));
228   actor->widget = ha;
229 }
230
231
232 void
233 change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
234 {
235     GtkWidget *image = NULL;
236     GdkPixbuf *pixbuf = NULL;
237     gchar     *str = NULL;
238
239     str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
240                             desktop_plugin->priv->theme, actor->filename);
241  
242     pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
243                                                actor->width, 
244                                                actor->height, 
245                                                NULL);
246     if(str)
247         g_free(str);
248     if (pixbuf){
249         image = gtk_image_new_from_pixbuf (pixbuf);
250         g_object_unref(G_OBJECT(pixbuf));
251     }
252     if (image){ 
253         g_signal_connect(G_OBJECT(image), "expose_event",
254                                        G_CALLBACK(expose_event), pixbuf);
255         if (g_object_get_data(G_OBJECT(actor->widget), "image")){
256             gtk_container_remove(GTK_CONTAINER(actor->widget), g_object_get_data(G_OBJECT(actor->widget), "image"));  
257         }
258         g_object_set_data(G_OBJECT(actor->widget), "image", image);
259         gtk_container_add (GTK_CONTAINER (actor->widget), image);
260         realize(actor->widget);
261         gtk_widget_show_all(actor->widget);
262         /* TO DO check it */
263        /*  gdk_flush (); */
264
265
266     }
267
268 }
269
270
271 void 
272 change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
273 {
274     gchar *newfile;
275     newfile = g_strdup_printf("%s%d.png", actor->name, desktop_plugin->priv->scene->daytime); 
276     if (actor->filename)
277             g_free(actor->filename);
278     actor->filename = newfile;
279     change_hildon_actor(actor, desktop_plugin);
280 }
281
282 void 
283 change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin)
284 {
285     gchar buffer[2048];
286
287     if (desktop_plugin->priv->right_corner)
288         gtk_widget_destroy(desktop_plugin->priv->right_corner);
289     snprintf(buffer, sizeof(buffer) - 1, "%s/%s/town%i_right_corner.png", \
290                                   THEME_PATH, desktop_plugin->priv->theme, desktop_plugin->priv->scene->daytime);
291     desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
292     if (desktop_plugin->priv->right_corner){
293         gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
294         gtk_widget_show (desktop_plugin->priv->right_corner);
295     }
296     change_static_actor(actor, desktop_plugin);
297
298 }
299
300 void
301 change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin)
302 {
303     gint y;
304     Actor *a;
305
306     if (!desktop_plugin->priv->rich_animation) return;
307
308     a = g_ptr_array_index(actor->child, 0);
309     y = a->y + 10;
310     if (y > 480) y = -480;
311     actor_set_position_full(a->widget, a->x, y, a->z);
312     a->y = y;
313     
314     a = g_ptr_array_index(actor->child, 1);
315     y = a->y + 10;
316     if (y > 480) y = -480;
317     actor_set_position_full(a->widget, a->x, y, a->z);
318     a->y = y;
319
320     a = g_ptr_array_index(actor->child, 2);
321     y = a->y + 20;
322     if (y > 480) y = -480;
323     actor_set_position_full(a->widget, a->x, y, a->z);
324     a->y = y;
325
326     a = g_ptr_array_index(actor->child, 3);
327     y = a->y + 20;
328     if (y > 480) y = -480;
329     actor_set_position_full(a->widget, a->x, y, a->z);
330     a->y = y;
331
332 }
333 #if 0
334 void
335 change_layer1(Actor * actor, AWallpaperPlugin *desktop_plugin)
336 {
337     gint y;
338     y = actor->y + 10;
339     if (y > 480) y = -480;
340     actor_set_position_full(actor->widget, actor->x, y, actor->z);
341     actor->y = y;
342 }
343
344 void
345 change_layer2(Actor * actor, AWallpaperPlugin *desktop_plugin)
346 {
347     gint y;
348     y = actor->y + 15;
349     if (y >= 480) y = -480;
350     actor_set_position_full(actor->widget, actor->x, y, actor->z);
351     actor->y = y;
352 }
353 #endif
354 /*
355 static gint 
356 get_time(gint t){
357     // уравнение изменения времени
358     return t*1.1;
359 }
360 */
361 static void 
362 destroy_scene(AWallpaperPlugin *desktop_plugin)
363 {
364     GSList * tmp = desktop_plugin->priv->scene->actors;
365     Actor *actor;
366     while (tmp != NULL){
367         actor = tmp->data;
368         if (actor){
369             if (actor->child){
370                 g_ptr_array_free(actor->child, TRUE);
371             }
372             if (actor->filename)
373                 g_free(actor->filename);
374             if (actor->name)
375                 g_free(actor->name);
376             gtk_widget_destroy(actor->widget);
377             //actor->widget = NULL;
378             g_free(actor);
379         }
380         tmp = g_slist_next(tmp);
381     }
382     g_slist_free(tmp);
383
384 }
385
386 void
387 reload_scene(AWallpaperPlugin *desktop_plugin)
388 {
389     fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);  
390     destroy_scene(desktop_plugin);
391     if (!strcmp(desktop_plugin->priv->theme,"Modern"))
392         init_scene(desktop_plugin);
393     else if (!strcmp(desktop_plugin->priv->theme,"Berlin")) 
394         init_scene1(desktop_plugin);
395     else if (!strcmp(desktop_plugin->priv->theme,"Matrix")) 
396         init_scene2(desktop_plugin);
397 }
398
399 static void
400 init_scene2(AWallpaperPlugin *desktop_plugin)
401 {
402   Actor *actor;
403   Scene *scene;
404   GPtrArray *child;
405   gint now = time(NULL);
406   gint y1, y2;
407
408   if (desktop_plugin->priv->rich_animation){
409       y1 = -480;
410       y2 = -480-480;
411   }else {
412       y1 = 0;
413       y2 = -480;
414   }
415
416   fprintf(stderr, "init scene2 \n");
417   scene = g_new0(Scene, 1);
418   //scene.daytime = get_daytime();
419   scene->actors = NULL;
420   desktop_plugin->priv->scene = scene;
421   
422   actor = init_object(desktop_plugin, "background", "bg.png", 
423                       0, 0, 5, 800, 480, 
424                       TRUE, TRUE, 100, 255, 
425                       NULL, NULL, NULL);
426   scene->actors = g_slist_append(scene->actors, actor);
427
428   actor = init_object(desktop_plugin, "symbols", "symbols.png", 
429                       0, 0, 10, 800, 480, 
430                       TRUE, TRUE, 100, 255, 
431                       NULL, NULL, NULL);
432   scene->actors = g_slist_append(scene->actors, actor);
433
434   child = g_ptr_array_sized_new(4);
435   actor = init_object(desktop_plugin, "layer1", "layer1_2.png", 
436                       0, y1, 6, 800, 960, 
437                       TRUE, TRUE, 100, 255, 
438                       NULL, NULL, NULL);
439   //actor->time_start_animation = now;
440   //actor->duration_animation = G_MAXINT;
441   scene->actors = g_slist_append(scene->actors, actor);
442   g_ptr_array_add(child, actor);
443
444   actor = init_object(desktop_plugin, "layer1", "layer1_1.png", 
445                       0, y2, 7, 800, 960, 
446                       TRUE, TRUE, 100, 255, 
447                       NULL, NULL, NULL);
448   //actor->time_start_animation = now;
449   //actor->duration_animation = G_MAXINT;
450   scene->actors = g_slist_append(scene->actors, actor);
451   g_ptr_array_add(child, actor);
452
453   actor = init_object(desktop_plugin, "layer2", "layer2_2.png", 
454                       0, y1, 8, 800, 960, 
455                       TRUE, TRUE, 100, 255, 
456                       NULL, NULL, NULL);
457   //actor->time_start_animation = now;
458   //actor->duration_animation = G_MAXINT;
459   scene->actors = g_slist_append(scene->actors, actor);
460   g_ptr_array_add(child, actor);
461
462   actor = init_object(desktop_plugin, "layer2", "layer2_1.png", 
463                       0, y2, 9, 800, 960, 
464                       TRUE, TRUE, 100, 255, 
465                       NULL, NULL, NULL);
466   //actor->time_start_animation = now;
467   //actor->duration_animation = G_MAXINT;
468   scene->actors = g_slist_append(scene->actors, actor);
469   g_ptr_array_add(child, actor);
470
471   actor = init_object(desktop_plugin, "layers", "", 
472                       0, y2, 9, 800, 960, 
473                       FALSE, FALSE, 100, 255, 
474                       (gpointer)&change_layer, NULL, child);
475   actor->time_start_animation = now;
476   actor->duration_animation = G_MAXINT;
477   scene->actors = g_slist_append(scene->actors, actor);
478
479   run_long_timeout(desktop_plugin);
480
481 }
482
483 /* Init Modern Scene */
484 static void
485 init_scene(AWallpaperPlugin *desktop_plugin)
486 {
487   Actor *actor;
488   Scene *scene;
489   gint now = time(NULL);
490   gint i;
491   gint winds[13][2];
492
493   //fprintf(stderr, "init scene \n");
494   scene = g_new0(Scene, 1);
495   scene->daytime = get_daytime();
496   scene->actors = NULL;
497   scene->wind_orientation = -1;
498   scene->wind_angle = 0.3;
499   /* init value for random */
500   scene->seed = time(NULL);
501   desktop_plugin->priv->scene = scene;
502
503   actor = init_object(desktop_plugin, "sky", "sky0.png", 
504                       0, 0, 5, 800, 480, 
505                       TRUE , TRUE, 100, 255, 
506                       (gpointer)&change_static_actor, NULL, NULL);
507   change_static_actor(actor, desktop_plugin);
508   scene->actors = g_slist_append(scene->actors, actor);
509   
510   actor = init_object(desktop_plugin, "sun", "sun.png", 
511                       0, 0, 6, 88, 88, 
512                       FALSE, FALSE, 100, 255, 
513                       (gpointer)&change_sun, NULL, NULL);
514   actor->time_start_animation = now;
515   actor->duration_animation = G_MAXINT;
516   change_sun(actor, desktop_plugin);
517   scene->actors = g_slist_append(scene->actors, actor);
518
519   //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
520     //                  TRUE, 100, 255, NULL, NULL);
521   //scene.actors = g_slist_append(scene.actors, actor);
522   
523   actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 
524                       0, fast_rnd(300)-97, 7, 150, 97, 
525                       FALSE, FALSE, 100, 255, 
526                       (gpointer)&change_cloud, NULL, NULL);
527   actor->time_start_animation = now + fast_rnd(20);
528   actor->duration_animation = 3*60;
529   scene->actors = g_slist_append(scene->actors, actor);
530   
531   actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 
532                       0, fast_rnd(300)-75, 7, 188, 75, 
533                       FALSE, FALSE, 100, 255, 
534                       (gpointer)&change_cloud, NULL, NULL);
535   actor->time_start_animation = now + fast_rnd(40)+10;
536   actor->duration_animation = 3*60;
537   scene->actors = g_slist_append(scene->actors, actor);
538
539   actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 
540                       0, fast_rnd(300)-75, 7, 150, 75, 
541                       FALSE, FALSE, 100, 255, 
542                       (gpointer)&change_cloud, NULL, NULL);
543   actor->time_start_animation = now + fast_rnd(60) + 20;
544   actor->duration_animation = 5*60;
545   scene->actors = g_slist_append(scene->actors, actor);
546
547
548   actor = init_object(desktop_plugin, "town", "town0.png", 
549                       0, 0, 8, 800, 480, 
550                       TRUE, TRUE, 100, 255, 
551                       (gpointer)&change_static_actor, NULL, NULL);
552   change_static_actor(actor, desktop_plugin);
553   scene->actors = g_slist_append(scene->actors, actor);
554
555   actor = init_object(desktop_plugin, "stend", "stend0.png", 
556                       482, 146, 9, 300, 305, 
557                       TRUE, TRUE, 100, 255, 
558                       (gpointer)&change_static_actor, NULL, NULL);
559   change_static_actor(actor, desktop_plugin);
560   scene->actors = g_slist_append(scene->actors, actor);
561
562   actor = init_object(desktop_plugin, "tram", "tram.png", 
563                       -300, 225, 10, 350, 210, 
564                       FALSE, FALSE, 100, 255, 
565                       (gpointer)&change_tram, NULL, NULL);
566   actor->time_start_animation = time(NULL) + fast_rnd(10); 
567   actor->duration_animation = 60;
568   scene->actors = g_slist_append(scene->actors, actor);
569
570   actor = init_object(desktop_plugin, "border", "border0.png", 
571                       0, 480-79, 11, 800, 79,
572                       TRUE, TRUE, 100, 255, 
573                       (gpointer)&change_static_actor_with_corner, NULL, NULL);
574   change_static_actor_with_corner(actor, desktop_plugin);
575   scene->actors = g_slist_append(scene->actors, actor);
576   
577   actor = init_object(desktop_plugin, "moon", "moon1.png", 
578                       400, 20, 6, 60, 60, 
579                       FALSE, FALSE, 100, 255, 
580                       (gpointer)&change_moon, NULL, NULL);
581   change_moon(actor, desktop_plugin);
582   scene->actors = g_slist_append(scene->actors, actor);
583
584   actor = init_object(desktop_plugin, "wind", "", 
585                       0, 0, 5, 0, 0, 
586                       FALSE, FALSE, 100, 255, 
587                       (gpointer)&change_wind, NULL, NULL);
588   change_wind(actor, desktop_plugin);
589   scene->actors = g_slist_append(scene->actors, actor);
590
591     /* windows in 4-th house  */
592
593     winds[0][0] = 482;
594     winds[0][1] = 180;
595
596     winds[1][0] = 495;
597     winds[1][1] = 179;
598
599     winds[2][0] = 482;
600     winds[2][1] = 191;
601
602     winds[3][0] = 495;
603     winds[3][1] = 190;
604     
605     winds[4][0] = 482;
606     winds[4][1] = 201;
607     
608     winds[5][0] = 495;
609     winds[5][1] = 210;
610     
611     winds[6][0] = 482;
612     winds[6][1] = 222;
613     
614     winds[7][0] = 495;
615     winds[7][1] = 221;
616     
617     winds[8][0] = 459;
618     winds[8][1] = 203;
619     
620     winds[9][0] = 495;
621     winds[9][1] = 241;
622     
623     winds[10][0] = 495;
624     winds[10][1] = 252;
625     
626     winds[11][0] = 482;
627     winds[11][1] = 273;
628     
629     winds[12][0] = 495;
630     winds[12][1] = 303;
631     for (i=0; i<13; i++){
632         actor = init_object(desktop_plugin, "window1", "window1.png", 
633                             winds[i][0], winds[i][1], 8, 8, 10, 
634                             FALSE, FALSE, 100, 255, 
635                             (gpointer)&change_window1, NULL, NULL);
636         //change_window1(actor, desktop_plugin);
637         actor->time_start_animation = now + fast_rnd(30);
638         scene->actors = g_slist_append(scene->actors, actor);
639
640     }
641     
642     /* windows in 1-th house  */
643     
644     winds[0][0] = 86;
645     winds[0][1] = 321;
646
647     winds[1][0] = 86;
648     winds[1][1] = 363;
649
650     winds[2][0] = 86;
651     winds[2][1] = 385;
652
653     winds[3][0] = 86;
654     winds[3][1] = 286;
655     
656     winds[4][0] = 94;
657     winds[4][1] = 232;
658     
659     winds[5][0] = 94;
660     winds[5][1] = 243;
661     
662     winds[6][0] = 94;
663     winds[6][1] = 265;
664     
665     winds[7][0] = 94;
666     winds[7][1] = 331;
667     for (i=0; i<8; i++){
668         actor = init_object(desktop_plugin, "window2", "window2.png", 
669                             winds[i][0], winds[i][1], 8, 8, 10, 
670                             FALSE, FALSE, 100, 255, 
671                             (gpointer)&change_window1, NULL, NULL);
672         //change_window1(actor, desktop_plugin);
673         actor->time_start_animation = now + fast_rnd(30);
674         scene->actors = g_slist_append(scene->actors, actor);
675
676     }
677     
678     /* windows in 3-th house  */
679     
680     winds[0][0] = 251;
681     winds[0][1] = 162;
682
683     winds[1][0] = 251;
684     winds[1][1] = 196;
685
686     winds[2][0] = 251;
687     winds[2][1] = 278;
688
689     winds[3][0] = 251;
690     winds[3][1] = 289;
691     
692     winds[4][0] = 313;
693     winds[4][1] = 173;
694     
695     winds[5][0] = 322;
696     winds[5][1] = 160;
697     
698     winds[6][0] = 303;
699     winds[6][1] = 217;
700     
701     winds[7][0] = 322;
702     winds[7][1] = 224;
703     
704     winds[8][0] = 323;
705     winds[8][1] = 217;
706     
707     winds[9][0] = 322;
708     winds[9][1] = 288;
709     
710     for (i=0; i<10; i++){
711         actor = init_object(desktop_plugin, "window3", "window3.png", 
712                             winds[i][0], winds[i][1], 8, 8, 10, 
713                             FALSE, FALSE, 100, 255, 
714                             (gpointer)&change_window1, NULL, NULL);
715         //change_window1(actor, desktop_plugin);
716         actor->time_start_animation = now + fast_rnd(30);
717         scene->actors = g_slist_append(scene->actors, actor);
718
719     }
720
721     /* windows in 5-th house  */
722     
723     winds[0][0] = 610;
724     winds[0][1] = 224;
725
726     winds[1][0] = 602;
727     winds[1][1] = 245;
728
729     winds[2][0] = 602;
730     winds[2][1] = 264;
731
732     winds[3][0] = 610;
733     winds[3][1] = 301;
734     
735     winds[4][0] = 610;
736     winds[4][1] = 320;
737     
738     winds[5][0] = 593;
739     winds[5][1] = 352;
740     
741     winds[6][0] = 610;
742     winds[6][1] = 368;
743     
744     for (i=0; i<7; i++){
745         actor = init_object(desktop_plugin, "window4", "window4.png", 
746                             winds[i][0], winds[i][1], 8, 8, 10, 
747                             FALSE, FALSE, 100, 255, 
748                             (gpointer)&change_window1, NULL, NULL);
749         //change_window1(actor, desktop_plugin);
750         actor->time_start_animation = now + fast_rnd(30);
751         scene->actors = g_slist_append(scene->actors, actor);
752
753     }
754
755     /* windows in 6-th house  */
756     
757     winds[0][0] = 717;
758     winds[0][1] = 283;
759
760     winds[1][0] = 698;
761     winds[1][1] = 293;
762
763     winds[2][0] = 717;
764     winds[2][1] = 315;
765
766     winds[3][0] = 717;
767     winds[3][1] = 323;
768     
769     winds[4][0] = 698;
770     winds[4][1] = 362;
771     
772     winds[5][0] = 698;
773     winds[5][1] = 400;
774     
775     for (i=0; i<6; i++){
776         actor = init_object(desktop_plugin, "window5", "window5.png", 
777                             winds[i][0], winds[i][1], 8, 8, 10, 
778                             FALSE, FALSE, 100, 255, 
779                             (gpointer)&change_window1, NULL, NULL);
780         //change_window1(actor, desktop_plugin);
781         actor->time_start_animation = now + fast_rnd(30);
782         scene->actors = g_slist_append(scene->actors, actor);
783
784     }
785     run_long_timeout(desktop_plugin);
786
787 #if 0    
788   anim = g_new0(Animation, 1);
789   anim->count = 1;
790   anim->actor = actor;
791   anim->func_change = &change_tram;
792   anim->func_time = NULL;
793   anim->timestart = time(NULL); 
794   anim->timeall = 10;
795   
796   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
797 #endif  
798 }
799
800 /* Init Berlin Scene */
801 static void
802 init_scene1(AWallpaperPlugin *desktop_plugin)
803 {
804   Actor *actor, *actor1, *actor2;
805   Scene *scene;
806   gint now = time(NULL);
807   gint i; 
808   gint winds[13][2];
809   GPtrArray *child = NULL;
810
811   scene = g_new0(Scene, 1);
812   scene->daytime = get_daytime();
813   scene->actors = NULL;
814   scene->wind_orientation = -1;
815   scene->wind_angle = 0.3;
816   /* init value for random */
817   scene->seed = time(NULL);
818   desktop_plugin->priv->scene = scene;
819   
820   actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
821                       TRUE, TRUE, 100, 255, 
822                       (gpointer)&change_static_actor, NULL, NULL);
823   change_static_actor(actor, desktop_plugin);
824   scene->actors = g_slist_append(scene->actors, actor);
825
826   
827   actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, 
828                       FALSE, FALSE, 100, 255, 
829                       (gpointer)&change_sun, NULL, NULL);
830   actor->time_start_animation = time(NULL);
831   actor->duration_animation = G_MAXINT;
832   change_sun(actor, desktop_plugin);
833   scene->actors = g_slist_append(scene->actors, actor);
834
835 #if 0
836   actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
837                       TRUE, 100, 255, NULL, NULL);
838   scene.actors = g_slist_append(scene.actors, actor);
839 #endif
840
841   actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60, 
842                       FALSE, FALSE, 100, 255, 
843                       (gpointer)&change_moon, NULL, NULL);
844   change_moon(actor, desktop_plugin);
845   scene->actors = g_slist_append(scene->actors, actor);
846   
847   actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, 
848                       FALSE, FALSE, 100, 255, 
849                       (gpointer)&change_cloud, NULL, NULL);
850   actor->time_start_animation = now + fast_rnd(30) + 10;
851   actor->duration_animation = 3*60;
852   scene->actors = g_slist_append(scene->actors, actor);
853   
854   actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, 
855                       FALSE, FALSE, 100, 255, 
856                       (gpointer)&change_cloud, NULL, NULL);
857   actor->time_start_animation = now + fast_rnd(10);
858   actor->duration_animation = 3*60;
859   scene->actors = g_slist_append(scene->actors, actor);
860
861   actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, 
862                       FALSE, FALSE, 100, 255, 
863                       (gpointer)&change_cloud, NULL, NULL);
864   actor->time_start_animation = now + fast_rnd(60) + 20;
865   actor->duration_animation = 5*60;
866   scene->actors = g_slist_append(scene->actors, actor);
867
868  
869   actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, 
870                       FALSE, FALSE, 100, 255, 
871                       (gpointer)&change_plane2, NULL, NULL);
872   actor->time_start_animation = now + fast_rnd(40) + 20;
873   actor->duration_animation = 60;
874   scene->actors = g_slist_append(scene->actors, actor);
875   
876   actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, 
877                       FALSE, FALSE, 100, 255, 
878                       (gpointer)&change_plane1, NULL, NULL);
879   actor->time_start_animation = now + fast_rnd(20);
880   actor->duration_animation = 30;
881   scene->actors = g_slist_append(scene->actors, actor);
882
883   actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 
884                       TRUE, TRUE, 100, 255, 
885                       (gpointer)&change_static_actor_with_corner, NULL, NULL);
886   change_static_actor_with_corner(actor, desktop_plugin);
887   scene->actors = g_slist_append(scene->actors, actor);
888
889   actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, 
890                       FALSE, FALSE, 100, 255, 
891                       (gpointer)&change_wind, NULL, NULL);
892   change_wind(actor, desktop_plugin);
893   scene->actors = g_slist_append(scene->actors, actor);
894
895   actor1 = init_object(desktop_plugin, "signal_red", "red.png", 
896                       486, 425, 10, 18, 38, 
897                       FALSE, TRUE, 100, 255, NULL, NULL, NULL);
898   //actor->time_start_animation = now + fast_rnd(30) + 10;  
899   scene->actors = g_slist_append(scene->actors, actor1);
900    
901   actor2 = init_object(desktop_plugin, "signal_green", "green.png", 
902                       486, 425, 10, 18, 38, 
903                       TRUE, TRUE, 100, 255, NULL, NULL, NULL);
904   //actor->time_start_animation = now + fast_rnd(30) + 10;  
905   scene->actors = g_slist_append(scene->actors, actor2);
906   child = g_ptr_array_sized_new(2);
907   g_ptr_array_add(child, actor1);
908   g_ptr_array_add(child, actor2);
909   actor = init_object(desktop_plugin, "signal", "",
910                       486, 425, 10, 18, 38,
911                       FALSE, FALSE, 100, 255, 
912                       (gpointer)&change_signal, NULL, child);
913   actor->time_start_animation = now + fast_rnd(30) + 10;
914   scene->actors = g_slist_append(scene->actors, actor);
915     
916     winds[0][0] = 389;
917     winds[0][1] = 305;
918
919     winds[1][0] = 373;
920     winds[1][1] = 306;
921
922     winds[2][0] = 355;
923     winds[2][1] = 306;
924
925     winds[3][0] = 356;
926     winds[3][1] = 288;
927     
928     winds[4][0] = 337;
929     winds[4][1] = 269;
930     
931     winds[5][0] = 372;
932     winds[5][1] = 268;
933   
934     winds[6][0] = 372;
935     winds[6][1] = 249;
936     
937     winds[7][0] = 388;
938     winds[7][1] = 249;
939     
940     winds[8][0] = 387;
941     winds[8][1] = 230;
942     
943     winds[9][0] = 372;
944     winds[9][1] = 211;
945     
946     winds[10][0] = 355;
947     winds[10][1] = 159;
948     
949     winds[11][0] = 335;
950     winds[11][1] = 158;
951     
952     winds[12][0] = 386;
953     winds[12][1] = 119;
954   
955     for (i=0; i<13; i++){
956         actor = init_object(desktop_plugin, "window", "window.png", 
957                             winds[i][0], winds[i][1], 10, 8, 9, 
958                             FALSE, TRUE, 100, 255, 
959                             (gpointer)&change_window1, NULL, NULL);
960         //change_window1(actor, desktop_plugin);
961         actor->time_start_animation = now + fast_rnd(30);
962         scene->actors = g_slist_append(scene->actors, actor);
963
964     }
965     
966     run_long_timeout(desktop_plugin);
967
968 }
969
970 void 
971 get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
972 {
973     gint y0 = 365;// - уровень горизонта
974     *x = (int)(azm * 800) - 64;
975     *y = (int)((1 - alt) * y0) - 64;
976     //fprintf(stderr, "sun pos alt=%f azm=%f x=%d y=%d\n", alt, azm, *x, *y);
977 }
978 #if 0
979 static void 
980 change_actor(GtkWidget * actor)
981 {
982     char * name;
983     gint x, y, daytime, scale;
984     gdouble sc;
985     double alt, azm;
986
987     GtkWidget *image;
988     GdkPixbuf *pixbuf;
989
990     void (*pfunc)(gpointer, gpointer);
991
992     name = g_object_get_data(G_OBJECT(actor), "name");
993     fprintf(stderr, "change actor %s\n", name);
994     if (name == "sun"){
995         pfunc = g_object_get_data(G_OBJECT(actor), "func");
996         if (pfunc)
997             (*pfunc)(actor, g_strdup(name));
998         daytime = get_daytime();
999         if (daytime != TIME_NIGHT){
1000             hildon_animation_actor_set_show(actor, 1);
1001             get_sun_pos(&alt, &azm);
1002             get_sun_screen_pos(alt, azm, &x, &y);
1003             actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
1004         }
1005     }
1006     
1007     if (name == "cloud1"){
1008         x = g_object_get_data(G_OBJECT(actor), "x");
1009         y = g_object_get_data(G_OBJECT(actor), "y");
1010         scale = g_object_get_data(G_OBJECT(actor), "scale");
1011
1012         /* Start */
1013         image = g_object_get_data(G_OBJECT(actor), "image");
1014         
1015         gtk_container_remove(actor, image);  
1016         pixbuf = gdk_pixbuf_new_from_file_at_size ("/usr/share/livewp/theme/Modern/sun.png", 
1017                                              200, 
1018                                              200, 
1019                                              NULL);
1020         if (pixbuf){
1021               image = gtk_image_new_from_pixbuf (pixbuf);
1022               g_object_unref(G_OBJECT(pixbuf));
1023         }
1024         g_signal_connect(G_OBJECT(image), "expose_event",
1025                                    G_CALLBACK(expose_event), pixbuf);
1026         gtk_container_add (GTK_CONTAINER (actor), image);
1027         realize(actor);
1028         gtk_widget_show_all(actor);
1029         /* End*/
1030
1031             
1032         x += 40;
1033         y -= 20;
1034         scale -= 10;
1035         if (x > 500){
1036             x = 400;
1037             y = 150;
1038             sc = 1;
1039         }
1040         sc = (double)scale / 100;
1041         hildon_animation_actor_set_scale(actor, sc, sc);
1042         fprintf(stderr, "cloud x=%d y=%d scale=%f", x, y, sc);
1043         actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
1044         g_object_set_data(G_OBJECT(actor), "x", x);
1045         g_object_set_data(G_OBJECT(actor), "y", y);
1046         g_object_set_data(G_OBJECT(actor), "scale", scale);
1047     }
1048
1049 }
1050 #endif
1051 static gboolean
1052 short_timeout (AWallpaperPlugin *desktop_plugin)
1053 {
1054     //gint daytime = get_daytime();
1055     GSList * tmp;
1056     void (*pfunc)(gpointer, gpointer);
1057     time_t now;
1058     Actor *actor;
1059     gboolean stop_flag = TRUE;
1060
1061 if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
1062         desktop_plugin->priv->short_timer = 0;
1063         return FALSE;
1064     }
1065
1066     now = time(NULL);
1067     //scene.daytime = daytime;
1068     /* fprintf(stderr, "Short timer %d\n", now); */
1069     tmp = desktop_plugin->priv->scene->actors;
1070     while (tmp != NULL){
1071            actor = tmp->data;
1072            if (now >= actor->time_start_animation  
1073                && actor->time_start_animation > 0
1074                /* && now - actor->time_start_animation <= actor->duration_animation*/){
1075                 pfunc = actor->func_change;
1076                 if (pfunc){ 
1077                     (*pfunc)(actor, desktop_plugin);
1078                     stop_flag = FALSE;
1079                 }
1080             }
1081             tmp = g_slist_next(tmp);
1082     }
1083     if (stop_flag){
1084          desktop_plugin->priv->short_timer = 0;
1085          return FALSE;
1086     }else
1087          return TRUE; /* keep running this event */
1088 }
1089
1090 void
1091 run_long_timeout(AWallpaperPlugin *desktop_plugin)
1092 {
1093
1094     gint daytime = get_daytime();
1095     GSList * tmp;
1096     void (*pfunc)(gpointer, gpointer);
1097     time_t now;
1098     Actor *actor;
1099
1100
1101     //fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer);
1102     if (desktop_plugin->priv->scene->daytime != daytime){
1103         desktop_plugin->priv->scene->daytime = daytime;
1104         tmp = desktop_plugin->priv->scene->actors;
1105         while (tmp != NULL){
1106             //change_actor(tmp->data);
1107             pfunc =((Actor*)tmp->data)->func_change;
1108             if (pfunc){
1109                 (*pfunc)(tmp->data, desktop_plugin);
1110             }
1111             tmp = g_slist_next(tmp);
1112         }
1113     }
1114    
1115     now = time(NULL);
1116     //fprintf(stderr, "Now  %d\n", now);
1117     tmp = desktop_plugin->priv->scene->actors;
1118     while (tmp != NULL){
1119         actor = tmp->data;
1120         if (now >= actor->time_start_animation  
1121             && actor->time_start_animation > 0
1122             && desktop_plugin->priv->short_timer == 0){
1123             /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
1124             if (desktop_plugin->priv->rich_animation){
1125                 actor->time_start_animation = now;
1126                 desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
1127             }
1128             else {
1129                 (*actor->func_change)(actor, desktop_plugin);
1130             }
1131         }
1132         tmp = g_slist_next(tmp);
1133     }
1134  
1135 }
1136
1137 static gboolean
1138 long_timeout (AWallpaperPlugin *desktop_plugin)
1139 {
1140     /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
1141     if (desktop_plugin->priv->long_timer == 0 )
1142         return FALSE;
1143     if (!desktop_plugin->priv->visible){
1144         if(desktop_plugin->priv->short_timer != 0){
1145             g_source_remove(desktop_plugin->priv->short_timer);
1146             desktop_plugin->priv->short_timer = 0;
1147         }
1148         desktop_plugin->priv->long_timer = 0;
1149         return FALSE;
1150     }
1151   
1152
1153     run_long_timeout(desktop_plugin);
1154     return TRUE; /* keep running this event */
1155 }
1156
1157 static void
1158 desktop_plugin_visible_notify (GObject    *object,
1159                                           GParamSpec *spec,
1160                                           AWallpaperPlugin *desktop_plugin)
1161 {
1162     gboolean visible;
1163     g_object_get (object, "is-on-current-desktop", &visible, NULL);
1164     /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
1165     if (visible){
1166         desktop_plugin->priv->visible = TRUE;
1167         if (desktop_plugin->priv->long_timer == 0 ){
1168             desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
1169             run_long_timeout(desktop_plugin);
1170         }
1171     }else{
1172         desktop_plugin->priv->visible = FALSE;
1173         if (desktop_plugin->priv->long_timer != 0 ){
1174             g_source_remove(desktop_plugin->priv->long_timer);
1175             desktop_plugin->priv->long_timer = 0;
1176         }
1177     }
1178 }
1179
1180 gboolean
1181 rich_animation_press(GtkWidget *widget, GdkEvent *event,
1182                                             gpointer user_data){
1183     fprintf(stderr,"gggggggggggggggggggg2222\n");
1184     return FALSE;
1185 }    
1186 static void
1187 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
1188 {
1189     GtkWidget *rich_animation;
1190     gchar           buffer[2048];
1191
1192
1193     //fprintf(stderr, "!!!!!!!plugin init \n");
1194     Animation_WallpaperPrivate *priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
1195     desktop_plugin->priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
1196     priv->osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
1197
1198     /* Load config */
1199     read_config(priv);
1200     /* Initialize DBUS */
1201     livewp_initialize_dbus(priv);
1202
1203     priv->desktop_plugin = desktop_plugin;
1204     priv->visible = TRUE;
1205     priv->short_timer = 0;
1206     //priv->theme = g_strdup("Modern");
1207     desktop_plugin->priv->main_widget = gtk_fixed_new();
1208
1209     gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 100, 32);
1210     desktop_plugin->priv->right_corner = NULL;
1211     snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town0_right_corner.png");
1212     desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
1213     if (desktop_plugin->priv->right_corner){
1214         gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
1215         gtk_widget_show (desktop_plugin->priv->right_corner);
1216     }
1217     /* Create rich animation event */
1218     rich_animation = gtk_event_box_new();
1219     if(rich_animation){
1220         gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
1221         gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
1222         gtk_widget_set_size_request(rich_animation, 100, 32);
1223         gtk_widget_show (rich_animation);
1224         g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
1225         gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), rich_animation, 0, 0);
1226     }
1227 /*
1228     GtkWidget *label = gtk_label_new ("ddddddddddddd"); 
1229     gtk_widget_set_size_request(label, 95, 30);
1230     gtk_widget_show (label);
1231 //    gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
1232     gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
1233 */
1234     hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
1235     g_signal_connect (desktop_plugin, "show-settings",
1236                              G_CALLBACK (show_settings), priv);
1237     gtk_widget_show (desktop_plugin->priv->main_widget);
1238     gtk_container_add (GTK_CONTAINER (desktop_plugin), desktop_plugin->priv->main_widget);
1239     init_applet_position();
1240
1241     
1242     fprintf(stderr, "!!!theme = %s\n", priv->theme);
1243     priv->scene = NULL;
1244     if (!strcmp(priv->theme,"Modern"))
1245         init_scene(desktop_plugin);
1246     else if (!strcmp(priv->theme,"Berlin")) 
1247         init_scene1(desktop_plugin);
1248     else if (!strcmp(priv->theme, "Matrix"))
1249         init_scene2(desktop_plugin);
1250     priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
1251     /* TODO Move scene to priv */
1252     //scene.timer_type = LONG_TIMER_TYPE;
1253     g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
1254                      G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
1255
1256    
1257     //sleep(2);
1258 }
1259
1260 static void
1261 lw_applet_finalize (GObject *object)
1262 {
1263      AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
1264      Animation_WallpaperPrivate *priv = desktop_plugin->priv;
1265      
1266      fprintf(stderr,"finalaze %i\n", priv->long_timer);
1267      if (priv->long_timer){
1268         g_source_remove(priv->long_timer);
1269         priv->long_timer = 0;
1270      }
1271      if (priv->short_timer){
1272         g_source_remove(priv->short_timer);
1273         priv->short_timer = 0;
1274      }
1275
1276      destroy_scene(desktop_plugin);
1277 }
1278
1279 static void
1280 animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
1281
1282     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
1283     GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
1284
1285     /* gobject */
1286     gobject_class->destroy = (gpointer)lw_applet_finalize;
1287     widget_class->realize = lw_applet_realize;
1288     widget_class->expose_event = lw_applet_expose_event;
1289
1290     g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));
1291
1292 }
1293
1294 static void
1295 animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
1296 }