]> git.lyx.org Git - features.git/commitdiff
Add LFUN_BRANCH_ADD_INSERT.
authorPavel Sanda <sanda@lyx.org>
Sat, 11 Jul 2009 09:38:31 +0000 (09:38 +0000)
committerPavel Sanda <sanda@lyx.org>
Sat, 11 Jul 2009 09:38:31 +0000 (09:38 +0000)
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

lib/ui/stdmenus.inc
src/BufferView.cpp
src/FuncCode.h
src/LyXAction.cpp

index f0d8778b2b0a2d2a46c930979ef9a9293d9e51a3..675888921830ccafa75f3bcefcb5a7638fcaeca6 100644 (file)
@@ -463,6 +463,8 @@ Menuset
 
        Menu "insert_branches"
                Branches
+               Separator
+               Item "Insert New Branch...|I" "branch-add-insert"
        End
        
        Menu "insert_phantom"
index 94d8c056bac533e22c44d87bca3209b0c1365458..936dcffc9af6abe4442a3c424506bd7030a23eef 100644 (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;
        }
index 3d879d04245bdaeb8d6e6c27263a7b403eda84fb..682ed20e0b1482486583472c73af2b89d05313ff 100644 (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
index 42085c8b33d32a17f901f6be51593797fe9da66a..0585e9e3c59310c883b9eb5f87a5646660cd385f 100644 (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