[gtk+/gtk-2-24] Make gtk2 demos comply with gseal
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] Make gtk2 demos comply with gseal
- Date: Sat, 26 May 2012 20:04:02 +0000 (UTC)
commit 5b91e0d501011d4dde3908267faba15373871790
Author: Connor Behan <connor behan gmail com>
Date: Wed Feb 29 21:30:05 2012 -0800
Make gtk2 demos comply with gseal
Demos in gtk-demo are supposed to be exemplary. However, if one were to
give them dummy main functions many of them would not compile with
-DGSEAL_ENABLE. This changes the demos to make them use accessor
functions whenever possible instead of direct changes to the struct
members.
http://bugzilla.gnome.org/show_bug.cgi?id=667155
demos/gtk-demo/changedisplay.c | 15 +++++---
demos/gtk-demo/clipboard.c | 2 +-
demos/gtk-demo/colorsel.c | 9 +++--
demos/gtk-demo/combobox.c | 2 +-
demos/gtk-demo/dialog.c | 2 +-
demos/gtk-demo/drawingarea.c | 22 +++++++----
demos/gtk-demo/entry_buffer.c | 2 +-
demos/gtk-demo/entry_completion.c | 2 +-
demos/gtk-demo/expander.c | 2 +-
demos/gtk-demo/hypertext.c | 4 +-
demos/gtk-demo/offscreen_window.c | 70 ++++++++++++++++++++----------------
demos/gtk-demo/offscreen_window2.c | 63 ++++++++++++++++++--------------
demos/gtk-demo/panes.c | 31 +++++++++-------
demos/gtk-demo/rotated_text.c | 9 +++--
demos/gtk-demo/search_entry.c | 2 +-
demos/gtk-demo/sizegroup.c | 2 +-
demos/gtk-demo/spinner.c | 2 +-
demos/gtk-demo/toolpalette.c | 14 +++++---
18 files changed, 147 insertions(+), 108 deletions(-)
---
diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c
index b4bed3d..3de3b84 100644
--- a/demos/gtk-demo/changedisplay.c
+++ b/demos/gtk-demo/changedisplay.c
@@ -128,7 +128,7 @@ query_for_toplevel (GdkScreen *screen,
gtk_widget_show_all (popup);
cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
- if (gdk_pointer_grab (popup->window, FALSE,
+ if (gdk_pointer_grab (gtk_widget_get_window (popup), FALSE,
GDK_BUTTON_RELEASE_MASK,
NULL,
cursor,
@@ -232,6 +232,7 @@ open_display_cb (GtkWidget *button,
GtkWidget *dialog;
GtkWidget *display_entry;
GtkWidget *dialog_label;
+ GtkWidget *content_area;
gchar *new_screen_name = NULL;
GdkDisplay *result = NULL;
@@ -247,12 +248,14 @@ open_display_cb (GtkWidget *button,
gtk_entry_set_activates_default (GTK_ENTRY (display_entry), TRUE);
dialog_label =
gtk_label_new ("Please enter the name of\nthe new display\n");
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog_label);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), display_entry);
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ gtk_container_add (GTK_CONTAINER (content_area), dialog_label);
+ gtk_container_add (GTK_CONTAINER (content_area), display_entry);
gtk_widget_grab_focus (display_entry);
- gtk_widget_show_all (GTK_BIN (dialog)->child);
+ gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (dialog)));
while (!result)
{
@@ -621,7 +624,7 @@ do_changedisplay (GtkWidget *do_widget)
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->window)->vbox), vbox,
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (info->window))), vbox,
TRUE, TRUE, 0);
frame = create_display_frame (info);
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index 6ec1517..9979d3d 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -125,7 +125,7 @@ drag_data_received (GtkWidget *widget,
{
GdkPixbuf *pixbuf;
- if (selection_data->length > 0)
+ if (gtk_selection_data_get_length (selection_data) > 0)
{
pixbuf = gtk_selection_data_get_pixbuf (selection_data);
gtk_image_set_from_pixbuf (GTK_IMAGE (data), pixbuf);
diff --git a/demos/gtk-demo/colorsel.c b/demos/gtk-demo/colorsel.c
index c671cea..ea3d3aa 100644
--- a/demos/gtk-demo/colorsel.c
+++ b/demos/gtk-demo/colorsel.c
@@ -19,14 +19,16 @@ expose_event_callback (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
- if (widget->window)
+ GdkWindow *window = gtk_widget_get_window (widget);
+
+ if (window)
{
GtkStyle *style;
cairo_t *cr;
style = gtk_widget_get_style (widget);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
gdk_cairo_rectangle (cr, &event->area);
@@ -50,7 +52,8 @@ change_color_callback (GtkWidget *button,
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
- colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel);
+ colorsel =
+ GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog)));
gtk_color_selection_set_previous_color (colorsel, &color);
gtk_color_selection_set_current_color (colorsel, &color);
diff --git a/demos/gtk-demo/combobox.c b/demos/gtk-demo/combobox.c
index 439db18..172c5af 100644
--- a/demos/gtk-demo/combobox.c
+++ b/demos/gtk-demo/combobox.c
@@ -435,7 +435,7 @@ do_combobox (GtkWidget *do_widget)
entry = g_object_new (TYPE_MASK_ENTRY, NULL);
MASK_ENTRY (entry)->mask = "^([0-9]*|One|Two|2\302\275|Three)$";
- gtk_container_remove (GTK_CONTAINER (combo), GTK_BIN (combo)->child);
+ gtk_container_remove (GTK_CONTAINER (combo), gtk_bin_get_child (GTK_BIN (combo)));
gtk_container_add (GTK_CONTAINER (combo), entry);
}
diff --git a/demos/gtk-demo/dialog.c b/demos/gtk-demo/dialog.c
index 301ee2f..4a49a94 100644
--- a/demos/gtk-demo/dialog.c
+++ b/demos/gtk-demo/dialog.c
@@ -53,7 +53,7 @@ interactive_dialog_clicked (GtkButton *button,
hbox = gtk_hbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, FALSE, 0);
stock = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 0);
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index 1b1c9bb..5aed1ef 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -26,14 +26,17 @@ scribble_configure_event (GtkWidget *widget,
gpointer data)
{
cairo_t *cr;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
if (surface)
cairo_surface_destroy (surface);
- surface = gdk_window_create_similar_surface (widget->window,
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
CAIRO_CONTENT_COLOR,
- widget->allocation.width,
- widget->allocation.height);
+ allocation.width,
+ allocation.height);
/* Initialize the surface to white */
cr = cairo_create (surface);
@@ -55,7 +58,7 @@ scribble_expose_event (GtkWidget *widget,
{
cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_set_source_surface (cr, surface, 0, 0);
gdk_cairo_rectangle (cr, &event->area);
@@ -89,7 +92,7 @@ draw_brush (GtkWidget *widget,
cairo_destroy (cr);
/* Now invalidate the affected region of the drawing area. */
- gdk_window_invalidate_rect (widget->window,
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget),
&update_rect,
FALSE);
}
@@ -148,6 +151,9 @@ checkerboard_expose (GtkWidget *da,
{
gint i, j, xcount, ycount;
cairo_t *cr;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (da, &allocation);
#define CHECK_SIZE 10
#define SPACING 2
@@ -159,17 +165,17 @@ checkerboard_expose (GtkWidget *da,
* works.
*/
- cr = gdk_cairo_create (da->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (da));
gdk_cairo_rectangle (cr, &event->area);
cairo_clip (cr);
xcount = 0;
i = SPACING;
- while (i < da->allocation.width)
+ while (i < allocation.width)
{
j = SPACING;
ycount = xcount % 2; /* start with even/odd depending on row */
- while (j < da->allocation.height)
+ while (j < allocation.height)
{
if (ycount % 2)
cairo_set_source_rgb (cr, 0.45777, 0, 0.45777);
diff --git a/demos/gtk-demo/entry_buffer.c b/demos/gtk-demo/entry_buffer.c
index 82f07c9..581719a 100644
--- a/demos/gtk-demo/entry_buffer.c
+++ b/demos/gtk-demo/entry_buffer.c
@@ -32,7 +32,7 @@ do_entry_buffer (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
label = gtk_label_new (NULL);
diff --git a/demos/gtk-demo/entry_completion.c b/demos/gtk-demo/entry_completion.c
index f7e61e9..2d122dc 100644
--- a/demos/gtk-demo/entry_completion.c
+++ b/demos/gtk-demo/entry_completion.c
@@ -59,7 +59,7 @@ do_entry_completion (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
label = gtk_label_new (NULL);
diff --git a/demos/gtk-demo/expander.c b/demos/gtk-demo/expander.c
index acd51ba..fd0401d 100644
--- a/demos/gtk-demo/expander.c
+++ b/demos/gtk-demo/expander.c
@@ -33,7 +33,7 @@ do_expander (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
label = gtk_label_new ("Expander demo. Click on the triangle for details.");
diff --git a/demos/gtk-demo/hypertext.c b/demos/gtk-demo/hypertext.c
index 8b67c05..aa41fe3 100644
--- a/demos/gtk-demo/hypertext.c
+++ b/demos/gtk-demo/hypertext.c
@@ -225,7 +225,7 @@ motion_notify_event (GtkWidget *text_view,
set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
- gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
+ gdk_window_get_pointer (gtk_widget_get_window (text_view), NULL, NULL, NULL);
return FALSE;
}
@@ -238,7 +238,7 @@ visibility_notify_event (GtkWidget *text_view,
{
gint wx, wy, bx, by;
- gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
+ gdk_window_get_pointer (gtk_widget_get_window (text_view), &wx, &wy, NULL);
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
GTK_TEXT_WINDOW_WIDGET,
diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c
index f85d572..d5483eb 100644
--- a/demos/gtk-demo/offscreen_window.c
+++ b/demos/gtk-demo/offscreen_window.c
@@ -74,7 +74,7 @@ to_child (GtkRotatedBin *bin,
s = sin (bin->angle);
c = cos (bin->angle);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
w = c * child_area.width + s * child_area.height;
h = s * child_area.width + c * child_area.height;
@@ -114,7 +114,7 @@ to_parent (GtkRotatedBin *bin,
s = sin (bin->angle);
c = cos (bin->angle);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
w = c * child_area.width + s * child_area.height;
h = s * child_area.width + c * child_area.height;
@@ -188,7 +188,7 @@ pick_offscreen_child (GdkWindow *offscreen_window,
{
to_child (bin, widget_x, widget_y, &x, &y);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
if (x >= 0 && x < child_area.width &&
y >= 0 && y < child_area.height)
@@ -224,19 +224,23 @@ static void
gtk_rotated_bin_realize (GtkWidget *widget)
{
GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
+ GdkWindow *gdk_window;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
GtkRequisition child_requisition;
+ GtkAllocation widget_allocation, bin_child_allocation;
+ GtkStyle *style;
gtk_widget_set_realized (widget, TRUE);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ gtk_widget_get_allocation (widget, &widget_allocation);
- 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;
+ 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;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_EXPOSURE_MASK
@@ -252,11 +256,11 @@ gtk_rotated_bin_realize (GtkWidget *widget)
attributes.wclass = GDK_INPUT_OUTPUT;
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);
- g_signal_connect (widget->window, "pick-embedded-child",
+
+ gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
+ gdk_window_set_user_data (gdk_window, widget);
+ g_signal_connect (gdk_window, "pick-embedded-child",
G_CALLBACK (pick_offscreen_child), bin);
attributes.window_type = GDK_WINDOW_OFFSCREEN;
@@ -264,24 +268,25 @@ gtk_rotated_bin_realize (GtkWidget *widget)
child_requisition.width = child_requisition.height = 0;
if (bin->child && gtk_widget_get_visible (bin->child))
{
- attributes.width = bin->child->allocation.width;
- attributes.height = bin->child->allocation.height;
+ gtk_widget_get_allocation (bin->child, &bin_child_allocation);
+ attributes.width = bin_child_allocation.width;
+ attributes.height = bin_child_allocation.height;
}
bin->offscreen_window = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (bin->offscreen_window, widget);
if (bin->child)
gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
- gdk_offscreen_window_set_embedder (bin->offscreen_window, widget->window);
+ gdk_offscreen_window_set_embedder (bin->offscreen_window, gtk_widget_get_window (widget));
g_signal_connect (bin->offscreen_window, "to-embedder",
G_CALLBACK (offscreen_window_to_parent), bin);
g_signal_connect (bin->offscreen_window, "from-embedder",
G_CALLBACK (offscreen_window_from_parent), bin);
- 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, bin->offscreen_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, gdk_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, bin->offscreen_window, GTK_STATE_NORMAL);
gdk_window_show (bin->offscreen_window);
}
@@ -376,9 +381,12 @@ gtk_rotated_bin_size_request (GtkWidget *widget,
{
GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
GtkRequisition child_requisition;
+ gint border_width;
double s, c;
double w, h;
-
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
child_requisition.width = 0;
child_requisition.height = 0;
@@ -390,8 +398,8 @@ gtk_rotated_bin_size_request (GtkWidget *widget,
w = c * child_requisition.width + s * child_requisition.height;
h = s * child_requisition.width + c * child_requisition.height;
- requisition->width = GTK_CONTAINER (widget)->border_width * 2 + w;
- requisition->height = GTK_CONTAINER (widget)->border_width * 2 + h;
+ requisition->width = border_width * 2 + w;
+ requisition->height = border_width * 2 + h;
}
static void
@@ -403,15 +411,15 @@ gtk_rotated_bin_size_allocate (GtkWidget *widget,
gint w, h;
gdouble s, c;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
w = allocation->width - border_width * 2;
h = allocation->height - border_width * 2;
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,
w, h);
@@ -452,7 +460,7 @@ static gboolean
gtk_rotated_bin_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;
}
@@ -468,7 +476,7 @@ gtk_rotated_bin_expose (GtkWidget *widget,
if (gtk_widget_is_drawable (widget))
{
- if (event->window == widget->window)
+ if (event->window == gtk_widget_get_window (widget))
{
GdkPixmap *pixmap;
GtkAllocation child_area;
@@ -477,9 +485,9 @@ gtk_rotated_bin_expose (GtkWidget *widget,
if (bin->child && gtk_widget_get_visible (bin->child))
{
pixmap = gdk_offscreen_window_get_pixmap (bin->offscreen_window);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
/* transform */
s = sin (bin->angle);
@@ -505,7 +513,7 @@ gtk_rotated_bin_expose (GtkWidget *widget,
}
else if (event->window == bin->offscreen_window)
{
- 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/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c
index b0947e4..3104639 100644
--- a/demos/gtk-demo/offscreen_window2.c
+++ b/demos/gtk-demo/offscreen_window2.c
@@ -126,7 +126,7 @@ pick_offscreen_child (GdkWindow *offscreen_window,
{
to_child (bin, widget_x, widget_y, &x, &y);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
if (x >= 0 && x < child_area.width &&
y >= 0 && y < child_area.height)
@@ -163,18 +163,22 @@ gtk_mirror_bin_realize (GtkWidget *widget)
{
GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
GdkWindowAttr attributes;
+ GdkWindow *gdk_window;
gint attributes_mask;
gint border_width;
GtkRequisition child_requisition;
+ GtkAllocation widget_allocation, bin_child_allocation;
+ GtkStyle *style;
gtk_widget_set_realized (widget, TRUE);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ gtk_widget_get_allocation (widget, &widget_allocation);
- 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;
+ 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;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_EXPOSURE_MASK
@@ -190,11 +194,11 @@ gtk_mirror_bin_realize (GtkWidget *widget)
attributes.wclass = GDK_INPUT_OUTPUT;
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);
- g_signal_connect (widget->window, "pick-embedded-child",
+
+ gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask)
+ gtk_widget_set_window (widget, gdk_window);
+ gdk_window_set_user_data (gdk_window, widget);
+ g_signal_connect (gdk_window, "pick-embedded-child",
G_CALLBACK (pick_offscreen_child), bin);
attributes.window_type = GDK_WINDOW_OFFSCREEN;
@@ -202,24 +206,25 @@ gtk_mirror_bin_realize (GtkWidget *widget)
child_requisition.width = child_requisition.height = 0;
if (bin->child && gtk_widget_get_visible (bin->child))
{
- attributes.width = bin->child->allocation.width;
- attributes.height = bin->child->allocation.height;
+ gtk_widget_get_allocation (bin->child, &bin_child_allocation);
+ attributes.width = bin_child_allocation.width;
+ attributes.height = bin_child_allocation.height;
}
bin->offscreen_window = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (bin->offscreen_window, widget);
if (bin->child)
gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
- gdk_offscreen_window_set_embedder (bin->offscreen_window, widget->window);
+ gdk_offscreen_window_set_embedder (bin->offscreen_window, gtk_widget_get_window (widget));
g_signal_connect (bin->offscreen_window, "to-embedder",
G_CALLBACK (offscreen_window_to_parent), bin);
g_signal_connect (bin->offscreen_window, "from-embedder",
G_CALLBACK (offscreen_window_from_parent), bin);
- 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, bin->offscreen_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, gdk_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, bin->offscreen_window, GTK_STATE_NORMAL);
gdk_window_show (bin->offscreen_window);
}
@@ -302,6 +307,9 @@ gtk_mirror_bin_size_request (GtkWidget *widget,
{
GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
GtkRequisition child_requisition;
+ gint border_width;
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
child_requisition.width = 0;
child_requisition.height = 0;
@@ -309,8 +317,8 @@ gtk_mirror_bin_size_request (GtkWidget *widget,
if (bin->child && gtk_widget_get_visible (bin->child))
gtk_widget_size_request (bin->child, &child_requisition);
- requisition->width = GTK_CONTAINER (widget)->border_width * 2 + child_requisition.width + 10;
- requisition->height = GTK_CONTAINER (widget)->border_width * 2 + child_requisition.height * 2 + 10;
+ requisition->width = border_width * 2 + child_requisition.width + 10;
+ requisition->height = border_width * 2 + child_requisition.height * 2 + 10;
}
static void
@@ -320,15 +328,16 @@ gtk_mirror_bin_size_allocate (GtkWidget *widget,
GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
gint border_width;
gint w, h;
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
w = allocation->width - border_width * 2;
h = allocation->height - border_width * 2;
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,
w, h);
@@ -357,7 +366,7 @@ static gboolean
gtk_mirror_bin_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;
}
@@ -371,7 +380,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
if (gtk_widget_is_drawable (widget))
{
- if (event->window == widget->window)
+ if (event->window == gtk_widget_get_window (widget))
{
GdkPixmap *pixmap;
cairo_t *cr;
@@ -383,7 +392,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
pixmap = gdk_offscreen_window_get_pixmap (bin->offscreen_window);
gdk_pixmap_get_size (pixmap, &width, &height);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_save (cr);
@@ -423,7 +432,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
}
else if (event->window == bin->offscreen_window)
{
- 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/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c
index 93f1aa1..bb00a3c 100644
--- a/demos/gtk-demo/panes.c
+++ b/demos/gtk-demo/panes.c
@@ -17,15 +17,14 @@ void
toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
- GtkPaned *paned = GTK_PANED (child->parent);
- gboolean is_child1 = (child == paned->child1);
+ GtkPaned *paned = GTK_PANED (gtk_widget_get_parent (child));
+ gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
gboolean resize, shrink;
- resize = is_child1 ? paned->child1_resize : paned->child2_resize;
- shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
+ gtk_container_child_get (GTK_CONTAINER (paned), child, "resize", &resize, "shrink", &shrink, NULL);
g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (child->parent), child);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (child)), child);
if (is_child1)
gtk_paned_pack1 (paned, child, !resize, shrink);
else
@@ -37,15 +36,14 @@ void
toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
- GtkPaned *paned = GTK_PANED (child->parent);
- gboolean is_child1 = (child == paned->child1);
+ GtkPaned *paned = GTK_PANED (gtk_widget_get_parent (child));
+ gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
gboolean resize, shrink;
- resize = is_child1 ? paned->child1_resize : paned->child2_resize;
- shrink = is_child1 ? paned->child1_shrink : paned->child2_shrink;
+ gtk_container_child_get (GTK_CONTAINER (paned), child, "resize", &resize, "shrink", &shrink, NULL);
g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (child->parent), child);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (child)), child);
if (is_child1)
gtk_paned_pack1 (paned, child, resize, !shrink);
else
@@ -63,6 +61,11 @@ create_pane_options (GtkPaned *paned,
GtkWidget *table;
GtkWidget *label;
GtkWidget *check_button;
+ GtkWidget *child1;
+ GtkWidget *child2;
+
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
frame = gtk_frame_new (frame_label);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
@@ -78,7 +81,7 @@ create_pane_options (GtkPaned *paned,
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 1, 2);
g_signal_connect (check_button, "toggled",
- G_CALLBACK (toggle_resize), paned->child1);
+ G_CALLBACK (toggle_resize), child1);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
@@ -86,7 +89,7 @@ create_pane_options (GtkPaned *paned,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE);
g_signal_connect (check_button, "toggled",
- G_CALLBACK (toggle_shrink), paned->child1);
+ G_CALLBACK (toggle_shrink), child1);
label = gtk_label_new (label2);
gtk_table_attach_defaults (GTK_TABLE (table), label,
@@ -98,7 +101,7 @@ create_pane_options (GtkPaned *paned,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE);
g_signal_connect (check_button, "toggled",
- G_CALLBACK (toggle_resize), paned->child2);
+ G_CALLBACK (toggle_resize), child2);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
@@ -106,7 +109,7 @@ create_pane_options (GtkPaned *paned,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
TRUE);
g_signal_connect (check_button, "toggled",
- G_CALLBACK (toggle_shrink), paned->child2);
+ G_CALLBACK (toggle_shrink), child2);
return frame;
}
diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c
index b83b2c3..67b29aa 100644
--- a/demos/gtk-demo/rotated_text.c
+++ b/demos/gtk-demo/rotated_text.c
@@ -107,9 +107,12 @@ rotated_text_expose_event (GtkWidget *widget,
cairo_pattern_t *pattern;
PangoAttrList *attrs;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
- int width = widget->allocation.width;
- int height = widget->allocation.height;
+ int width = allocation.width;
+ int height = allocation.height;
double device_radius;
int i;
@@ -117,7 +120,7 @@ rotated_text_expose_event (GtkWidget *widget,
* space coordinates for the centered square where we draw are [-RADIUS, RADIUS],
* [-RADIUS, RADIUS].
* We first center, then change the scale. */
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
device_radius = MIN (width, height) / 2.;
cairo_translate (cr,
device_radius + (width - 2 * device_radius) / 2,
diff --git a/demos/gtk-demo/search_entry.c b/demos/gtk-demo/search_entry.c
index 580dd13..a9b715e 100644
--- a/demos/gtk-demo/search_entry.c
+++ b/demos/gtk-demo/search_entry.c
@@ -264,7 +264,7 @@ do_search_entry (GtkWidget *do_widget)
G_CALLBACK (search_entry_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
label = gtk_label_new (NULL);
diff --git a/demos/gtk-demo/sizegroup.c b/demos/gtk-demo/sizegroup.c
index 1ce746e..326d16b 100644
--- a/demos/gtk-demo/sizegroup.c
+++ b/demos/gtk-demo/sizegroup.c
@@ -116,7 +116,7 @@ do_sizegroup (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
diff --git a/demos/gtk-demo/spinner.c b/demos/gtk-demo/spinner.c
index cf82440..c750ca0 100644
--- a/demos/gtk-demo/spinner.c
+++ b/demos/gtk-demo/spinner.c
@@ -48,7 +48,7 @@ do_spinner (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
/* Sensitive */
diff --git a/demos/gtk-demo/toolpalette.c b/demos/gtk-demo/toolpalette.c
index e9bc926..f2f2a6b 100644
--- a/demos/gtk-demo/toolpalette.c
+++ b/demos/gtk-demo/toolpalette.c
@@ -86,13 +86,15 @@ canvas_expose_event (GtkWidget *widget,
{
cairo_t *cr;
GList *iter;
+ GtkAllocation allocation;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
+ 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);
for (iter = canvas_items; iter; iter = iter->next)
@@ -176,6 +178,7 @@ palette_drag_data_received (GtkWidget *widget,
GtkToolItemGroup *drop_group = NULL;
GtkWidget *drag_palette = gtk_drag_get_source_widget (context);
GtkWidget *drag_item = NULL;
+ GtkAllocation allocation;
while (drag_palette && !GTK_IS_TOOL_PALETTE (drag_palette))
drag_palette = gtk_widget_get_parent (drag_palette);
@@ -186,6 +189,7 @@ palette_drag_data_received (GtkWidget *widget,
selection);
drop_group = gtk_tool_palette_get_drop_group (GTK_TOOL_PALETTE (widget),
x, y);
+ gtk_widget_get_allocation (GTK_WIDGET (drop_group), &allocation);
}
if (GTK_IS_TOOL_ITEM_GROUP (drag_item))
@@ -195,8 +199,8 @@ palette_drag_data_received (GtkWidget *widget,
else if (GTK_IS_TOOL_ITEM (drag_item) && drop_group)
palette_drop_item (GTK_TOOL_ITEM (drag_item),
drop_group,
- x - GTK_WIDGET (drop_group)->allocation.x,
- y - GTK_WIDGET (drop_group)->allocation.y);
+ x - allocation.x,
+ y - allocation.y);
}
/********************************/
@@ -372,7 +376,7 @@ on_combo_orientation_changed (GtkComboBox *combo_box,
gpointer user_data)
{
GtkToolPalette *palette = GTK_TOOL_PALETTE (user_data);
- GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW (GTK_WIDGET (palette)->parent);
+ GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (palette)));
GtkTreeModel *model = gtk_combo_box_get_model (combo_box);
GtkTreeIter iter;
gint val = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]