#include "livewp-home-widget.h"
#include <gconf/gconf-client.h>
#include "livewp-rules.h"
+#include <sys/time.h>
#define PLUGIN_NAME "livewp-home-widget.desktop-0"
#define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/%s/position"
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)
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);
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);
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 */
}
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);