struct ctx
{
+ GtkWidget *draw;
GdkPixbuf *picture;
GArray *points;
int i;
+ gboolean move;
};
#define FILENAME "/home/cascardo/fotos/debconf.jpg"
gboolean
queue (gpointer data)
{
- gtk_widget_queue_draw (GTK_WIDGET (data));
- return TRUE;
+ struct ctx *ctx;
+ ctx = (struct ctx *) data;
+ gtk_widget_queue_draw (GTK_WIDGET (ctx->draw));
+ ctx->move = TRUE;
+ return FALSE;
}
gboolean
struct ctx *ctx;
Point point;
ctx = (struct ctx *) data;
- ctx->i = (ctx->i >= ctx->points->len) ? 0 : ctx->i + 1;
+ if (ctx->move)
+ ctx->i = (ctx->i >= ctx->points->len) ? 0 : ctx->i + 1;
point = g_array_index (ctx->points, Point, ctx->i);
screen = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
event->area.width, event->area.height);
gdk_draw_pixbuf (widget->window, NULL, screen, 0, 0, 0, 0, -1, -1,
GDK_RGB_DITHER_NONE, 0, 0);
gdk_pixbuf_unref (screen);
+ if (point.name)
+ {
+ g_timeout_add (3000, queue, ctx);
+ }
+ else
+ {
+ g_timeout_add (10, queue, ctx);
+ }
+ ctx->move = FALSE;
return FALSE;
}
int bits_per_sample;
int width, height;
GtkWidget *window;
- GtkWidget *draw;
struct ctx ctx;
gtk_init (&argc, &argv);
if (argc < 2)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
- draw = gtk_drawing_area_new ();
- gtk_widget_set_size_request (draw, width, height);
- gtk_container_add (GTK_CONTAINER (window), draw);
+ ctx.draw = gtk_drawing_area_new ();
+ gtk_widget_set_size_request (ctx.draw, width, height);
+ gtk_container_add (GTK_CONTAINER (window), ctx.draw);
gtk_widget_show_all (window);
- g_signal_connect (G_OBJECT (draw), "expose_event",
+ g_signal_connect (G_OBJECT (ctx.draw), "expose_event",
G_CALLBACK (expose), &ctx);
- g_timeout_add (10, queue, draw);
+ g_timeout_add (10, queue, &ctx);
gtk_main ();
gdk_pixbuf_unref (ctx.picture);
return 0;
int inc, err, thre, swap;
int x1, y1, x2, y2;
int x, y;
- rect.name = src->name;
+ rect.name = NULL;
err = 0;
swap = 0;
x1 = src->x;
rect.x = strtol (buffer, &next, 0);
rect.y = strtol (next+1, &next, 0);
strtol (next, &next, 0);
- if (i > 0)
- InsertLine (points, &last, &rect);
while (isspace (*next)) next++;
rect.name = g_strdup (next);
+ if (i > 0)
+ InsertLine (points, &last, &rect);
+ g_array_append_val (points, rect);
last = rect;
i++;
}