Move the toolbar flags setting into a separate section to allow the

user to set them easily, as discussed


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7154 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-06-11 19:21:46 +00:00
parent 205fdc7045
commit 5a87c5379a
7 changed files with 118 additions and 49 deletions

View File

@ -1,3 +1,9 @@
2003-06-11 John Levon <levon@movementarian.org>
* ui/stdtoolbars.ui: move flags to ...
* ui/default.ui: ... Toolbars section here
2003-06-11 John Levon <levon@movementarian.org>
* ui/stdtoolbars.ui: show Extra toolbar by default

View File

@ -4,3 +4,24 @@
Include "stdmenus.ui"
Include "stdtoolbars.ui"
# Which toolbars to use.
#
# The second parameter are the flags :
#
# on: the toolbar is visible
# off: the toolbar is not visible
# math: the toolbar is visible only when in math
# table: the toolbar is visible only when in a table
# top: the toolbar should be at the top of the window
# bottom: the toolbar should be at the bottom of the window
# left: the toolbar should be at the left of the window
# right: the toolbar should be at the right of the window
#
Toolbars
"Standard" "on,top"
"Extra" "on,top"
"Table" "off,bottom"
"Math" "off,bottom"
"Command Buffer" "off,bottom"
End

View File

@ -1,17 +1,6 @@
# A Toolbar starts like :
#
# Toolbar "Name" "on"
#
# The second parameter are the flags :
#
# on: the toolbar is visible
# off: the toolbar is not visible
# math: the toolbar is visible only when in math
# table: the toolbar is visible only when in a table
# top: the toolbar should be at the top of the window
# bottom: the toolbar should be at the bottom of the window
# left: the toolbar should be at the left of the window
# right: the toolbar should be at the right of the window
# Toolbar "Name"
#
# Only four commands are allowed inside the begin_toolbar and end_toolbar
# directives:
@ -36,8 +25,6 @@
#
# This is the default toolbar:
# slight rationalisations here
Toolbar "Standard" "on,top"
Layouts
Item "New document" "buffer-new"

View File

@ -1,3 +1,10 @@
2003-06-11 John Levon <levon@movementarian.org>
* lyx_main.C:
* ToolbarBackend.h:
* ToolbarBackend.C: add "Toolbars" section and
put the flags there
2003-06-10 Angus Leeming <leeming@lyx.org>
* lfuns.h:

View File

@ -71,38 +71,6 @@ void ToolbarBackend::read(LyXLex & lex)
tb.name = lex.getString();
lex.next(true);
tb.flags = static_cast<Flags>(0);
string flagstr = lex.getString();
vector<string> flags = getVectorFromString(flagstr);
vector<string>::const_iterator cit = flags.begin();
vector<string>::const_iterator end = flags.end();
for (; cit != end; ++cit) {
int flag = 0;
if (!compare_ascii_no_case(*cit, "off"))
flag = OFF;
else if (!compare_ascii_no_case(*cit, "on"))
flag = ON;
else if (!compare_ascii_no_case(*cit, "math"))
flag = MATH;
else if (!compare_ascii_no_case(*cit, "table"))
flag = TABLE;
else if (!compare_ascii_no_case(*cit, "top"))
flag = TOP;
else if (!compare_ascii_no_case(*cit, "bottom"))
flag = BOTTOM;
else if (!compare_ascii_no_case(*cit, "left"))
flag = LEFT;
else if (!compare_ascii_no_case(*cit, "right"))
flag = RIGHT;
else {
lyxerr << "ToolbarBackend::read: unrecognised token:`"
<< *cit << '\'' << endl;
}
tb.flags = static_cast<Flags>(tb.flags | flag);
}
bool quit = false;
lex.pushTable(toolTags, TO_LAST - 1);
@ -152,6 +120,74 @@ void ToolbarBackend::read(LyXLex & lex)
}
void ToolbarBackend::readToolbars(LyXLex & lex)
{
//consistency check
if (compare_ascii_no_case(lex.getString(), "toolbars")) {
lyxerr << "ToolbarBackend::read: ERROR wrong token:`"
<< lex.getString() << '\'' << endl;
}
lex.next(true);
while (lex.isOK()) {
string name = lex.getString();
lex.next(true);
if (!compare_ascii_no_case(name, "end"))
return;
Toolbars::iterator tcit = toolbars.begin();
Toolbars::iterator tend = toolbars.end();
for (; tcit != tend; ++tcit) {
if (tcit->name == name)
break;
}
if (tcit == tend) {
lyxerr << "ToolbarBackend: undefined toolbar "
<< name << endl;
return;
}
tcit->flags = static_cast<Flags>(0);
string flagstr = lex.getString();
lex.next(true);
vector<string> flags = getVectorFromString(flagstr);
vector<string>::const_iterator cit = flags.begin();
vector<string>::const_iterator end = flags.end();
for (; cit != end; ++cit) {
int flag = 0;
if (!compare_ascii_no_case(*cit, "off"))
flag = OFF;
else if (!compare_ascii_no_case(*cit, "on"))
flag = ON;
else if (!compare_ascii_no_case(*cit, "math"))
flag = MATH;
else if (!compare_ascii_no_case(*cit, "table"))
flag = TABLE;
else if (!compare_ascii_no_case(*cit, "top"))
flag = TOP;
else if (!compare_ascii_no_case(*cit, "bottom"))
flag = BOTTOM;
else if (!compare_ascii_no_case(*cit, "left"))
flag = LEFT;
else if (!compare_ascii_no_case(*cit, "right"))
flag = RIGHT;
else {
lyxerr << "ToolbarBackend::read: unrecognised token:`"
<< *cit << '\'' << endl;
}
tcit->flags = static_cast<Flags>(tcit->flags | flag);
}
usedtoolbars.push_back(*tcit);
}
}
void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
{
tb.items.push_back(make_pair(action, tooltip));

View File

@ -68,16 +68,19 @@ public:
/// iterator for all toolbars
Toolbars::const_iterator begin() const {
return toolbars.begin();
return usedtoolbars.begin();
}
Toolbars::const_iterator end() const {
return toolbars.end();
return usedtoolbars.end();
}
/// read a toolbar from the file
void read(LyXLex &);
/// read the used toolbars
void readToolbars(LyXLex &);
/// return a full path of an XPM for the given action
static string const getIcon(int action);
@ -90,6 +93,9 @@ private:
/// all the toolbars
Toolbars toolbars;
/// toolbars listed
Toolbars usedtoolbars;
};
/// The global instance

View File

@ -635,6 +635,7 @@ void LyX::readUIFile(string const & name)
enum Uitags {
ui_menuset = 1,
ui_toolbar,
ui_toolbars,
ui_include,
ui_last
};
@ -642,7 +643,8 @@ void LyX::readUIFile(string const & name)
struct keyword_item uitags[ui_last - 1] = {
{ "include", ui_include },
{ "menuset", ui_menuset },
{ "toolbar", ui_toolbar }
{ "toolbar", ui_toolbar },
{ "toolbars", ui_toolbars }
};
// Ensure that a file is read only once (prevents include loops)
@ -697,6 +699,10 @@ void LyX::readUIFile(string const & name)
toolbarbackend.read(lex);
break;
case ui_toolbars:
toolbarbackend.readToolbars(lex);
break;
default:
if (!rtrim(lex.getString()).empty())
lex.printError("LyX::ReadUIFile: "