On Wed, Nov 12, 2014 at 4:56 PM, Scott Kostyshak <skost...@lyx.org> wrote:
> On Wed, Nov 12, 2014 at 9:48 AM, Jean-Marc Lasgouttes
> <lasgout...@lyx.org> wrote:
>> For now, I would propose to have the function do nothing in this case, but
>> not be disabled.
>
> Sounds good.

Attached is a patch.

Scott
From bf2776a5b92eb9a282cd5c90b8311ff10b05dd90 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Wed, 12 Nov 2014 20:31:38 -0500
Subject: [PATCH] Do nothing if converting to the same type of Note

The advantage is that the buffer will no longer be
marked as dirty when converting to the same type.

A quick break here is done instead of disabling the
LFUN because disabling the LFUN would lead to a greyed out
entry, which might confuse users. In the future, we might
want to have a radio button for switching between notes.
---
 src/insets/InsetNote.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp
index 6bb294d..3705502 100644
--- a/src/insets/InsetNote.cpp
+++ b/src/insets/InsetNote.cpp
@@ -149,7 +149,18 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
 	switch (cmd.action()) {
 
-	case LFUN_INSET_MODIFY:
+	case LFUN_INSET_MODIFY: {
+		// Do not do anything if converting to the same type of Note.
+		// A quick break here is done instead of disabling the LFUN
+		// because disabling the LFUN would lead to a greyed out
+		// entry, which might confuse users.
+		// In the future, we might want to have a radio button for
+		// switching between notes.
+		InsetNoteParams params;
+		string2params(to_utf8(cmd.argument()), params);
+		if (params_.type == params.type)
+		  break;
+
 		cur.recordUndoInset(ATOMIC_UNDO, this);
 		string2params(to_utf8(cmd.argument()), params_);
 		setButtonLabel();
@@ -157,6 +168,7 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
 		// a full buffer update
 		cur.forceBufferUpdate();
 		break;
+	}
 
 	case LFUN_INSET_DIALOG_UPDATE:
 		cur.bv().updateDialog("note", params2string(params()));
-- 
1.9.1

Reply via email to