almost done xsnow theme
[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 <gconf/gconf-client.h>
28 #include "livewp-rules.h"
29 #include "livewp-scene.h"
30 #include <sys/time.h>
31 #include <stdlib.h>
32
33 #define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/position"
34 #define GCONF_KEY_MODIFIED "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/modified"
35 #define GCONF_KEY_VIEW     "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/view"
36
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))
41 static void
42 lw_applet_realize (GtkWidget *widget)
43 {
44     GdkScreen *screen;
45     gchar * strid; 
46     gint id; 
47     AWallpaperPlugin *desktop_plugin = widget;
48     char* child_argv[] =  {"/usr/bin/livewp", "0", (char *) 0 };
49
50
51     strid = g_strdup(hd_plugin_item_get_plugin_id (HD_PLUGIN_ITEM (widget)));
52
53     id = strid[strlen(strid)-1] - '0';
54     desktop_plugin->priv->view = id;
55     g_free(strid); 
56     
57
58     switch (id){
59             case 0: child_argv[1] = "1";
60                 break;
61             case 1: child_argv[1] = "2";
62                 break;
63             case 2: child_argv[1] = "3";
64                 break;
65             case 3: child_argv[1] = "4";
66                 break;
67     }
68     desktop_plugin->priv->pid = fork();
69     if (desktop_plugin->priv->pid == 0){
70         execvp("/usr/bin/livewp", child_argv);
71         fprintf(stderr,"Problem with new process");
72     }
73     fprintf(stderr,"dssssssddddddddddddddddddd\n");
74     desktop_plugin_visible_notify(widget, NULL, desktop_plugin->priv);
75 #if 0
76     /* Load config */
77     read_config(desktop_plugin->priv);
78
79     init_scene_theme(desktop_plugin);
80         
81     desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
82 #endif
83     screen = gtk_widget_get_screen (widget);
84     gtk_widget_set_colormap (widget,
85                                 gdk_screen_get_rgba_colormap (screen));
86     gtk_widget_set_app_paintable (widget,
87                                 TRUE);
88     GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
89 }
90
91
92 static gboolean
93 lw_applet_expose_event(GtkWidget      *widget,
94                                         GdkEventExpose *event)
95 {
96   cairo_t *cr;
97
98   /* Create cairo context */
99   cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
100   gdk_cairo_region (cr, event->region);
101   cairo_clip (cr);
102
103   /* Draw alpha background */
104   cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
105   cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
106   cairo_paint (cr);
107
108   /* Free context */
109   cairo_destroy (cr);
110
111   return GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->expose_event (widget,
112                                                                                   event);
113 }
114
115 static gboolean
116 expose_event (GtkWidget *widget,GdkEventExpose *event,
117      gpointer data)
118 {
119     cairo_t *cr;
120     GdkPixbuf *pixbuf = (GdkPixbuf *) data;
121         
122     cr = gdk_cairo_create(widget->window);
123     if (cr){
124         gdk_cairo_region(cr, event->region);
125         cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
126         gdk_cairo_set_source_pixbuf(cr, pixbuf, 0.0, 0.0);
127         cairo_paint(cr);
128         cairo_destroy(cr);
129     }
130     return TRUE;
131 }
132
133 static void
134 realize (GtkWidget *widget)
135 {
136     GdkScreen *screen;
137     screen = gtk_widget_get_screen (widget);
138     gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));
139 }
140 /* Set position of widget on desktop */
141 static void
142 init_applet_position(gint *xapplet, gint *yapplet)
143 {
144   GSList *position = NULL;
145   gchar *position_key;
146   gchar *modified_key;
147   gchar *modified;
148   GError *error = NULL;
149   gint i;
150   GConfClient   *gconf_client = gconf_client_get_default ();
151   for (i=0;i<4;i++){
152       position_key = g_strdup_printf (GCONF_KEY_POSITION, i);
153       position = gconf_client_get_list (gconf_client,
154                                         position_key,
155                                         GCONF_VALUE_INT,
156                                         NULL);
157       if (position && position->data && position->next->data){
158         *xapplet = GPOINTER_TO_INT (position->data);
159         *yapplet = GPOINTER_TO_INT (position->next->data);
160       }else{
161         position = g_slist_prepend (g_slist_prepend (NULL,
162                                           GINT_TO_POINTER (Ystartposition)),
163                               GINT_TO_POINTER (Xstartposition));
164         gconf_client_set_list (gconf_client,
165                                    position_key,
166                                    GCONF_VALUE_INT,
167                                position,
168                        &error);
169         *xapplet = Xstartposition;
170         *yapplet = Ystartposition;
171       }
172       g_free (position_key);
173       modified = g_strdup_printf ("%i", 0);
174       modified_key = g_strdup_printf (GCONF_KEY_MODIFIED, i);
175       gconf_client_set_string (gconf_client,
176                                modified_key,
177                                modified,
178                                &error);
179       g_free(modified);
180       g_free(modified_key);
181       modified_key = g_strdup_printf (GCONF_KEY_VIEW, i);
182       gconf_client_set_int (gconf_client,
183                                modified_key,
184                                (i+1),
185                                &error);
186       g_free(modified_key);
187
188   }
189   gconf_client_clear_cache(gconf_client);
190   g_object_unref(gconf_client);
191 }
192 #if 0
193 void
194 actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
195 {
196 /*  fprintf(stderr, "actor_set_position_full z=%d\n", z); */
197     hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-0, y-0, z);
198 }
199 #endif
200
201 void
202 destroy_hildon_actor(Actor *actor)
203 {
204     //fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
205     gtk_widget_destroy(actor->widget);
206     actor->widget = NULL;
207 }
208
209 void
210 create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin) 
211 {
212   GtkWidget *ha = NULL;
213   GdkPixbuf *pixbuf = NULL;
214   GtkWidget *image = NULL;
215   GtkWidget *label = NULL;
216
217   ha = hildon_animation_actor_new();
218   label = gtk_label_new(NULL);  
219
220   if (label){
221     //g_signal_connect(G_OBJECT(label), "expose_event", G_CALLBACK(expose_event), NULL);
222
223     gtk_container_add (GTK_CONTAINER (ha), label);
224   }  
225   realize(ha);
226   gtk_widget_show(label);
227   gtk_widget_show_all(ha);
228   
229   /* TO DO check it */
230   /*  gdk_flush (); */
231
232   //g_object_set_data(G_OBJECT(ha), "image", image);
233   actor->image = label;
234   hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin->priv->window));
235   actor->widget = ha;
236   set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
237   set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
238   set_actor_visible(actor, actor->visible);
239 }
240
241
242
243 void
244 create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) 
245 {
246   GtkWidget *ha = NULL;
247   GdkPixbuf *pixbuf = NULL;
248   GtkWidget *image = NULL;
249   gchar     *str = NULL;
250
251   ha = hildon_animation_actor_new();
252   str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
253                         desktop_plugin->priv->theme, actor->filename);
254   pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
255                                              actor->width, 
256                                              actor->height, 
257                                              NULL);
258   /* fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str); */
259   if (str)
260       g_free(str);
261   if (pixbuf){
262       image = gtk_image_new_from_pixbuf (pixbuf);
263       g_object_unref(G_OBJECT(pixbuf));
264   }
265   if (image){
266     g_signal_connect(G_OBJECT(image), "expose_event",
267                            G_CALLBACK(expose_event), pixbuf);
268     gtk_container_add (GTK_CONTAINER (ha), image);
269   }  
270   realize(ha);
271   gtk_widget_show_all(ha);
272   
273   /* TO DO check it */
274   /*  gdk_flush (); */
275
276   //g_object_set_data(G_OBJECT(ha), "image", image);
277   actor->image = image;
278   hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin->priv->window));
279
280   actor->widget = ha;
281   set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
282   set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
283   set_actor_visible(actor, actor->visible);
284 }
285
286
287 void
288 change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
289 {
290     GtkWidget *image = NULL;
291     GdkPixbuf *pixbuf = NULL;
292     gchar     *str = NULL;
293
294     str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
295                             desktop_plugin->priv->theme, actor->filename);
296  
297     pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
298                                                actor->width, 
299                                                actor->height, 
300                                                NULL);
301     if(str)
302         g_free(str);
303     if (pixbuf){
304         image = gtk_image_new_from_pixbuf (pixbuf);
305         g_object_unref(G_OBJECT(pixbuf));
306     }
307     if (image){ 
308         g_signal_connect(G_OBJECT(image), "expose_event",
309                                        G_CALLBACK(expose_event), pixbuf);
310         //if (g_object_get_data(G_OBJECT(actor->widget), "image")){
311         if (actor->image){
312             gtk_container_remove(GTK_CONTAINER(actor->widget), actor->image);  
313         }
314         //g_object_set_data(G_OBJECT(actor->widget), "image", image);
315         actor->image = image;
316         gtk_container_add (GTK_CONTAINER (actor->widget), image);
317         realize(actor->widget);
318         gtk_widget_show_all(actor->widget);
319         /* TO DO check it */
320        /*  gdk_flush (); */
321
322
323     }
324
325 }
326
327
328 static gboolean
329 short_timeout (AWallpaperPlugin *desktop_plugin)
330 {
331     //gint daytime = get_daytime();
332     GSList * tmp;
333     void (*pfunc)(gpointer, gpointer);
334     time_t now;
335     Actor *actor;
336     gboolean stop_flag = TRUE;
337
338 if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
339         desktop_plugin->priv->short_timer = 0;
340         return FALSE;
341     }
342
343     now = time(NULL);
344     //scene.daytime = daytime;
345     /* fprintf(stderr, "Short timer %d\n", now); */
346     tmp = desktop_plugin->priv->scene->actors;
347     while (tmp != NULL){
348            actor = tmp->data;
349            if (now >= actor->time_start_animation  
350                && actor->time_start_animation > 0
351                /* && now - actor->time_start_animation <= actor->duration_animation*/){
352                 pfunc = actor->func_change;
353                 if (pfunc){ 
354                     (*pfunc)(actor, desktop_plugin);
355                     stop_flag = FALSE;
356                 }
357             }
358             tmp = g_slist_next(tmp);
359     }
360     if (stop_flag){
361          desktop_plugin->priv->short_timer = 0;
362          return FALSE;
363     }else
364          return TRUE; /* keep running this event */
365 }
366
367 void
368 run_long_timeout(AWallpaperPlugin *desktop_plugin)
369 {
370
371     gint daytime = get_daytime();
372     GSList * tmp;
373     void (*pfunc)(gpointer, gpointer);
374     time_t now;
375     Actor *actor;
376
377     if (!desktop_plugin->priv->scene)
378         return;
379     /* fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer); */
380     if (desktop_plugin->priv->scene->daytime != daytime){
381         desktop_plugin->priv->scene->daytime = daytime;
382         tmp = desktop_plugin->priv->scene->actors;
383         while (tmp != NULL){
384             //change_actor(tmp->data);
385             pfunc =((Actor*)tmp->data)->func_change;
386             if (pfunc){
387                 (*pfunc)(tmp->data, desktop_plugin);
388             }
389             tmp = g_slist_next(tmp);
390         }
391     }
392    
393     now = time(NULL);
394     fprintf(stderr, "Now  %d\n", now);
395     tmp = desktop_plugin->priv->scene->actors;
396     while (tmp != NULL){
397         actor = tmp->data;
398         if (now >= actor->time_start_animation  
399             && actor->time_start_animation > 0
400             && desktop_plugin->priv->short_timer == 0){
401             /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
402             if (desktop_plugin->priv->rich_animation){
403                 actor->time_start_animation = now;
404                 desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
405             }
406             else {
407                 (*actor->func_change)(actor, desktop_plugin);
408             }
409         }
410         tmp = g_slist_next(tmp);
411     }
412  
413 }
414
415 gboolean
416 long_timeout (AWallpaperPlugin *desktop_plugin)
417 {
418     /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
419     if (desktop_plugin->priv->long_timer == 0 )
420         return FALSE;
421     if (!desktop_plugin->priv->visible){
422         if(desktop_plugin->priv->short_timer != 0){
423             g_source_remove(desktop_plugin->priv->short_timer);
424             desktop_plugin->priv->short_timer = 0;
425         }
426         desktop_plugin->priv->long_timer = 0;
427         return FALSE;
428     }
429   
430
431     run_long_timeout(desktop_plugin);
432     return TRUE; /* keep running this event */
433 }
434
435 void
436 desktop_plugin_visible_notify (GObject    *object,
437                                           GParamSpec *spec,
438                                           AWallpaperPlugin *desktop_plugin)
439 {
440     gboolean visible;
441     Animation_WallpaperPrivate *priv = desktop_plugin->priv;
442     g_object_get (object, "is-on-current-desktop", &visible, NULL);
443     fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); 
444     if (priv){
445              switch (priv->view + 1){
446                 case 1: if (visible)
447                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
448                                           LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW1);
449                         else
450                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
451                                           LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW1);
452                         break;
453                 case 2: if (visible)
454                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
455                                           LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW2);
456                         else
457                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
458                                           LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW2);
459                         break;
460                 case 3: if (visible)
461                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
462                                           LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW3);
463                         else
464                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
465                                           LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW3);
466                         break;
467                 case 4: if (visible)
468                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
469                                           LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW4);
470                         else
471                                 send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
472                                           LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW4);
473                         break;
474              }
475      }
476
477 }
478
479 gboolean
480 rich_animation_press(GtkWidget *widget, GdkEvent *event,
481                                             gpointer user_data){
482     fprintf(stderr,"gggggggggggggggggggg2222\n");
483     return FALSE;
484 }    
485
486 gboolean
487 send_alive_event(Animation_WallpaperPrivate *priv) 
488 {
489     fprintf(stderr, "send_alive_event\n");
490     switch (priv->view + 1){
491         case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
492                                   LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW1);
493                 break;
494         case 2: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
495                                   LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW2);
496                 break;
497         case 3: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
498                                   LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW3);
499                 break;
500         case 4: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
501                                   LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW4);
502                 break;
503     }
504
505     return TRUE;
506 }
507
508 static void
509 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
510 {
511     GtkWidget *rich_animation;
512     gchar           buffer[2048];
513     gchar str[128];
514
515     //fprintf(stderr, "!!!!!!!plugin init \n");
516     Animation_WallpaperPrivate *priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
517     desktop_plugin->priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
518     priv->osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
519
520         /* Initialize DBUS */
521     livewp_initialize_dbus(priv);
522
523     priv->desktop_plugin = desktop_plugin;
524     priv->window = desktop_plugin;
525     priv->visible = FALSE;
526     priv->short_timer = 0;
527     priv->xapplet = 0;
528     priv->yapplet = 0;
529     priv->scene = NULL;
530     priv->theme = g_strdup("Modern");
531 //#if 0 
532     priv->hash_scene_func = g_hash_table_new(g_str_hash, g_str_equal);
533     
534     g_hash_table_insert(priv->hash_scene_func, g_strdup("Berlin"), (gpointer)&init_scene_Berlin);
535     g_hash_table_insert(priv->hash_scene_func, g_strdup("Modern"), (gpointer)&init_scene_Modern);
536     g_hash_table_insert(priv->hash_scene_func, g_strdup("Matrix"), (gpointer)&init_scene_Matrix);
537     g_hash_table_insert(priv->hash_scene_func, g_strdup("Accel"), (gpointer)&init_scene_Accel);
538     g_hash_table_insert(priv->hash_scene_func, g_strdup("Video"), (gpointer)&init_scene_Video);
539     g_hash_table_insert(priv->hash_scene_func, g_strdup("Xsnow"), (gpointer)&init_scene_Video);
540 //#endif
541     //priv->theme = g_strdup("Accel");
542     desktop_plugin->priv->main_widget = gtk_fixed_new();
543
544     gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 1, 1);
545     gtk_widget_show (desktop_plugin->priv->main_widget);
546     gtk_container_add (GTK_CONTAINER (desktop_plugin), desktop_plugin->priv->main_widget);
547     init_applet_position(&(priv->xapplet), &(priv->yapplet));
548
549     
550     priv->scene = NULL;
551     g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
552                    G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
553
554     priv->alive_timer = g_timeout_add(60000*3, (GtkFunction)send_alive_event, priv);  /* One per 3 minute */ 
555 }
556
557 static void
558 lw_applet_finalize (GObject *object)
559 {
560      int status = 0; int wpid; 
561 fprintf(stderr,"lw_applet_finalize\n");
562      AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
563      Animation_WallpaperPrivate *priv = desktop_plugin->priv;
564 /*
565      
566      if (priv){
567              livewp_deinitialize_dbus(priv);
568              fprintf(stderr,"finalaze %i\n", priv->long_timer);
569              if (priv->long_timer){
570                 g_source_remove(priv->long_timer);
571                 priv->long_timer = 0;
572              }
573              if (priv->short_timer){
574                 g_source_remove(priv->short_timer);
575                 priv->short_timer = 0;
576              }
577
578              destroy_scene(desktop_plugin);
579      }
580 */    
581      
582      if (priv){
583              switch (priv->view + 1){
584                 case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
585                                           LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW1);
586                         break;
587                 case 2: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
588                                           LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW2);
589                         break;
590                 case 3: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
591                                           LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW3);
592                         break;
593                 case 4: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
594                                           LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW4);
595                         break;
596              }
597      }
598      if(priv->alive_timer > 0) 
599          g_source_remove(priv->alive_timer);
600
601      livewp_deinitialize_dbus(priv);
602      while (TRUE){
603          wpid = wait(&status);
604          if (wpid == priv->pid)
605              break;
606      }
607 }
608
609 static void
610 desktop_widget_finalize (GObject *object)
611 {
612      AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
613      Animation_WallpaperPrivate *priv = desktop_plugin->priv;
614      
615        /* Call the base class's implementation: */
616       G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
617 }
618
619 static void
620 animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
621
622     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
623     GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
624     GObjectClass *object_class = G_OBJECT_CLASS (klass);
625
626     /* gobject */
627     gobject_class->destroy = (gpointer)lw_applet_finalize;
628     object_class->finalize = desktop_widget_finalize;
629     widget_class->realize = lw_applet_realize;
630 //    widget_class->expose_event = lw_applet_expose_event;
631
632     g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));
633
634 }
635
636 static void
637 animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
638 }
639
640 Animation_WallpaperPrivate*
641 animation_wallpaper_plugin_new (void)
642 {
643   return g_object_new (Animation_Wallpaper_TYPE_HOME_PLUGIN , NULL);
644 }
645