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