]> git.lyx.org Git - features.git/blobdiff - lib/configure.py
Show toolbar context menu only when clicking on the toolbar
[features.git] / lib / configure.py
index aadb156ed11ec7ac9f4582e26cf48021863ed650..1547000b372e25eaf2edb339f471f6d1e5b60a89 100644 (file)
@@ -217,7 +217,7 @@ def checkTeXPaths():
             if sys.version_info[0] < 3:
                 inpname = shortPath(unicode(tmpfname, encoding)).replace('\\', '/')
             else:
-                inpname = shortPath(tmpfname).replace('\\', '/') 
+                inpname = shortPath(tmpfname).replace('\\', '/')
         else:
             inpname = cmdOutput('cygpath -m ' + tmpfname)
         logname = os.path.basename(re.sub("(?i).ltx", ".log", inpname))
@@ -530,19 +530,35 @@ def checkInkscape():
     try:
         aKey = winreg.OpenKey(aReg, r"inkscape.svg\DefaultIcon")
         val = winreg.QueryValueEx(aKey, "")
-        return str(val[0]).split('"')[1]
+        valentry = str(val[0])
+        if valentry.find('"') > 0:
+            return valentry.split('"')[1]
+        elif valentry.find(',') > 0:
+            return valentry.split(',')[0]
+        else:
+            return 'inkscape'
     except EnvironmentError:
         try:
-            aKey = winreg.OpenKey(aReg, r"Applications\inkscape.exe\shell\open\command")
+            aKey = winreg.OpenKey(aReg, r"inkscape.SVG\shell\open\command")
             val = winreg.QueryValueEx(aKey, "")
             return str(val[0]).split('"')[1]
         except EnvironmentError:
-            return 'inkscape'
+            try:
+                aKey = winreg.OpenKey(aReg, r"Applications\inkscape.exe\shell\open\command")
+                val = winreg.QueryValueEx(aKey, "")
+                return str(val[0]).split('"')[1]
+            except EnvironmentError:
+                return 'inkscape'
+
 
 def checkInkscapeStable():
     ''' Check whether we use Inkscape >= 1.0 '''
-    version_string = cmdOutput("inkscape --version")
-    if version_string.find('0.9') > 0:
+    inkscape_bin = inkscape_cl
+    if os.name == 'nt':
+        # Windows needs the full path, quoted if it contains spaces
+        inkscape_bin = quoteIfSpace(os.path.join(inkscape_path, inkscape_cl))
+    version_string = cmdOutput(inkscape_bin + " --version")
+    if version_string.find(' 0.') > 0:
         return False
     else:
         return True
@@ -664,8 +680,7 @@ def checkFormatEntries(dtl_tools):
     #
     checkViewerEditor('a text editor', texteditors,
         rc_entry = [r'''\Format asciichess asc    "Plain text (chess output)"  "" ""   "%%"    ""      ""
-\Format docbook    sgml    DocBook                B  ""        "%%"    "document,menu=export"  ""
-\Format docbook-xml xml   "DocBook (XML)"         "" ""        "%%"    "document,menu=export"  "application/docbook+xml"
+\Format docbook5   xml    "DocBook 5"             "" ""        "%%"    "document,menu=export"  "application/docbook+xml"
 \Format dot        dot    "Graphviz Dot"          "" ""        "%%"    "vector"        "text/vnd.graphviz"
 \Format dviluatex  tex    "LaTeX (dviluatex)"     "" "" "%%"   "document,menu=export"  ""
 \Format platex     tex    "LaTeX (pLaTeX)"        "" "" "%%"   "document,menu=export"  ""
@@ -1142,7 +1157,7 @@ def checkConverterEntries():
 \converter svgz       png        "%%"    ""'''],
             path = ['', inkscape_path])
     #
