From: tanya Date: Fri, 30 Apr 2010 10:53:01 +0000 (+0300) Subject: continued restructuring X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=b389be0204e594e91715ade6d15bdc541a43aea9;p=livewp continued restructuring --- diff --git a/applet/src/livewp-actor.c b/applet/src/livewp-actor.c index f8d4009..1a35526 100644 --- a/applet/src/livewp-actor.c +++ b/applet/src/livewp-actor.c @@ -68,12 +68,53 @@ init_object(AWallpaperPlugin *desktop_plugin, return actor; } +void +destroy_actor(Actor *actor) +{ + if (actor){ + if (actor->child){ + g_ptr_array_free(actor->child, TRUE); + } + if (actor->filename) + g_free(actor->filename); + if (actor->name) + g_free(actor->name); + gtk_widget_destroy(actor->widget); + //actor->widget = NULL; + g_free(actor); + } +} static gint path_line(gint x0, gint x1, double t) { // уравниение прямой return ((x1 - x0) * t + x0); } +static void +set_actor_scale(Actor *actor, double scalex, double scaley) +{ + hildon_animation_actor_set_scale( + HILDON_ANIMATION_ACTOR(actor->widget), + scalex, + scaley + ); + +} + +static void +set_actor_visible(Actor *actor, gboolean visible) +{ + hildon_animation_actor_set_show(HILDON_ANIMATION_ACTOR(actor->widget), visible); +} + +void +set_actor_position(Actor *actor, gint x, gint y, gint z, AWallpaperPlugin *desktop_plugin) +{ + hildon_animation_actor_set_position_full(HILDON_ANIMATION_ACTOR (actor->widget), + x-desktop_plugin->priv->xapplet, + y-desktop_plugin->priv->yapplet, + z); +} void change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin) @@ -122,7 +163,7 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin) y = 0.001920*x*x - 1.536*x + 337.2; //y = a*x*x + b*x + c; - actor_set_position_full(actor->widget, x, y, actor->z); + set_actor_position(actor, x, y, actor->z, desktop_plugin); if (t>=2){ actor->time_start_animation = sec; @@ -155,7 +196,7 @@ change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin) get_sun_screen_pos(alt, azm, &x, &y); actor->x = x; actor->y = y; - actor_set_position_full(actor->widget, x, y, actor->z); + set_actor_position(actor, x, y, actor->z, desktop_plugin); actor->time_start_animation = time(NULL) + 60; }else if (actor->visible){ actor->visible = FALSE; @@ -200,7 +241,7 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin) x = path_line(x0, x1, t); y = path_line(y0, y1, t); scale = path_line(scale0, scale1, t); - actor_set_position_full(actor->widget, x, y, actor->z); + set_actor_position(actor, x, y, actor->z, desktop_plugin); set_actor_scale(actor, (double)scale/100, (double)scale/100); if (t >= 1){ /* stop animation */ @@ -241,7 +282,7 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin) x = path_line(x0, x1, t); y = path_line(y0, y1, t); //scale = path_line(scale0, scale1, t); - actor_set_position_full(actor->widget, x, y, actor->z); + set_actor_position(actor, x, y, actor->z, desktop_plugin); if (t >= 1){ /* stop animation */ actor->visible = FALSE; @@ -285,7 +326,7 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin) x = path_line(x0, x1, t); y = path_line(y0, y1, t); //scale = path_line(scale0, scale1, t); - actor_set_position_full(actor->widget, x, y, actor->z); + set_actor_position(actor, x, y, actor->z, desktop_plugin); if (t >= 1){ /* stop animation */ actor->visible = FALSE; @@ -344,7 +385,7 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin) y = -desktop_plugin->priv->scene->wind_angle * (x - x0) + actor->y; scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0)); - actor_set_position_full(actor->widget, x, y, actor->z); + set_actor_position(actor, x, y, actor->z, desktop_plugin); set_actor_scale(actor, (double)scale/100, (double)scale/100); if ((y < y1 || y > y0) || t >= 1){ /* stop animation */ @@ -418,18 +459,36 @@ change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin) } void -set_actor_scale(Actor *actor, double scalex, double scaley) +change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin) { - hildon_animation_actor_set_scale( - HILDON_ANIMATION_ACTOR(actor->widget), - scalex, - scaley - ); + gint y; + Actor *a; -} + if (!desktop_plugin->priv->rich_animation) return; -void -set_actor_visible(Actor *actor, gboolean visible) -{ - hildon_animation_actor_set_show(HILDON_ANIMATION_ACTOR(actor->widget), visible); + a = g_ptr_array_index(actor->child, 0); + y = a->y + 10; + if (y > 480) y = -480; + set_actor_position(a, a->x, y, a->z, desktop_plugin); + a->y = y; + + a = g_ptr_array_index(actor->child, 1); + y = a->y + 10; + if (y > 480) y = -480; + set_actor_position(a, a->x, y, a->z, desktop_plugin); + a->y = y; + + a = g_ptr_array_index(actor->child, 2); + y = a->y + 20; + if (y > 480) y = -480; + set_actor_position(a, a->x, y, a->z, desktop_plugin); + a->y = y; + + a = g_ptr_array_index(actor->child, 3); + y = a->y + 20; + if (y > 480) y = -480; + set_actor_position(a, a->x, y, a->z, desktop_plugin); + a->y = y; } + + diff --git a/applet/src/livewp-actor.h b/applet/src/livewp-actor.h index 8437f7a..05c3124 100644 --- a/applet/src/livewp-actor.h +++ b/applet/src/livewp-actor.h @@ -44,7 +44,8 @@ Actor* init_object(AWallpaperPlugin *desktop_plugin, void (*pfunc_probability)(Actor*), GPtrArray *child ); - +void destroy_actor(Actor *actor); +void set_actor_position(Actor *actor, gint x, gint y, gint z, AWallpaperPlugin *desktop_plugin); void change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin); @@ -54,7 +55,5 @@ void change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin); void change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin); void change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin); -void set_actor_scale(Actor *actor, double scalex, double scaley); -void set_actor_visible(Actor *actor, gboolean visible); void change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin); #endif diff --git a/applet/src/livewp-common.h b/applet/src/livewp-common.h index 2c38d96..213777d 100644 --- a/applet/src/livewp-common.h +++ b/applet/src/livewp-common.h @@ -67,6 +67,8 @@ struct _Animation_WallpaperPrivate DBusConnection *dbus_conn_session; osso_context_t *osso; Scene *scene; + gint xapplet; + gint yapplet; }; struct _AWallpaperPlugin diff --git a/applet/src/livewp-home-widget.c b/applet/src/livewp-home-widget.c index a181dc5..f12baa2 100644 --- a/applet/src/livewp-home-widget.c +++ b/applet/src/livewp-home-widget.c @@ -44,8 +44,7 @@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_H #define Xstartposition 700 #define Ystartposition 448 -gint xapplet = 0, yapplet = 0; -//Scene scene; +//gint xapplet = 0, yapplet = 0; static void lw_applet_realize (GtkWidget *widget) @@ -112,7 +111,7 @@ realize (GtkWidget *widget) /* Set position of widget on desktop */ static void -init_applet_position(void) +init_applet_position(gint *xapplet, gint *yapplet) { GSList *position = NULL; gchar *position_key; @@ -126,8 +125,8 @@ init_applet_position(void) GCONF_VALUE_INT, NULL); if (position && position->data && position->next->data){ - xapplet = GPOINTER_TO_INT (position->data); - yapplet = GPOINTER_TO_INT (position->next->data); + *xapplet = GPOINTER_TO_INT (position->data); + *yapplet = GPOINTER_TO_INT (position->next->data); }else{ position = g_slist_prepend (g_slist_prepend (NULL, GINT_TO_POINTER (Ystartposition)), @@ -137,8 +136,8 @@ init_applet_position(void) GCONF_VALUE_INT, position, &error); - xapplet = Xstartposition; - yapplet = Ystartposition; + *xapplet = Xstartposition; + *yapplet = Ystartposition; } g_free (position_key); modified = g_strdup_printf ("%i", 0); @@ -157,7 +156,7 @@ void actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z) { /* fprintf(stderr, "actor_set_position_full z=%d\n", z); */ - hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-xapplet, y-yapplet, z); + hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-0, y-0, z); } @@ -214,7 +213,7 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) G_CALLBACK(expose_event), pixbuf); gtk_container_add (GTK_CONTAINER (ha), image); } - actor_set_position_full(ha, actor->x, actor->y, actor->z); + //actor_set_position_full(ha, actor->x, actor->y, actor->z); hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(ha), (double)actor->scale/100, (double)actor->scale/100); realize(ha); gtk_widget_show_all(ha); @@ -226,6 +225,7 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) g_object_set_data(G_OBJECT(ha), "image", image); hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin)); actor->widget = ha; + set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin); } @@ -297,60 +297,6 @@ change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin) } -void -change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin) -{ - gint y; - Actor *a; - - if (!desktop_plugin->priv->rich_animation) return; - - a = g_ptr_array_index(actor->child, 0); - y = a->y + 10; - if (y > 480) y = -480; - actor_set_position_full(a->widget, a->x, y, a->z); - a->y = y; - - a = g_ptr_array_index(actor->child, 1); - y = a->y + 10; - if (y > 480) y = -480; - actor_set_position_full(a->widget, a->x, y, a->z); - a->y = y; - - a = g_ptr_array_index(actor->child, 2); - y = a->y + 20; - if (y > 480) y = -480; - actor_set_position_full(a->widget, a->x, y, a->z); - a->y = y; - - a = g_ptr_array_index(actor->child, 3); - y = a->y + 20; - if (y > 480) y = -480; - actor_set_position_full(a->widget, a->x, y, a->z); - a->y = y; - -} -#if 0 -void -change_layer1(Actor * actor, AWallpaperPlugin *desktop_plugin) -{ - gint y; - y = actor->y + 10; - if (y > 480) y = -480; - actor_set_position_full(actor->widget, actor->x, y, actor->z); - actor->y = y; -} - -void -change_layer2(Actor * actor, AWallpaperPlugin *desktop_plugin) -{ - gint y; - y = actor->y + 15; - if (y >= 480) y = -480; - actor_set_position_full(actor->widget, actor->x, y, actor->z); - actor->y = y; -} -#endif /* static gint get_time(gint t){ @@ -362,21 +308,8 @@ static void destroy_scene(AWallpaperPlugin *desktop_plugin) { GSList * tmp = desktop_plugin->priv->scene->actors; - Actor *actor; while (tmp != NULL){ - actor = tmp->data; - if (actor){ - if (actor->child){ - g_ptr_array_free(actor->child, TRUE); - } - if (actor->filename) - g_free(actor->filename); - if (actor->name) - g_free(actor->name); - gtk_widget_destroy(actor->widget); - //actor->widget = NULL; - g_free(actor); - } + destroy_actor(tmp->data); tmp = g_slist_next(tmp); } g_slist_free(tmp); @@ -1203,6 +1136,8 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin) priv->desktop_plugin = desktop_plugin; priv->visible = TRUE; priv->short_timer = 0; + priv->xapplet = 0; + priv->yapplet = 0; //priv->theme = g_strdup("Modern"); desktop_plugin->priv->main_widget = gtk_fixed_new(); @@ -1228,7 +1163,7 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin) GtkWidget *label = gtk_label_new ("ddddddddddddd"); gtk_widget_set_size_request(label, 95, 30); gtk_widget_show (label); -// gtk_container_add (GTK_CONTAINER (desktop_plugin), label); + gtk_container_add (GTK_CONTAINER (desktop_plugin), label); gtk_fixed_put(GTK_FIXED(widget), label, 0, 0); */ hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE); @@ -1236,7 +1171,7 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin) G_CALLBACK (show_settings), priv); gtk_widget_show (desktop_plugin->priv->main_widget); gtk_container_add (GTK_CONTAINER (desktop_plugin), desktop_plugin->priv->main_widget); - init_applet_position(); + init_applet_position(&(priv->xapplet), &(priv->yapplet)); fprintf(stderr, "!!!theme = %s\n", priv->theme);