tests/testgtk.c: Use accessor functions to access GtkWidget

This commit is contained in:
Javier Jardón
2010-08-16 00:33:57 +02:00
parent 1b7b30bf31
commit 252a8fc048

View File

@ -131,18 +131,21 @@ static gboolean
on_alpha_window_expose (GtkWidget *widget, on_alpha_window_expose (GtkWidget *widget,
GdkEventExpose *expose) GdkEventExpose *expose)
{ {
GtkAllocation allocation;
cairo_t *cr; cairo_t *cr;
cairo_pattern_t *pattern; cairo_pattern_t *pattern;
int radius; int radius;
cr = gdk_cairo_create (widget->window); cr = gdk_cairo_create (gtk_widget_get_window (widget));
radius = MIN (widget->allocation.width, widget->allocation.height) / 2; gtk_widget_get_allocation (widget, &allocation);
pattern = cairo_pattern_create_radial (widget->allocation.width / 2,
widget->allocation.height / 2, radius = MIN (allocation.width, allocation.height) / 2;
pattern = cairo_pattern_create_radial (allocation.width / 2,
allocation.height / 2,
0.0, 0.0,
widget->allocation.width / 2, allocation.width / 2,
widget->allocation.height / 2, allocation.height / 2,
radius * 1.33); radius * 1.33);
if (gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget)) && if (gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget)) &&
@ -357,7 +360,7 @@ transparent_expose (GtkWidget *widget,
{ {
cairo_t *cr; cairo_t *cr;
cr = gdk_cairo_create (widget->window); cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
gdk_cairo_region (cr, event->region); gdk_cairo_region (cr, event->region);
cairo_fill (cr); cairo_fill (cr);
@ -381,6 +384,7 @@ static gboolean
window_expose_event (GtkWidget *widget, window_expose_event (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event)
{ {
GtkAllocation allocation;
cairo_region_t *region; cairo_region_t *region;
GtkWidget *child; GtkWidget *child;
cairo_t *cr; cairo_t *cr;
@ -389,15 +393,17 @@ window_expose_event (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (widget)); child = gtk_bin_get_child (GTK_BIN (widget));
/* create a cairo context to draw to the window */ /* create a cairo context to draw to the window */
cr = gdk_cairo_create (widget->window); cr = gdk_cairo_create (gtk_widget_get_window (widget));
gtk_widget_get_allocation (child, &allocation);
/* the source data is the (composited) event box */ /* the source data is the (composited) event box */
gdk_cairo_set_source_pixmap (cr, child->window, gdk_cairo_set_source_pixmap (cr, gtk_widget_get_window (child),
child->allocation.x, allocation.x,
child->allocation.y); allocation.y);
/* draw no more than our expose event intersects our child */ /* draw no more than our expose event intersects our child */
region = cairo_region_create_rectangle (&child->allocation); region = cairo_region_create_rectangle (&allocation);
cairo_region_intersect (region, event->region); cairo_region_intersect (region, event->region);
gdk_cairo_region (cr, region); gdk_cairo_region (cr, region);
cairo_clip (cr); cairo_clip (cr);
@ -463,7 +469,8 @@ create_composited_window (GtkWidget *widget)
/* set the event box GdkWindow to be composited. /* set the event box GdkWindow to be composited.
* obviously must be performed after event box is realised. * obviously must be performed after event box is realised.
*/ */
gdk_window_set_composited (event->window, TRUE); gdk_window_set_composited (gtk_widget_get_window (event),
TRUE);
/* set up the compositing handler. /* set up the compositing handler.
* note that we do _after so that the normal (red) background is drawn * note that we do _after so that the normal (red) background is drawn
@ -586,7 +593,8 @@ pattern_hadj_changed (GtkAdjustment *adj,
if (gtk_widget_get_realized (darea)) if (gtk_widget_get_realized (darea))
{ {
gdk_window_scroll (darea->window, *old_value - new_value, 0); gdk_window_scroll (gtk_widget_get_window (darea),
*old_value - new_value, 0);
*old_value = new_value; *old_value = new_value;
} }
} }
@ -600,7 +608,8 @@ pattern_vadj_changed (GtkAdjustment *adj,
if (gtk_widget_get_realized (darea)) if (gtk_widget_get_realized (darea))
{ {
gdk_window_scroll (darea->window, 0, *old_value - new_value); gdk_window_scroll (gtk_widget_get_window (darea),
0, *old_value - new_value);
*old_value = new_value; *old_value = new_value;
} }
} }
@ -609,8 +618,11 @@ static void
pattern_realize (GtkWidget *widget, pattern_realize (GtkWidget *widget,
gpointer data) gpointer data)
{ {
pattern_set_bg (widget, widget->window, 0); GdkWindow *window;
create_pattern (widget, widget->window, 1, PATTERN_SIZE, PATTERN_SIZE);
window = gtk_widget_get_window (widget);
pattern_set_bg (widget, window, 0);
create_pattern (widget, window, 1, PATTERN_SIZE, PATTERN_SIZE);
} }
static void static void
@ -1430,8 +1442,8 @@ create_toolbar (GtkWidget *widget)
{ {
GtkWidget *icon; GtkWidget *icon;
icon = new_pixbuf ("test.xpm", window->window, icon = new_pixbuf ("test.xpm", gtk_widget_get_window (window),
&window->style->bg[GTK_STATE_NORMAL]); &gtk_widget_get_style (window)->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, create_toolbar_items[i].label); toolitem = gtk_tool_button_new (icon, create_toolbar_items[i].label);
} }
if (create_toolbar_items[i].callback) if (create_toolbar_items[i].callback)
@ -1501,8 +1513,8 @@ make_toolbar (GtkWidget *window)
toolitem = gtk_separator_tool_item_new (); toolitem = gtk_separator_tool_item_new ();
continue; continue;
} }
icon = new_pixbuf ("test.xpm", window->window, icon = new_pixbuf ("test.xpm", gtk_widget_get_window (window),
&window->style->bg[GTK_STATE_NORMAL]); &gtk_widget_get_style (window)->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, make_toolbar_items[i].label); toolitem = gtk_tool_button_new (icon, make_toolbar_items[i].label);
gtk_tool_item_set_tooltip_text (toolitem, make_toolbar_items[i].tooltip); gtk_tool_item_set_tooltip_text (toolitem, make_toolbar_items[i].tooltip);
if (make_toolbar_items[i].callback != NULL) if (make_toolbar_items[i].callback != NULL)
@ -1705,23 +1717,30 @@ static gboolean
gridded_geometry_expose (GtkWidget *widget, gridded_geometry_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event)
{ {
int i, j; GtkAllocation allocation;
GtkStateType state;
GtkStyle *style;
cairo_t *cr; cairo_t *cr;
int i, j;
cr = gdk_cairo_create (widget->window); gtk_widget_get_allocation (widget, &allocation);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height); cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_color (cr, &widget->style->base[widget->state]);
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
gdk_cairo_set_source_color (cr, &style->base[state]);
cairo_fill (cr); cairo_fill (cr);
for (i = 0 ; i * GRID_SIZE < widget->allocation.width; i++) for (i = 0 ; i * GRID_SIZE < allocation.width; i++)
for (j = 0 ; j * GRID_SIZE < widget->allocation.height; j++) for (j = 0 ; j * GRID_SIZE < allocation.height; j++)
{ {
if ((i + j) % 2 == 0) if ((i + j) % 2 == 0)
cairo_rectangle (cr, i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE); cairo_rectangle (cr, i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE);
} }
gdk_cairo_set_source_color (cr, &widget->style->text[widget->state]); gdk_cairo_set_source_color (cr, &style->text[state]);
cairo_fill (cr); cairo_fill (cr);
cairo_destroy (cr); cairo_destroy (cr);
@ -2351,6 +2370,7 @@ on_rotated_text_expose (GtkWidget *widget,
GdkEventExpose *event, GdkEventExpose *event,
GdkPixbuf *tile_pixbuf) GdkPixbuf *tile_pixbuf)
{ {
GtkAllocation allocation;
static const gchar *words[] = { "The", "grand", "old", "Duke", "of", "York", static const gchar *words[] = { "The", "grand", "old", "Duke", "of", "York",
"had", "10,000", "men" }; "had", "10,000", "men" };
int n_words; int n_words;
@ -2371,11 +2391,13 @@ on_rotated_text_expose (GtkWidget *widget,
else else
cairo_set_source_rgb (cr, 0, 0, 0); cairo_set_source_rgb (cr, 0, 0, 0);
radius = MIN (widget->allocation.width, widget->allocation.height) / 2.; gtk_widget_get_allocation (widget, &allocation);
radius = MIN (allocation.width, allocation.height) / 2.;
cairo_translate (cr, cairo_translate (cr,
radius + (widget->allocation.width - 2 * radius) / 2, radius + (allocation.width - 2 * radius) / 2,
radius + (widget->allocation.height - 2 * radius) / 2); radius + (allocation.height - 2 * radius) / 2);
cairo_scale (cr, radius / DEFAULT_TEXT_RADIUS, radius / DEFAULT_TEXT_RADIUS); cairo_scale (cr, radius / DEFAULT_TEXT_RADIUS, radius / DEFAULT_TEXT_RADIUS);
context = gtk_widget_get_pango_context (widget); context = gtk_widget_get_pango_context (widget);
@ -2484,9 +2506,12 @@ set_parent_signal (GtkWidget *child,
GtkWidget *old_parent, GtkWidget *old_parent,
gpointer func_data) gpointer func_data)
{ {
GtkWidget *parent;
parent = gtk_widget_get_parent (child);
g_message ("set_parent for \"%s\": new parent: \"%s\", old parent: \"%s\", data: %d\n", g_message ("set_parent for \"%s\": new parent: \"%s\", old parent: \"%s\", data: %d\n",
g_type_name (G_OBJECT_TYPE (child)), g_type_name (G_OBJECT_TYPE (child)),
child->parent ? g_type_name (G_OBJECT_TYPE (child->parent)) : "NULL", parent ? g_type_name (G_OBJECT_TYPE (parent)) : "NULL",
old_parent ? g_type_name (G_OBJECT_TYPE (old_parent)) : "NULL", old_parent ? g_type_name (G_OBJECT_TYPE (old_parent)) : "NULL",
GPOINTER_TO_INT (func_data)); GPOINTER_TO_INT (func_data));
} }
@ -2612,16 +2637,18 @@ grippy_button_press (GtkWidget *area, GdkEventButton *event, GdkWindowEdge edge)
static gboolean static gboolean
grippy_expose (GtkWidget *area, GdkEventExpose *event, GdkWindowEdge edge) grippy_expose (GtkWidget *area, GdkEventExpose *event, GdkWindowEdge edge)
{ {
gtk_paint_resize_grip (area->style, GtkAllocation allocation;
area->window,
gtk_widget_get_allocation (area, &allocation);
gtk_paint_resize_grip (gtk_widget_get_style (area),
gtk_widget_get_window (area),
gtk_widget_get_state (area), gtk_widget_get_state (area),
&event->area, &event->area,
area, area,
"statusbar", "statusbar",
edge, edge,
0, 0, 0, 0,
area->allocation.width, allocation.width, allocation.height);
area->allocation.height);
return TRUE; return TRUE;
} }
@ -2756,7 +2783,8 @@ uposition_configure (GtkWidget *window)
lx = g_object_get_data (G_OBJECT (window), "x"); lx = g_object_get_data (G_OBJECT (window), "x");
ly = g_object_get_data (G_OBJECT (window), "y"); ly = g_object_get_data (G_OBJECT (window), "y");
gdk_window_get_root_origin (window->window, &upositionx, &upositiony); gdk_window_get_root_origin (gtk_widget_get_window (window),
&upositionx, &upositiony);
sprintf (buffer, "%d", upositionx); sprintf (buffer, "%d", upositionx);
gtk_label_set_text (lx, buffer); gtk_label_set_text (lx, buffer);
sprintf (buffer, "%d", upositiony); sprintf (buffer, "%d", upositiony);
@ -2891,6 +2919,7 @@ create_pixbuf (GtkWidget *widget)
GtkWidget *label; GtkWidget *label;
GtkWidget *separator; GtkWidget *separator;
GtkWidget *pixbufwid; GtkWidget *pixbufwid;
GdkWindow *gdk_window;
if (!window) if (!window)
{ {
@ -2917,7 +2946,9 @@ create_pixbuf (GtkWidget *widget)
button = gtk_button_new (); button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
pixbufwid = new_pixbuf ("test.xpm", window->window, NULL); gdk_window = gtk_widget_get_window (window);
pixbufwid = new_pixbuf ("test.xpm", gdk_window, NULL);
label = gtk_label_new ("Pixbuf\ntest"); label = gtk_label_new ("Pixbuf\ntest");
box3 = gtk_hbox_new (FALSE, 0); box3 = gtk_hbox_new (FALSE, 0);
@ -2928,8 +2959,8 @@ create_pixbuf (GtkWidget *widget)
button = gtk_button_new (); button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
pixbufwid = new_pixbuf ("test.xpm", window->window, NULL); pixbufwid = new_pixbuf ("test.xpm", gdk_window, NULL);
label = gtk_label_new ("Pixbuf\ntest"); label = gtk_label_new ("Pixbuf\ntest");
box3 = gtk_hbox_new (FALSE, 0); box3 = gtk_hbox_new (FALSE, 0);
@ -3962,7 +3993,7 @@ scrolled_windows_remove (GtkWidget *widget, GtkWidget *scrollwin)
} }
else else
{ {
sw_parent = scrollwin->parent; sw_parent = gtk_widget_get_parent (scrollwin);
sw_float_parent = gtk_window_new (GTK_WINDOW_TOPLEVEL); sw_float_parent = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (sw_float_parent), gtk_window_set_screen (GTK_WINDOW (sw_float_parent),
gtk_widget_get_screen (widget)); gtk_widget_get_screen (widget));
@ -4999,6 +5030,7 @@ cursor_expose_event (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
gpointer user_data) gpointer user_data)
{ {
GtkAllocation allocation;
GtkDrawingArea *darea; GtkDrawingArea *darea;
GdkDrawable *drawable; GdkDrawable *drawable;
guint max_width; guint max_width;
@ -5009,9 +5041,11 @@ cursor_expose_event (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE); g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE);
darea = GTK_DRAWING_AREA (widget); darea = GTK_DRAWING_AREA (widget);
drawable = widget->window; drawable = gtk_widget_get_window (widget);
max_width = widget->allocation.width;
max_height = widget->allocation.height; gtk_widget_get_allocation (widget, &allocation);
max_width = allocation.width;
max_height = allocation.height;
cr = gdk_cairo_create (drawable); cr = gdk_cairo_create (drawable);
@ -5023,7 +5057,7 @@ cursor_expose_event (GtkWidget *widget,
cairo_rectangle (cr, 0, max_height / 2, max_width, max_height / 2); cairo_rectangle (cr, 0, max_height / 2, max_width, max_height / 2);
cairo_fill (cr); cairo_fill (cr);
gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_NORMAL]); gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->bg[GTK_STATE_NORMAL]);
cairo_rectangle (cr, max_width / 3, max_height / 3, max_width / 3, max_height / 3); cairo_rectangle (cr, max_width / 3, max_height / 3, max_width / 3, max_height / 3);
cairo_fill (cr); cairo_fill (cr);
@ -5060,7 +5094,8 @@ set_cursor (GtkWidget *spinner,
g_type_class_unref (class); g_type_class_unref (class);
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), c); cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), c);
gdk_window_set_cursor (widget->window, cursor); gdk_window_set_cursor (gtk_widget_get_window (widget),
cursor);
gdk_cursor_unref (cursor); gdk_cursor_unref (cursor);
} }
@ -7212,7 +7247,7 @@ shape_pressed (GtkWidget *widget, GdkEventButton *event)
p->y = (int) event->y; p->y = (int) event->y;
gtk_grab_add (widget); gtk_grab_add (widget);
gdk_pointer_grab (widget->window, TRUE, gdk_pointer_grab (gtk_widget_get_window (widget), TRUE,
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK, GDK_POINTER_MOTION_HINT_MASK,
@ -7404,7 +7439,7 @@ create_shapes (GtkWidget *widget)
x += 20; x += 20;
} }
gdk_window_shape_combine_region (with_region->window, gdk_window_shape_combine_region (gtk_widget_get_window (with_region),
region, region,
0, 0); 0, 0);
} }
@ -7426,6 +7461,7 @@ create_wmhints (GtkWidget *widget)
GtkWidget *box1; GtkWidget *box1;
GtkWidget *box2; GtkWidget *box2;
GdkBitmap *circles; GdkBitmap *circles;
GdkWindow *gdk_window;
cairo_surface_t *image; cairo_surface_t *image;
cairo_t *cr; cairo_t *cr;
@ -7444,8 +7480,9 @@ create_wmhints (GtkWidget *widget)
gtk_container_set_border_width (GTK_CONTAINER (window), 0); gtk_container_set_border_width (GTK_CONTAINER (window), 0);
gtk_widget_realize (window); gtk_widget_realize (window);
circles = gdk_pixmap_new (window->window, circles_width, circles_height, 1); gdk_window = gtk_widget_get_window (window);
circles = gdk_pixmap_new (gdk_window, circles_width, circles_height, 1);
cr = gdk_cairo_create (circles); cr = gdk_cairo_create (circles);
image = cairo_image_surface_create_for_data (circles_bits, CAIRO_FORMAT_A1, image = cairo_image_surface_create_for_data (circles_bits, CAIRO_FORMAT_A1,
circles_width, circles_height, circles_width, circles_height,
@ -7456,14 +7493,14 @@ create_wmhints (GtkWidget *widget)
cairo_paint (cr); cairo_paint (cr);
cairo_destroy (cr); cairo_destroy (cr);
gdk_window_set_icon (window->window, NULL, gdk_window_set_icon (gdk_window, NULL,
circles, circles); circles, circles);
gdk_window_set_icon_name (window->window, "WMHints Test Icon"); gdk_window_set_icon_name (gdk_window, "WMHints Test Icon");
gdk_window_set_decorations (window->window, GDK_DECOR_ALL | GDK_DECOR_MENU); gdk_window_set_decorations (gdk_window, GDK_DECOR_ALL | GDK_DECOR_MENU);
gdk_window_set_functions (window->window, GDK_FUNC_ALL | GDK_FUNC_RESIZE); gdk_window_set_functions (gdk_window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
box1 = gtk_vbox_new (FALSE, 0); box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1); gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show (box1); gtk_widget_show (box1);
@ -8749,7 +8786,7 @@ find_widget (GtkWidget *widget, FindWidgetData *data)
gint x_offset = 0; gint x_offset = 0;
gint y_offset = 0; gint y_offset = 0;
new_allocation = widget->allocation; gtk_widget_get_allocation (widget, &new_allocation);
if (data->found || !gtk_widget_get_mapped (widget)) if (data->found || !gtk_widget_get_mapped (widget))
return; return;
@ -8765,11 +8802,11 @@ find_widget (GtkWidget *widget, FindWidgetData *data)
new_allocation.x = 0; new_allocation.x = 0;
new_allocation.y = 0; new_allocation.y = 0;
} }
if (widget->parent && !data->first) if (gtk_widget_get_parent (widget) && !data->first)
{ {
GdkWindow *window = widget->window; GdkWindow *window = gtk_widget_get_window (widget);
while (window != widget->parent->window) while (window != gtk_widget_get_window (gtk_widget_get_parent (widget)))
{ {
gint tx, ty, twidth, theight; gint tx, ty, twidth, theight;
gdk_drawable_get_size (window, &twidth, &theight); gdk_drawable_get_size (window, &twidth, &theight);
@ -8794,7 +8831,7 @@ find_widget (GtkWidget *widget, FindWidgetData *data)
x_offset += tx; x_offset += tx;
new_allocation.y += ty; new_allocation.y += ty;
y_offset += ty; y_offset += ty;
window = gdk_window_get_parent (window); window = gdk_window_get_parent (window);
} }
} }
@ -8856,7 +8893,7 @@ find_widget_at_pointer (GdkDisplay *display)
if (widget) if (widget)
{ {
gdk_window_get_pointer (widget->window, gdk_window_get_pointer (gtk_widget_get_window (widget),
&x, &y, NULL); &x, &y, NULL);
data.x = x; data.x = x;
@ -8938,6 +8975,7 @@ static void
query_properties (GtkButton *button, query_properties (GtkButton *button,
struct PropertiesData *data) struct PropertiesData *data)
{ {
GtkWidget *widget = GTK_WIDGET (button);
gint failure; gint failure;
g_signal_connect (button, "event", g_signal_connect (button, "event",
@ -8945,17 +8983,17 @@ query_properties (GtkButton *button,
if (!data->cursor) if (!data->cursor)
data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (button)), data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
GDK_TARGET); GDK_TARGET);
failure = gdk_pointer_grab (GTK_WIDGET (button)->window, failure = gdk_pointer_grab (gtk_widget_get_window (widget),
TRUE, TRUE,
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
NULL, NULL,
data->cursor, data->cursor,
GDK_CURRENT_TIME); GDK_CURRENT_TIME);
gtk_grab_add (GTK_WIDGET (button)); gtk_grab_add (widget);
data->in_query = TRUE; data->in_query = TRUE;
} }
@ -9067,7 +9105,7 @@ snapshot_widget_event (GtkWidget *widget,
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
pixmap = gtk_widget_get_snapshot (res_widget, NULL); pixmap = gtk_widget_get_snapshot (res_widget, NULL);
gtk_widget_realize (window); gtk_widget_realize (window);
if (gdk_drawable_get_depth (window->window) != gdk_drawable_get_depth (pixmap)) if (gdk_drawable_get_depth (gtk_widget_get_window (window)) != gdk_drawable_get_depth (pixmap))
{ {
/* this branch is needed to convert ARGB -> RGB */ /* this branch is needed to convert ARGB -> RGB */
int width, height; int width, height;
@ -9098,25 +9136,26 @@ static void
snapshot_widget (GtkButton *button, snapshot_widget (GtkButton *button,
struct SnapshotData *data) struct SnapshotData *data)
{ {
GtkWidget *widget = GTK_WIDGET (button);
gint failure; gint failure;
g_signal_connect (button, "event", g_signal_connect (button, "event",
G_CALLBACK (snapshot_widget_event), data); G_CALLBACK (snapshot_widget_event), data);
data->is_toplevel = GTK_WIDGET (button) == data->toplevel_button; data->is_toplevel = widget == data->toplevel_button;
if (!data->cursor) if (!data->cursor)
data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (button)), data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
GDK_TARGET); GDK_TARGET);
failure = gdk_pointer_grab (GTK_WIDGET (button)->window, failure = gdk_pointer_grab (gtk_widget_get_window (widget),
TRUE, TRUE,
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
NULL, NULL,
data->cursor, data->cursor,
GDK_CURRENT_TIME); GDK_CURRENT_TIME);
gtk_grab_add (GTK_WIDGET (button)); gtk_grab_add (widget);
data->in_query = TRUE; data->in_query = TRUE;
} }
@ -9328,6 +9367,7 @@ static gint
scroll_test_expose (GtkWidget *widget, GdkEventExpose *event, scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
GtkAdjustment *adj) GtkAdjustment *adj)
{ {
GdkWindow *window;
gint i,j; gint i,j;
gint imin, imax, jmin, jmax; gint imin, imax, jmin, jmax;
cairo_t *cr; cairo_t *cr;
@ -9338,11 +9378,13 @@ scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
jmin = ((int)adj->value + event->area.y) / 10; jmin = ((int)adj->value + event->area.y) / 10;
jmax = ((int)adj->value + event->area.y + event->area.height + 9) / 10; jmax = ((int)adj->value + event->area.y + event->area.height + 9) / 10;
gdk_window_clear_area (widget->window, window = gtk_widget_get_window (widget);
gdk_window_clear_area (window,
event->area.x, event->area.y, event->area.x, event->area.y,
event->area.width, event->area.height); event->area.width, event->area.height);
cr = gdk_cairo_create (widget->window); cr = gdk_cairo_create (window);
for (i=imin; i<imax; i++) for (i=imin; i<imax; i++)
for (j=jmin; j<jmax; j++) for (j=jmin; j<jmax; j++)
@ -9373,8 +9415,11 @@ static void
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event, scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
GtkAdjustment *adj) GtkAdjustment *adj)
{ {
adj->page_increment = 0.9 * widget->allocation.height; GtkAllocation allocation;
adj->page_size = widget->allocation.height;
gtk_widget_get_allocation (widget, &allocation);
adj->page_increment = 0.9 * allocation.height;
adj->page_size = allocation.height;
g_signal_emit_by_name (adj, "changed"); g_signal_emit_by_name (adj, "changed");
} }
@ -9382,7 +9427,7 @@ scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
static void static void
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget) scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{ {
/* gint source_min = (int)adj->value - scroll_test_pos; */ GdkWindow *window;
gint dy; gint dy;
dy = scroll_test_pos - (int)adj->value; dy = scroll_test_pos - (int)adj->value;
@ -9390,8 +9435,10 @@ scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
if (!gtk_widget_is_drawable (widget)) if (!gtk_widget_is_drawable (widget))
return; return;
gdk_window_scroll (widget->window, 0, dy);
gdk_window_process_updates (widget->window, FALSE); window = gtk_widget_get_window (widget);
gdk_window_scroll (window, 0, dy);
gdk_window_process_updates (window, FALSE);
} }