-    checkProg('Gnuplot', ['gnuplot'], 
+    checkProg('Gnuplot', ['gnuplot'],
         rc_entry = [ r'''\Format gnuplot     "gp, gnuplot"    "Gnuplot"     "" "" ""  "vector" "text/plain"
 \converter gnuplot      pdf6      "python -tt $$s/scripts/gnuplot2pdf.py $$i $$o"    "needauth"''' ])
     #
@@ -1229,7 +1244,6 @@ def checkConverterEntries():
     # Entries that do not need checkProg
     addToRC(r'''
 \converter csv        lyx        "python -tt $$s/scripts/csv2lyx.py $$i $$o"   ""
-\converter docbook    docbook-xml "cp $$i $$o" "xml"
 \converter fen        asciichess "python -tt $$s/scripts/fen2ascii.py $$i $$o" ""
 \converter lyx        lyx13x     "python -tt $$s/lyx2lyx/lyx2lyx -V 1.3 -o $$o $$i"    ""
 \converter lyx        lyx14x     "python -tt $$s/lyx2lyx/lyx2lyx -V 1.4 -o $$o $$i"    ""
@@ -1247,6 +1261,7 @@ def checkConverterEntries():
 \converter klyx       lyx        "python -tt $$s/lyx2lyx/lyx2lyx -c euc_kr -o $$o $$i" ""
 \converter lyxpreview png        "python -tt $$s/scripts/lyxpreview2bitmap.py --png"   ""
 \converter lyxpreview ppm        "python -tt $$s/scripts/lyxpreview2bitmap.py --ppm"   ""
+\converter docbook    docbook5   "cp $$i $$o"  "xml"
 ''')
 
 
@@ -1283,7 +1298,7 @@ def checkOtherEntries():
         rc_entry = [ r'\jbibtex_command "automatic"' ],
         alt_rc_entry = [ r'\jbibtex_alternatives "%%"' ])
     checkProgAlternatives('available index processors',
-        ['texindy $$x -t $$b.ilg', 'makeindex -c -q', 'xindy -M texindy $$x -t $$b.ilg'],
+        ['texindy $$x -t $$b.ilg', 'xindex -l $$lcode', 'makeindex -c -q', 'xindy -M texindy $$x -t $$b.ilg'],
         rc_entry = [ r'\index_command "%%"' ],
         alt_rc_entry = [ r'\index_alternatives "%%"' ])
     checkProg('an index processor appropriate to Japanese',
@@ -1300,6 +1315,7 @@ def checkOtherEntries():
     ## FIXME: MAPLE is not used anywhere
     # path, MAPLE = checkProg('Maple', ['maple'])
     # Add the rest of the entries (no checkProg is required)
+    addToRC(r'''\citation_search_view "python -tt $$s/scripts/lyxpaperview.py"''')
     addToRC(r'''\copier    fig        "python -tt $$s/scripts/fig_copy.py $$i $$o"
 \copier    pstex      "python -tt $$s/scripts/tex_copy.py $$i $$o $$l"
 \copier    pdftex     "python -tt $$s/scripts/tex_copy.py $$i $$o $$l"
@@ -1314,7 +1330,7 @@ def _checkForClassExtension(x):
     else:
         return x.strip()
 
-def processLayoutFile(file, bool_docbook):
+def processLayoutFile(file):
     ''' process layout file and get a line of result
 
         Declare lines look like this:
@@ -1352,7 +1368,7 @@ def processLayoutFile(file, bool_docbook):
         qres = q.match(line)
         if res != None:
             (classtype, optAll, opt, opt1, desc) = res.groups()
-            avai = {'LaTeX': 'false', 'DocBook': bool_docbook}[classtype]
+            avai = {'LaTeX': 'false', 'DocBook': 'true'}[classtype]
             if opt == None:
                 opt = classname
                 prereq_latex = _checkForClassExtension(classname)
@@ -1360,8 +1376,7 @@ def processLayoutFile(file, bool_docbook):
                 prereq_list = optAll[1:-1].split(',')
                 prereq_list = list(map(_checkForClassExtension, prereq_list))
                 prereq_latex = ','.join(prereq_list)
-            prereq_docbook = {'true':'', 'false':'docbook'}[bool_docbook]
-            prereq = {'LaTeX':prereq_latex, 'DocBook':prereq_docbook}[classtype]
+            prereq = {'LaTeX': prereq_latex, 'DocBook': ''}[classtype]
             classdeclaration = ('"%s" "%s" "%s" "%s" "%s"'
                                % (classname, opt, desc, avai, prereq))
             if categorydeclaration != '""':
@@ -1376,7 +1391,7 @@ def processLayoutFile(file, bool_docbook):
     return ""
 
 
-def checkLatexConfig(check_config, bool_docbook):
+def checkLatexConfig(check_config):
     ''' Explore the LaTeX configuration
         Return None (will be passed to sys.exit()) for success.
     '''
@@ -1414,7 +1429,7 @@ def checkLatexConfig(check_config, bool_docbook):
             # make sure the same class is not considered twice
             if foundClasses.count(cleanclass) == 0: # not found before
                 foundClasses.append(cleanclass)
-                retval = processLayoutFile(file, bool_docbook)
+                retval = processLayoutFile(file)
                 if retval:
                     tx.write(retval + os.linesep)
         tx.close()
@@ -1435,7 +1450,7 @@ def checkLatexConfig(check_config, bool_docbook):
     if not os.path.isfile( 'chkconfig.ltx' ):
         shutil.copyfile( os.path.join(srcdir, 'chkconfig.ltx'), 'chkconfig.ltx' )
         rmcopy = True
-    writeToFile('wrap_chkconfig.ltx', '%s\n\\input{chkconfig.ltx}\n' % docbook_cmd)
+    writeToFile('wrap_chkconfig.ltx', '\\def\\hasdocbook{yes}\n\\input{chkconfig.ltx}\n')
     # Construct the list of classes to test for.
     # build the list of available layout files and convert it to commands
     # for chkconfig.ltx
@@ -1548,14 +1563,22 @@ def checkModulesConfig():
           continue
 
       seen.append(filename)
-      retval = processModuleFile(file, filename, bool_docbook)
-      if retval:
-          tx.write(retval)
+      try:
+          retval = processModuleFile(file, filename)
+          if retval:
+              tx.write(retval)
+      except UnicodeDecodeError:
+          logger.warning("**************************************************\n"
+                         "Module file '%s'\n"
+                         "cannot be decoded in utf-8.\n"
+                         "Please check if the file has the correct encoding.\n"
+                         "Skipping this file!\n"
+                         "**************************************************" % filename)
   tx.close()
   logger.info('\tdone')
 
 
-def processModuleFile(file, filename, bool_docbook):
+def processModuleFile(file, filename):
     ''' process module file and get a line of result
 
         The top of a module file should look like this:
@@ -1679,14 +1702,14 @@ def checkCiteEnginesConfig():
           continue
 
       seen.append(filename)
-      retval = processCiteEngineFile(file, filename, bool_docbook)
+      retval = processCiteEngineFile(file, filename)
       if retval:
           tx.write(retval)
   tx.close()
   logger.info('\tdone')
 
 
-def processCiteEngineFile(file, filename, bool_docbook):
+def processCiteEngineFile(file, filename):
     ''' process cite engines file and get a line of result
 
         The top of a cite engine file should look like this:
@@ -1853,7 +1876,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 31
+    lyxrc_fileformat = 33
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
@@ -1918,12 +1941,11 @@ Format %i
     # On Windows, we need to call the "inkscape.com" wrapper
     # for command line purposes. Other OSes do not differentiate.
     inkscape_cl = inkscape_gui
-    inkscape_stable = checkInkscapeStable()
     if os.name == 'nt':
         inkscape_cl = inkscape_gui.replace('.exe', '.com')
+    inkscape_stable = checkInkscapeStable()
     checkFormatEntries(dtl_tools)
     checkConverterEntries()
-    (chk_docbook, bool_docbook, docbook_cmd) = checkDocBook()
     checkTeXAllowSpaces()
     windows_style_tex_paths = checkTeXPaths()
     if windows_style_tex_paths:
@@ -1935,7 +1957,7 @@ Format %i
     checkCiteEnginesConfig()
     checkXTemplates()
     # --without-latex-config can disable lyx_check_config
-    ret = checkLatexConfig(lyx_check_config and LATEX, bool_docbook)
+    ret = checkLatexConfig(lyx_check_config and LATEX)
     removeTempFiles()
     # The return error code can be 256. Because most systems expect an error code
     # in the range 0-127, 256 can be interpretted as 'success'. Because we expect