Skip to content
This repository was archived by the owner on Aug 29, 2021. It is now read-only.

Commit 9b6f122

Browse files
committed
Fix screenshot demo allocation
1 parent 2898d74 commit 9b6f122

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/goat-utils.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@ void goat_util_draw_num (cairo_t *cr, double x, double y, double d, GoatPosition
2222

2323
PangoRectangle logrect;
2424
pango_layout_get_pixel_extents (lay, NULL, &logrect);
25-
g_print ("logrect//// x=%i y=%i w=%i h=%i\n", logrect.x, logrect.y, logrect.width,
26-
logrect.height);
25+
g_print ("logrect//// x=%i y=%i w=%i h=%i\n", logrect.x, logrect.y, logrect.width, logrect.height);
2726
g_print ("x=%lf y=%lf\n\n", x, y);
2827
double modifierx, modifiery;
28+
{
29+
GEnumClass *enum_class;
30+
GEnumValue *enum_value;
31+
32+
enum_class = g_type_class_ref (GOAT_TYPE_POSITION);
33+
enum_value = g_enum_get_value (enum_class, penalty);
34+
35+
g_print ("number where: %s\n", enum_value->value_name);
36+
37+
g_type_class_unref (enum_class);
38+
}
2939
switch (penalty) {
3040
case GOAT_POSITION_BOTTOM:
3141
modifierx = (double)(logrect.width) * -0.5;
32-
modifiery = (double)(logrect.height);
42+
modifiery = (double)(logrect.height) * -1.;
3343
break;
3444
case GOAT_POSITION_LEFT:
3545
modifierx = (double)(logrect.width) * -1.0;

tests/screenshot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ void destroy (GtkWidget *widget, gpointer data)
1414
GtkAllocation allocation;
1515

1616
gtk_widget_get_allocation (widget, &allocation);
17-
surface =
18-
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, allocation.height, allocation.width);
17+
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, allocation.width, allocation.height);
1918
g_assert (surface);
2019
cr = cairo_create (surface);
2120
gtk_widget_draw (GTK_WIDGET (widget), cr);
22-
g_assert (cairo_surface_write_to_png (surface, "./screenshot.png") == CAIRO_STATUS_SUCCESS);
21+
const cairo_status_t status = cairo_surface_write_to_png (surface, "./screenshot.png");
22+
g_assert (status == CAIRO_STATUS_SUCCESS);
2323
cairo_surface_destroy (surface);
2424
cairo_destroy (cr);
2525
}

0 commit comments

Comments
 (0)