Handling of context menus of nested insets is very difficult at the
moment. Especially when the insets are of the same type. This was
introduced in cs 24618.

The comment for changeset 24618 read the following:

"Allow LFUN_INSET_SETTINGS with enclosing inset if this particular
dialog has been _explicitely_ requested."

which is about the following piece of code:

Inset & inset = cur.inset();  
if (cmd.getArg(0) == insetName(inset.lyxCode())) {  
     // This inset dialog has been explicitely
     // requested.
     inset.showInsetDialog(bv);
     break;
}

If, however, two notes (e.g.) are nested into each other, then you can't
say that "inset-settings note" _explicitly_ requests the enclosing inset
instead of the 'enclosee'.

The attached patch applies the command to the next-inset in such a case.

Is this OK ?

see:
http://www.lyx.org/trac/changeset/24618
see also:
http://bugzilla.lyx.org/show_bug.cgi?id=4821
Index: src/BufferView.cpp
===================================================================
--- src/BufferView.cpp	(revision 26686)
+++ src/BufferView.cpp	(working copy)
@@ -947,13 +947,14 @@
 
 	case LFUN_INSET_SETTINGS: {
 		InsetCode code = cur.inset().lyxCode();
-		if (cmd.getArg(0) == insetName(code)) {
+		InsetCode next_code = cur.nextInset()
+			? cur.nextInset()->lyxCode() : NO_CODE;
+		if (cmd.getArg(0) == insetName(code)
+		    && cmd.getArg(0) != insetName(next_code)) {
 			flag.setEnabled(true);
 			break;
 		}
 		bool enable = false;
-		InsetCode next_code = cur.nextInset()
-			? cur.nextInset()->lyxCode() : NO_CODE;
 		//FIXME: remove these special cases:
 		switch (next_code) {
 			case TABULAR_CODE:
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp	(revision 26686)
+++ src/Text3.cpp	(working copy)
@@ -842,13 +842,14 @@
 
 	case LFUN_INSET_SETTINGS: {
 		Inset & inset = cur.inset();
-		if (cmd.getArg(0) == insetName(inset.lyxCode())) {
+		Inset * next_inset = cur.nextInset();
+		if (cmd.getArg(0) == insetName(inset.lyxCode()) && (!next_inset
+		    || cmd.getArg(0) != insetName(next_inset->lyxCode()))) {
 			// This inset dialog has been explicitely requested.
 			inset.showInsetDialog(bv);
 			break;
 		}
 		// else, if there is an inset at the cursor, access this
-		Inset * next_inset = cur.nextInset();
 		if (next_inset) {
 			next_inset->showInsetDialog(bv);
 			break;

Reply via email to