From: tanya Date: Fri, 9 Apr 2010 13:54:51 +0000 (+0300) Subject: tram is done X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=e5089f3b83d7dd649822a64103492649f79684e7;p=livewp tram is done --- diff --git a/applet/src/livewp-common.h b/applet/src/livewp-common.h index 5d6be56..66b1fee 100644 --- a/applet/src/livewp-common.h +++ b/applet/src/livewp-common.h @@ -33,7 +33,7 @@ #define THEME_PATH "/usr/share/livewp/theme" #define SHORT_TIMER 100 /* 100 milisecond */ //#define LONG_TIMER 10*60*1000 /* 10 minutes */ -#define LONG_TIMER 20*1000 /* 10 minutes */ +#define LONG_TIMER 5*1000 /* 10 minutes */ enum { SHORT_TIMER_TYPE, LONG_TIMER_TYPE }; diff --git a/applet/src/livewp-home-widget.c b/applet/src/livewp-home-widget.c index b9be927..acdb602 100644 --- a/applet/src/livewp-home-widget.c +++ b/applet/src/livewp-home-widget.c @@ -26,6 +26,7 @@ #include "livewp-home-widget.h" #include #include "livewp-rules.h" +#include #define PLUGIN_NAME "livewp-home-widget.desktop-0" #define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/%s/position" @@ -290,10 +291,19 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin) gint x0 = -300, y0 = 225, scale0 = 100, x1 = 800, y1 = 162, scale1 = 130, x, y, scale; + struct timeval tvb; + suseconds_t ms; + long sec; + + gettimeofday(&tvb, NULL); + gint daytime = get_daytime(); + ms = tvb.tv_usec; + sec = tvb.tv_sec; time_t now = time(NULL); double t; - +// fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now); + if (!actor->visible){ actor->visible = TRUE; if (daytime == TIME_NIGHT) @@ -302,7 +312,7 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin) actor->filename = g_strdup("tram.png"); create_hildon_actor(actor, desktop_plugin); } - t = (double)(now - actor->time_start_animation) / actor->duration_animation; + t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation; x = path_line(x0, x1, t); y = path_line(y0, y1, t); scale = path_line(scale0, scale1, t); @@ -536,7 +546,7 @@ fprintf(stderr, "init scene \n"); actor = init_object(desktop_plugin, "tram", "tram_dark.png", -300, 225, 25, 350, 210, FALSE, 100, 255, &change_tram, NULL); actor->time_start_animation = time(NULL) + 10; - actor->duration_animation = 20; + actor->duration_animation = 60; scene.actors = g_slist_append(scene.actors, actor); #if 0 anim = g_new0(Animation, 1); @@ -691,30 +701,33 @@ short_timeout (AWallpaperPlugin *desktop_plugin) gint t; Actor *actor; gboolean stop_flag = TRUE; - - now = time(NULL); -fprintf(stderr, "Short timer %d\n", now); - tmp = 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; + + if (!desktop_plugin->priv->visible) + return TRUE; + + now = time(NULL); + fprintf(stderr, "Short timer %d\n", now); + tmp = 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); - } - - scene.daytime = daytime; - if (stop_flag){ - desktop_plugin->priv->short_timer = 0; - return FALSE; - }else - return TRUE; /* keep running this event */ + tmp = g_slist_next(tmp); + } + + scene.daytime = daytime; + if (stop_flag){ + desktop_plugin->priv->short_timer = 0; + return FALSE; + }else + return TRUE; /* keep running this event */ } @@ -753,8 +766,8 @@ fprintf(stderr, "timer daytime=%d\n", daytime); if (now >= actor->time_start_animation && actor->time_start_animation > 0 && desktop_plugin->priv->short_timer == 0){ - fprintf(stderr, "start shor timer act = %s\n", actor->name); actor->time_start_animation = now; + fprintf(stderr, "start shor timer act = %s %d\n", actor->name, now); desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, short_timeout, desktop_plugin); } tmp = g_slist_next(tmp);