#define Ystartposition 425
gint xapplet = 0, yapplet = 0;
-GSList * objects_list = NULL;
Scene scene;
static void
void
destroy_hildon_actor(Actor *actor)
{
- fprintf(stderr, "estroy_hildon_actor %p\n",actor->widget);
+ fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
gtk_widget_destroy(actor->widget);
actor->widget = NULL;
}
srand(time(NULL));
return rand() % max;
}
-guint seed;
gint fast_rnd(gint max)
{
guint offset = 12923;
guint multiplier = 4079;
- seed = seed * multiplier + offset;
- return (gint)(seed % max);
+ scene.seed = scene.seed * multiplier + offset;
+ return (gint)(scene.seed % max);
}
gint
char *newfile;
if (actor){
- if (get_daytime() == TIME_NIGHT){
+ if (scene.daytime == TIME_NIGHT){
if (!actor->visible){
actor->visible = TRUE;
phase = get_moon_phase();
sec = tvb.tv_sec;
// fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
+ if (scene.daytime != TIME_NIGHT){
+ if (actor->time_start_animation == 0){
+ actor->time_start_animation = sec + probability_plane();
+ return;
+ }
+ }
if (!actor->visible){
actor->visible = TRUE;
- if (scene.daytime == TIME_NIGHT){
- if (actor->filename)
- g_free(actor->filename);
- actor->filename = g_strdup("tu154.png");
- }else{
- if (actor->filename)
- g_free(actor->filename);
- actor->filename = g_strdup("tu154.png");
- }
create_hildon_actor(actor, desktop_plugin);
}
t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
/* stop animation */
actor->visible = FALSE;
destroy_hildon_actor(actor);
- actor->time_start_animation = sec + probability_plane();
+ if (scene.daytime == TIME_NIGHT)
+ actor->time_start_animation = 0;
+ else
+ actor->time_start_animation = sec + probability_plane();
}
}
ms = tvb.tv_usec;
sec = tvb.tv_sec;
// fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
-
+ if (scene.daytime != TIME_NIGHT){
+ if (actor->time_start_animation == 0){
+ actor->time_start_animation = sec + probability_plane();
+ return;
+ }
+ }
if (!actor->visible){
actor->visible = TRUE;
- if (scene.daytime == TIME_NIGHT){
- if (actor->filename)
- g_free(actor->filename);
- if (scene.daytime == TIME_NIGHT)
- actor->filename = g_strdup("plane3.png");
- }else{
- if (actor->filename)
- g_free(actor->filename);
- actor->filename = g_strdup("plane3.png");
- }
create_hildon_actor(actor, desktop_plugin);
}
+
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);
/* stop animation */
actor->visible = FALSE;
destroy_hildon_actor(actor);
- actor->time_start_animation = sec + probability_plane();
+ if (scene.daytime == TIME_NIGHT)
+ actor->time_start_animation = 0;
+ else
+ actor->time_start_animation = sec + probability_plane();
}
}
void
change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin)
{
- scene.wind_orientation = fast_rnd(2) - 1;
- scene.wind_angle = (double)(fast_rnd(400) - 200) / 100;
- actor->time_start_animation = time(NULL) + (fast_rnd(20) + 10) * 60;
+ scene.wind_orientation = fast_rnd(2);
+ if (scene.wind_orientation == 0) scene.wind_orientation = -1;
+ scene.wind_angle = (double)(fast_rnd(200) - 100) / 100;
+ actor->time_start_animation = time(NULL) + (fast_rnd(10) + 10) * 60;
fprintf(stderr, "change wind orient = %d angle = %f after = %d\n", scene.wind_orientation, scene.wind_angle, actor->time_start_animation-time(NULL));
}
void
change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin)
{
- gint daytime;
gchar *newfile;
- if (!actor) return;
- daytime = get_daytime();
- newfile = g_strdup_printf("%s%d.png", actor->name, daytime);
+ newfile = g_strdup_printf("%s%d.png", actor->name, scene.daytime);
if (actor->filename)
g_free(actor->filename);
actor->filename = newfile;
scene.actors = NULL;
scene.wind_orientation = -1;
scene.wind_angle = 0.3;
+ /* init value for random */
+ scene.seed = time(NULL);
+
actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, 5, 800, 480,
scene.actors = NULL;
scene.wind_orientation = -1;
scene.wind_angle = 0.3;
+ /* init value for random */
+ scene.seed = time(NULL);
+
actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
change_moon(actor, desktop_plugin);
scene.actors = g_slist_append(scene.actors, actor);
- actor = init_object(desktop_plugin, "cloud1", "cloud2.png", 0, fast_rnd(300), 7, 188, 75,
+ actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
FALSE, 100, 255, (gpointer)&change_cloud, NULL);
- actor->time_start_animation = now + fast_rnd(3) * 60;
+ actor->time_start_animation = now + fast_rnd(180);
+ actor->duration_animation = 5*60;
+ scene.actors = g_slist_append(scene.actors, actor);
+
+ actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
+ FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+ actor->time_start_animation = now + fast_rnd(180);
+ actor->duration_animation = 5*60;
+ scene.actors = g_slist_append(scene.actors, actor);
+
+ actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
+ FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+ actor->time_start_animation = now + fast_rnd(180);
actor->duration_animation = 5*60;
scene.actors = g_slist_append(scene.actors, actor);
+
actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
FALSE, 100, 255, (gpointer)&change_plane2, NULL);
actor->time_start_animation = now + probability_plane();
change_static_actor(actor, desktop_plugin);
scene.actors = g_slist_append(scene.actors, actor);
+ actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
+ FALSE, 100, 255, (gpointer)&change_wind, NULL);
+ change_wind(actor, desktop_plugin);
+ scene.actors = g_slist_append(scene.actors, actor);
}
static gboolean
short_timeout (AWallpaperPlugin *desktop_plugin)
{
- gint daytime = get_daytime();
- GSList * tmp;
- void (*pfunc)(gpointer, gpointer);
- time_t now;
- Actor *actor;
- gboolean stop_flag = TRUE;
+ gint daytime = get_daytime();
+ GSList * tmp;
+ void (*pfunc)(gpointer, gpointer);
+ time_t now;
+ Actor *actor;
+ gboolean stop_flag = TRUE;
if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
desktop_plugin->priv->short_timer = 0;
fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer);
if (desktop_plugin->priv->long_timer == 0 )
return FALSE;
- /* TODO remove timeout */
if (!desktop_plugin->priv->visible){
- desktop_plugin->priv->short_timer = 0;
+ if(desktop_plugin->priv->short_timer != 0){
+ g_source_remove(desktop_plugin->priv->short_timer);
+ desktop_plugin->priv->short_timer = 0;
+ }
return FALSE;
}
//fprintf(stderr, "timer daytime=%d\n", daytime);
if (scene.daytime != daytime){
+ scene.daytime = daytime;
tmp = scene.actors;
while (tmp != NULL){
//change_actor(tmp->data);
tmp = g_slist_next(tmp);
}
- scene.daytime = daytime;
return TRUE; /* keep running this event */
}
/* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
if (visible){
desktop_plugin->priv->visible = TRUE;
- if ( desktop_plugin->priv->long_timer == 0){
+ if (desktop_plugin->priv->long_timer == 0 )
desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
- }
}else{
desktop_plugin->priv->visible = FALSE;
- g_source_remove(desktop_plugin->priv->long_timer);
- desktop_plugin->priv->long_timer = 0;
+ if (desktop_plugin->priv->long_timer != 0 ){
+ g_source_remove(desktop_plugin->priv->long_timer);
+ desktop_plugin->priv->long_timer = 0;
+ }
}
}
gboolean
rich_animation_press(GtkWidget *widget, GdkEvent *event,
gpointer user_data){
- fprintf(stderr,"gggggggggggggggggggg\n");
+ fprintf(stderr,"gggggggggggggggggggg2222\n");
}
static void
animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
priv->desktop_plugin = desktop_plugin;
widget = gtk_fixed_new();
- gtk_widget_set_size_request(widget, 95, 68);
+ gtk_widget_set_size_request(widget, 95, 50);
snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town_right_corner.png");
background_town = gtk_image_new_from_file (buffer);
if (background_town){
if(rich_animation){
gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
- gtk_widget_set_size_request(rich_animation, 95, 60);
+ gtk_widget_set_size_request(rich_animation, 95, 50);
gtk_widget_show (rich_animation);
g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
gtk_fixed_put(GTK_FIXED(widget), rich_animation, 0, 0);
gtk_container_add (GTK_CONTAINER (desktop_plugin), widget);
init_applet_position();
- /* start value for random */
- seed = time(NULL);
-
+
fprintf(stderr, "!!!theme = %s\n", priv->theme);
if (!strcmp(priv->theme,"Modern"))
init_scene(desktop_plugin);
}
static void
-animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {}
+animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
+}