Merge branch 'master' of https://vcs.maemo.org/git/livewp
[livewp] / applet / src / livewp-home-widget.c
index d5c7e9b..e208f7d 100644 (file)
@@ -39,7 +39,6 @@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_H
 #define Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj,\
                                                           Animation_Wallpaper_TYPE_HOME_PLUGIN,\
                                                           Animation_WallpaperPrivate))
-
 static void
 lw_applet_realize (GtkWidget *widget)
 {
@@ -102,7 +101,6 @@ realize (GtkWidget *widget)
     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)
@@ -199,6 +197,7 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
   //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));
+
   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);
@@ -296,7 +295,8 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin)
     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;
@@ -375,14 +375,12 @@ desktop_plugin_visible_notify (GObject    *object,
         }
     }
 }
-
 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)
 {
@@ -405,6 +403,8 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
     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);
     
@@ -433,13 +433,12 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
         g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
         gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), rich_animation, 0, 0);
     }
-/*
-    GtkWidget *label = gtk_label_new ("ddddddddddddd"); 
+#if 0
+    GtkWidget *label = gtk_label_new ("1111ddddddddd");
     gtk_widget_set_size_request(label, 95, 30);
     gtk_widget_show (label);
     gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
-    gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
-*/
+#endif
     hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
     g_signal_connect (desktop_plugin, "show-settings",
                             G_CALLBACK (show_settings), priv);
@@ -466,7 +465,7 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *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);
+                   G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
 
    
     //sleep(2);
@@ -475,21 +474,50 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
 static void
 lw_applet_finalize (GObject *object)
 {
+fprintf(stderr,"lw_applet_finalize\n");
+/*
      AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
      Animation_WallpaperPrivate *priv = desktop_plugin->priv;
-
-     livewp_deinitialize_dbus(priv);
-     fprintf(stderr,"finalaze %i\n", priv->long_timer);
-     if (priv->long_timer){
-        g_source_remove(priv->long_timer);
-        priv->long_timer = 0;
-     }
-     if (priv->short_timer){
-        g_source_remove(priv->short_timer);
-        priv->short_timer = 0;
+     
+     if (priv){
+            livewp_deinitialize_dbus(priv);
+            fprintf(stderr,"finalaze %i\n", priv->long_timer);
+            if (priv->long_timer){
+               g_source_remove(priv->long_timer);
+               priv->long_timer = 0;
+            }
+            if (priv->short_timer){
+               g_source_remove(priv->short_timer);
+               priv->short_timer = 0;
+            }
+
+            destroy_scene(desktop_plugin);
      }
+*/
+}
 
-     destroy_scene(desktop_plugin);
+static void
+desktop_widget_finalize (GObject *object)
+{
+     AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
+     Animation_WallpaperPrivate *priv = desktop_plugin->priv;
+     
+     if (priv){
+            livewp_deinitialize_dbus(priv);
+            fprintf(stderr,"finalaze %i\n", priv->long_timer);
+            if (priv->long_timer){
+               g_source_remove(priv->long_timer);
+               priv->long_timer = 0;
+            }
+            if (priv->short_timer){
+               g_source_remove(priv->short_timer);
+               priv->short_timer = 0;
+            }
+
+            destroy_scene(desktop_plugin);
+     }
+      /* Call the base class's implementation: */
+      G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
 }
 
 static void
@@ -497,9 +525,11 @@ animation_wallpaper_plugin_class_init (AWallpaperPluginClass *klass) {
 
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
     GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
     /* gobject */
     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;
 
@@ -511,4 +541,9 @@ static void
 animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
 }
 
+Animation_WallpaperPrivate*
+animation_wallpaper_plugin_new (void)
+{
+  return g_object_new (Animation_Wallpaper_TYPE_HOME_PLUGIN , NULL);
+}