Print bug on Windows ?



I wrote a simple printing test that shows a probable GTK+ bug when run on Windows OS.
Test draws one red rectangle over the page area.

When run on Linux, page preview looks good.
When run on Windows, rectangle does not fill entire area of the page (not counting margins)! I've checked if the problem could be due to larger margins, but that is not it. It seems to be a bug.
Can anyone confirm this.

Screenshot of the correct Linux behaviour is at: http://notecase.sourceforge.net/temp/printtest_ok.jpg Screenshot of incorrect Windows behaviour is at: http://notecase.sourceforge.net/temp/printtest_not_ok.jpg
(save to disk to properly view the big white area at the bottom of the page)

On Windows, I've tested with VS200 using GTK+ 2.10.11 from http://gladewin32.sourceforge.net Later I've updated this GTK to latest 2.12.1 using Tor's "official" Windows build (http://www.gimp.org/~tml/gimp/win32).

Is this a Win32 port bug ?
Does anyone have the same problems ?

Regards,
 Miroslav

PS. Test code:

#include <gtk/gtk.h>

GtkWidget *window1;
void create_window();
static void on_test(GtkButton *button, gpointer user_data);
static void begin_print (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data); static void draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data);

int main (int argc, char *argv[])
{
gtk_init (&argc, &argv);
create_window();
gtk_main ();
return 0;
}

void create_window()
{
GtkWidget *button5;

window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window1), "test");
gtk_widget_show (window1);
g_signal_connect (window1, "destroy", G_CALLBACK (gtk_main_quit), NULL);

button5 = gtk_button_new_with_mnemonic("Click");
gtk_widget_show (button5);
gtk_container_add (GTK_CONTAINER (window1), button5);

g_signal_connect(button5, "clicked", G_CALLBACK (on_test), NULL);
}

void begin_print (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
//one test page
gtk_print_operation_set_n_pages (operation, 1);

GtkPageSetup *page_setup = gtk_print_context_get_page_setup (context);
gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_PORTRAIT);
}

void on_test(GtkButton *button, gpointer user_data)
{
GtkPrintOperation *operation;
GError *error = NULL;

operation = gtk_print_operation_new ();
gtk_print_operation_set_show_progress(operation, TRUE);
gtk_print_operation_set_unit(operation, GTK_UNIT_POINTS);

g_signal_connect (G_OBJECT (operation), "begin-print", G_CALLBACK (begin_print), NULL); g_signal_connect (G_OBJECT (operation), "draw-page", G_CALLBACK (draw_page), NULL);

gtk_print_operation_run (operation, (GtkPrintOperationAction)GTK_PRINT_OPERATION_ACTION_PREVIEW, GTK_WINDOW (window1), &error);
g_object_unref (operation);
}

void draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr,
   gpointer           user_data)
{
cairo_t *cr;

cr = gtk_print_context_get_cairo_context (context);

// draw a red rectangle, as wide as the paper (inside the margins)
cairo_set_source_rgb (cr, 1.0, 0, 0);
cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), gtk_print_context_get_height (context));
cairo_fill (cr);
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]