From 9dc18220400d9a6f4fe3e65ba73d77f4844d249a Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Mon, 20 Dec 2010 05:20:21 +0100
Subject: Fix problems discovered while testing on Windows.
* Set the working directory for glib-genmarshal correctly.
* Use one more path suffix when searching for glibconfig.h.
* Don't assume that gdk_screen_get_resolution() returns
a useful value.
---
src/ld-canvas.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/ld-canvas.c b/src/ld-canvas.c
index 0667adb..259d7d1 100644
--- a/src/ld-canvas.c
+++ b/src/ld-canvas.c
@@ -36,6 +36,9 @@
/* Tolerance on all sides of symbols for strokes. */
#define SYMBOL_AREA_TOLERANCE 0.5
+/* The default screen resolution in DPI units. */
+#define DEFAULT_SCREEN_RESOLUTION 96
+
/*
* LdCanvasPrivate:
* @diagram: A diagram object assigned to this canvas as a model.
@@ -455,11 +458,16 @@ ld_canvas_get_library (LdCanvas *self)
static gdouble
ld_canvas_get_base_unit_in_px (GtkWidget *self)
{
+ gdouble resolution;
+
g_return_val_if_fail (GTK_IS_WIDGET (self), 1);
+ resolution = gdk_screen_get_resolution (gtk_widget_get_screen (self));
+ if (resolution == -1)
+ resolution = DEFAULT_SCREEN_RESOLUTION;
+
/* XXX: It might look better if the unit was rounded to a whole number. */
- return gdk_screen_get_resolution (gtk_widget_get_screen (self))
- / MM_PER_INCH * LD_CANVAS_BASE_UNIT_LENGTH;
+ return resolution / MM_PER_INCH * LD_CANVAS_BASE_UNIT_LENGTH;
}
/*
--
cgit v1.2.3-70-g09d2