]> git.lyx.org Git - features.git/blobdiff - src/insets/insetbranch.C
change "support/std_sstream.h" to <sstream>
[features.git] / src / insets / insetbranch.C
index 800e56ceb10debfe2094fad2508c54d4ed7a4ecf..1485bb8f053bdaec9c12845a3b9269b8838ed633 100644 (file)
@@ -23,7 +23,7 @@
 #include "lyxlex.h"
 #include "paragraph.h"
 
-#include "support/std_sstream.h"
+#include <sstream>
 
 using std::string;
 using std::auto_ptr;
@@ -93,7 +93,8 @@ void InsetBranch::setButtonLabel()
        font.decSize();
        font.decSize();
 
-       setLabel("Branch: " + params_.branch);
+       string s = "Branch: " + params_.branch;
+       setLabel(isOpen() ? s : getNewLabel(s) );
        font.setColor(LColor::foreground);
        if (!params_.branch.empty())
                setBackgroundColor(lcolor.getFromLyXName(params_.branch));
@@ -110,7 +111,7 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const
 }
 
 
-void InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetBranch::priv_dispatch(LCursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -139,6 +140,43 @@ void InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        InsetCollapsable::priv_dispatch(cur, cmd);
                break;
 
+
+       case LFUN_INSET_TOGGLE:
+               // We assume that this lfun is indeed going to be dispatched.
+               cur.dispatched();
+
+               if (cmd.argument == "open")
+                       setStatus(Open);
+               else if (cmd.argument == "close") {
+                       setStatus(Collapsed);
+                       leaveInset(cur, *this);
+        } else if (cmd.argument == "toggle") {
+                       if (isOpen()) {
+                               setStatus(Collapsed);
+                               leaveInset(cur, *this);
+                       } else
+                       setStatus(Open);
+
+               // The branch inset uses "assign".
+               } else if (cmd.argument == "assign"
+                          || cmd.argument.empty()) {
+                       BranchList const & branchlist =
+                               cur.buffer().params().branchlist();
+                       if (isBranchSelected(branchlist)) {
+                               if (status() != Open)
+                                       setStatus(Open);
+                               else
+                                       cur.undispatched();
+                       } else {
+                               if (status() != Collapsed) {
+                                       setStatus(Collapsed);
+                                       leaveInset(cur, *this);
+                               } else
+                                       cur.undispatched();
+                       }
+               }
+               break;
+
        default:
                InsetCollapsable::priv_dispatch(cur, cmd);
                break;
@@ -162,7 +200,7 @@ int InsetBranch::latex(Buffer const & buf, ostream & os,
                       OutputParams const & runparams) const
 {
        return isBranchSelected(buf.params().branchlist()) ?
-               inset.latex(buf, os, runparams) : 0;
+               InsetText::latex(buf, os, runparams) : 0;
 }
 
 
@@ -170,7 +208,7 @@ int InsetBranch::linuxdoc(Buffer const & buf, std::ostream & os,
                          OutputParams const & runparams) const
 {
        return isBranchSelected(buf.params().branchlist()) ?
-               inset.linuxdoc(buf, os, runparams) : 0;
+               InsetText::linuxdoc(buf, os, runparams) : 0;
 }
 
 
@@ -178,7 +216,7 @@ int InsetBranch::docbook(Buffer const & buf, std::ostream & os,
                         OutputParams const & runparams) const
 {
        return isBranchSelected(buf.params().branchlist()) ?
-               inset.docbook(buf, os, runparams) : 0;
+               InsetText::docbook(buf, os, runparams) : 0;
 }
 
 
@@ -186,18 +224,18 @@ int InsetBranch::plaintext(Buffer const & buf, std::ostream & os,
                           OutputParams const & runparams) const
 {
        return isBranchSelected(buf.params().branchlist()) ?
-               inset.plaintext(buf, os, runparams): 0;
+               InsetText::plaintext(buf, os, runparams): 0;
 }
 
 
 void InsetBranch::validate(LaTeXFeatures & features) const
 {
-       inset.validate(features);
+       InsetText::validate(features);
 }
 
 
 
-string const InsetBranchMailer:: name_("branch");
+string const InsetBranchMailer::name_("branch");
 
 InsetBranchMailer::InsetBranchMailer(InsetBranch & inset)
        : inset_(inset)