fixed syntax error
[livewp] / applet / src / livewp-home-widget.c
index 384327b..3cba177 100644 (file)
@@ -7,8 +7,8 @@
  *       for the code
  * 
  * This software is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of
  * the License, or (at your option) any later version.
  * 
  * This software is distributed in the hope that it will be useful, but
@@ -29,6 +29,8 @@
 #include "livewp-scene.h"
 #include <sys/time.h>
 #include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
 
 #define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/position"
 #define GCONF_KEY_MODIFIED "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/modified"
@@ -44,16 +46,16 @@ lw_applet_realize (GtkWidget *widget)
     GdkScreen *screen;
     gchar * strid; 
     gint id; 
-    AWallpaperPlugin *desktop_plugin = widget;
+    AWallpaperPlugin *desktop_plugin = (AWallpaperPlugin *)widget;
     char* child_argv[] =  {"/usr/bin/livewp", "0", (char *) 0 };
 
 
     strid = g_strdup(hd_plugin_item_get_plugin_id (HD_PLUGIN_ITEM (widget)));
+
     id = strid[strlen(strid)-1] - '0';
     desktop_plugin->priv->view = id;
     g_free(strid); 
     
-    fprintf(stderr,"ID !!!!!!!!!! %i\n",id);
 
     switch (id){
            case 0: child_argv[1] = "1";
@@ -65,20 +67,20 @@ lw_applet_realize (GtkWidget *widget)
            case 3: child_argv[1] = "4";
                break;
     }
-    desktop_plugin->priv->pid = fork();
-    if (desktop_plugin->priv->pid == 0){
-       fprintf(stderr,"New proceess !!!!!!!!!! %s\n",child_argv[1]);
-       execvp("/usr/bin/livewp", child_argv);
-       fprintf(stderr,"Problem with new process");
+    desktop_plugin->priv->one_in_all_view = get_one_in_all_views_from_config();
+    /* Check one theme in all view mode */
+    if (!desktop_plugin->priv->one_in_all_view || 
+        (desktop_plugin->priv->one_in_all_view && id == 0)){
+           /* Start a new process */
+           desktop_plugin->priv->pid = fork();
+           if (desktop_plugin->priv->pid == 0){
+               execvp("/usr/bin/livewp", child_argv);
+               fprintf(stderr,"Problem with new process");
+           }
     }
-#if 0
-    /* Load config */
-    read_config(desktop_plugin->priv);
-
-    init_scene_theme(desktop_plugin);
-        
-    desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
-#endif
+
+    desktop_plugin_visible_notify((GObject *)widget, NULL, desktop_plugin);
+
     screen = gtk_widget_get_screen (widget);
     gtk_widget_set_colormap (widget,
                                 gdk_screen_get_rgba_colormap (screen));
@@ -87,55 +89,6 @@ lw_applet_realize (GtkWidget *widget)
     GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
 }
 
-
-static gboolean
-lw_applet_expose_event(GtkWidget      *widget,
-                                        GdkEventExpose *event)
-{
-  cairo_t *cr;
-
-  /* Create cairo context */
-  cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
-  /* Draw alpha background */
-  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-  cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
-  cairo_paint (cr);
-
-  /* Free context */
-  cairo_destroy (cr);
-
-  return GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->expose_event (widget,
-                                                                                  event);
-}
-
-static gboolean
-expose_event (GtkWidget *widget,GdkEventExpose *event,
-     gpointer data)
-{
-    cairo_t *cr;
-    GdkPixbuf *pixbuf = (GdkPixbuf *) data;
-       
-    cr = gdk_cairo_create(widget->window);
-    if (cr){
-        gdk_cairo_region(cr, event->region);
-        cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
-        gdk_cairo_set_source_pixbuf(cr, pixbuf, 0.0, 0.0);
-        cairo_paint(cr);
-        cairo_destroy(cr);
-    }
-    return TRUE;
-}
-
-static void
-realize (GtkWidget *widget)
-{
-    GdkScreen *screen;
-    screen = gtk_widget_get_screen (widget);
-    gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));
-}
 /* Set position of widget on desktop */
 static void
 init_applet_position(gint *xapplet, gint *yapplet)
@@ -188,283 +141,141 @@ init_applet_position(gint *xapplet, gint *yapplet)
   gconf_client_clear_cache(gconf_client);
   g_object_unref(gconf_client);
 }
