Add LFUN_BRANCH_ADD_INSERT.

http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg152890.html


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30467 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2009-07-11 09:38:31 +00:00
parent 5c4758357f
commit edb52c37d2
4 changed files with 39 additions and 0 deletions

View File

@ -463,6 +463,8 @@ Menuset
Menu "insert_branches"
Branches
Separator
Item "Insert New Branch...|I" "branch-add-insert"
End
Menu "insert_phantom"

View File

@ -935,6 +935,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
case LFUN_NOTES_MUTATE:
case LFUN_ALL_INSETS_TOGGLE:
case LFUN_STATISTICS:
case LFUN_BRANCH_ADD_INSERT:
flag.setEnabled(true);
break;
@ -1504,6 +1505,29 @@ bool BufferView::dispatch(FuncRequest const & cmd)
break;
}
case LFUN_BRANCH_ADD_INSERT: {
docstring branch_name = from_utf8(cmd.getArg(0));
if (branch_name.empty())
if (!Alert::askForText(branch_name, _("Branch name")) ||
branch_name.empty())
break;
DispatchResult drtmp;
buffer_.dispatch(FuncRequest(LFUN_BRANCH_ADD, branch_name), drtmp);
if (drtmp.error()) {
Alert::warning(_("Branch already exists"), drtmp.message());
break;
}
BranchList & branch_list = buffer_.params().branchlist();
Branch const * branch = branch_list.find(branch_name);
string const x11hexname = X11hexname(branch->color());
docstring const str = branch_name + ' ' + from_ascii(x11hexname);
lyx::dispatch(FuncRequest(LFUN_SET_COLOR, str));
lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
break;
}
default:
return false;
}

View File

@ -436,6 +436,8 @@ enum FuncCode
LFUN_BUFFER_EXPORT, // Lgb 97-07-29
LFUN_BUFFER_TOGGLE_COMPRESSION, // bpeng 20060427
LFUN_BRANCH_ADD, // spitz 20090707
LFUN_BRANCH_ADD_INSERT,
// 340
LFUN_BRANCHES_RENAME, // spitz 20090709
LFUN_LASTACTION // end of the table

View File

@ -3327,6 +3327,17 @@ void LyXAction::init()
* \endvar
*/
{ LFUN_BRANCHES_RENAME, "branches-rename", Noop, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_BRANCH_ADD_INSERT
* \li Action: Create new branch and directly put the branch inset into
the document.
* \li Syntax: branch-add-insert [<NAME>]
* \li Params: <NAME>: Branch name. If it is not specified, you will be asked.
* \li Origin: sanda, 10 Jul 2009
* \endvar
*/
{ LFUN_BRANCH_ADD_INSERT, "branch-add-insert", Noop, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_LABEL_COPY_AS_REF