Context menu item to add unknown branch (rest of #7643)

This commit is contained in:
Juergen Spitzmueller 2012-09-30 17:32:00 +02:00
parent fab7d42608
commit 3588f2f696
3 changed files with 19 additions and 5 deletions

View File

@ -443,6 +443,7 @@ Menuset
OptItem "Deactivate Branch|e" "branch-deactivate"
OptItem "Activate Branch in Master|M" "branch-master-activate"
OptItem "Deactivate Branch in Master|v" "branch-master-deactivate"
OptItem "Add Unknown Branch|w" "branch-add"
End
#

View File

@ -3501,7 +3501,7 @@ void LyXAction::init()
* \li Origin: spitz, 7 Jul 2009
* \endvar
*/
{ LFUN_BRANCH_ADD, "branch-add", Noop, Buffer },
{ LFUN_BRANCH_ADD, "branch-add", AtPoint, Buffer },
/*!
@ -3536,7 +3536,7 @@ void LyXAction::init()
* \li Origin: spitz, 30 Sep 2012
* \endvar
*/
{ LFUN_BRANCH_MASTER_ACTIVATE, "branch-master-activate", AtPoint, Buffer },
{ LFUN_BRANCH_MASTER_ACTIVATE, "branch-master-activate", AtPoint, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_BRANCH_MASTER_DEACTIVATE
* \li Action: De-activate the branch in the master buffer.
@ -3545,7 +3545,7 @@ void LyXAction::init()
* \li Origin: spitz, 30 Sep 2012
* \endvar
*/
{ LFUN_BRANCH_MASTER_DEACTIVATE, "branch-master-deactivate", AtPoint, Buffer },
{ LFUN_BRANCH_MASTER_DEACTIVATE, "branch-master-deactivate", AtPoint, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_BRANCHES_RENAME

View File

@ -23,6 +23,7 @@
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "Lexer.h"
#include "LyX.h"
#include "OutputParams.h"
#include "output_xhtml.h"
#include "TextClass.h"
@ -165,6 +166,9 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
}
break;
}
case LFUN_BRANCH_ADD:
lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
break;
case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign")
setStatus(cur, isBranchSelected() ? Open : Collapsed);
@ -182,13 +186,20 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
bool const known_branch =
buffer().params().branchlist().find(params_.branch);
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
flag.setEnabled(true);
break;
case LFUN_BRANCH_ACTIVATE:
flag.setEnabled(!isBranchSelected(true));
flag.setEnabled(known_branch && !isBranchSelected(true));
break;
case LFUN_BRANCH_ADD:
flag.setEnabled(!known_branch);
break;
case LFUN_BRANCH_DEACTIVATE:
@ -196,7 +207,9 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
break;
case LFUN_BRANCH_MASTER_ACTIVATE:
flag.setEnabled(buffer().parent() && !isBranchSelected());
flag.setEnabled(buffer().parent()
&& buffer().masterBuffer()->params().branchlist().find(params_.branch)
&& !isBranchSelected());
break;
case LFUN_BRANCH_MASTER_DEACTIVATE: