}
static gint
-get_time(gint t)
-{
+get_time(gint t){
// уравнение изменения времени
return t*1.1;
}
static void
-destroy_scene(void)
-{
+destroy_scene(void){
GSList * tmp = scene.actors;
while (tmp != NULL){
if (tmp->data){
}
#endif
static gboolean
-plugin_on_timeout (AWallpaperPlugin *desktop_plugin)
+short_timeout (AWallpaperPlugin *desktop_plugin)
+{
+ gint daytime = get_daytime();
+ GSList * tmp;
+ gchar * name;
+ void (*pfunc)(gpointer, gpointer);
+ time_t now;
+ 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;
+ }
+ }
+ 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 */
+}
+
+
+static gboolean
+long_timeout (AWallpaperPlugin *desktop_plugin)
{
gint daytime = get_daytime();
GSList * tmp;
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);
+ && desktop_plugin->priv->short_timer == 0){
+ fprintf(stderr, "start shor timer act = %s\n", actor->name);
+ actor->time_start_animation = now;
+ desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, short_timeout, desktop_plugin);
}
tmp = g_slist_next(tmp);
}
init_scene(desktop_plugin);
else if (!strcmp(priv->theme,"Berlin"))
init_scene(desktop_plugin);
- priv->timer = g_timeout_add(LONG_TIMER, plugin_on_timeout, desktop_plugin);
+ priv->long_timer = g_timeout_add(LONG_TIMER, long_timeout, desktop_plugin);
+ priv->short_timer = 0;
/* TODO Move scene to priv */
scene.timer_type = LONG_TIMER_TYPE;
}
AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
Animation_WallpaperPrivate *priv = desktop_plugin->priv;
- if (priv->timer){
- g_source_remove(priv->timer);
- priv->timer = NULL;
+ 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();
}