gs->ps_export_pagelist = NULL;
gs->ps_export_filename = NULL;
-
- gs->orientation = GTK_GS_ORIENTATION_NONE;
}
static void
cmap = gdk_window_get_colormap (gs->pstarget);
gdk_drawable_get_size (gs->bpixmap, &width, &height);
+ LOG ("Get from drawable\n");
pixbuf = gdk_pixbuf_get_from_drawable (NULL, gs->bpixmap, cmap,
0, 0, 0, 0,
width, height);
+ LOG ("Get from drawable done\n");
g_signal_emit_by_name (gs, "render_finished", pixbuf);
g_object_unref (pixbuf);
}
gs->busy = FALSE;
push_pixbuf (gs);
+ LOG ("Pixbuf pushed");
}
return TRUE;
}
static void
-setup_pixmap (PSDocument *gs, int page, double scale)
+setup_pixmap (PSDocument *gs, int page, double scale, int rotation)
{
GdkGC *fill;
GdkColor white = { 0, 0xFFFF, 0xFFFF, 0xFFFF }; /* pixel, r, g, b */
int pixmap_width, pixmap_height;
ev_document_get_page_size (EV_DOCUMENT (gs), page, &width, &height);
- pixmap_width = width * scale + 0.5;
- pixmap_height = height * scale + 0.5;
+
+ if (rotation == 90 || rotation == 270) {
+ pixmap_height = width * scale + 0.5;
+ pixmap_width = height * scale + 0.5;
+ } else {
+ pixmap_width = width * scale + 0.5;
+ pixmap_height = height * scale + 0.5;
+ }
if(gs->bpixmap) {
int w, h;
*lly = new_lly;
}
-static int
-get_page_orientation (PSDocument *gs, int page)
-{
- int orientation;
-
- orientation = GTK_GS_ORIENTATION_NONE;
-
- if (gs->structured_doc) {
- orientation = gs->doc->pages[page].orientation;
- }
- if (orientation == GTK_GS_ORIENTATION_NONE) {
- orientation = gs->doc->default_page_orientation;
- }
- if (orientation == GTK_GS_ORIENTATION_NONE) {
- orientation = gs->doc->orientation;
- }
- if (orientation == GTK_GS_ORIENTATION_NONE) {
- orientation = GTK_GS_ORIENTATION_PORTRAIT;
- }
- if (gs->orientation != GTK_GS_ORIENTATION_NONE) {
- orientation = gs->orientation;
- }
-
- return orientation;
-}
-
static void
-setup_page (PSDocument *gs, int page, double scale)
+setup_page (PSDocument *gs, int page, double scale, int rotation)
{
gchar *buf;
- int urx, ury, llx, lly, orientation;
char scaled_xdpi[G_ASCII_DTOSTR_BUF_SIZE];
char scaled_ydpi[G_ASCII_DTOSTR_BUF_SIZE];
+ int urx, ury, llx, lly;
LOG ("Setup the page");
get_page_box (gs, page, &urx, &ury, &llx, &lly);
- orientation = get_page_orientation (gs, page);
g_ascii_dtostr (scaled_xdpi, G_ASCII_DTOSTR_BUF_SIZE, get_xdpi (gs) * scale);
g_ascii_dtostr (scaled_ydpi, G_ASCII_DTOSTR_BUF_SIZE, get_ydpi (gs) * scale);
buf = g_strdup_printf ("%ld %d %d %d %d %d %s %s %d %d %d %d",
- 0L, orientation * 90, llx, lly, urx, ury,
+ 0L, rotation, llx, lly, urx, ury,
scaled_xdpi, scaled_ydpi,
0, 0, 0, 0);
LOG ("GS property %s", buf);
/* sucessfully uncompressed file */
gs->gs_filename_unc = filename_unc;
} else {
- gchar *utf8 = NULL;
+ gchar *filename_dsp;
gchar *msg;
/* report error */
- utf8 = g_locale_to_utf8 (gs->gs_filename, -1, NULL, NULL, NULL);
-
- if (utf8) {
- msg = g_strdup_printf (_("Error while decompressing file %s:\n"), utf8);
- } else {
- msg = g_strdup (_("Error while decompressing file\n"));
- }
-
- g_free (utf8);
+ filename_dsp = g_filename_display_name (gs->gs_filename);
+ msg = g_strdup_printf (_("Error while decompressing file %s:\n"), filename_dsp);
+ g_free (filename_dsp);
interpreter_failed (gs, msg);
g_free (msg);
gchar *filename = NULL;
if (!file_readable(fname)) {
- gchar *utf8 = NULL;
+ gchar *filename_dsp;
gchar *msg;
- utf8 = g_locale_to_utf8 (fname, -1, NULL, NULL, NULL);
-
- if (utf8) {
- msg = g_strdup_printf (_("Cannot open file %s.\n"), utf8);
- } else {
- msg = g_strdup (_("Cannot open file.\n"));
- }
-
- g_free (utf8);
+ filename_dsp = g_filename_display_name (fname);
+ msg = g_strdup_printf (_("Cannot open file %s.\n"), filename_dsp);
+ g_free (filename_dsp);
interpreter_failed (gs, msg);
g_free (msg);
result = document_load (PS_DOCUMENT (document), filename);
if (!result) {
- gchar *utf8 = NULL;
+ gchar *filename_dsp;
- utf8 = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
+ filename_dsp = g_filename_display_name (filename);
- if (utf8) {
- g_set_error (error, G_FILE_ERROR,
- G_FILE_ERROR_FAILED,
- _("Failed to load document '%s'"),
- utf8);
- } else {
- g_set_error (error, G_FILE_ERROR,
- G_FILE_ERROR_FAILED,
- _("Failed to load document"));
- }
+ g_set_error (error, G_FILE_ERROR,
+ G_FILE_ERROR_FAILED,
+ _("Failed to load document '%s'"),
+ filename_dsp);
- g_free (utf8);
+ g_free (filename_dsp);
}
g_free (filename);
double *height)
{
PSDocument *gs = PS_DOCUMENT (document);
- int w, h;
- int urx, ury, llx, lly, orientation;
+ int urx, ury, llx, lly;
get_page_box (PS_DOCUMENT (document), page, &urx, &ury, &llx, &lly);
- orientation = get_page_orientation (PS_DOCUMENT (document), page);
-
- switch (orientation) {
- case GTK_GS_ORIENTATION_PORTRAIT:
- case GTK_GS_ORIENTATION_UPSIDEDOWN:
- w = (urx - llx) / 72.0 * get_xdpi (gs) + 0.5;
- h = (ury - lly) / 72.0 * get_ydpi (gs) + 0.5;
- break;
- case GTK_GS_ORIENTATION_LANDSCAPE:
- case GTK_GS_ORIENTATION_SEASCAPE:
- w = (ury - lly) / 72.0 * get_xdpi (gs) + 0.5;
- h = (urx - llx) / 72.0 * get_ydpi (gs) + 0.5;
- break;
- default:
- w = h = 0;
- g_assert_not_reached ();
- break;
- }
if (width) {
- *width = w;
+ *width = (urx - llx) / 72.0 * get_xdpi (gs) + 0.5;
}
if (height) {
- *height = h;
+ *height = (ury - lly) / 72.0 * get_ydpi (gs) + 0.5;
}
}
}
static void
-ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double scale)
+ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double scale, int rotation)
{
PSDocument *gs = PS_DOCUMENT (renderer);
gs);
}
- setup_pixmap (gs, page, scale);
- setup_page (gs, page, scale);
+ setup_pixmap (gs, page, scale, rotation);
+ setup_page (gs, page, scale, rotation);
render_page (gs, page);
}