On Thu, Oct 19, 2006 at 06:58:32PM +0200, Enrico Forestieri wrote:

> Ach! This one actually works for dvipdfm, too.

Uhm, there is no reason to limit this to Windows. I modified the patch
such that a lyxpdfview command is considered a not overridable (by the
auto feature) viewer for pdf on any platform.

In this way one could write a script using the pdfopen and pdfclose
utilities (which are available on linux, too) to circumvent the
brain dead acroread.

However, thinking about it, introducing a noauto flag seems the
right thing to do here, but perhaps we can do that in 1.5 only.

-- 
Enrico
Index: lib/configure.py
===================================================================
--- lib/configure.py    (revision 15373)
+++ lib/configure.py    (working copy)
@@ -84,6 +84,36 @@ def setEnviron():
     os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')
 
 
+def setPDFviewer(prefs):
+    ''' Set the lyxpdfview command directly in preferences if no pdf viewer
+        is already set, such that it is not overridden by the the auto open
+        feature
+    '''
+    if os.access(prefs, os.F_OK):
+        p1 = re.compile(r'^\\format "pdf"')
+        p2 = re.compile(r'^\\format "pdf2"')
+        p3 = re.compile(r'^\\format "pdf3"')
+        r1 = r2 = r3 = None
+        for line in open(prefs).readlines():
+            if r1 == None:
+                r1 = p1.search(line)
+            if r2 == None:
+                r2 = p2.search(line)
+            if r3 == None:
+                r3 = p3.search(line)
+        if r1 == None:
+            writeToFile(prefs, '\\format "pdf" "pdf" "PDF (ps2pdf)" "P" 
"lyxpdfview" ""\n', append = True)
+        if r2 == None:
+            writeToFile(prefs, '\\format "pdf2" "pdf" "PDF (pdflatex)" "F" 
"lyxpdfview" ""\n', append = True)
+        if r3 == None:
+            writeToFile(prefs, '\\format "pdf3" "pdf" "PDF (dvipdfm)" "m" 
"lyxpdfview" ""\n', append = True)
+    else:
+        writeToFile(prefs, '''\\format "pdf" "pdf" "PDF (ps2pdf)" "P" 
"lyxpdfview" ""
+\\format "pdf2" "pdf" "PDF (pdflatex)" "F" "lyxpdfview" ""
+\\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "lyxpdfview" ""
+''')
+
+
 def createDirectories():
     ''' Create the build directories if necessary '''
     for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
@@ -263,9 +293,12 @@ def checkFormatEntries():  
         rc_entry = [r'''\Format eps        eps     EPS                    "" 
"%%"      ""
 \Format ps         ps      Postscript             t  "%%"      ""'''])
     #
-    checkViewer('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \
-                            'xpdf', 'kpdf', 'kghostview'],
-        rc_entry = [r'''\Format pdf        pdf    "PDF (ps2pdf)"          P  
"%%"      ""
+    if (checkProg('a not overridable PDF previewer', ['lyxpdfview']) != ['', 
'']):
+        setPDFviewer("preferences")
+    else:
+        checkViewer('a PDF previewer', ['acrobat', 'acroread', 'gv', 
'ghostview', \
+                                'xpdf', 'kpdf', 'kghostview'],
+            rc_entry = [r'''\Format pdf        pdf    "PDF (ps2pdf)"          
P  "%%"  ""
 \Format pdf2       pdf    "PDF (pdflatex)"        F  "%%"      ""
 \Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"      ""'''])
     #

Reply via email to