Jürgen Spitzmüller wrote:
> The lfun should probably be renamed LFUN_TOGGLE_TOC.

The attached patch does this (LFUN_TOC_TOGGLE).

OK to apply?

Jürgen
Index: src/LyXAction.cpp
===================================================================
--- src/LyXAction.cpp	(Revision 18108)
+++ src/LyXAction.cpp	(Arbeitskopie)
@@ -289,7 +289,7 @@
 #endif
 		{ LFUN_THESAURUS_ENTRY, "thesaurus-entry", ReadOnly },
 		{ LFUN_TOC_INSERT, "toc-insert", Noop },
-		{ LFUN_TOC_VIEW, "toc-view", ReadOnly },
+		{ LFUN_TOC_TOGGLE, "toc-toggle", ReadOnly },
 		{ LFUN_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR, "toggle-cursor-follows-scrollbar", ReadOnly },
 		{ LFUN_UNDO, "undo", Noop },
 		{ LFUN_UP, "up", ReadOnly | NoUpdate},
Index: src/LyXFunc.cpp
===================================================================
--- src/LyXFunc.cpp	(Revision 18108)
+++ src/LyXFunc.cpp	(Arbeitskopie)
@@ -614,6 +614,11 @@
 		break;
 	}
 
+	case LFUN_TOC_TOGGLE: {
+		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:
@@ -1091,11 +1095,15 @@
 				theApp()->gui().closeAllViews();
 			break;
 
-		case LFUN_TOC_VIEW: {
+		case LFUN_TOC_TOGGLE: {
 			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;
 		}
 
Index: src/lfuns.h
===================================================================
--- src/lfuns.h	(Revision 18108)
+++ src/lfuns.h	(Arbeitskopie)
@@ -40,7 +40,7 @@
 	// 5
 	LFUN_BUFFER_WRITE_AS,
 	LFUN_BUILD_PROGRAM,
-	LFUN_TOC_VIEW,
+	LFUN_TOC_TOGGLE,
 	LFUN_BUFFER_VIEW,
 	LFUN_BUFFER_CLOSE,
 	// 10
 # Full author contact details are available in file CREDITS.
Index: lib/ui/stdmenus.inc
===================================================================
--- lib/ui/stdmenus.inc	(Revision 18108)
+++ lib/ui/stdmenus.inc	(Arbeitskopie)
@@ -406,7 +406,7 @@
 		Submenu "Change Tracking|C" "document_change"
 		OptItem "Build Program|B" "build-program"
 		Item "LaTeX Log|L" "dialog-show latexlog"
-		Item "Table of Contents|T" "toc-view"
+		Item "Table of Contents|T" "toc-toggle"
 		Item "Start Appendix Here|A" "appendix"
 		Separator
 		Item "Compressed|o" "buffer-toggle-compression"
Index: lib/ui/classic.ui
===================================================================
--- lib/ui/classic.ui	(Revision 18108)
+++ lib/ui/classic.ui	(Arbeitskopie)
@@ -357,7 +357,7 @@
 		Submenu "Update|U" "update"
 		Separator
 		Item "LaTeX Log|L" "dialog-show latexlog"
-		Item "Table of Contents|C" "toc-view"
+		Item "Table of Contents|C" "toc-toggle"
 		Item "TeX Information|X" "dialog-show texinfo"
 	End
 

Reply via email to