From b83b99407431e0f7778c4ab5c6a6d1bc3559159e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 12 Sep 2011 18:43:28 +0100 Subject: [PATCH 3/6] util/show-edges: Use accerssor functions instead direct access --- util/show-edges.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/util/show-edges.c b/util/show-edges.c index 3c3d738..57df57c 100644 --- a/util/show-edges.c +++ b/util/show-edges.c @@ -100,6 +100,7 @@ trap_view_draw (TrapView *self, cairo_t *cr) { traps_t *traps; edges_t *edges; + GtkAllocation allocation; gdouble sf_x, sf_y, sf; gdouble mid, dim; gdouble x0, x1, y0, y1; @@ -135,13 +136,15 @@ trap_view_draw (TrapView *self, cairo_t *cr) } else extents = edges->extents; + gtk_widget_get_allocation (&(self->widget), &allocation); + mid = (extents.p2.x + extents.p1.x) / 2.; dim = (extents.p2.x - extents.p1.x) / 2. * 1.25; - sf_x = self->widget.allocation.width / dim / 2; + sf_x = allocation.width / dim / 2; mid = (extents.p2.y + extents.p1.y) / 2.; dim = (extents.p2.y - extents.p1.y) / 2. * 1.25; - sf_y = self->widget.allocation.height / dim / 2; + sf_y = allocation.height / dim / 2; sf = MIN (sf_x, sf_y); @@ -708,7 +711,7 @@ trap_view_expose (GtkWidget *w, GdkEventExpose *ev) TrapView *self = (TrapView *) w; cairo_t *cr; - cr = gdk_cairo_create (w->window); + cr = gdk_cairo_create (gtk_widget_get_window (w)); gdk_cairo_region (cr, ev->region); cairo_clip (cr); @@ -877,15 +880,19 @@ trap_view_motion (GtkWidget *w, GdkEventMotion *ev) static void trap_view_realize (GtkWidget *widget) { + GtkAllocation allocation; GdkWindowAttr attributes; + GdkWindow *gdk_window; gtk_widget_set_realized (widget, TRUE); + gtk_widget_get_allocation (widget, &allocation); + attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = allocation.width; + attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -898,25 +905,29 @@ trap_view_realize (GtkWidget *widget) GDK_BUTTON_MOTION_MASK | GDK_EXPOSURE_MASK; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, - GDK_WA_X | GDK_WA_Y | - GDK_WA_VISUAL | GDK_WA_COLORMAP); - gdk_window_set_user_data (widget->window, widget); + gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, + GDK_WA_X | GDK_WA_Y | + GDK_WA_VISUAL | GDK_WA_COLORMAP); + gtk_widget_set_window (widget, gdk_window); + gdk_window_set_user_data (gdk_window, widget); - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_widget_style_attach (widget); + gtk_style_set_background (gtk_widget_get_style (widget), gdk_window, GTK_STATE_NORMAL); } static void trap_view_size_allocate (GtkWidget *w, GdkRectangle *r) { TrapView *self = (TrapView *) w; + GtkAllocation allocation; GTK_WIDGET_CLASS (trap_view_parent_class)->size_allocate (w, r); - self->mag_x = w->allocation.width - self->mag_size - 10; - self->mag_y = w->allocation.height - self->mag_size - 10; + gtk_widget_get_allocation (w, &allocation); + + self->mag_x = allocation.width - self->mag_size - 10; + self->mag_y = allocation.height - self->mag_size - 10; } static void -- 1.7.5.4