debug sun & moon
authortanya <tanya@tanin.oblgaz>
Thu, 8 Apr 2010 13:23:34 +0000 (16:23 +0300)
committertanya <tanya@tanin.oblgaz>
Thu, 8 Apr 2010 13:23:34 +0000 (16:23 +0300)
applet/src/livewp-home-widget.c

index b9a626f..e4f4aff 100644 (file)
@@ -91,11 +91,13 @@ expose_event (GtkWidget *widget,GdkEventExpose *event,
     GdkPixbuf *pixbuf = (GdkPixbuf *) data;
        
     cr = gdk_cairo_create(widget->window);
-    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);
+    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;
 }
 
@@ -160,6 +162,7 @@ actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
 void
 destroy_hildon_actor(Actor *actor)
 {
+    fprintf(stderr, "estroy_hildon_actor %p\n",actor->widget);
     gtk_widget_destroy(actor->widget);
     actor->widget = NULL;
 }
@@ -223,17 +226,12 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
         if (daytime == TIME_NIGHT){
             if (!actor->visible){
                 actor->visible = TRUE;
-#if 0
                 phase = get_moon_phase();
-    fprintf(stderr, "change moon %d\n", phase);
-    fprintf(stderr, "actor name %s\n", actor->name);
-    fprintf(stderr, "actor ytghg %s\n", desktop_plugin->priv->theme);
                 newfile = g_strdup_printf( "%s/%s/%s%d.png", THEME_PATH, desktop_plugin->priv->theme, actor->name, phase);
-#endif
 
                 create_hildon_actor(actor, desktop_plugin);
-                //actor->filename = newfile;
-                //change_hildon_actor(actor, desktop_plugin);
+                actor->filename = newfile;
+                change_hildon_actor(actor, desktop_plugin);
 
             }
             //actor->x = 400;
@@ -258,13 +256,13 @@ change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
     double alt, azm;
     gint x, y, z, daytime;
 
-    fprintf(stderr, "change sun %d\n", actor->time_start_animation);
     if (actor){
         daytime = get_daytime();
         if (daytime != TIME_NIGHT){
             if (!actor->visible){
                 actor->visible = TRUE;
-                create_hildon_actor(desktop_plugin, actor);
+
+                create_hildon_actor(actor, desktop_plugin);
             }
             get_sun_pos(&alt, &azm);
             get_sun_screen_pos(alt, azm, &x, &y);
@@ -272,7 +270,6 @@ change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
             actor->y = y;
             actor_set_position_full(actor->widget, x, y, actor->z);
             probability_sun(actor);
-            fprintf(stderr, "after change sun %d\n", actor->time_start_animation);
          }else if (actor->visible){
             actor->visible = FALSE;
             destroy_hildon_actor(actor);
@@ -287,11 +284,11 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
   GtkWidget *ha = NULL;
   GdkPixbuf *pixbuf = NULL;
   GtkWidget *image = NULL;
+  gchar *str;
 
+  fprintf(stderr, "create_hildon_actor %s\n", actor->name);
   ha = hildon_animation_actor_new();
-  gchar str[256];
-  snprintf(str, 255, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, actor->filename);
-  fprintf(stderr, "!!!create ha !!!!file = %s\n", str);
+  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, 
@@ -305,7 +302,6 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
                            G_CALLBACK(expose_event), pixbuf);
     gtk_container_add (GTK_CONTAINER (ha), image);
   }  
-fprintf(stderr, "creage ha x=%d y=%d z=%d visible=%d w=%i h=>%i ", actor->x, actor->y, actor->z, actor->visible, actor->width, actor->height);
   actor_set_position_full(ha, actor->x, actor->y, actor->z);
   hildon_animation_actor_set_show (ha, actor->visible);
   hildon_animation_actor_set_scale(ha, (double)actor->scale/100, (double)actor->scale/100);
@@ -327,7 +323,7 @@ fprintf(stderr, "creage ha x=%d y=%d z=%d visible=%d w=%i h=>%i ", actor->x, act
   g_object_set_data(G_OBJECT(ha), "func", pfunc);
   */
   hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), desktop_plugin);
-      fprintf(stderr, "image %p\n", desktop_plugin);
+      fprintf(stderr, "ha %p\n", ha);
   actor->widget = ha;
 }
 
@@ -365,14 +361,10 @@ void
 change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {
     gint daytime;
-    gchar newfile[2048];
+    gchar *newfile;
     if (!actor) return;
     daytime = get_daytime();
-    fprintf(stderr,"Name %s\n", actor->name); 
-    fprintf(stderr,"daytime %i\n", daytime); 
-    fprintf(stderr,"theme %s\n", desktop_plugin->priv->theme); 
-    snprintf(newfile, 2047, "%s/%s/%s%d.png", THEME_PATH, desktop_plugin->priv->theme, actor->name, daytime);
-    fprintf(stderr, "11%s\n", newfile);
+    newfile = g_strdup_printf("%s/%s/%s%d.png", THEME_PATH, desktop_plugin->priv->theme, actor->name, daytime); 
     actor->filename = newfile;
     change_hildon_actor(actor, desktop_plugin);
 }
@@ -394,7 +386,6 @@ change_tram(GtkWidget * actor, double t)
     x = path_line(x0, x1, t);
     y = path_line(y0, y1, t);
     scale = path_line(scale0, scale1, t);
-    fprintf(stderr, "path tram:  t=%f, x=%d, y=%d, scale=%d\n", t, x, y, scale);
     actor_set_position_full(actor, x, y, g_object_get_data(G_OBJECT(actor), "z"));
     hildon_animation_actor_set_scale(actor, (double)scale/100, (double)scale/100);
 }
@@ -480,7 +471,7 @@ init_scene(AWallpaperPlugin *desktop_plugin)
   GSList * list = NULL;
   gchar str[256];
 
-fprintf(stderr, "init scene modern\n");
+fprintf(stderr, "init scene \n");
   scene.daytime = get_daytime();
   scene.actors = NULL;
   //get_sun_pos(&alt, &azm);