]> www.fi.muni.cz Git - evince.git/commitdiff
Runtime check for gs interpreter. Fix for the bug #320868. Thanks to
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 12 Feb 2006 23:02:46 +0000 (23:02 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 12 Feb 2006 23:02:46 +0000 (23:02 +0000)
* configure.ac:
* ps/gsdefaults.c: (gtk_gs_defaults_get_paper_sizes):
* ps/gsdefaults.h:
* ps/ps-document.c: (start_interpreter), (ps_document_load):

Runtime check for gs interpreter. Fix for the bug #320868.
Thanks to Antoine Dopffer antoine.dopffer@free.fr

ChangeLog
configure.ac
ps/gsdefaults.c
ps/gsdefaults.h
ps/ps-document.c

index fd14ad8a1b83a2c35293483e44f7dd3d750262e9..1167b7d34710f26dc053d84c232ad37d5226f672 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-02-13  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * configure.ac:
+       * ps/gsdefaults.c: (gtk_gs_defaults_get_paper_sizes):
+       * ps/gsdefaults.h:
+       * ps/ps-document.c: (start_interpreter), (ps_document_load):
+       
+       Runtime check for gs interpreter. Fix for the bug #320868.
+       Thanks to Antoine Dopffer antoine.dopffer@free.fr
+
 2006-02-12  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-application.c: 
index 3035de75d85c454853ec19186c584264b132f581..aafd6f3c7fe942a32bd4aabf2846ef05a79de725 100644 (file)
@@ -171,19 +171,6 @@ fi
 AM_CONDITIONAL(ENABLE_PS, test x$enable_ps = xyes)
 
 if test x$enable_ps = xyes; then
-AC_ARG_WITH(gs,
-            [AC_HELP_STRING([--with-gs=dir], [Directory Where GhostScript package is installed.])])
-
-if test "x$with_gs" = "x"; then
-        AC_PATH_PROG(GS_PROG, gs)
-        if test -z "$GS_PROG"; then
-                AC_MSG_ERROR(Unable to find GhostScript in the PATH. Provide the full path for GhostScript(--with-gs=PATH). You need to have Ghostscript installed in order to run evince)
-        fi
-else
-        GS_PROG=$with_gs
-fi
-
-AC_DEFINE_UNQUOTED(GS_PATH, "$GS_PROG", [Path to the 'gs' executable.])
 
 dnl check for GS version
 AC_MSG_CHECKING(for Ghostscript version...)
index a0c61d5a3fbb4a536410420bc7c4218d82e1bf8c..2263fcac0f61eb63694c2c7e40de452f8025383f 100644 (file)
@@ -51,13 +51,7 @@ GtkGSPaperSize gtk_gs_paper_sizes[] = {
 GtkGSPaperSize *
 gtk_gs_defaults_get_paper_sizes()
 {
-  return gtk_gs_paper_sizes;
-}
-
-const gchar *
-gtk_gs_defaults_get_interpreter_cmd()
-{
-    return GS_PATH;
+       return gtk_gs_paper_sizes;
 }
 
 const gchar *
index 08431ff78dcf799e162c4468f609b15cbec2978d..2f50f6f64281069897d8817cfa41cbdc32e44691 100644 (file)
@@ -31,7 +31,6 @@ G_BEGIN_DECLS
 /* defaults accessors */
 
 GtkGSPaperSize *gtk_gs_defaults_get_paper_sizes(void);
-const gchar *gtk_gs_defaults_get_interpreter_cmd(void);
 const gchar *gtk_gs_defaults_get_ungzip_cmd(void);
 const gchar *gtk_gs_defaults_get_unbzip2_cmd(void);
 
index 3ce591f9efaf10db08cc214e5f8c3456da273ea2..75009dc9844f54c4ed8ef6ede8240c26a19d36f9 100644 (file)
@@ -616,7 +616,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 +628,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];
        }
@@ -1056,27 +1058,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;