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