Don't directly access widget->allocation
This commit is contained in:
committed by
Stéphane Lesimple
parent
3967ff3cae
commit
eadbf54aae
@@ -135,22 +135,24 @@ int GuiCurveLogY(Curve *curve, gdouble y) /* not really a log */
|
||||
***/
|
||||
|
||||
void GuiUpdateCurveGeometry(Curve *curve, char *largest_left_label, int right_padding)
|
||||
{ GtkAllocation *a = &curve->widget->allocation;
|
||||
{ GtkAllocation a = {0};
|
||||
int w,h;
|
||||
|
||||
gtk_widget_get_allocation(curve->widget, &a);
|
||||
|
||||
/* Top and bottom margins */
|
||||
|
||||
GuiSetText(curve->layout, curve->leftLabel, &w, &h);
|
||||
curve->topY = h + 10;
|
||||
|
||||
GuiSetText(curve->layout, "0123456789", &w, &h);
|
||||
curve->bottomY = a->height - h - 10;
|
||||
curve->bottomY = a.height - h - 10;
|
||||
|
||||
/* Left and right margins */
|
||||
|
||||
GuiSetText(curve->layout, largest_left_label, &w, &h);
|
||||
curve->leftX = 5 + 6 + 3 + w;
|
||||
curve->rightX = a->width - right_padding;
|
||||
curve->rightX = a.width - right_padding;
|
||||
|
||||
/* Add space for the lograithmic curve */
|
||||
|
||||
|
||||
@@ -235,7 +235,9 @@ void GuiFreeLabelWithOnlineHelp(LabelWithOnlineHelp *lwoh)
|
||||
|
||||
static gboolean wrapper_fix_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
{ int *last_width = (int*)data;
|
||||
int label_width = widget->allocation.width;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
int label_width = a.width;
|
||||
|
||||
if(*last_width == label_width) /* short circuit expose events */
|
||||
return FALSE; /* without size changes */
|
||||
|
||||
@@ -158,10 +158,11 @@ static void redraw_spiral(GtkWidget *widget)
|
||||
/* Calculate the geometry of the spiral */
|
||||
|
||||
static void update_geometry(GtkWidget *widget)
|
||||
{ GtkAllocation *a = &widget->allocation;
|
||||
{ GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
|
||||
Closure->readAdaptiveSpiral->mx = a->width - 15 - Closure->readAdaptiveSpiral->diameter / 2;
|
||||
Closure->readAdaptiveSpiral->my = a->height / 2;
|
||||
Closure->readAdaptiveSpiral->mx = a.width - 15 - Closure->readAdaptiveSpiral->diameter / 2;
|
||||
Closure->readAdaptiveSpiral->my = a.height / 2;
|
||||
}
|
||||
|
||||
/* Expose event handler */
|
||||
@@ -339,11 +340,12 @@ void GuiResetAdaptiveReadWindow()
|
||||
|
||||
if(Closure->readAdaptiveDrawingArea->window)
|
||||
{ static GdkRectangle rect;
|
||||
GtkAllocation *a = &Closure->readAdaptiveDrawingArea->allocation;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(Closure->readAdaptiveDrawingArea, &a);
|
||||
|
||||
rect.x = rect.y = 0;
|
||||
rect.width = a->width;
|
||||
rect.height = a->height;
|
||||
rect.width = a.width;
|
||||
rect.height = a.height;
|
||||
|
||||
gdk_window_clear(Closure->readAdaptiveDrawingArea->window);
|
||||
gdk_window_invalidate_rect(Closure->readAdaptiveDrawingArea->window, &rect, FALSE);
|
||||
|
||||
@@ -280,7 +280,8 @@ void GuiMarkExistingSectors(void)
|
||||
|
||||
static void update_geometry(void)
|
||||
{ GtkWidget *widget = Closure->readLinearDrawingArea;
|
||||
GtkAllocation *a = &widget->allocation;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
|
||||
/* Curve geometry */
|
||||
|
||||
@@ -289,8 +290,8 @@ static void update_geometry(void)
|
||||
|
||||
/* Spiral center */
|
||||
|
||||
Closure->readLinearSpiral->mx = a->width - 15 - Closure->readLinearSpiral->diameter / 2;
|
||||
Closure->readLinearSpiral->my = a->height / 2;
|
||||
Closure->readLinearSpiral->mx = a.width - 15 - Closure->readLinearSpiral->diameter / 2;
|
||||
Closure->readLinearSpiral->my = a.height / 2;
|
||||
|
||||
if(Closure->crcBuf && Closure->crcBuf->crcCached)
|
||||
{ int w,h;
|
||||
|
||||
@@ -141,7 +141,8 @@ static void redraw_spiral(RS01Widgets *wl)
|
||||
|
||||
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
{ RS01Widgets *wl = (RS01Widgets*)data;
|
||||
GtkAllocation *a = &widget->allocation;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
int w,h,size;
|
||||
|
||||
/* Finish spiral initialization */
|
||||
@@ -154,8 +155,8 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
|
||||
GuiSetText(wl->cmpLayout, _("Missing sectors"), &w, &h);
|
||||
size = wl->cmpSpiral->diameter + 20 + 3*(10+h); /* approx. size of spiral + labels */
|
||||
|
||||
wl->cmpSpiral->mx = a->width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a->height - size)/2;
|
||||
wl->cmpSpiral->mx = a.width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2;
|
||||
|
||||
if(event->count) /* Exposure compression */
|
||||
{ return TRUE;
|
||||
|
||||
@@ -134,7 +134,8 @@ static void redraw_spiral(RS02Widgets *wl)
|
||||
|
||||
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
{ RS02Widgets *wl = (RS02Widgets*)data;
|
||||
GtkAllocation *a = &widget->allocation;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
int w,h,size;
|
||||
|
||||
/* Finish spiral initialization */
|
||||
@@ -147,8 +148,8 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
|
||||
GuiSetText(wl->cmpLayout, _("Missing sectors"), &w, &h);
|
||||
size = wl->cmpSpiral->diameter + 20 + 3*(10+h); /* approx. size of spiral + labels */
|
||||
|
||||
wl->cmpSpiral->mx = a->width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a->height - size)/2;
|
||||
wl->cmpSpiral->mx = a.width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2;
|
||||
|
||||
if(!event->count) /* Exposure compression */
|
||||
redraw_spiral(wl); /* Redraw the spiral */
|
||||
|
||||
@@ -144,7 +144,8 @@ static void redraw_spiral(RS03Widgets *wl)
|
||||
|
||||
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
{ RS03Widgets *wl = (RS03Widgets*)data;
|
||||
GtkAllocation *a = &widget->allocation;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
int w,h,size;
|
||||
|
||||
/* Finish spiral initialization */
|
||||
@@ -157,8 +158,8 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
|
||||
GuiSetText(wl->cmpLayout, _("Missing sectors"), &w, &h);
|
||||
size = wl->cmpSpiral->diameter + 20 + 3*(10+h); /* approx. size of spiral + labels */
|
||||
|
||||
wl->cmpSpiral->mx = a->width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a->height - size)/2;
|
||||
wl->cmpSpiral->mx = a.width / 2;
|
||||
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2;
|
||||
|
||||
if(!event->count) /* Exposure compression */
|
||||
redraw_spiral(wl); /* Redraw the spiral */
|
||||
|
||||
@@ -70,12 +70,13 @@ Spiral* GuiCreateSpiral(GdkColor *outline, GdkColor *fill,
|
||||
}
|
||||
|
||||
void GuiSetSpiralWidget(Spiral *spiral, GtkWidget *widget)
|
||||
{ GtkAllocation *al = &widget->allocation;
|
||||
{ GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
|
||||
if(!spiral->drawable)
|
||||
{ spiral->drawable = widget->window;
|
||||
spiral->mx = al->width/2;
|
||||
spiral->my = al->height/2;
|
||||
spiral->mx = a.width/2;
|
||||
spiral->my = a.height/2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user