X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=applet%2Fsrc%2Ffifteen.c;h=4227d84c88c665dc4099fb8bb68ebf7f67c1d897;hb=881c9dcda97b09e9f645f96e2bd82c9bf959a337;hp=b9b1994377b2b27a0c2647614d8c349859b5ba42;hpb=300a0f3965b92e8405c2cfcf874cb039ece77d13;p=livewp diff --git a/applet/src/fifteen.c b/applet/src/fifteen.c index b9b1994..4227d84 100644 --- a/applet/src/fifteen.c +++ b/applet/src/fifteen.c @@ -1,7 +1,9 @@ #include #include +#include #include "livewp-common.h" #include "livewp-actor.h" +#include "livewp-dbus.h" enum { UP = 0, @@ -10,8 +12,8 @@ enum { LEFT = 3 }; -const gint width = 200; -const gint height = 120; +const gint width = 110; +const gint height = 110; typedef struct _Scene1 Scene1; struct _Scene1 @@ -40,37 +42,6 @@ void init_pg(gint *pg) pg[j] = t; } } -#if 0 -gint move(gint direction, AWallpaperPlugin *desktop_plugin) -{ - gint bone; - Actor *actor; - switch (direction) { - case UP: - bone = empty + 4; - if (bone > 15) return -1; - break; - case RIGHT: - bone = empty - 1; - if (empty % 4 == 0) return -1; - break; - case DOWN: - bone = empty - 4; - if (bone < 0) return -1; - break; - case LEFT: - bone = empty + 1; - if (bone % 4 == 0) return -1; - } - //actor = actors[pg[bone]]; - cur = bone; - //set_actor_position(actor, (empty%4)*width, (empty/4)*height, actor->z, desktop_plugin); - //pg[empty] = pg[bone]; - //pg[bone] = 15; - //empty = bone; - return pg[bone]; -} -#endif void reinit(AWallpaperPlugin *desktop_plugin) { fprintf(stderr, "reinit\n"); @@ -112,13 +83,14 @@ void moving_all(gint num, gint max, AWallpaperPlugin *desktop_plugin) { gint i, axis; double angle; - angle = 360*(max - num)/max; + angle = 360*(max - num)*(max-num)/(max*max); for (i=0; i<15; i++){ - if (i%2 == 0) axis = HILDON_AA_Y_AXIS; - else axis = HILDON_AA_X_AXIS; - set_actor_rotation(actors[i], axis, angle, 0, 0, 0); + if (i%2 == 0) axis = HILDON_AA_X_AXIS; + else axis = HILDON_AA_Y_AXIS; + set_actor_rotation(actors[i], axis, angle, width/2, height/2, 0); } - if (num == (int)max/2){ + //if (num == (int)max/2){ + if (num == 0){ reinit(desktop_plugin); } } @@ -132,8 +104,8 @@ gboolean main_timer(AWallpaperPlugin *desktop_plugin) moving_all(scene->timer_num, 20, desktop_plugin); return; } - //char * accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord"; - char * accel_filename = "/home/tanya/coord"; + char * accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord"; + //char * accel_filename = "/home/tanya/coord"; gint direction = -1, bone; FILE *fd = NULL; @@ -182,7 +154,7 @@ gboolean main_timer(AWallpaperPlugin *desktop_plugin) if (bone < 0) return TRUE; } } else return TRUE; - fprintf(stderr, "move %d\n", bone); + //fprintf(stderr, "move %d\n", bone); scene->bone = bone; scene->timer_num = 10; @@ -191,7 +163,11 @@ gboolean main_timer(AWallpaperPlugin *desktop_plugin) void init_actors(AWallpaperPlugin *desktop_plugin) { gint i; - //Actor *actors[15]; + Actor *actor; + actor = init_object(desktop_plugin, "background", g_strdup("background.jpg"), + -180, -15, 2, 800, 480, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); for (i=0; i<15; i++){ actors[i] = init_object(desktop_plugin, "bone", g_strdup_printf("%d.png", i+1), 0, 0, 2, width, height, @@ -200,6 +176,30 @@ void init_actors(AWallpaperPlugin *desktop_plugin) } //return actors; } +void +quit_from_program (Animation_WallpaperPrivate *priv) +{ + gtk_main_quit(); +} + +void +view_state_changed (Animation_WallpaperPrivate *priv) +{ + if (priv->visible && priv->long_timer == 0){ + priv->long_timer = g_timeout_add(50, main_timer, priv->desktop_plugin); + //fprintf(stderr, "visible = 1 timeout_add %d\n", priv->long_timer); + }else { + //fprintf(stderr, "visible = 0 timer remove %d\n", priv->long_timer); + g_source_remove(priv->long_timer); + priv->long_timer = 0; + } + +} +gint +read_config (Animation_WallpaperPrivate *priv){} +void +reload_scene(AWallpaperPlugin *desktop_plugin){} + int main( int argc, char *argv[] ) { GtkWidget *window; @@ -207,20 +207,43 @@ int main( int argc, char *argv[] ) Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1); scene = g_new0(Scene1, 1); Actor *actor; - gint i; + gint i, c, window_id=0, view=0; gint pg[16]; + while ((c = getopt(argc, argv, ":v:w:")) != -1){ + switch (c){ + case 'v': + view = atoi(optarg); + break; + case 'w': + window_id = atoi(optarg); + } + } + + //fprintf(stderr, "view=%d window_id=%d\n", view, window_id); + hildon_gtk_init (&argc, &argv); - g_set_application_name ("Simplest example"); + g_set_application_name ("Fifteen"); window = hildon_window_new (); + //gtk_window_fullscreen (GTK_WINDOW(window)); + gtk_window_set_title(window,"Fifteen"); + gtk_window_set_wmclass(window,"Fifteen_exec","Fifteen_exec"); + //window->window = window_id; g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); priv->window = window; priv->theme = g_strdup("Fifteen"); - priv->xapplet = 0; - priv->yapplet = 0; + priv->xapplet = -180; + priv->yapplet = -15; + priv->desktop_plugin = desktop_plugin; + priv->view = view; + priv->long_timer = 0; desktop_plugin->priv = priv; + priv->osso = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL); + livewp_initialize_dbus(priv); + + //init_pg(pg); scene->pg = pg; //scene->actors = init_actors(desktop_plugin); @@ -228,7 +251,8 @@ int main( int argc, char *argv[] ) scene->timer_num = 0; reinit(desktop_plugin); gtk_widget_show (window); - g_timeout_add(100, main_timer, desktop_plugin); + priv->long_timer = g_timeout_add(50, main_timer, desktop_plugin); + //fprintf(stderr, "create timer %d\n", priv->long_timer); gtk_main (); return 0; }