-#if 0
-void
-actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
-{
-/*  fprintf(stderr, "actor_set_position_full z=%d\n", z); */
-    hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-0, y-0, z);
-}
-#endif
-
-void
-destroy_hildon_actor(Actor *actor)
-{
-    //fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
-    gtk_widget_destroy(actor->widget);
-    actor->widget = NULL;
-}
-
-void
-create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin) 
-{
-  GtkWidget *ha = NULL;
-  GdkPixbuf *pixbuf = NULL;
-  GtkWidget *image = NULL;
-  GtkWidget *label = NULL;
-
-  ha = hildon_animation_actor_new();
-  label = gtk_label_new(NULL);  
-
-  if (label){
-    //g_signal_connect(G_OBJECT(label), "expose_event", G_CALLBACK(expose_event), NULL);
-
-    gtk_container_add (GTK_CONTAINER (ha), label);
-  }  
-  realize(ha);
-  gtk_widget_show(label);
-  gtk_widget_show_all(ha);
-  
-  /* TO DO check it */
-  /*  gdk_flush (); */
-
-  //g_object_set_data(G_OBJECT(ha), "image", image);
-  actor->image = label;
-  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin->priv->window));
-  actor->widget = ha;
-  set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
-  set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
-  set_actor_visible(actor, actor->visible);
-}
-
-
-
-void
-create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) 
-{
-  GtkWidget *ha = NULL;
-  GdkPixbuf *pixbuf = NULL;
-  GtkWidget *image = NULL;
-  gchar     *str = NULL;
-
-  ha = hildon_animation_actor_new();
-  str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
-                        desktop_plugin->priv->theme, actor->filename);
-  pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
-                                             actor->width, 
-                                             actor->height, 
-                                             NULL);
-  /* fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str); */
-  if (str)
-      g_free(str);
-  if (pixbuf){
-      image = gtk_image_new_from_pixbuf (pixbuf);
-      g_object_unref(G_OBJECT(pixbuf));
-  }
-  if (image){
-    g_signal_connect(G_OBJECT(image), "expose_event",
-                           G_CALLBACK(expose_event), pixbuf);
-    gtk_container_add (GTK_CONTAINER (ha), image);
-  }  
-  realize(ha);
-  gtk_widget_show_all(ha);
-  
-  /* TO DO check it */
-  /*  gdk_flush (); */
-
-  //g_object_set_data(G_OBJECT(ha), "image", image);
-  actor->image = image;
-  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin->priv->window));
-
-  actor->widget = ha;
-  set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
-  set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
-  set_actor_visible(actor, actor->visible);
-}
-
 
 void
-change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
+desktop_plugin_visible_notify (GObject    *object,
+                                          GParamSpec *spec,
+                                          AWallpaperPlugin *desktop_plugin)
 {
-    GtkWidget *image = NULL;
-    GdkPixbuf *pixbuf = NULL;
-    gchar     *str = NULL;
-
-    str = g_strdup_printf( "%s/%s/%s", THEME_PATH, 
-                            desktop_plugin->priv->theme, actor->filename);
-    pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
-                                               actor->width, 
-                                               actor->height, 
-                                               NULL);
-    if(str)
-        g_free(str);
-    if (pixbuf){
-        image = gtk_image_new_from_pixbuf (pixbuf);
-        g_object_unref(G_OBJECT(pixbuf));
-    }
-    if (image){ 
-        g_signal_connect(G_OBJECT(image), "expose_event",
-                                       G_CALLBACK(expose_event), pixbuf);
-        //if (g_object_get_data(G_OBJECT(actor->widget), "image")){
-        if (actor->image){
-            gtk_container_remove(GTK_CONTAINER(actor->widget), actor->image);  
-        }
-        //g_object_set_data(G_OBJECT(actor->widget), "image", image);
-        actor->image = image;
-        gtk_container_add (GTK_CONTAINER (actor->widget), image);
-        realize(actor->widget);
-        gtk_widget_show_all(actor->widget);
-        /* TO DO check it */
-       /*  gdk_flush (); */
-
-
-    }
-
-}
-
+    gboolean visible;
+    Animation_WallpaperPrivate *priv = desktop_plugin->priv;
+    g_object_get (object, "is-on-current-desktop", &visible, NULL);
+    fprintf (stderr, "LWP is-on-current-desktop changed. visible: %u", visible); 
+    if (priv){
+             if (priv->one_in_all_view){
+                    if (visible)
+                       send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW1);
+                    else{
+                       /* start any application on current view */
+                       if ((priv->view + 1) == current_active_view())
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW1);
+                    }
+                    return;
+             }
+            switch (priv->view + 1){
+               case 1: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW1);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW1);
+                       break;
+               case 2: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW2);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW2);
+                       break;
+               case 3: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW3);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW3);
+                       break;
+               case 4: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW4);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW4);
+                       break;
+              case 5: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW5);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW5);
+                       break;
+              case 6: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW6);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW6);
+                       break;
+              case 7: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW7);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW7);
+                       break;
+              case 8: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW8);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW8);
+                       break;
+              case 9: if (visible)
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW9);
+                       else
+                               send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW9);
+                       break;
 
