[LyX/master] Allow syncing open/close status of branch inset with it's activation status.

Pavel Sanda sanda at lyx.org
Sat Apr 16 21:44:05 UTC 2022


commit 02ffd6dd70be2a376b5d09b55099aa75338a2889
Author: Pavel Sanda <sanda at lyx.org>
Date:   Sun Apr 17 00:16:19 2022 +0200

    Allow syncing open/close status of branch inset with it's activation status.
    
    This was kicked out by 742b39f4 (the code in inset toggle survived).
    https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg217311.html
---
 src/FuncCode.h             |    1 +
 src/LyXAction.cpp          |    9 +++++++++
 src/insets/InsetBranch.cpp |    9 ++++++++-
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/src/FuncCode.h b/src/FuncCode.h
index 20231eb..8337c1f 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -502,6 +502,7 @@ enum FuncCode
 	LFUN_SPELLING_REMOVE_LOCAL,     // jspitzm 20210307
 	LFUN_FINISHED_DOWN,             // lasgouttes 20210629
 	LFUN_FINISHED_UP,               // lasgouttes 20210629
+	LFUN_BRANCH_SYNC_ALL,           // sanda 20220415
 	LFUN_LASTACTION                 // end of the table
 };
 
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index ea60f53..c88c1b9 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -453,6 +453,15 @@ void LyXAction::init()
 		{ LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
 
 /*!
+ * \var lyx::FuncCode lyx::LFUN_BRANCH_SYNC_ALL
+ * \li Action: Open/close all insets of selected branch (depending on its selection status).
+ * \li Syntax: branch-toggle-all
+ * \li Origin: sanda, 15 April 2022
+ * \endvar
+ */
+		{ LFUN_BRANCH_SYNC_ALL, "branch-sync-all", AtPoint, Buffer },
+
+/*!
  * \var lyx::FuncCode lyx::LFUN_BRANCH_INVERT
  * \li Action: Toggles inversion status of branch inset.
  * \li Syntax: branch-invert
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 7a102ce..a30930a 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -224,9 +224,12 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
 	case LFUN_BRANCH_ADD:
 		lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
 		break;
+	case LFUN_BRANCH_SYNC_ALL:
+		lyx::dispatch(FuncRequest(LFUN_INSET_FORALL, "Branch:" + params_.branch + " inset-toggle assign"));
+		break;
 	case LFUN_INSET_TOGGLE:
 		if (cmd.argument() == "assign")
-			setStatus(cur, isBranchSelected() ? Open : Collapsed);
+			setStatus(cur, (isBranchSelected(true) != params_.inverted) ? Open : Collapsed);
 		else
 			InsetCollapsible::doDispatch(cur, cmd);
 		break;
@@ -276,6 +279,10 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
 		flag.setEnabled(buffer().parent() && isBranchSelected());
 		break;
 
+	case LFUN_BRANCH_SYNC_ALL:
+		flag.setEnabled(known_branch);
+		break;
+
 	case LFUN_INSET_TOGGLE:
 		if (cmd.argument() == "assign")
 			flag.setEnabled(true);


More information about the lyx-cvs mailing list