Jean-Marc Lasgouttes wrote:
> Stefan> I haven't found out how to fix the menu item as well. At the
> Stefan> moment it greys out when the drawer is visible. It should
> Stefan> switch between "Show TOC" and "Hide TOC" or it should be a
> Stefan> toggle menu item. Would be happy about some hint where to
> Stefan> look.
>
> You have to change getStatus for the TOC lfun to that it returns
> setOnOff true/false as needed. Look at this for example:
>
>         case LFUN_BUFFER_TOGGLE_READ_ONLY:
>                 flag.setOnOff(buf->isReadonly());
>                 break;

Why isReadonly()?
The attached patch turns the item to a toogle. The lfun should probably be 
renamed LFUN_TOGGLE_TOC.

Jürgen
Index: src/LyXFunc.cpp
===================================================================
--- src/LyXFunc.cpp	(Revision 18108)
+++ src/LyXFunc.cpp	(Arbeitskopie)
@@ -614,6 +614,11 @@
 		break;
 	}
 
+	case LFUN_TOC_VIEW: {
+		flag.setOnOff(lyx_view_->getDialogs().visible("toc"));
+		break;
+	}
+
 	// this one is difficult to get right. As a half-baked
 	// solution, we consider only the first action of the sequence
 	case LFUN_COMMAND_SEQUENCE: {
@@ -637,7 +642,6 @@
 	case LFUN_BUFFER_UPDATE:
 	case LFUN_BUFFER_VIEW:
 	case LFUN_BUFFER_IMPORT:
-	case LFUN_TOC_VIEW:
 	case LFUN_BUFFER_AUTO_SAVE:
 	case LFUN_RECONFIGURE:
 	case LFUN_HELP_OPEN:
@@ -1095,7 +1099,10 @@
 			BOOST_ASSERT(lyx_view_);
 			InsetCommandParams p("tableofcontents");
 			string const data = InsetCommandMailer::params2string("toc", p);
-			lyx_view_->getDialogs().show("toc", data, 0);
+			if (lyx_view_->getDialogs().visible("toc"))
+				lyx_view_->getDialogs().hide("toc", lyx_view_->getDialogs().getOpenInset("toc"));
+			else
+				lyx_view_->getDialogs().show("toc", data, 0);
 			break;
 		}
 

Reply via email to