From c8385431c83e7a009659ac93c9b59159f6ab5e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 12 Sep 2011 18:49:15 +0100 Subject: [PATCH 4/6] util/show-events: Use accessor functions instead direc access --- util/show-events.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/util/show-events.c b/util/show-events.c index 2359e46..484e248 100644 --- a/util/show-events.c +++ b/util/show-events.c @@ -295,6 +295,7 @@ static void event_view_draw (EventView *self, cairo_t *cr) { events_t *events; + GtkAllocation allocation; gdouble sf_x, sf_y, sf; gdouble mid, dim; gdouble x0, x1, y0, y1; @@ -309,13 +310,15 @@ event_view_draw (EventView *self, cairo_t *cr) if (events == NULL) return; + gtk_widget_get_allocation (&(self->widget), &allocation); + mid = (events->extents.p2.x + events->extents.p1.x) / 2.; dim = (events->extents.p2.x - events->extents.p1.x) / 2. * 1.2; - sf_x = self->widget.allocation.width / dim / 2; + sf_x = allocation.width / dim / 2; mid = (events->extents.p2.y + events->extents.p1.y) / 2.; dim = (events->extents.p2.y - events->extents.p1.y) / 2. * 1.2; - sf_y = self->widget.allocation.height / dim / 2; + sf_y = allocation.height / dim / 2; sf = MIN (sf_x, sf_y); @@ -388,7 +391,7 @@ event_view_expose (GtkWidget *w, GdkEventExpose *ev) EventView *self = (EventView *) 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); @@ -554,15 +557,19 @@ event_view_motion (GtkWidget *w, GdkEventMotion *ev) static void event_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); @@ -575,25 +582,29 @@ event_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 event_view_size_allocate (GtkWidget *w, GdkRectangle *r) { EventView *self = (EventView *) w; + GtkAllocation allocation; GTK_WIDGET_CLASS (event_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