static GtkWidget*
init_object(AWallpaperPlugin *desktop_plugin, gchar * name, gchar * filename, gint x, gint y, gint z, gint width, gint height, gboolean visible, gint scale, gint opacity, void (*pfunc)(GtkWidget*, gpointer))
{
- GtkWidget *actor;
- GdkPixbuf *pixbuf;
- GtkWidget *image;
+ GtkWidget *actor = NULL;
+ GdkPixbuf *pixbuf = NULL;
+ GtkWidget *image = NULL;
actor = hildon_animation_actor_new();
gchar str[256];
- snprintf(str, 255, "/%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, filename);
- //fprintf(stderr, "!!!init object !!!!\nname = %s file = %s\n", name, str);
+ snprintf(str, 255, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, filename);
+ //fprintf(stderr, "!!!init object !!!!file = %s\n", str);
pixbuf = gdk_pixbuf_new_from_file_at_size (str,
width,
height,
image = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref(G_OBJECT(pixbuf));
}
- g_signal_connect(G_OBJECT(image), "expose_event",
+ if (image){
+ g_signal_connect(G_OBJECT(image), "expose_event",
G_CALLBACK(expose_event), pixbuf);
- gtk_container_add (GTK_CONTAINER (actor), image);
+ gtk_container_add (GTK_CONTAINER (actor), image);
+ }
actor_set_position_full(actor, x, y, z);
hildon_animation_actor_set_show (actor, visible);
}
}
}
+void change_static_actor(GtkWidget * actor, gpointer data)
+{
+ gint daytime;
+ gchar newfile[2048];
+ gchar * name;
+ GtkWidget *image;
+ GdkPixbuf *pixbuf;
+ AWallpaperPlugin *desktop_plugin;
+ if (!actor) return;
+ if (!data) return;
+ desktop_plugin = data;
+ daytime = get_daytime();
+
+ name = g_object_get_data(G_OBJECT(actor), "name");
+ snprintf(newfile, 2047, "%s/%s/%s%i.png", THEME_PATH, desktop_plugin->priv->theme, name, daytime);
+
+ pixbuf = gdk_pixbuf_new_from_file_at_size (newfile,
+ g_object_get_data(G_OBJECT(actor), "width"),
+ g_object_get_data(G_OBJECT(actor), "height"),
+ NULL);
+ if (pixbuf){
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ g_object_unref(G_OBJECT(pixbuf));
+ }
+
+ g_signal_connect(G_OBJECT(image), "expose_event",
+ G_CALLBACK(expose_event), pixbuf);
+ if (g_object_get_data(G_OBJECT(actor), "image")){
+ gtk_container_remove(actor, g_object_get_data(G_OBJECT(actor), "image"));
+ }
+ g_object_set_data(G_OBJECT(actor), "image", image);
+ gtk_container_add (GTK_CONTAINER (actor), image);
+ realize(actor);
+ gtk_widget_show_all(actor);
+}
void change_tram(GtkWidget * actor, gpointer data)
{
double alt, azm;
}
}
+static gint path_line(gint x0, gint x1, gint t_all, gint t)
+{
+ // уравниение прямой
+ return ((x1 - x0) / t_all * t + x0);
+}
static void path_tram(GtkWidget * actor, gint t)
{
gint x0 = -300, y0 = 191, scale0 = 100, t0 = 0,
x1 = 800, y1 = 119, scale1 = 130, t1 = 100,
x, y, scale;
- x = 12 * t - 300;
- y = -0.72 * t + 191;
- scale = 0.3 * t + 100;
+ x = path_line(x0, x1, t1, t);
+ y = path_line(y0, y1, t1, t);
+ scale = path_line(scale0, scale1, t1, t);
//fprintf(stderr, "path tram: t=%i, x=%i, y=%i, scale=%i\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);
}
static gint get_time(gint t)
{
+ // уравнение изменения времени
return t*1.1;
-
}
scene.dynamic_actors = NULL;
scene.static_actors = NULL;
- get_sun_pos(&alt, &azm);
- get_sun_screen_pos(alt, azm, &x, &y);
- actor = init_object(desktop_plugin, "sun", "sun.png", x, y, 11, 88, 88, 1, 100, 255, &change_sun);
+ //get_sun_pos(&alt, &azm);
+ //get_sun_screen_pos(alt, azm, &x, &y);
+ actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 11, 88, 88, 1, 100, 255, &change_sun);
+ change_sun(actor, NULL);
//scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
- //ma1->multiactor_init("sun", g_slist_append(list, G_OBJECT(actor)));
+ actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, 5, 800, 480, 1, 100, 255, &change_static_actor);
+ change_static_actor(G_OBJECT(actor), desktop_plugin);
+ scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
- snprintf(str, 255, "sky%i.png", scene.daytime);
- actor = init_object(desktop_plugin, "sky", str, 0, 0, 5, 800, 480, 1, 100, 255, NULL);
- scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
-
- snprintf(str, 255, "town%i.png", scene.daytime);
- actor = init_object(desktop_plugin, "town", str, 0, 480-374, 10, 800, 374, 1, 100, 255, NULL);
+ actor = init_object(desktop_plugin, "town", "town.png", 0, 480-374, 10, 800, 374, 1, 100, 255, NULL);
+ change_static_actor(G_OBJECT(actor), desktop_plugin);
scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
- snprintf(str, 255, "border%i.png", scene.daytime);
- actor = init_object(desktop_plugin, "border", str, 0, 480-79, 30, 800, 79, 1, 100, 255, NULL);
+ actor = init_object(desktop_plugin, "border", "border.png", 0, 480-79, 30, 800, 79, 1, 100, 255, NULL);
+ change_static_actor(G_OBJECT(actor), desktop_plugin);
scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
//if (scene.daytime == TIME_DAY) snprintf(str, 255, "tram.png");
{
GtkWidget *label;
+ //fprintf(stderr, "!!!!!!!plugin init \n");
Animation_WallpaperPrivate *priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
desktop_plugin->priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
/* Load config */
gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
init_applet_position();
init_scene(desktop_plugin);
- priv->timer = g_timeout_add(500, plugin_on_timeout, desktop_plugin);
+ priv->timer = g_timeout_add(100, plugin_on_timeout, desktop_plugin);
}
static void