summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-08-30 14:56:28 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-08-30 14:56:28 +0900
commit54d44a9bd04cfbed8426614fc69c027a46f41a14 (patch)
tree34bdf65a6e8d5d6d4016154345d1d803ba0da379 /tests
parentb3b22c31b997fb85b3319b392a1a69407703184c (diff)
parent67194ed77b153eb5a7eb6c596f3c20e274b7787a (diff)
downloadgtk+-native-layout.tar.gz
Merge branch 'master' into native-layoutnative-layout
Conflicts: gtk/gtkplug.c gtk/gtkscrolledwindow.c
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/gtkoffscreenbox.c94
-rw-r--r--tests/print-editor.c14
-rw-r--r--tests/testcairo.c6
-rw-r--r--tests/testellipsise.c19
-rw-r--r--tests/testframe.c11
-rw-r--r--tests/testgtk.c215
-rw-r--r--tests/testheightforwidth.c4
-rw-r--r--tests/testiconview-keynav.c8
-rw-r--r--tests/testinput.c25
-rw-r--r--tests/testoffscreen.c4
-rw-r--r--tests/testoffscreenwindow.c2
-rw-r--r--tests/testselection.c2
-rw-r--r--tests/testsocket.c6
-rw-r--r--tests/testsocket_common.c6
-rw-r--r--tests/testtooltips.c13
-rw-r--r--tests/testwindows.c13
-rw-r--r--tests/testwrapbox.c547
-rw-r--r--tests/testxinerama.c2
19 files changed, 822 insertions, 177 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a729c24891..b7bc39508c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -89,7 +89,8 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testgrouping \
testtooltips \
testexpander \
- testvolumebutton
+ testvolumebutton \
+ testwrapbox
if USE_X11
noinst_PROGRAMS += testapplication
@@ -170,6 +171,7 @@ testactions_DEPENDENCIES = $(TEST_DEPS)
testgrouping_DEPENDENCIES = $(TEST_DEPS)
testtooltips_DEPENDENCIES = $(TEST_DEPS)
testvolumebutton_DEPENDENCIES = $(TEST_DEPS)
+testwrapbox_DEPENDENCIES = $(TEST_DEPS)
testwindows_DEPENDENCIES = $(TEST_DEPS)
testexpander_DEPENDENCIES = $(TEST_DEPS)
@@ -238,6 +240,7 @@ testactions_LDADD = $(LDADDS)
testgrouping_LDADD = $(LDADDS)
testtooltips_LDADD = $(LDADDS)
testvolumebutton_LDADD = $(LDADDS)
+testwrapbox_LDADD = $(LDADDS)
testwindows_LDADD = $(LDADDS)
testexpander_LDADD = $(LDADDS)
@@ -337,6 +340,9 @@ testrecentchoosermenu_SOURCES = \
testvolumebutton_SOURCES = \
testvolumebutton.c
+testwrapbox_SOURCES = \
+ testwrapbox.c
+
testoffscreen_SOURCES = \
gtkoffscreenbox.c \
gtkoffscreenbox.h \
diff --git a/tests/gtkoffscreenbox.c b/tests/gtkoffscreenbox.c
index 71b36db43c..6a4646966c 100644
--- a/tests/gtkoffscreenbox.c
+++ b/tests/gtkoffscreenbox.c
@@ -47,10 +47,11 @@ to_child_2 (GtkOffscreenBox *offscreen_box,
x = widget_x;
y = widget_y;
+ gtk_widget_get_allocation (offscreen_box->child1, &child_area);
if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- y -= offscreen_box->child1->allocation.height;
+ y -= child_area.height;
- child_area = offscreen_box->child2->allocation;
+ gtk_widget_get_allocation (offscreen_box->child2, &child_area);
x -= child_area.width / 2;
y -= child_area.height / 2;
@@ -79,7 +80,7 @@ to_parent_2 (GtkOffscreenBox *offscreen_box,
double x, y, xr, yr;
double cos_angle, sin_angle;
- child_area = offscreen_box->child2->allocation;
+ gtk_widget_get_allocation (offscreen_box->child2, &child_area);
x = offscreen_x;
y = offscreen_y;
@@ -98,8 +99,9 @@ to_parent_2 (GtkOffscreenBox *offscreen_box,
x += child_area.width / 2;
y += child_area.height / 2;
+ gtk_widget_get_allocation (offscreen_box->child1, &child_area);
if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
- y += offscreen_box->child1->allocation.height;
+ y += child_area.height;
*x_out = x;
*y_out = y;
@@ -156,7 +158,7 @@ pick_offscreen_child (GdkWindow *offscreen_window,
widget_x, widget_y,
&x, &y);
- child_area = offscreen_box->child2->allocation;
+ gtk_widget_get_allocation (offscreen_box->child2, &child_area);
if (x >= 0 && x < child_area.width &&
y >= 0 && y < child_area.height)
@@ -168,7 +170,7 @@ pick_offscreen_child (GdkWindow *offscreen_window,
x = widget_x;
y = widget_y;
- child_area = offscreen_box->child1->allocation;
+ gtk_widget_get_allocation (offscreen_box->child1, &child_area);
if (x >= 0 && x < child_area.width &&
y >= 0 && y < child_area.height)
@@ -232,6 +234,9 @@ static void
gtk_offscreen_box_realize (GtkWidget *widget)
{
GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
+ GtkAllocation allocation, child_area;
+ GtkStyle *style;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
guint border_width;
@@ -242,10 +247,12 @@ gtk_offscreen_box_realize (GtkWidget *widget)
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = widget->allocation.height - 2 * border_width;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - 2 * border_width;
+ attributes.height = allocation.height - 2 * border_width;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_EXPOSURE_MASK
@@ -262,11 +269,12 @@ gtk_offscreen_box_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
- g_signal_connect (widget->window, "pick-embedded-child",
+ g_signal_connect (window, "pick-embedded-child",
G_CALLBACK (pick_offscreen_child), offscreen_box);
attributes.window_type = GDK_WINDOW_OFFSCREEN;
@@ -275,9 +283,11 @@ gtk_offscreen_box_realize (GtkWidget *widget)
attributes.x = attributes.y = 0;
if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
{
- attributes.width = offscreen_box->child1->allocation.width;
- attributes.height = offscreen_box->child1->allocation.height;
- start_y += offscreen_box->child1->allocation.height;
+ gtk_widget_get_allocation (offscreen_box->child1, &child_area);
+
+ attributes.width = child_area.width;
+ attributes.height = child_area.height;
+ start_y += child_area.height;
}
offscreen_box->offscreen_window1 = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
@@ -286,8 +296,8 @@ gtk_offscreen_box_realize (GtkWidget *widget)
gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1);
gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1,
- widget->window);
-
+ window);
+
g_signal_connect (offscreen_box->offscreen_window1, "to-embedder",
G_CALLBACK (offscreen_window_to_parent1), offscreen_box);
g_signal_connect (offscreen_box->offscreen_window1, "from-embedder",
@@ -298,8 +308,10 @@ gtk_offscreen_box_realize (GtkWidget *widget)
child_requisition.width = child_requisition.height = 0;
if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
{
- attributes.width = offscreen_box->child2->allocation.width;
- attributes.height = offscreen_box->child2->allocation.height;
+ gtk_widget_get_allocation (offscreen_box->child2, &child_area);
+
+ attributes.width = child_area.width;
+ attributes.height = child_area.height;
}
offscreen_box->offscreen_window2 = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
@@ -307,17 +319,17 @@ gtk_offscreen_box_realize (GtkWidget *widget)
if (offscreen_box->child2)
gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2);
gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2,
- widget->window);
+ window);
g_signal_connect (offscreen_box->offscreen_window2, "to-embedder",
G_CALLBACK (offscreen_window_to_parent2), offscreen_box);
g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",
G_CALLBACK (offscreen_window_from_parent2), offscreen_box);
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, offscreen_box->offscreen_window1, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, offscreen_box->offscreen_window2, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, offscreen_box->offscreen_window1, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, offscreen_box->offscreen_window2, GTK_STATE_NORMAL);
gdk_window_show (offscreen_box->offscreen_window1);
gdk_window_show (offscreen_box->offscreen_window2);
@@ -496,13 +508,14 @@ gtk_offscreen_box_size_allocate (GtkWidget *widget,
gint start_y;
guint border_width;
- widget->allocation = *allocation;
offscreen_box = GTK_OFFSCREEN_BOX (widget);
+ gtk_widget_set_allocation (widget, allocation);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x + border_width,
allocation->y + border_width,
allocation->width - border_width * 2,
@@ -518,7 +531,7 @@ gtk_offscreen_box_size_allocate (GtkWidget *widget,
gtk_widget_get_child_requisition (offscreen_box->child1, &child_requisition);
child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE - 1.0) / 2;
child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE - 1.0) / 2;
- child_allocation.width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
+ child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
child_allocation.height = child_requisition.height;
start_y += CHILD1_SIZE_SCALE * child_requisition.height;
@@ -542,7 +555,7 @@ gtk_offscreen_box_size_allocate (GtkWidget *widget,
gtk_widget_get_child_requisition (offscreen_box->child2, &child_requisition);
child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE - 1.0) / 2;
child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE - 1.0) / 2;
- child_allocation.width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
+ child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
child_allocation.height = child_requisition.height;
start_y += CHILD2_SIZE_SCALE * child_requisition.height;
@@ -563,7 +576,8 @@ static gboolean
gtk_offscreen_box_damage (GtkWidget *widget,
GdkEventExpose *event)
{
- gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget),
+ NULL, FALSE);
return TRUE;
}
@@ -573,10 +587,12 @@ gtk_offscreen_box_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
+ GdkWindow *window;
if (gtk_widget_is_drawable (widget))
{
- if (event->window == widget->window)
+ window = gtk_widget_get_window (widget);
+ if (event->window == window)
{
GdkPixmap *pixmap;
GtkAllocation child_area;
@@ -586,9 +602,9 @@ gtk_offscreen_box_expose (GtkWidget *widget,
if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
{
pixmap = gdk_offscreen_window_get_pixmap (offscreen_box->offscreen_window1);
- child_area = offscreen_box->child1->allocation;
+ gtk_widget_get_allocation (offscreen_box->child1, &child_area);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
cairo_paint (cr);
@@ -603,9 +619,9 @@ gtk_offscreen_box_expose (GtkWidget *widget,
gint w, h;
pixmap = gdk_offscreen_window_get_pixmap (offscreen_box->offscreen_window2);
- child_area = offscreen_box->child2->allocation;
+ gtk_widget_get_allocation (offscreen_box->child2, &child_area);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
/* transform */
cairo_translate (cr, 0, start_y);
@@ -627,7 +643,7 @@ gtk_offscreen_box_expose (GtkWidget *widget,
}
else if (event->window == offscreen_box->offscreen_window1)
{
- gtk_paint_flat_box (widget->style, event->window,
+ gtk_paint_flat_box (gtk_widget_get_style (widget), event->window,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
&event->area, widget, "blah",
0, 0, -1, -1);
@@ -639,7 +655,7 @@ gtk_offscreen_box_expose (GtkWidget *widget,
}
else if (event->window == offscreen_box->offscreen_window2)
{
- gtk_paint_flat_box (widget->style, event->window,
+ gtk_paint_flat_box (gtk_widget_get_style (widget), event->window,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
&event->area, widget, "blah",
0, 0, -1, -1);
diff --git a/tests/print-editor.c b/tests/print-editor.c
index b476e013cd..b8d4bf41b3 100644
--- a/tests/print-editor.c
+++ b/tests/print-editor.c
@@ -447,7 +447,7 @@ preview_expose (GtkWidget *widget,
{
PreviewOp *pop = data;
- gdk_window_clear (pop->area->window);
+ gdk_window_clear (gtk_widget_get_window (pop->area));
gtk_print_operation_preview_render_page (pop->preview,
pop->page - 1);
@@ -481,6 +481,7 @@ preview_got_page_size (GtkPrintOperationPreview *preview,
gpointer data)
{
PreviewOp *pop = data;
+ GtkAllocation allocation;
GtkPaperSize *paper_size;
double w, h;
cairo_t *cr;
@@ -491,10 +492,11 @@ preview_got_page_size (GtkPrintOperationPreview *preview,
w = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH);
h = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH);
- cr = gdk_cairo_create (pop->area->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (pop->area));
- dpi_x = pop->area->allocation.width/w;
- dpi_y = pop->area->allocation.height/h;
+ gtk_widget_get_allocation (pop->area, &allocation);
+ dpi_x = allocation.width/w;
+ dpi_y = allocation.height/h;
if (fabs (dpi_x - pop->dpi_x) > 0.001 ||
fabs (dpi_y - pop->dpi_y) > 0.001)
@@ -570,8 +572,8 @@ preview_cb (GtkPrintOperation *op,
gtk_widget_set_double_buffered (da, FALSE);
gtk_widget_realize (da);
-
- cr = gdk_cairo_create (da->window);
+
+ cr = gdk_cairo_create (gtk_widget_get_window (da));
/* TODO: What dpi to use here? This will be used for pagination.. */
gtk_print_context_set_cairo_context (context, cr, 72, 72);
diff --git a/tests/testcairo.c b/tests/testcairo.c
index b2a232b026..dc3a27cfc2 100644
--- a/tests/testcairo.c
+++ b/tests/testcairo.c
@@ -195,11 +195,13 @@ on_expose_event (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
+ GtkAllocation allocation;
cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
- draw (cr, widget->allocation.width, widget->allocation.height);
+ gtk_widget_get_allocation (widget, &allocation);
+ draw (cr, allocation.width, allocation.height);
cairo_destroy (cr);
diff --git a/tests/testellipsise.c b/tests/testellipsise.c
index 805998c1c0..1020456479 100644
--- a/tests/testellipsise.c
+++ b/tests/testellipsise.c
@@ -70,17 +70,20 @@ ebox_expose_event_cb (GtkWidget *widget,
{
PangoLayout *layout;
const double dashes[] = { 6, 18 };
+ GtkAllocation allocation, label_allocation;
GtkRequisition minimum_size, natural_size;
GtkWidget *label = data;
cairo_t *cr;
gint x, y;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_translate (cr, -0.5, -0.5);
cairo_set_line_width (cr, 1);
+ gtk_widget_get_allocation (widget, &allocation);
+
cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
cairo_fill (cr);
gtk_widget_translate_coordinates (label, widget, 0, 0, &x, &y);
@@ -97,22 +100,24 @@ ebox_expose_event_cb (GtkWidget *widget,
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
+ gtk_widget_get_allocation (label, &label_allocation);
+
cairo_rectangle (cr,
- x + 0.5 * (label->allocation.width - minimum_size.width),
- y + 0.5 * (label->allocation.height - minimum_size.height),
+ x + 0.5 * (label_allocation.width - minimum_size.width),
+ y + 0.5 * (label_allocation.height - minimum_size.height),
minimum_size.width, minimum_size.height);
cairo_set_source_rgb (cr, 0.8, 0.2, 0.2);
cairo_set_dash (cr, NULL, 0, 0);
cairo_stroke (cr);
- cairo_rectangle (cr, x, y, label->allocation.width, label->allocation.height);
+ cairo_rectangle (cr, x, y, label_allocation.width, label_allocation.height);
cairo_set_source_rgb (cr, 0.2, 0.2, 0.8);
cairo_set_dash (cr, dashes, 2, 0.5);
cairo_stroke (cr);
cairo_rectangle (cr,
- x + 0.5 * (label->allocation.width - natural_size.width),
- y + 0.5 * (label->allocation.height - natural_size.height),
+ x + 0.5 * (label_allocation.width - natural_size.width),
+ y + 0.5 * (label_allocation.height - natural_size.height),
natural_size.width, natural_size.height);
cairo_set_source_rgb (cr, 0.2, 0.8, 0.2);
cairo_set_dash (cr, dashes, 2, 12.5);
diff --git a/tests/testframe.c b/tests/testframe.c
index df1aa2150e..401457ef2d 100644
--- a/tests/testframe.c
+++ b/tests/testframe.c
@@ -27,7 +27,7 @@ spin_ythickness_cb (GtkSpinButton *spin, gpointer user_data)
GtkRcStyle *rcstyle;
rcstyle = gtk_rc_style_new ();
- rcstyle->xthickness = GTK_WIDGET (frame)->style->xthickness;
+ rcstyle->xthickness = gtk_widget_get_style (frame)->xthickness;
rcstyle->ythickness = gtk_spin_button_get_value (spin);
gtk_widget_modify_style (frame, rcstyle);
@@ -42,7 +42,7 @@ spin_xthickness_cb (GtkSpinButton *spin, gpointer user_data)
rcstyle = gtk_rc_style_new ();
rcstyle->xthickness = gtk_spin_button_get_value (spin);
- rcstyle->ythickness = GTK_WIDGET (frame)->style->ythickness;
+ rcstyle->ythickness = gtk_widget_get_style (frame)->ythickness;
gtk_widget_modify_style (frame, rcstyle);
g_object_unref (rcstyle);
@@ -88,6 +88,7 @@ spin_yalign_cb (GtkSpinButton *spin, GtkFrame *frame)
int main (int argc, char **argv)
{
+ GtkStyle *style;
GtkWidget *window, *frame, *xthickness_spin, *ythickness_spin, *vbox;
GtkWidget *xalign_spin, *yalign_spin, *button, *table, *label;
gfloat xalign, yalign;
@@ -112,13 +113,15 @@ int main (int argc, char **argv)
table = gtk_table_new (4, 2, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+ style = gtk_widget_get_style (frame);
+
/* Spin to control xthickness */
label = gtk_label_new ("xthickness: ");
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
xthickness_spin = gtk_spin_button_new_with_range (0, 250, 1);
g_signal_connect (G_OBJECT (xthickness_spin), "value-changed", G_CALLBACK (spin_xthickness_cb), frame);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (xthickness_spin), frame->style->xthickness);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (xthickness_spin), style->xthickness);
gtk_table_attach_defaults (GTK_TABLE (table), xthickness_spin, 1, 2, 0, 1);
/* Spin to control ythickness */
@@ -127,7 +130,7 @@ int main (int argc, char **argv)
ythickness_spin = gtk_spin_button_new_with_range (0, 250, 1);
g_signal_connect (G_OBJECT (ythickness_spin), "value-changed", G_CALLBACK (spin_ythickness_cb), frame);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (ythickness_spin), frame->style->ythickness);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ythickness_spin), style->ythickness);
gtk_table_attach_defaults (GTK_TABLE (table), ythickness_spin, 1, 2, 1, 2);
gtk_frame_get_label_align (GTK_FRAME (frame), &xalign, &yalign);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 0260a55acb..3a7ad842fa 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -131,18 +131,21 @@ static gboolean
on_alpha_window_expose (GtkWidget *widget,
GdkEventExpose *expose)
{
+ GtkAllocation allocation;
cairo_t *cr;
cairo_pattern_t *pattern;
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;
- pattern = cairo_pattern_create_radial (widget->allocation.width / 2,
- widget->allocation.height / 2,
+ gtk_widget_get_allocation (widget, &allocation);
+
+ radius = MIN (allocation.width, allocation.height) / 2;
+ pattern = cairo_pattern_create_radial (allocation.width / 2,
+ allocation.height / 2,
0.0,
- widget->allocation.width / 2,
- widget->allocation.height / 2,
+ allocation.width / 2,
+ allocation.height / 2,
radius * 1.33);
if (gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget)) &&
@@ -357,7 +360,7 @@ transparent_expose (GtkWidget *widget,
{
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);
gdk_cairo_region (cr, event->region);
cairo_fill (cr);
@@ -381,6 +384,7 @@ static gboolean
window_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
cairo_region_t *region;
GtkWidget *child;
cairo_t *cr;
@@ -389,15 +393,17 @@ window_expose_event (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (widget));
/* 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 */
- gdk_cairo_set_source_pixmap (cr, child->window,
- child->allocation.x,
- child->allocation.y);
+ gdk_cairo_set_source_pixmap (cr, gtk_widget_get_window (child),
+ allocation.x,
+ allocation.y);
/* 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);
gdk_cairo_region (cr, region);
cairo_clip (cr);
@@ -463,7 +469,8 @@ create_composited_window (GtkWidget *widget)
/* set the event box GdkWindow to be composited.
* 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.
* 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))
{
- 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;
}
}
@@ -600,7 +608,8 @@ pattern_vadj_changed (GtkAdjustment *adj,
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;
}
}
@@ -609,8 +618,11 @@ static void
pattern_realize (GtkWidget *widget,
gpointer data)
{
- pattern_set_bg (widget, widget->window, 0);
- create_pattern (widget, widget->window, 1, PATTERN_SIZE, PATTERN_SIZE);
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
+ pattern_set_bg (widget, window, 0);
+ create_pattern (widget, window, 1, PATTERN_SIZE, PATTERN_SIZE);
}
static void
@@ -1430,8 +1442,8 @@ create_toolbar (GtkWidget *widget)
{
GtkWidget *icon;
- icon = new_pixbuf ("test.xpm", window->window,
- &window->style->bg[GTK_STATE_NORMAL]);
+ icon = new_pixbuf ("test.xpm", gtk_widget_get_window (window),
+ &gtk_widget_get_style (window)->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, create_toolbar_items[i].label);
}
if (create_toolbar_items[i].callback)
@@ -1501,8 +1513,8 @@ make_toolbar (GtkWidget *window)
toolitem = gtk_separator_tool_item_new ();
continue;
}
- icon = new_pixbuf ("test.xpm", window->window,
- &window->style->bg[GTK_STATE_NORMAL]);
+ icon = new_pixbuf ("test.xpm", gtk_widget_get_window (window),
+ &gtk_widget_get_style (window)->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, make_toolbar_items[i].label);
gtk_tool_item_set_tooltip_text (toolitem, make_toolbar_items[i].tooltip);
if (make_toolbar_items[i].callback != NULL)
@@ -1705,23 +1717,30 @@ static gboolean
gridded_geometry_expose (GtkWidget *widget,
GdkEventExpose *event)
{
- int i, j;
+ GtkAllocation allocation;
+ GtkStateType state;
+ GtkStyle *style;
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);
- gdk_cairo_set_source_color (cr, &widget->style->base[widget->state]);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ gdk_cairo_set_source_color (cr, &style->base[state]);
cairo_fill (cr);
-
- for (i = 0 ; i * GRID_SIZE < widget->allocation.width; i++)
- for (j = 0 ; j * GRID_SIZE < widget->allocation.height; j++)
+
+ for (i = 0 ; i * GRID_SIZE < allocation.width; i++)
+ for (j = 0 ; j * GRID_SIZE < allocation.height; j++)
{
if ((i + j) % 2 == 0)
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_destroy (cr);
@@ -2351,6 +2370,7 @@ on_rotated_text_expose (GtkWidget *widget,
GdkEventExpose *event,
GdkPixbuf *tile_pixbuf)
{
+ GtkAllocation allocation;
static const gchar *words[] = { "The", "grand", "old", "Duke", "of", "York",
"had", "10,000", "men" };
int n_words;
@@ -2371,11 +2391,13 @@ on_rotated_text_expose (GtkWidget *widget,
else
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,
- radius + (widget->allocation.width - 2 * radius) / 2,
- radius + (widget->allocation.height - 2 * radius) / 2);
+ radius + (allocation.width - 2 * radius) / 2,
+ radius + (allocation.height - 2 * radius) / 2);
cairo_scale (cr, radius / DEFAULT_TEXT_RADIUS, radius / DEFAULT_TEXT_RADIUS);
context = gtk_widget_get_pango_context (widget);
@@ -2484,9 +2506,12 @@ set_parent_signal (GtkWidget *child,
GtkWidget *old_parent,
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_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",
GPOINTER_TO_INT (func_data));
}
@@ -2612,16 +2637,18 @@ grippy_button_press (GtkWidget *area, GdkEventButton *event, GdkWindowEdge edge)
static gboolean
grippy_expose (GtkWidget *area, GdkEventExpose *event, GdkWindowEdge edge)
{
- gtk_paint_resize_grip (area->style,
- area->window,
+ GtkAllocation allocation;
+
+ 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),
&event->area,
area,
"statusbar",
edge,
0, 0,
- area->allocation.width,
- area->allocation.height);
+ allocation.width, allocation.height);
return TRUE;
}
@@ -2756,7 +2783,8 @@ uposition_configure (GtkWidget *window)
lx = g_object_get_data (G_OBJECT (window), "x");
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);
gtk_label_set_text (lx, buffer);
sprintf (buffer, "%d", upositiony);
@@ -2891,6 +2919,7 @@ create_pixbuf (GtkWidget *widget)
GtkWidget *label;
GtkWidget *separator;
GtkWidget *pixbufwid;
+ GdkWindow *gdk_window;
if (!window)
{
@@ -2917,7 +2946,9 @@ create_pixbuf (GtkWidget *widget)
button = gtk_button_new ();
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");
box3 = gtk_hbox_new (FALSE, 0);
@@ -2928,8 +2959,8 @@ create_pixbuf (GtkWidget *widget)
button = gtk_button_new ();
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");
box3 = gtk_hbox_new (FALSE, 0);
@@ -3962,7 +3993,7 @@ scrolled_windows_remove (GtkWidget *widget, GtkWidget *scrollwin)
}
else
{
- sw_parent = scrollwin->parent;
+ sw_parent = gtk_widget_get_parent (scrollwin);
sw_float_parent = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (sw_float_parent),
gtk_widget_get_screen (widget));
@@ -4999,6 +5030,7 @@ cursor_expose_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkDrawingArea *darea;
GdkDrawable *drawable;
guint max_width;
@@ -5009,9 +5041,11 @@ cursor_expose_event (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE);
darea = GTK_DRAWING_AREA (widget);
- drawable = widget->window;
- max_width = widget->allocation.width;
- max_height = widget->allocation.height;
+ drawable = gtk_widget_get_window (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ max_width = allocation.width;
+ max_height = allocation.height;
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_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_fill (cr);
@@ -5060,7 +5094,8 @@ set_cursor (GtkWidget *spinner,
g_type_class_unref (class);
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);
}
@@ -7212,7 +7247,7 @@ shape_pressed (GtkWidget *widget, GdkEventButton *event)
p->y = (int) event->y;
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_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK,
@@ -7404,7 +7439,7 @@ create_shapes (GtkWidget *widget)
x += 20;
}
- gdk_window_shape_combine_region (with_region->window,
+ gdk_window_shape_combine_region (gtk_widget_get_window (with_region),
region,
0, 0);
}
@@ -7426,6 +7461,7 @@ create_wmhints (GtkWidget *widget)
GtkWidget *box1;
GtkWidget *box2;
GdkBitmap *circles;
+ GdkWindow *gdk_window;
cairo_surface_t *image;
cairo_t *cr;
@@ -7444,8 +7480,9 @@ create_wmhints (GtkWidget *widget)
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
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);
image = cairo_image_surface_create_for_data (circles_bits, CAIRO_FORMAT_A1,
circles_width, circles_height,
@@ -7456,14 +7493,14 @@ create_wmhints (GtkWidget *widget)
cairo_paint (cr);
cairo_destroy (cr);
- gdk_window_set_icon (window->window, NULL,
+ gdk_window_set_icon (gdk_window, NULL,
circles, circles);
-
- gdk_window_set_icon_name (window->window, "WMHints Test Icon");
-
- gdk_window_set_decorations (window->window, GDK_DECOR_ALL | GDK_DECOR_MENU);
- gdk_window_set_functions (window->window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
-
+
+ gdk_window_set_icon_name (gdk_window, "WMHints Test Icon");
+
+ gdk_window_set_decorations (gdk_window, GDK_DECOR_ALL | GDK_DECOR_MENU);
+ gdk_window_set_functions (gdk_window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
+
box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show (box1);
@@ -7516,7 +7553,7 @@ window_state_callback (GtkWidget *widget,
GtkWidget *label = data;
gchar *msg;
- msg = g_strconcat (GTK_WINDOW (widget)->title, ": ",
+ msg = g_strconcat (gtk_window_get_title (GTK_WINDOW (widget)), ": ",
(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) ?
"withdrawn" : "not withdrawn", ", ",
(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) ?
@@ -8749,7 +8786,7 @@ find_widget (GtkWidget *widget, FindWidgetData *data)
gint x_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))
return;
@@ -8765,11 +8802,11 @@ find_widget (GtkWidget *widget, FindWidgetData *data)
new_allocation.x = 0;
new_allocation.y = 0;
}
-
- if (widget->parent && !data->first)
+
+ if (gtk_widget_get_parent (widget) && !data->first)
{
- GdkWindow *window = widget->window;
- while (window != widget->parent->window)
+ GdkWindow *window = gtk_widget_get_window (widget);
+ while (window != gtk_widget_get_window (gtk_widget_get_parent (widget)))
{
gint tx, ty, twidth, theight;
gdk_drawable_get_size (window, &twidth, &theight);
@@ -8794,7 +8831,7 @@ find_widget (GtkWidget *widget, FindWidgetData *data)
x_offset += tx;
new_allocation.y += ty;
y_offset += ty;
-
+
window = gdk_window_get_parent (window);
}
}
@@ -8856,7 +8893,7 @@ find_widget_at_pointer (GdkDisplay *display)
if (widget)
{
- gdk_window_get_pointer (widget->window,
+ gdk_window_get_pointer (gtk_widget_get_window (widget),
&x, &y, NULL);
data.x = x;
@@ -8938,6 +8975,7 @@ static void
query_properties (GtkButton *button,
struct PropertiesData *data)
{
+ GtkWidget *widget = GTK_WIDGET (button);
gint failure;
g_signal_connect (button, "event",
@@ -8945,17 +8983,17 @@ query_properties (GtkButton *button,
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);
-
- failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
+
+ failure = gdk_pointer_grab (gtk_widget_get_window (widget),
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
- gtk_grab_add (GTK_WIDGET (button));
+ gtk_grab_add (widget);
data->in_query = TRUE;
}
@@ -9067,7 +9105,7 @@ snapshot_widget_event (GtkWidget *widget,
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
pixmap = gtk_widget_get_snapshot (res_widget, NULL);
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 */
int width, height;
@@ -9098,25 +9136,26 @@ static void
snapshot_widget (GtkButton *button,
struct SnapshotData *data)
{
+ GtkWidget *widget = GTK_WIDGET (button);
gint failure;
g_signal_connect (button, "event",
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)
- 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);
-
- failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
+
+ failure = gdk_pointer_grab (gtk_widget_get_window (widget),
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
- gtk_grab_add (GTK_WIDGET (button));
+ gtk_grab_add (widget);
data->in_query = TRUE;
}
@@ -9328,6 +9367,7 @@ static gint
scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
GtkAdjustment *adj)
{
+ GdkWindow *window;
gint i,j;
gint imin, imax, jmin, jmax;
cairo_t *cr;
@@ -9338,11 +9378,13 @@ scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
jmin = ((int)adj->value + event->area.y) / 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.width, event->area.height);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
for (i=imin; i<imax; i++)
for (j=jmin; j<jmax; j++)
@@ -9373,8 +9415,11 @@ static void
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
GtkAdjustment *adj)
{
- adj->page_increment = 0.9 * widget->allocation.height;
- adj->page_size = widget->allocation.height;
+ GtkAllocation allocation;
+
+ 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");
}
@@ -9382,7 +9427,7 @@ scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
static void
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{
- /* gint source_min = (int)adj->value - scroll_test_pos; */
+ GdkWindow *window;
gint dy;
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))
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);
}
diff --git a/tests/testheightforwidth.c b/tests/testheightforwidth.c
index bc164521ff..26e9ea84ce 100644
--- a/tests/testheightforwidth.c
+++ b/tests/testheightforwidth.c
@@ -1031,7 +1031,7 @@ TestInterface interfaces[] = {
" </row>"
" <row>"
" <col id=\"0\" translatable=\"yes\">to demonstrate natural</col>"
- " <col id=\"1\" translatable=\"yes\">gtk-info</col>"
+ " <col id=\"1\" translatable=\"yes\">gtk-execute</col>"
" <col id=\"2\" translatable=\"yes\">is not</col>"
" <col id=\"3\" translatable=\"yes\">can</col>"
" </row>"
@@ -1086,7 +1086,7 @@ TestInterface interfaces[] = {
" </row>"
" <row>"
" <col id=\"0\" translatable=\"yes\">to demonstrate height-for-width</col>"
- " <col id=\"1\" translatable=\"yes\">gtk-info</col>"
+ " <col id=\"1\" translatable=\"yes\">gtk-execute</col>"
" <col id=\"2\" translatable=\"yes\">is not</col>"
" <col id=\"3\" translatable=\"yes\">can</col>"
" </row>"
diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c
index 367a227491..928fbc5d93 100644
--- a/tests/testiconview-keynav.c
+++ b/tests/testiconview-keynav.c
@@ -213,11 +213,15 @@ static void
header_style_set (GtkWidget *widget,
GtkStyle *old_style)
{
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+
g_signal_handlers_block_by_func (widget, header_style_set, NULL);
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL,
- &widget->style->base[GTK_STATE_NORMAL]);
+ &style->base[GTK_STATE_NORMAL]);
gtk_widget_modify_fg (widget, GTK_STATE_NORMAL,
- &widget->style->text[GTK_STATE_NORMAL]);
+ &style->text[GTK_STATE_NORMAL]);
g_signal_handlers_unblock_by_func (widget, header_style_set, NULL);
}
diff --git a/tests/testinput.c b/tests/testinput.c
index 16ad3ee7e6..1f00c18eae 100644
--- a/tests/testinput.c
+++ b/tests/testinput.c
@@ -52,7 +52,7 @@ update_cursor (GtkWidget *widget, gdouble x, gdouble y)
if (pixmap != NULL)
{
- cairo_t *cr = gdk_cairo_create (widget->window);
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
if (cursor_present && (cursor_present != state ||
x != cursor_x || y != cursor_y))
@@ -83,14 +83,18 @@ update_cursor (GtkWidget *widget, gdouble x, gdouble y)
static gint
configure_event (GtkWidget *widget, GdkEventConfigure *event)
{
+ GtkAllocation allocation;
cairo_t *cr;
if (pixmap)
g_object_unref (pixmap);
- pixmap = gdk_pixmap_new(widget->window,
- widget->allocation.width,
- widget->allocation.height,
- -1);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
+ allocation.width,
+ allocation.height,
+ -1);
cr = gdk_cairo_create (pixmap);
cairo_set_source_rgb (cr, 1, 1, 1);
@@ -105,7 +109,7 @@ configure_event (GtkWidget *widget, GdkEventConfigure *event)
static gint
expose_event (GtkWidget *widget, GdkEventExpose *event)
{
- cairo_t *cr = gdk_cairo_create (widget->window);
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
gdk_cairo_rectangle (cr, &event->area);
@@ -122,14 +126,17 @@ static void
draw_brush (GtkWidget *widget, GdkInputSource source,
gdouble x, gdouble y, gdouble pressure)
{
+ GtkStyle *style;
GdkColor color;
GdkRectangle update_rect;
cairo_t *cr;
+ style = gtk_widget_get_style (widget);
+
switch (source)
{
case GDK_SOURCE_MOUSE:
- color = widget->style->dark[gtk_widget_get_state (widget)];
+ color = style->dark[gtk_widget_get_state (widget)];
break;
case GDK_SOURCE_PEN:
color.red = color.green = color.blue = 0;
@@ -138,7 +145,7 @@ draw_brush (GtkWidget *widget, GdkInputSource source,
color.red = color.green = color.blue = 65535;
break;
default:
- color = widget->style->light[gtk_widget_get_state (widget)];
+ color = style->light[gtk_widget_get_state (widget)];
}
update_rect.x = x - 10 * pressure;
@@ -155,7 +162,7 @@ draw_brush (GtkWidget *widget, GdkInputSource source,
gtk_widget_queue_draw_area (widget,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
- gdk_window_process_updates (widget->window, TRUE);
+ gdk_window_process_updates (gtk_widget_get_window (widget), TRUE);
}
static guint32 motion_time;
diff --git a/tests/testoffscreen.c b/tests/testoffscreen.c
index ac711f5c26..bd92c7058c 100644
--- a/tests/testoffscreen.c
+++ b/tests/testoffscreen.c
@@ -383,8 +383,8 @@ main (int argc,
gtk_widget_show (redirect_win);
gtk_widget_realize (redirect_win);
gtk_widget_realize (window);
- gdk_window_redirect_to_drawable (window->window,
- GDK_DRAWABLE (redirect_win->window),
+ gdk_window_redirect_to_drawable (gtk_widget_get_window (window),
+ GDK_DRAWABLE (gtk_widget_get_window (redirect_win)),
0, 0, 0, 0, -1, -1);
}
diff --git a/tests/testoffscreenwindow.c b/tests/testoffscreenwindow.c
index 852a073c49..bf6a321f13 100644
--- a/tests/testoffscreenwindow.c
+++ b/tests/testoffscreenwindow.c
@@ -13,7 +13,7 @@ da_expose (GtkWidget *widget,
{
pixmap = gtk_offscreen_window_get_pixmap (offscreen);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_pixmap (cr, pixmap, 50, 50);
cairo_paint (cr);
cairo_destroy (cr);
diff --git a/tests/testselection.c b/tests/testselection.c
index 77ac3452bf..ff7a99caa6 100644
--- a/tests/testselection.c
+++ b/tests/testselection.c
@@ -152,7 +152,7 @@ selection_toggled (GtkWidget *widget)
{
if (have_selection)
{
- if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == widget->window)
+ if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == gtk_widget_get_window (widget))
gtk_selection_owner_set (NULL, GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
have_selection = FALSE;
diff --git a/tests/testsocket.c b/tests/testsocket.c
index 103b965805..b8310fce64 100644
--- a/tests/testsocket.c
+++ b/tests/testsocket.c
@@ -286,7 +286,8 @@ grab_window_toggled (GtkToggleButton *button,
{
int status;
- status = gdk_keyboard_grab (widget->window, FALSE, GDK_CURRENT_TIME);
+ status = gdk_keyboard_grab (gtk_widget_get_window (widget),
+ FALSE, GDK_CURRENT_TIME);
if (status != GDK_GRAB_SUCCESS)
g_warning ("Could not grab keyboard! (%s)", grab_string (status));
@@ -325,12 +326,13 @@ main (int argc, char *argv[])
menubar = gtk_menu_bar_new ();
menuitem = gtk_menu_item_new_with_mnemonic ("_File");
+ gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
+
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_mnemonic ("_Quit");
g_signal_connect (menuitem, "activate", G_CALLBACK (quit_cb), window);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
diff --git a/tests/testsocket_common.c b/tests/testsocket_common.c
index f6937b8417..da28f3a81c 100644
--- a/tests/testsocket_common.c
+++ b/tests/testsocket_common.c
@@ -182,8 +182,6 @@ create_menubar (GtkWindow *window)
menuitem = gtk_menu_item_new_with_mnemonic ("O_K");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
- menu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_mnemonic ("_Help");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
@@ -277,9 +275,9 @@ create_child_plug (guint32 xid,
if (gtk_widget_get_realized (window))
#if defined (GDK_WINDOWING_X11)
- return GDK_WINDOW_XID (window->window);
+ return GDK_WINDOW_XID (gtk_widget_get_window (window));
#elif defined (GDK_WINDOWING_WIN32)
- return (guint32) GDK_WINDOW_HWND (window->window);
+ return (guint32) GDK_WINDOW_HWND (gtk_widget_get_window (window));
#endif
else
return 0;
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 8aee9583e6..c228c23241 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -209,16 +209,19 @@ drawing_area_expose (GtkWidget *drawing_area,
GdkEventExpose *event,
gpointer data)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
gint i;
cairo_t *cr;
- gdk_window_get_pointer (drawing_area->window, NULL, NULL, NULL);
+ window = gtk_widget_get_window (drawing_area);
- cr = gdk_cairo_create (drawing_area->window);
+ gdk_window_get_pointer (window, NULL, NULL, NULL);
- cairo_rectangle (cr, 0, 0,
- drawing_area->allocation.width,
- drawing_area->allocation.height);
+ cr = gdk_cairo_create (window);
+
+ gtk_widget_get_allocation (drawing_area, &allocation);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_fill (cr);
diff --git a/tests/testwindows.c b/tests/testwindows.c
index 4d276ed4a3..520e167e55 100644
--- a/tests/testwindows.c
+++ b/tests/testwindows.c
@@ -209,7 +209,7 @@ add_window_clicked (GtkWidget *button,
if (l != NULL)
parent = l->data;
else
- parent = darea->window;
+ parent = gtk_widget_get_window (darea);
g_list_free (l);
@@ -284,7 +284,7 @@ save_clicked (GtkWidget *button,
s = g_string_new ("");
- save_children (s, darea->window);
+ save_children (s, gtk_widget_get_window (darea));
dialog = gtk_file_chooser_dialog_new ("Filename for window data",
NULL,
@@ -362,18 +362,21 @@ parse_window (GdkWindow *parent, char **lines)
static void
load_file (GFile *file)
{
+ GdkWindow *window;
char *data;
char **lines, **l;
if (g_file_load_contents (file, NULL, &data, NULL, NULL, NULL))
{
- destroy_children (darea->window);
+ window = gtk_widget_get_window (darea);
+
+ destroy_children (window);
lines = g_strsplit (data, "\n", -1);
l = lines;
while (*l != NULL)
- l = parse_window (darea->window, l);
+ l = parse_window (window, l);
}
update_store ();
@@ -774,7 +777,7 @@ update_store (void)
gtk_tree_store_clear (window_store);
- add_children (window_store, darea->window, NULL);
+ add_children (window_store, gtk_widget_get_window (darea), NULL);
gtk_tree_view_expand_all (GTK_TREE_VIEW (treeview));
select_windows (selected);
diff --git a/tests/testwrapbox.c b/tests/testwrapbox.c
new file mode 100644
index 0000000000..0cc2916cad
--- /dev/null
+++ b/tests/testwrapbox.c
@@ -0,0 +1,547 @@
+/* testwrapbox.c
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * Author:
+ * Tristan Van Berkom <tristan.van.berkom@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+enum {
+ SIMPLE_ITEMS = 0,
+ WRAPPY_ITEMS,
+ STOCK_ITEMS
+};
+
+#define INITIAL_ALLOCATION_MODE GTK_WRAP_ALLOCATE_HOMOGENEOUS
+#define INITIAL_SPREADING GTK_WRAP_BOX_SPREAD_BEGIN
+#define INITIAL_MINIMUM_LENGTH 3
+#define INITIAL_HSPACING 2
+#define INITIAL_VSPACING 2
+
+static GtkWrapBox *the_wrapbox = NULL;
+static gint items_type = SIMPLE_ITEMS;
+static GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL;
+static gboolean items_xexpand = TRUE;
+static gboolean items_yexpand = TRUE;
+static gboolean items_xfill = TRUE;
+static gboolean items_yfill = TRUE;
+static gint items_xpad = 0;
+static gint items_ypad = 0;
+
+
+static void
+populate_wrapbox_simple (GtkWrapBox *wrapbox)
+{
+ GtkWidget *widget, *frame;
+ gint i;
+
+ for (i = 0; i < 30; i++)
+ {
+ gchar *text = g_strdup_printf ("Item %02d", i);
+
+ widget = gtk_label_new (text);
+ frame = gtk_frame_new (NULL);
+ gtk_widget_show (widget);
+ gtk_widget_show (frame);
+
+ gtk_container_add (GTK_CONTAINER (frame), widget);
+
+ if (text_orientation == GTK_ORIENTATION_VERTICAL)
+ gtk_label_set_angle (GTK_LABEL (widget), 90);
+
+ gtk_wrap_box_insert_child (GTK_WRAP_BOX (wrapbox), frame, -1,
+ items_xpad, items_ypad,
+ items_xexpand, items_yexpand, items_xfill, items_yfill);
+
+ g_free (text);
+ }
+}
+
+static void
+populate_wrapbox_wrappy (GtkWrapBox *wrapbox)
+{
+ GtkWidget *widget, *frame;
+ gint i;
+
+ const gchar *strings[] = {
+ "These are", "some wrappy label", "texts", "of various", "lengths.",
+ "They should always be", "shown", "consecutively. Except it's",
+ "hard to say", "where exactly the", "label", "will wrap", "and where exactly",
+ "the actual", "container", "will wrap.", "This label is really really really long !",
+ "Let's add some more", "labels to the",
+ "mix. Just to", "make sure we", "got something to work", "with here."
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (strings); i++)
+ {
+ widget = gtk_label_new (strings[i]);
+ frame = gtk_frame_new (NULL);
+ gtk_widget_show (widget);
+ gtk_widget_show (frame);
+
+ if (text_orientation == GTK_ORIENTATION_VERTICAL)
+ gtk_label_set_angle (GTK_LABEL (widget), 90);
+
+ gtk_container_add (GTK_CONTAINER (frame), widget);
+
+ gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (widget), PANGO_WRAP_WORD);
+ gtk_label_set_width_chars (GTK_LABEL (widget), 10);
+
+ gtk_wrap_box_insert_child (GTK_WRAP_BOX (wrapbox), frame, -1,
+ items_xpad, items_ypad,
+ items_xexpand, items_yexpand, items_xfill, items_yfill);
+ }
+}
+
+
+static void
+populate_wrapbox_stock (GtkWrapBox *wrapbox)
+{
+ GtkWidget *widget;
+ static GSList *stock_ids = NULL;
+ GSList *l;
+ gint i;
+
+ if (!stock_ids)
+ stock_ids = gtk_stock_list_ids ();
+
+ for (i = 0, l = stock_ids; i < 30 && l != NULL; i++, l = l->next)
+ {
+ gchar *stock_id = l->data;
+
+ widget = gtk_button_new_from_stock (stock_id);
+ gtk_widget_show (widget);
+
+ gtk_wrap_box_insert_child (GTK_WRAP_BOX (wrapbox), widget, -1,
+ items_xpad, items_ypad,
+ items_xexpand, items_yexpand, items_xfill, items_yfill);
+ }
+}
+
+static void
+populate_items (GtkWrapBox *wrapbox)
+{
+ GList *children, *l;
+
+ /* Remove all children first */
+ children = gtk_container_get_children (GTK_CONTAINER (wrapbox));
+ for (l = children; l; l = l->next)
+ {
+ GtkWidget *child = l->data;
+
+ gtk_container_remove (GTK_CONTAINER (wrapbox), child);
+ }
+ g_list_free (children);
+
+ if (items_type == SIMPLE_ITEMS)
+ populate_wrapbox_simple (wrapbox);
+ else if (items_type == WRAPPY_ITEMS)
+ populate_wrapbox_wrappy (wrapbox);
+ else if (items_type == STOCK_ITEMS)
+ populate_wrapbox_stock (wrapbox);
+}
+
+
+static void
+mode_changed (GtkComboBox *box,
+ GtkWrapBox *wrapbox)
+{
+ GtkWrapAllocationMode mode = gtk_combo_box_get_active (box);
+
+ gtk_wrap_box_set_allocation_mode (wrapbox, mode);
+}
+
+static void
+spreading_changed (GtkComboBox *box,
+ GtkWrapBox *wrapbox)
+{
+ GtkWrapBoxSpreading spreading = gtk_combo_box_get_active (box);
+
+ gtk_wrap_box_set_spreading (wrapbox, spreading);
+}
+
+static void
+orientation_changed (GtkComboBox *box,
+ GtkWrapBox *wrapbox)
+{
+ GtkOrientation orientation = gtk_combo_box_get_active (box);
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (wrapbox), orientation);
+}
+
+static void
+line_length_changed (GtkSpinButton *spin,
+ GtkWrapBox *wrapbox)
+{
+ gint length = gtk_spin_button_get_value_as_int (spin);
+
+ gtk_wrap_box_set_minimum_line_children (wrapbox, length);
+}
+
+static void
+spacing_changed (GtkSpinButton *button,
+ gpointer data)
+{
+ GtkOrientation orientation = GPOINTER_TO_INT (data);
+ gint state = gtk_spin_button_get_value_as_int (button);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_wrap_box_set_horizontal_spacing (the_wrapbox, state);
+ else
+ gtk_wrap_box_set_vertical_spacing (the_wrapbox, state);
+}
+
+
+static void
+items_changed (GtkComboBox *box,
+ GtkWrapBox *wrapbox)
+{
+ items_type = gtk_combo_box_get_active (box);
+
+ populate_items (wrapbox);
+}
+
+static void
+text_orientation_changed (GtkComboBox *box,
+ GtkWrapBox *wrapbox)
+{
+ text_orientation = gtk_combo_box_get_active (box);
+
+ populate_items (wrapbox);
+}
+
+static void
+child_option_toggled (GtkToggleButton *button,
+ gboolean *state)
+{
+ *state = gtk_toggle_button_get_active (button);
+
+ populate_items (the_wrapbox);
+}
+
+static void
+child_padding_changed (GtkSpinButton *button,
+ gint *state)
+{
+ *state = gtk_spin_button_get_value_as_int (button);
+
+ populate_items (the_wrapbox);
+}
+
+static GtkWidget *
+create_window (void)
+{
+ GtkWidget *window, *hbox, *vbox, *frame, *wrapbox_cntl, *items_cntl;
+ GtkWidget *wrapbox, *widget, *expander, *swindow;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ hbox = gtk_hbox_new (FALSE, 2);
+ vbox = gtk_vbox_new (FALSE, 6);
+
+ gtk_container_set_border_width (GTK_CONTAINER (window), 8);
+
+ gtk_widget_show (vbox);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (window), hbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Wrap Box");
+ gtk_widget_show (frame);
+ gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
+
+ swindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (swindow);
+ gtk_container_add (GTK_CONTAINER (frame), swindow);
+
+ wrapbox = gtk_wrap_box_new (INITIAL_ALLOCATION_MODE, INITIAL_SPREADING,
+ INITIAL_HSPACING, INITIAL_VSPACING);
+ the_wrapbox = (GtkWrapBox *)wrapbox;
+ gtk_wrap_box_set_minimum_line_children (GTK_WRAP_BOX (wrapbox), INITIAL_MINIMUM_LENGTH);
+ gtk_widget_show (wrapbox);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), wrapbox);
+
+ /* Add Wrapbox test control frame */
+ expander = gtk_expander_new ("Wrap Box controls");
+ gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
+ wrapbox_cntl = gtk_vbox_new (FALSE, 2);
+ gtk_widget_show (wrapbox_cntl);
+ gtk_widget_show (expander);
+ gtk_container_add (GTK_CONTAINER (expander), wrapbox_cntl);
+ gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
+
+ /* Add Allocation mode control */
+ widget = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Wrap Freely");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Align items");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Homogeneous");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_ALLOCATION_MODE);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the wrapbox allocation mode");
+ gtk_box_pack_start (GTK_BOX (wrapbox_cntl), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (mode_changed), wrapbox);
+
+ /* Add Spreading control */
+ widget = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Spread Begin");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Spread End");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Spread Even");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Spread Expand");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_SPREADING);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the wrapbox spread mode");
+ gtk_box_pack_start (GTK_BOX (wrapbox_cntl), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (spreading_changed), wrapbox);
+
+ /* Add Orientation control */
+ widget = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Horizontal");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Vertical");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the wrapbox orientation");
+ gtk_box_pack_start (GTK_BOX (wrapbox_cntl), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (orientation_changed), wrapbox);
+
+ /* Add minimum line length in items control */
+ widget = gtk_spin_button_new_with_range (1, 10, 1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_MINIMUM_LENGTH);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the minimum amount of items per line before wrapping");
+ gtk_box_pack_start (GTK_BOX (wrapbox_cntl), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (line_length_changed), wrapbox);
+ g_signal_connect (G_OBJECT (widget), "value-changed",
+ G_CALLBACK (line_length_changed), wrapbox);
+
+ /* Add horizontal/vertical spacing controls */
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ widget = gtk_label_new ("H Spacing");
+ gtk_widget_show (widget);
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+
+ widget = gtk_spin_button_new_with_range (0, 30, 1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_HSPACING);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the horizontal spacing between children");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));
+ g_signal_connect (G_OBJECT (widget), "value-changed",
+ G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));
+
+ gtk_box_pack_start (GTK_BOX (wrapbox_cntl), hbox, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ widget = gtk_label_new ("V Spacing");
+ gtk_widget_show (widget);
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+
+ widget = gtk_spin_button_new_with_range (0, 30, 1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_VSPACING);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the vertical spacing between children");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL));
+ g_signal_connect (G_OBJECT (widget), "value-changed",
+ G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL));
+
+ gtk_box_pack_start (GTK_BOX (wrapbox_cntl), hbox, FALSE, FALSE, 0);
+
+
+ /* Add test items control frame */
+ expander = gtk_expander_new ("Test item controls");
+ gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
+ items_cntl = gtk_vbox_new (FALSE, 2);
+ gtk_widget_show (items_cntl);
+ gtk_widget_show (expander);
+ gtk_container_add (GTK_CONTAINER (expander), items_cntl);
+ gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
+
+ /* Add Items control */
+ widget = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Simple");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Wrappy");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Stock");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the item set to use");
+ gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (items_changed), wrapbox);
+
+
+ /* Add Text Orientation control */
+ widget = gtk_combo_box_new_text ();
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Horizontal");
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Vertical");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the item's text orientation (cant be done for stock buttons)");
+ gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (text_orientation_changed), wrapbox);
+
+
+ /* Add expand/fill options */
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ widget = gtk_check_button_new_with_label ("X Expand");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set whether the items expand horizontally");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "toggled",
+ G_CALLBACK (child_option_toggled), &items_xexpand);
+
+
+ widget = gtk_check_button_new_with_label ("X Fill");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set whether the items fill their allotted size horizontally");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "toggled",
+ G_CALLBACK (child_option_toggled), &items_xfill);
+
+ gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);
+
+
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ widget = gtk_check_button_new_with_label ("Y Expand");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set whether the items expand vertically");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "toggled",
+ G_CALLBACK (child_option_toggled), &items_yexpand);
+
+
+ widget = gtk_check_button_new_with_label ("Y Fill");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set whether the items fill their allotted size vertically");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "toggled",
+ G_CALLBACK (child_option_toggled), &items_yfill);
+
+ gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);
+
+
+ /* Add x/y padding options */
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ widget = gtk_label_new ("X Padding");
+ gtk_widget_show (widget);
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+
+ widget = gtk_spin_button_new_with_range (0, 30, 1);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the horizontal padding values for children");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (child_padding_changed), &items_xpad);
+ g_signal_connect (G_OBJECT (widget), "value-changed",
+ G_CALLBACK (child_padding_changed), &items_xpad);
+
+ gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);
+
+
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ widget = gtk_label_new ("Y Padding");
+ gtk_widget_show (widget);
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+
+ widget = gtk_spin_button_new_with_range (0, 30, 1);
+ gtk_widget_show (widget);
+
+ gtk_widget_set_tooltip_text (widget, "Set the vertical padding values for children");
+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (child_padding_changed), &items_ypad);
+ g_signal_connect (G_OBJECT (widget), "value-changed",
+ G_CALLBACK (child_padding_changed), &items_ypad);
+
+ gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);
+
+ populate_items (GTK_WRAP_BOX (wrapbox));
+
+ return window;
+}
+
+
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+
+ gtk_init (&argc, &argv);
+
+ window = create_window ();
+
+ g_signal_connect (window, "delete-event",
+ G_CALLBACK (gtk_main_quit), window);
+
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/tests/testxinerama.c b/tests/testxinerama.c
index d9d37a9f4e..e41752aabf 100644
--- a/tests/testxinerama.c
+++ b/tests/testxinerama.c
@@ -32,7 +32,7 @@ request (GtkWidget *widget,
gchar *str;
GdkScreen *screen = gtk_widget_get_screen (widget);
gint i = gdk_screen_get_monitor_at_window (screen,
- widget->window);
+ gtk_widget_get_window (widget));
if (i < 0)
str = g_strdup ("<big><span foreground='white' background='black'>Not on a monitor </span></big>");