How do you use GdkRectangle to determine whether you size-allocate is growing or shrinking?
I have a callback for the size-allocate
signal on my GtkScrolledWindow. I want to scroll to the right when I am adding stuff to 开发者_StackOverflow社区that window. This works fine but introduces a subtle bug when removing items from that window. I would like to only scroll the window when adding stuff. I see the signal receives a GdkRectangle but I am unsure how to use it.
First size-allocate signal run-first, that means, If I'm not wrong, before the default handler. So you can get the GdkRectangle of the widget with gtk_widget_get_allocation, and compare it with the new one. Now GdkRectangle is a cairo_rectangle_int_t and the definition of that is:
typedef struct {
int x, y;
int width, height;
} cairo_rectangle_int_t;
So you can check width and heights, with the old ones.
精彩评论