]> 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 ef8b06db3e3527243cc154c8e00a9c2e16306071..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));
@@ -139,6 +140,43 @@ void InsetBranch::priv_dispatch(LCursor & cur, FuncRequest & 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;