Pavel Sanda wrote:
> great , i'll prepare new patch once Juergen stuff is in.

if there is no objection i'll commit this one soon.
pavel
diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc
index f0d8778..6758889 100644
--- a/lib/ui/stdmenus.inc
+++ b/lib/ui/stdmenus.inc
@@ -463,6 +463,8 @@ Menuset
 
        Menu "insert_branches"
                Branches
+               Separator
+               Item "Insert New Branch...|I" "branch-add-insert"
        End
        
        Menu "insert_phantom"
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 94d8c05..936dcff 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -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;
        }
diff --git a/src/FuncCode.h b/src/FuncCode.h
index 3d879d0..682ed20 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -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
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 4282139..2cc46a1 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -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

Reply via email to