-static gboolean
-short_timeout (AWallpaperPlugin *desktop_plugin)
-{
-    //gint daytime = get_daytime();
-    GSList * tmp;
-    void (*pfunc)(gpointer, gpointer);
-    time_t now;
-    Actor *actor;
-    gboolean stop_flag = TRUE;
-
-if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
-        desktop_plugin->priv->short_timer = 0;
-        return FALSE;
-    }
+            }
 
-    now = time(NULL);
-    //scene.daytime = daytime;
-    /* fprintf(stderr, "Short timer %d\n", now); */
-    tmp = desktop_plugin->priv->scene->actors;
-    while (tmp != NULL){
-           actor = tmp->data;
-           if (now >= actor->time_start_animation  
-               && actor->time_start_animation > 0
-               /* && now - actor->time_start_animation <= actor->duration_animation*/){
-                pfunc = actor->func_change;
-                if (pfunc){ 
-                    (*pfunc)(actor, desktop_plugin);
-                    stop_flag = FALSE;
-                }
-            }
-            tmp = g_slist_next(tmp);
-    }
-    if (stop_flag){
-         desktop_plugin->priv->short_timer = 0;
-         return FALSE;
-    }else
-         return TRUE; /* keep running this event */
+     }
+    
 }
 
-void
-run_long_timeout(AWallpaperPlugin *desktop_plugin)
+gboolean
+send_alive_event(Animation_WallpaperPrivate *priv) 
 {
+    switch (priv->view + 1){
+       case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW1);
+               break;
+       case 2: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW2);
+               break;
+       case 3: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW3);
+               break;
+       case 4: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW4);
+               break;
+       case 5: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW5);
+               break;
+       case 6: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW6);
+               break;
+       case 7: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW7);
+               break;
+       case 8: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW8);
+               break;
+       case 9: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                 LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW9);
+               break;
 
-    gint daytime = get_daytime();
-    GSList * tmp;
-    void (*pfunc)(gpointer, gpointer);
-    time_t now;
-    Actor *actor;
-
-    if (!desktop_plugin->priv->scene)
-       return;
-    /* fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer); */
-    if (desktop_plugin->priv->scene->daytime != daytime){
-        desktop_plugin->priv->scene->daytime = daytime;
-        tmp = desktop_plugin->priv->scene->actors;
-        while (tmp != NULL){
-            //change_actor(tmp->data);
-            pfunc =((Actor*)tmp->data)->func_change;
-            if (pfunc){
-                (*pfunc)(tmp->data, desktop_plugin);
-            }
-            tmp = g_slist_next(tmp);
-        }
-    }
-   
-    now = time(NULL);
-    fprintf(stderr, "Now  %d\n", now);
-    tmp = desktop_plugin->priv->scene->actors;
-    while (tmp != NULL){
-        actor = tmp->data;
-        if (now >= actor->time_start_animation  
-            && actor->time_start_animation > 0
-            && desktop_plugin->priv->short_timer == 0){
-            /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
-            if (desktop_plugin->priv->rich_animation){
-                actor->time_start_animation = now;
-                desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
-            }
-            else {
-                (*actor->func_change)(actor, desktop_plugin);
-            }
-        }
-        tmp = g_slist_next(tmp);
-    }
-}
 
-gboolean
-long_timeout (AWallpaperPlugin *desktop_plugin)
-{
-    /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
-    if (desktop_plugin->priv->long_timer == 0 )
-        return FALSE;
-    if (!desktop_plugin->priv->visible){
-        if(desktop_plugin->priv->short_timer != 0){
-            g_source_remove(desktop_plugin->priv->short_timer);
-            desktop_plugin->priv->short_timer = 0;
-        }
-        desktop_plugin->priv->long_timer = 0;
-        return FALSE;
     }
-  
 
-    run_long_timeout(desktop_plugin);
-    return TRUE; /* keep running this event */
+    return TRUE;
 }
 
 static void
