Commit 29b6e658 authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

Fix problems in handling custom paper sizes. The DEVMODE::dmPaperWidth and

2008-07-30  Tor Lillqvist  <tml@novell.com>

	* gtk/gtkprintoperation-win32.c: Fix problems in handling custom
	paper sizes. The DEVMODE::dmPaperWidth and dmPaperLength are in
	tenths of a millimeter, and the RECT passed to CreateEnhMetaFile()
	is in hundredths of a millimeter. Patch by Sven Neumann.


svn path=/trunk/; revision=20916
parent fb7ce7db
2008-07-30 Tor Lillqvist <tml@novell.com>
* gtk/gtkprintoperation-win32.c: Fix problems in handling custom
paper sizes. The DEVMODE::dmPaperWidth and dmPaperLength are in
tenths of a millimeter, and the RECT passed to CreateEnhMetaFile()
is in hundredths of a millimeter. Patch by Sven Neumann.
2008-07-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreemodel.c: Small doc improvements.
......
......@@ -439,6 +439,8 @@ win32_start_page (GtkPrintOperation *op,
{
devmode->dmPaperSize = DMPAPER_USER;
devmode->dmFields |= DM_PAPERWIDTH | DM_PAPERLENGTH;
/* Lengths in DEVMODE are in tenths of a millimeter */
devmode->dmPaperWidth = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM) * 10.0;
devmode->dmPaperLength = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM) * 10.0;
}
......@@ -672,10 +674,12 @@ devmode_to_settings (GtkPrintSettings *settings,
-1, NULL, NULL, NULL);
if (form_name == NULL || form_name[0] == 0)
form_name = g_strdup (_("Custom size"));
/* Lengths in DEVMODE are in tenths of a millimeter */
paper_size = gtk_paper_size_new_custom (form_name,
form_name,
devmode->dmPaperWidth * 10.0,
devmode->dmPaperLength * 10.0,
devmode->dmPaperWidth / 10.0,
devmode->dmPaperLength / 10.0,
GTK_UNIT_MM);
gtk_print_settings_set_paper_size (settings, paper_size);
gtk_paper_size_free (paper_size);
......@@ -954,8 +958,10 @@ devmode_from_settings (GtkPrintSettings *settings,
{
devmode->dmPaperSize = DMPAPER_USER;
devmode->dmFields |= DM_PAPERWIDTH | DM_PAPERLENGTH;
devmode->dmPaperWidth = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM) / 10.0;
devmode->dmPaperLength = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM) / 10.0;
/* Lengths in DEVMODE are in tenths of a millimeter */
devmode->dmPaperWidth = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM) * 10.0;
devmode->dmPaperLength = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM) * 10.0;
}
gtk_paper_size_free (paper_size);
}
......@@ -1726,7 +1732,6 @@ _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation
gchar **target)
{
GtkPaperSize *paper_size;
double w, h;
HDC metafile_dc;
RECT rect;
char *template;
......@@ -1745,13 +1750,12 @@ _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation
g_free (filename);
paper_size = gtk_page_setup_get_paper_size (page_setup);
w = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM);
h = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM);
/* The rectangle dimensions are given in hundredths of a millimeter */
rect.left = 0;
rect.right = w*100;
rect.right = 100.0 * gtk_paper_size_get_width (paper_size, GTK_UNIT_MM);
rect.top = 0;
rect.bottom = h*100;
rect.bottom = 100.0 * gtk_paper_size_get_height (paper_size, GTK_UNIT_MM);
metafile_dc = CreateEnhMetaFileW (NULL, filename_utf16,
&rect, L"Gtk+\0Print Preview\0\0");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment