X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=ps%2Fps-document.c;h=34579674c302add2e07d0964c4e537ee323c0638;hb=fd14b21cb40cce1c61d8eafa9cc03ea59160892b;hp=3ce591f9efaf10db08cc214e5f8c3456da273ea2;hpb=f70259ac7eb87fe33ba3c99afc20b044f9121cb6;p=evince.git diff --git a/ps/ps-document.c b/ps/ps-document.c index 3ce591f9..34579674 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -210,6 +210,9 @@ push_pixbuf (PSDocument *gs) GdkColormap *cmap; GdkPixbuf *pixbuf; int width, height; + + if (gs->pstarget == NULL) + return; cmap = gdk_window_get_colormap (gs->pstarget); gdk_drawable_get_size (gs->bpixmap, &width, &height); @@ -311,6 +314,9 @@ setup_pixmap (PSDocument *gs, int page, double scale, int rotation) GdkColormap *colormap; double width, height; int pixmap_width, pixmap_height; + + if (gs->pstarget == NULL) + return; ev_document_get_page_size (EV_DOCUMENT (gs), page, &width, &height); @@ -616,7 +622,7 @@ start_interpreter (PSDocument *gs) #define NUM_GS_ARGS (NUM_ARGS - 20) #define NUM_ALPHA_ARGS 10 - char *argv[NUM_ARGS], *dir, *gv_env; + char *argv[NUM_ARGS], *dir, *gv_env, *gs_path; char **gs_args, **alpha_args = NULL; int argc = 0, i; @@ -628,7 +634,9 @@ start_interpreter (PSDocument *gs) stop_interpreter(gs); /* set up the args... */ - gs_args = g_strsplit (gtk_gs_defaults_get_interpreter_cmd (), " ", NUM_GS_ARGS); + gs_path = g_find_program_in_path ("gs"); + gs_args = g_strsplit (gs_path, " ", NUM_GS_ARGS); + g_free (gs_path); for(i = 0; i < NUM_GS_ARGS && gs_args[i]; i++, argc++) { argv[argc] = gs_args[i]; } @@ -889,7 +897,7 @@ check_filecompressed (PSDocument * gs) /* report error */ filename_dsp = g_filename_display_name (gs->gs_filename); - msg = g_strdup_printf (_("Error while decompressing file %s:\n"), filename_dsp); + msg = g_strdup_printf (_("Error while decompressing file “%s”:\n"), filename_dsp); g_free (filename_dsp); interpreter_failed (gs, msg); @@ -949,7 +957,7 @@ document_load (PSDocument *gs, const gchar *fname) gchar *msg; filename_dsp = g_filename_display_name (fname); - msg = g_strdup_printf (_("Cannot open file %s.\n"), filename_dsp); + msg = g_strdup_printf (_("Cannot open file “%s”.\n"), filename_dsp); g_free (filename_dsp); interpreter_failed (gs, msg); @@ -1056,27 +1064,39 @@ ps_document_load (EvDocument *document, const char *uri, GError **error) { - gboolean result; char *filename; + char *gs_path; + gboolean result; filename = g_filename_from_uri (uri, NULL, error); if (!filename) return FALSE; - result = document_load (PS_DOCUMENT (document), filename); - if (!result) { - gchar *filename_dsp; - - filename_dsp = g_filename_display_name (filename); - - g_set_error (error, G_FILE_ERROR, - G_FILE_ERROR_FAILED, - _("Failed to load document '%s'"), - filename_dsp); - - g_free (filename_dsp); + gs_path = g_find_program_in_path ("gs"); + if (!gs_path) { + gchar *filename_dsp; + filename_dsp = g_filename_display_name (filename); + g_set_error(error, + G_FILE_ERROR, + G_FILE_ERROR_NOENT, + _("Failed to load document “%s”. Ghostscript interpreter was not found in path"), + filename); + g_free (filename_dsp); + result = FALSE; + } else { + result = document_load (PS_DOCUMENT (document), filename); + if (!result) { + gchar *filename_dsp; + filename_dsp = g_filename_display_name (filename); + + g_set_error (error, G_FILE_ERROR, + G_FILE_ERROR_FAILED, + _("Failed to load document “%s”"), + filename_dsp); + g_free (filename_dsp); + } + g_free (gs_path); } - g_free (filename); return result;