-desktop_plugin_visible_notify (GObject    *object,
-                                          GParamSpec *spec,
-                                          AWallpaperPlugin *desktop_plugin)
-{
-    gboolean visible;
-    g_object_get (object, "is-on-current-desktop", &visible, NULL);
-    /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
-    if (visible){
-        desktop_plugin->priv->visible = TRUE;
-        if (desktop_plugin->priv->long_timer == 0 ){
-            desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
-            run_long_timeout(desktop_plugin);
-        }
-    }else{
-        desktop_plugin->priv->visible = FALSE;
-        if (desktop_plugin->priv->long_timer != 0 ){
-            g_source_remove(desktop_plugin->priv->long_timer);
-            desktop_plugin->priv->long_timer = 0;
-        }
-    }
-}
-gboolean
-rich_animation_press(GtkWidget *widget, GdkEvent *event,
-                                            gpointer user_data){
-    fprintf(stderr,"gggggggggggggggggggg2222\n");
-    return FALSE;
-}    
-static void
 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
 {
-    GtkWidget *rich_animation;
-    gchar           buffer[2048];
-    gchar str[128];
 
     //fprintf(stderr, "!!!!!!!plugin init \n");
     Animation_WallpaperPrivate *priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
@@ -475,21 +286,15 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
     livewp_initialize_dbus(priv);
 
     priv->desktop_plugin = desktop_plugin;
-    priv->window = desktop_plugin;
+    priv->window = (GtkWidget *)desktop_plugin;
     priv->visible = FALSE;
     priv->short_timer = 0;
     priv->xapplet = 0;
     priv->yapplet = 0;
     priv->scene = NULL;
-//    priv->theme = g_strdup("Modern");
-//#if 0 
-    priv->hash_scene_func = g_hash_table_new(g_str_hash, g_str_equal);
-    
-    g_hash_table_insert(priv->hash_scene_func, g_strdup("Berlin"), (gpointer)&init_scene_Berlin);
-    g_hash_table_insert(priv->hash_scene_func, g_strdup("Modern"), (gpointer)&init_scene_Modern);
-    g_hash_table_insert(priv->hash_scene_func, g_strdup("Matrix"), (gpointer)&init_scene_Matrix);
-//#endif
-    //priv->theme = g_strdup("Modern");
+    priv->pid = 0;
+    priv->theme = g_strdup("Modern");
+    //priv->theme = g_strdup("Accel");
     desktop_plugin->priv->main_widget = gtk_fixed_new();
 
     gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 1, 1);
@@ -498,28 +303,11 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
     init_applet_position(&(priv->xapplet), &(priv->yapplet));
 
     
-    //fprintf(stderr, "!!!theme = %s\n", priv->theme);
-    //snprintf(str, sizeof(str) - 1, "%s", "init_scene2");
-    //fprintf(stderr, " str = %s\n", str);
     priv->scene = NULL;
-#if 0
-    if (!strcmp(priv->theme,"Modern"))
-        init_scene_Modern(desktop_plugin);
-    else if (!strcmp(priv->theme,"Berlin")) 
-        init_scene_Berlin(desktop_plugin);
-    else if (!strcmp(priv->theme, "Matrix"))
-        init_scene_Matrix(desktop_plugin);
-#endif
-//    init_scene_theme(desktop_plugin);
-        
-//    priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
-    /* TODO Move scene to priv */
-    //scene.timer_type = LONG_TIMER_TYPE;
     g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
                    G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
 
-   
-    //sleep(2);
+    priv->alive_timer = g_timeout_add(60000*3, (GtkFunction)send_alive_event, priv);  /* One per 3 minute */ 
 }
 
 static void
@@ -546,10 +334,8 @@ fprintf(stderr,"lw_applet_finalize\n");
             destroy_scene(desktop_plugin);
      }
 */    
-     
      if (priv){
-            livewp_deinitialize_dbus(priv);
-            switch (priv->view){
+            switch (priv->view + 1){
                case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
                                          LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW1);
                        break;
@@ -562,25 +348,43 @@ fprintf(stderr,"lw_applet_finalize\n");
                case 4: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
                                          LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW4);
                        break;
+               case 5: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW5);
+                       break;
+               case 6: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW6);
+                       break;
+               case 7: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW7);
+                       break;
+               case 8: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW8);
+                       break;
+               case 9: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE, 
+                                         LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW9);
+                       break;
             }
      }
-     while (TRUE){
-        fprintf(stderr,"checking true\n");
-         wpid = wait(&status);
-        if (wpid == priv->pid)
-            break;
+     if(priv->alive_timer > 0) 
+         g_source_remove(priv->alive_timer);
+
+     livewp_deinitialize_dbus(priv);
+
+     if (priv->pid >0){
+            while (TRUE){
+                wpid = wait(&status);
+                if (wpid == priv->pid)
+                    break;
+            }
      }
-     fprintf(stderr,"out from applet\n");
 }
 
 static void
 desktop_widget_finalize (GObject *object)
 {
-     AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
-     Animation_WallpaperPrivate *priv = desktop_plugin->priv;
-     
-       /* Call the base class's implementation: */
-      G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
+fprintf(stderr,"desktop lw_applet_finalize\n");
+      /* Call the base class's implementation: */
+     G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
 }
 
 static void
@@ -594,7 +398,6 @@ animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
     gobject_class->destroy = (gpointer)lw_applet_finalize;
     object_class->finalize = desktop_widget_finalize;
     widget_class->realize = lw_applet_realize;
-    widget_class->expose_event = lw_applet_expose_event;
 
     g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));