A GUI for nomencl settings. Adds the possibility to enter a custom length.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29779 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-05-22 16:26:15 +00:00
parent 9f48cc9137
commit e9cbe2f80f
13 changed files with 130 additions and 14 deletions

View 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.

View 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

View 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]],

View 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"
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

View 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;

View 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.

View 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: {

View 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")

View 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;
}

View 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")

View 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 \

View File

@ -19,9 +19,11 @@
#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

View 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); }
};