On Tue, Mar 29, 2022 at 07:54:31AM -0400, Scott Kostyshak wrote:
> On Tue, Mar 29, 2022 at 01:33:32PM +0200, Pavel Sanda wrote:
> > On Mon, Mar 28, 2022 at 07:52:33PM -0400, Scott Kostyshak wrote:
> > > > Is this intended? How do I open all activated branch insets now?
> > > 
> > > I don't know if we have that functionality. Not sure it helps, but to
> > > open all branch insets of "my-branch-name":
> > > 
> > >   inset-forall Branch:my-branch-name inset-toggle open
> > > 
> > > And to close:
> > > 
> > >   inset-forall Branch:my-branch-name inset-toggle close
> > > 
> > > Assuming the above doesn't satisfy your workflow, then we should make a
> > > new LFUN that handles branch insets according to whether they are
> > > activated.
> > 
> > To have an option to open/close them all would be helpful.
> > I don't push for the automatic toggling we used to have but some
> > way how to chage that through UI would be helpful.
> > What would be UI way which wouldn't disturb you?
> 
> I guess in Document > Settings > Branches? 

First I thought it's good idea, but if I added button for toggling
with your lfun, it would be triggered immediately instead after
confirming dialog. Or one would need new params just for this which
feels we are stretching things too far..

> and/or in the context menu when right-clicking on a branch?

The attached patch solves the problem for me.
I would like to get at least the lfun to the master (I can add note about this 
lfun for binding to tutorial). Objections?

If you like I can add the entry to the context menu of branch inset (part of the
current patch), but I am equivalently happy to have in just in my private
patchset.

Pavel
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index ed9a9da9fa..73e9685d68 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -535,6 +535,7 @@ Menuset
                OptItem "Deactivate Branch in Master|v" 
"branch-master-deactivate"
                OptItem "Invert Inset|I" "branch-invert"
                OptItem "Add Unknown Branch|w" "branch-add"
+               OptItem "Toggle All" "branch-toggle-all"
        End
 
 #
diff --git a/src/FuncCode.h b/src/FuncCode.h
index 20231eb164..4306e30eb9 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_TOGGLE_ALL,         // sanda 20220322
        LFUN_LASTACTION                 // end of the table
 };
 
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index ea60f53754..a7dcf29deb 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -452,6 +452,15 @@ void LyXAction::init()
  */
                { LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
 
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BRANCH_TOGGLE_ALL
+ * \li Action: Toggles open/close status of all insets of selected branch.
+ * \li Syntax: branch-toggle-all
+ * \li Origin: sanda, 29 March 2022
+ * \endvar
+ */
+               { LFUN_BRANCH_TOGGLE_ALL, "branch-toggle-all", AtPoint, Buffer 
},
+
 /*!
  * \var lyx::FuncCode lyx::LFUN_BRANCH_INVERT
  * \li Action: Toggles inversion status of branch inset.
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 2b60ca6f44..c486514963 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -224,6 +224,9 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & 
cmd)
        case LFUN_BRANCH_ADD:
                lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
                break;
+       case LFUN_BRANCH_TOGGLE_ALL:
+               lyx::dispatch(FuncRequest(LFUN_INSET_FORALL, "Branch:" + 
params_.branch + " inset-toggle toggle"));
+               break;
        case LFUN_INSET_TOGGLE:
                if (cmd.argument() == "assign")
                        setStatus(cur, isBranchSelected() ? Open : Collapsed);
@@ -276,6 +279,10 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest 
const & cmd,
                flag.setEnabled(buffer().parent() && isBranchSelected());
                break;
 
+       case LFUN_BRANCH_TOGGLE_ALL:
+               flag.setEnabled(known_branch);
+               break;
+
        case LFUN_INSET_TOGGLE:
                if (cmd.argument() == "assign")
                        flag.setEnabled(true);
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to