]> git.lyx.org Git - features.git/commitdiff
Implement checks for available modules both in BufferParams and in the gui.
authorRichard Heck <rgheck@comcast.net>
Sat, 5 Jan 2008 16:56:30 +0000 (16:56 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 5 Jan 2008 16:56:30 +0000 (16:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22387 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferParams.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h

index 11145b8189424076579b679df22ec667744476da..dc2823911dc75cc136a1c453ecf87a6a14f9b575 100644 (file)
@@ -1413,6 +1413,13 @@ void BufferParams::makeTextClass()
                                        endl;
                        continue;
                }
+               if (!lm->isAvailable()) {
+                       docstring const msg =
+                                               bformat(_("The module %1$s requires a package that is\n"
+                                               "not available in your LaTeX installation. LaTeX output\n"
+                                               "may not be possible.\n"), from_utf8(modName));
+                       frontend::Alert::warning(_("Package not available"), msg);
+               }
                FileName layout_file = libFileSearch("layouts", lm->filename);
                textClass_->read(layout_file, TextClass::MODULE);
        }
index d884e9b9f6bee74dfd9f7c522ffa5ff36b8ca946..7063e9e0e2d2c228a6e356280e8d2dc1db4b54e4 100644 (file)
@@ -951,8 +951,16 @@ void GuiDocument::updateModuleInfo()
                        }
                        pkgdesc += pkgList[i];
                }
-               if (!pkgdesc.empty())
-                       desc += " Requires " + pkgdesc + ".";
+               if (!pkgdesc.empty()) {
+                       if (!desc.empty())
+                               desc += " ";
+                       desc += ("Requires " + pkgdesc + ".");
+               }
+               if (!isModuleAvailable(modName)) {
+                       if (!desc.empty())
+                               desc += "\n";
+                       desc += "WARNING: Some packages are unavailable!";
+               }
                latexModule->infoML->document()->setPlainText(toqstr(desc));
        }
 }
@@ -1689,13 +1697,12 @@ string GuiDocument::getModuleDescription(string const & modName) const
 {
        LyXModule const * const mod = moduleList[modName];
        if (!mod)
-               return string("Module unavailable!");
+               return string("Module not found!");
        return mod->description;
 }
 
 
-vector<string>
-GuiDocument::getPackageList(string const & modName) const
+vector<string> GuiDocument::getPackageList(string const & modName) const
 {
        LyXModule const * const mod = moduleList[modName];
        if (!mod)
@@ -1704,6 +1711,13 @@ GuiDocument::getPackageList(string const & modName) const
 }
 
 
+bool GuiDocument::isModuleAvailable(string const & modName) const
+{
+       LyXModule * mod = moduleList[modName];
+       return mod->isAvailable();
+}
+
+
 TextClass const & GuiDocument::textClass() const
 {
        return textclasslist[bp_.getBaseClass()];
index 5fb2e3082829ca5b4cabc9d307a87519ae8a5ab1..90a93f8314d6cef7114bf4de146cf2b1b1530bf2 100644 (file)
@@ -186,6 +186,8 @@ protected:
        ///
        std::vector<std::string> getPackageList(std::string const & modName) const;
        ///
+       bool isModuleAvailable(std::string const & modName) const;
+       ///
        void setLanguage() const;
        ///
        void saveAsDefault() const;