]> git.lyx.org Git - features.git/commitdiff
A GUI for nomencl settings. Adds the possibility to enter a custom length.
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 22 May 2009 16:26:15 +0000 (16:26 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 22 May 2009 16:26:15 +0000 (16:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29779 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
development/FORMAT
development/scons/scons_manifest.py
lib/lyx2lyx/lyx_2_0.py
lib/ui/stdcontext.inc
src/Buffer.cpp
src/LyXAction.cpp
src/LyXFunc.cpp
src/Text3.cpp
src/frontends/qt4/GuiPrintindex.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Makefile.am
src/insets/InsetNomencl.cpp
src/insets/InsetNomencl.h

index 3e819429e92a7284af8460585d556dcf72a3c51a..7aa34539104dd262a4e614646e24090ee556ec16 100644 (file)
@@ -1,7 +1,11 @@
 LyX file-format changes
 -----------------------
 
-2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
+2009-05-22 Jürgen Spitzmüller <spitz@lyx.org>
+       * Format incremented to 360: param width for nomencl_print
+       CommandInset.
+
+2009-05-22 Jürgen Spitzmüller <spitz@lyx.org>
        * Format incremented to 359: param set_width for nomencl_print
        CommandInset.
 
index bba4c29cdf65f9cb03de8e23aca96a8ffdb39add..fe384078d1c6a12deafc5f67095f9ccd3e3d24c3 100644 (file)
@@ -746,6 +746,7 @@ src_frontends_qt4_header_files = Split('''
     GuiPrefs.h
     GuiPrint.h
     GuiPrintindex.h
+    GuiPrintNomencl.h
     GuiRef.h
     GuiSearch.h
     GuiSelection.h
@@ -841,6 +842,7 @@ src_frontends_qt4_files = Split('''
     GuiPrefs.cpp
     GuiPrint.cpp
     GuiPrintindex.cpp
+    GuiPrintNomencl.cpp
     GuiRef.cpp
     GuiSearch.cpp
     GuiSelection.cpp
@@ -953,6 +955,7 @@ src_frontends_qt4_ui_files = Split('''
     PrefsUi.ui
     PrintUi.ui
     PrintindexUi.ui
+    PrintNomenclUi.ui
     RefUi.ui
     SearchUi.ui
     SendtoUi.ui
index bd4a4778ea594d74a95d4f74867a627235e7c57b..2d562a373f22271f5af20b23fc793fc3c4b298ee 100644 (file)
@@ -688,6 +688,25 @@ def revert_nomencl_width(document):
       i = i + 1
 
 
+def revert_nomencl_cwidth(document):
+    " Remove width param from nomencl_print "
+    i = 0
+    while True:
+      i = find_token(document.body, "\\begin_inset CommandInset nomencl_print", i)
+      if i == -1:
+        break
+      j = find_end_of_inset(document.body, i)
+      l = find_token(document.body, "width", i, j)
+      if l == -1:
+            document.warning("Can't find width option for nomencl_print!")
+            i = j
+            continue
+      width = get_value(document.body, "width", i, j).strip('"')
+      del document.body[l]
+      add_to_preamble(document, ["\\setlength{\\nomlabelwidth}{" + width + "}"])
+      i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -706,10 +725,12 @@ convert = [[346, []],
            [356, []],
            [357, []],
            [358, []],
-           [359, [convert_nomencl_width]]
+           [359, [convert_nomencl_width]],
+           [360, []]
           ]
 
-revert =  [[358, [revert_nomencl_width]],
+revert =  [[359, [revert_nomencl_cwidth]],
+           [358, [revert_nomencl_width]],
            [357, [revert_custom_processors]],
            [356, [revert_ulinelatex]],
            [355, [revert_uulinewave]],
index 4b5bc7ca6b55418a8fd6b3c24cb5393d83e165cb..5794c52b905f6200f6020fc3a8c3bcc21349bb74 100644 (file)
@@ -43,7 +43,7 @@ Menuset
                Item "Eqnarray Environment|E" "math-mutate eqnarray"
                Submenu "AMS Environment|A" "ams_environment"
                Separator               
-               OptItem "Number whole Formula|N" "math-number-toggle"\r
+               OptItem "Number whole Formula|N" "math-number-toggle"
                OptItem "Number this Line|u" "math-number-line-toggle"
                OptItem "Equation Label|L" "label-insert"
                OptItem "Copy as Reference|R" "copy-label-as-reference"
@@ -534,6 +534,14 @@ Menuset
                OptItem "Settings...|S" "inset-settings"
        End
 
+#
+# Nomencl List context menu
+#
+
+       Menu "context-nomenclprint"
+               OptItem "Settings...|S" "inset-settings"
+       End
+
 
 #
 # Toc Changes context menu
index 8dca38038dd28c87a6ade9d62f5664f1e5b7724b..d9d9547df5d00f26556036b5e141fd24718756d5 100644 (file)
@@ -125,7 +125,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 359;  // jspitzm: nomencl auto calculation
+int const LYX_FORMAT = 360;  // jspitzm: nomencl custom width
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
index 40322b3edb6e74402801a2f357901a83dcb6bcfa..a45643eb1d3e3e28cf3af8db58f74da28e1edb0f 100644 (file)
@@ -2529,9 +2529,9 @@ void LyXAction::init()
  * \li Params: <NAME>: aboutlyx|bibitem|bibtex|box|branch|changes|character|citation|\n
                document|errorlist|ert|external|file|findreplace|findreplaceadv|float|graphics|\n
                href|include|index|index_print|info|label|listings|log|mathdelimiter|\n
-               mathmatrix|mathspace|nomenclature|note|paragraph|phantom|prefs|print|ref|\n
-               sendto|space|spellchecker|symbols|tabular|tabularcreate|thesaurus|texinfo|\n
-               toc|view-source|vspace|wrap|<SPECIAL> \n
+               mathmatrix|mathspace|nomenclature|note|paragraph|phantom|prefs|print|\n
+               nomencl_print|ref|sendto|space|spellchecker|symbols|tabular|tabularcreate|\n
+               thesaurus|texinfo|toc|view-source|vspace|wrap|<SPECIAL> \n
                <SPECIAL>: latexlog|vclog \n
                <DATA>: data, usually settings for the given dialog. Use debug mode for the
                        details.
index 77802907b952124275fa4234c40a7d7dcf5adc1c..1cd5375e20de6ce2bcfdb64e8315ec306fa8885e 100644 (file)
@@ -1129,6 +1129,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        case INDEX_CODE:
                        case LABEL_CODE:
                        case NOMENCL_CODE:
+                       case NOMENCL_PRINT_CODE:
                        case REF_CODE:
                        case TOC_CODE:
                        case HYPERLINK_CODE: {
index 5121b5808a1f451a06c7e275c9cb39176ffd52df..c8e4a4b1ead300c1196a1fbda9ffca122ce7bedb 100644 (file)
@@ -1630,7 +1630,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                dispatch(cur, fr);
                break;
        }
-
+       
        case LFUN_NOMENCL_PRINT:
        case LFUN_TOC_INSERT:
        case LFUN_LINE_INSERT:
@@ -2127,6 +2127,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        code = INDEX_PRINT_CODE;
                else if (cmd.argument() == "nomenclature")
                        code = NOMENCL_CODE;
+               else if (cmd.argument() == "nomencl_print")
+                       code = NOMENCL_PRINT_CODE;
                else if (cmd.argument() == "label")
                        code = LABEL_CODE;
                else if (cmd.argument() == "note")
index 3542ebfdef81af1b967e23c5aaba475e695ab1ac..c639fd9e4735e978c96872bac29c31c4898f4a6b 100644 (file)
@@ -114,6 +114,7 @@ bool GuiPrintindex::initialiseParams(string const & data)
        // The name passed with LFUN_INSET_APPLY is also the name
        // used to identify the mailer.
        InsetCommand::string2params("index_print", data, params_);
+       paramsToDialog(params_);
        return true;
 }
 
index 044ec2beb2b8a3b01b3d5e3a9d192cf20e93f31d..a2f86c26fadacd5af855d64e19da0e9ceafff055 100644 (file)
@@ -2420,9 +2420,9 @@ char const * const dialognames[] = {
 "findreplaceadv", "float", "graphics", "href", "include", "index",
 "index_print", "info", "listings", "label", "log", "mathdelimiter",
 "mathmatrix", "mathspace", "nomenclature", "note", "paragraph", "phantom",
-"prefs", "print", "ref", "sendto", "space", "spellchecker", "symbols",
-"tabular", "tabularcreate", "thesaurus", "texinfo", "toc", "view-source",
-"vspace", "wrap" };
+"prefs", "print", "nomencl_print", "ref", "sendto", "space", "spellchecker",
+"symbols", "tabular", "tabularcreate", "thesaurus", "texinfo", "toc",
+"view-source", "vspace", "wrap" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -2611,6 +2611,7 @@ Dialog * createGuiPhantom(GuiView & lv);
 Dialog * createGuiPreferences(GuiView & lv);
 Dialog * createGuiPrint(GuiView & lv);
 Dialog * createGuiPrintindex(GuiView & lv);
+Dialog * createGuiPrintNomencl(GuiView & lv);
 Dialog * createGuiRef(GuiView & lv);
 Dialog * createGuiSearch(GuiView & lv);
 Dialog * createGuiSearchAdv(GuiView & lv);
@@ -2696,6 +2697,8 @@ Dialog * GuiView::build(string const & name)
                return createGuiPreferences(*this);
        if (name == "print")
                return createGuiPrint(*this);
+       if (name == "nomencl_print")
+               return createGuiPrintNomencl(*this);
        if (name == "ref")
                return createGuiRef(*this);
        if (name == "sendto")
index 99319b1691180d55d9406da9449aa8a36f79e015..634e336ce8b545c9988b76e08cf2fe19973a6986 100644 (file)
@@ -106,6 +106,7 @@ SOURCEFILES = \
        GuiPrefs.cpp \
        GuiPrint.cpp \
        GuiPrintindex.cpp \
+       GuiPrintNomencl.cpp \
        GuiRef.cpp \
        GuiSearch.cpp \
        GuiSelection.cpp \
@@ -203,6 +204,7 @@ MOCHEADER = \
        GuiPrefs.h \
        GuiPrint.h \
        GuiPrintindex.h \
+       GuiPrintNomencl.h \
        GuiRef.h \
        GuiSearch.h \
        GuiSelection.h \
@@ -302,6 +304,7 @@ UIFILES = \
        PrefUi.ui \
        PrintUi.ui \
        PrintindexUi.ui \
+       PrintNomenclUi.ui \
        RefUi.ui \
        SearchUi.ui \
        SendtoUi.ui \
index 0389afe7fe34d72bee32a4bc85b8670ac96857af..d73b701f2929dab14b57304b3fdf2cedbb38f0d3 100644 (file)
 #include "DispatchResult.h"
 #include "Font.h"
 #include "FuncRequest.h"
+#include "FuncStatus.h"
 #include "InsetIterator.h"
 #include "InsetList.h"
 #include "LaTeXFeatures.h"
+#include "Length.h"
 #include "MetricsInfo.h"
 #include "sgml.h"
 
@@ -122,7 +124,7 @@ void InsetNomencl::validate(LaTeXFeatures & features) const
 /////////////////////////////////////////////////////////////////////
 
 InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
-       : InsetCommand(p, "printnomenclature")
+       : InsetCommand(p, "nomencl_print")
 {}
 
 
@@ -134,8 +136,10 @@ ParamInfo const & InsetPrintNomencl::findInfo(string const & /* cmdName */)
        static ParamInfo param_info_;
        if (param_info_.empty()) {
                // how is the width set?
-               // values: none|auto
+               // values: none|auto|custom
                param_info_.add("set_width", ParamInfo::LYX_INTERNAL);
+               // custom width
+               param_info_.add("width", ParamInfo::LYX_INTERNAL);
        }
        return param_info_;
 }
@@ -147,6 +151,47 @@ docstring InsetPrintNomencl::screenLabel() const
 }
 
 
+void InsetPrintNomencl::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+       switch (cmd.action) {
+
+       case LFUN_INSET_MODIFY: {
+               InsetCommandParams p(NOMENCL_PRINT_CODE);
+               // FIXME UNICODE
+               InsetCommand::string2params("nomencl_print",
+                       to_utf8(cmd.argument()), p);
+               if (p.getCmdName().empty()) {
+                       cur.noUpdate();
+                       break;
+               }
+               setParams(p);
+               break;
+       }
+
+       default:
+               InsetCommand::doDispatch(cur, cmd);
+               break;
+       }
+}
+
+
+bool InsetPrintNomencl::getStatus(Cursor & cur, FuncRequest const & cmd,
+       FuncStatus & status) const
+{
+       switch (cmd.action) {
+
+       case LFUN_INSET_DIALOG_UPDATE:
+       case LFUN_INSET_MODIFY:
+               status.setEnabled(true);
+               return true;
+
+       default:
+               return InsetCommand::getStatus(cur, cmd, status);
+       }
+}
+
+
+
 int InsetPrintNomencl::docbook(odocstream & os, OutputParams const &) const
 {
        os << "<glossary>\n";
@@ -232,6 +277,16 @@ int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const
                        os << " {}\n";
                        lines += 5;
                }
+       } else if (getParam("set_width") == "custom") {
+               // custom length as optional arg of \printnomenclature
+               string const width =
+                       Length(to_ascii(getParam("width"))).asLatexString();
+               os << '\\'
+                  << from_ascii(getCmdName())
+                  << '['
+                  << from_ascii(width)
+                  << "]{}";
+               return lines;
        }
        // output the command \printnomenclature
        os << getCommand();
@@ -253,4 +308,10 @@ InsetCode InsetPrintNomencl::lyxCode() const
 }
 
 
+docstring InsetPrintNomencl::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-nomenclprint");
+}
+
+
 } // namespace lyx
index 87595fd1ea05a471555a79c08bc44553d2c676ff..5ebf4964d1cf7cf29d9888827cedbbd43ed351ab 100644 (file)
@@ -66,6 +66,8 @@ public:
        ///
        InsetCode lyxCode() const;
        ///
+       bool hasSettings() const { return true; }
+       ///
        DisplayType display() const { return AlignCenter; }
        ///
        docstring screenLabel() const;
@@ -78,6 +80,13 @@ public:
                { return s == "printnomenclature"; }
        ///
        int latex(odocstream &, OutputParams const &) const;
+       ///
+       docstring contextMenu(BufferView const & bv, int x, int y) const;
+protected:
+       ///
+       void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
 private:
        Inset * clone() const { return new InsetPrintNomencl(*this); }
 };