On Thu, Oct 19, 2006 at 06:51:58PM +0200, Enrico Forestieri wrote:
> On Thu, Oct 19, 2006 at 04:22:08PM +0200, Joost Verburg wrote:
> > Jean-Marc Lasgouttes wrote:
> > >What would be the best solution is definitely to have the installer
> > >set pdfview as PDF handler. There is reason to think that LyX is be the
> > >only one which suffers from this *&$^%&^^$!*# braindead Acrobat thing.
> >
> > This is not possible. How can you set something as pdf handler that is
> > actually supposed to use the default pdf handler?
> >
> > >So, if we come back to pdfview (BTW, very bad name, google finds a lot
> > >of different ones). How is it implemented? Is it a script or a
> > >program? Where does it comes from? Does it work only with Acrobat?
> >
> > I'm going to write it if a method to override the auto-detection is
> > accepted. It will be a program and any name you like can be used.
> >
> > It will prevent file locking problems when Acrobat is used (using the
> > pdf tools from Adobe) and will do nothing special when this is not the case.
>
> Joost, what about the attached patch?
>
> On Windows (both Win32 and Cygwin) it directly writes to preferences
> the viewer for the pdf formats, such that the auto feature is overridden.
> However, it first checks that an entry is not already present (meaning
> that the user has chosen something). It works for me.
>
> Jean-Marc, is that acceptable?
Ach! This one actually works for dvipdfm, too.
--
Enrico
Index: lib/configure.py
===================================================================
--- lib/configure.py (revision 15373)
+++ lib/configure.py (working copy)
@@ -84,6 +84,35 @@ def setEnviron():
os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C')
+def setWinPDFviewer(prefs):
+ ''' On Windows, set the pdfview command directly in preferences if none 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"
"pdfview" ""\n', append = True)
+ if r2 == None:
+ writeToFile(prefs, '\\format "pdf2" "pdf" "PDF (pdflatex)" "F"
"pdfview" ""\n', append = True)
+ if r3 == None:
+ writeToFile(prefs, '\\format "pdf3" "pdf" "PDF (dvipdfm)" "m"
"pdfview" ""\n', append = True)
+ else:
+ writeToFile(prefs, '''\\format "pdf" "pdf" "PDF (ps2pdf)" "P"
"pdfview" ""
+\\format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" ""
+\\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" ""
+''')
+
+
def createDirectories():
''' Create the build directories if necessary '''
for dir in ['bind', 'clipart', 'doc', 'examples', 'images', 'kbd', \
@@ -263,9 +292,13 @@ 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 ((os.name == 'nt' or sys.platform == 'cygwin') and
+ checkProg('a PDF previewer', ['pdfview']) != ['', '']):
+ setWinPDFviewer("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 "%%" ""'''])
#