On Tuesday 17 June 2003 12:48 pm, Jean-Marc Lasgouttes wrote:
> Angus> Replace these
> Angus>         { LFUN_DIALOG_PREFERENCES, "dialog-preferences", NoBuffer },
> Angus>         { LFUN_FORKS_SHOW, "show-forks", NoBuffer },
> Angus>         { LFUN_HELP_ABOUTLYX, "help-aboutlyx", NoBuffer },
> Angus>         { LFUN_HELP_TEXINFO, "help-Texinfo", NoBuffer },
> Angus>         { LFUN_LATEX_LOG, "latex-view-log", ReadOnly },
> Angus>         { LFUN_LAYOUT_CHARACTER, "layout-character", ReadOnly },
> Angus>         { LFUN_LAYOUT_DOCUMENT, "layout-document", ReadOnly },
> Angus>         { LFUN_LAYOUT_PREAMBLE, "layout-preamble", ReadOnly },
> Angus>         { LFUN_MATH_PANEL, "math-panel", Noop },
> Angus>         { LFUN_MENUPRINT, "buffer-print", ReadOnly },
> Angus>         { LFUN_MENUSEARCH, "find-replace", ReadOnly },
> Angus>         { LFUN_SPELLCHECK, "spellchecker", Noop },
> Angus>         { LFUN_VC_HISTORY, "vc-history", ReadOnly },
> Angus> with this
> Angus>         { LFUN_DIALOG_SHOW, "dialog-show", Argument },
>
> The current solution to this kind of problem is to code the
> limitations in LyXFunc::getStatus(). It is done for that. I know
> getStatus is not a great thing, but it is the correct solution in the
> current context.
>
> The flags are just a shortcut for coding simple restrictions in a
> table driven way. We do not have to code everything there.
>
> JMarc

JMarc, could you have a look at this then. It appears to work perfectly but...
Angus

(The !buf part of getStatus would eventually expand to cover all relevant 
dialogs)
Index: lib/ui/classic.ui
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/classic.ui,v
retrieving revision 1.3
diff -u -p -r1.3 classic.ui
--- lib/ui/classic.ui	23 May 2003 13:56:00 -0000	1.3
+++ lib/ui/classic.ui	18 Jun 2003 09:56:33 -0000
@@ -75,13 +75,13 @@ Menuset
 		Submenu "Math|M" "edit_math"
 		Separator
 		#Item "Read Only" "buffer-toggle-read-only"
-		Item "Spellchecker...|S" "spellchecker"
+		Item "Spellchecker...|S" "dialog-show spellchecker"
 		Item "Thesaurus..." "thesaurus-entry"
 		Item "Check TeX|h" "buffer-chktex"
 		Item "Open/Close float|l" "inset-toggle"
 		Submenu "Change tracking|g" "edit_change"
 		Separator
-		Item "Preferences...|P" "dialog-preferences"
+		Item "Preferences...|P" "dialog-show preferences"
 		Item "Reconfigure|R" "reconfigure"
 	End
 
@@ -248,7 +248,7 @@ Menuset
 		Item "Split Environment|S" "math-insert \split"
 	Separator
 		Submenu "Font Change|f" "insert_math_font"
-		Item "Math Panel|l" "math-panel"
+		Item "Math Panel|l" "dialog-show mathpanel"
 	End
 
 	Menu "insert_math_font"
@@ -331,8 +331,8 @@ Menuset
 		Separator
 		Item "LaTeX Logfile|L" "latex-view-log"
 		Item "Table of Contents|T" "toc-view"
-		Item "Child Processes|C" "show-forks"
-		Item "TeX Information|X" "help-Texinfo"
+		Item "Child Processes|C" "dialog-show forks"
+		Item "TeX Information|X" "dialog-show texinfo"
 	End
 
 	Menu "update"
@@ -384,7 +384,7 @@ Menuset
 		Item "Table of Contents|a" "help-open TOC"
 		Item "LaTeX Configuration|L" "help-open LaTeXConfig"
 		Separator
-		Item "About LyX|X" "help-aboutlyx"
+		Item "About LyX|X" "dialog-show aboutlyx"
 	End
 
 End
Index: lib/ui/stdmenus.ui
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/stdmenus.ui,v
retrieving revision 1.12
diff -u -p -r1.12 stdmenus.ui
--- lib/ui/stdmenus.ui	17 Jun 2003 15:33:44 -0000	1.12
+++ lib/ui/stdmenus.ui	18 Jun 2003 09:56:33 -0000
@@ -270,7 +270,7 @@ Menuset
 		Item "Cases Environment|C" "math-insert \cases"
 		Separator
 		Submenu "Font Change|f" "insert_math_font"
-		Item "Math Panel|l" "math-panel"
+		Item "Math Panel|l" "dialog-show mathpanel"
 	End
 
 	Menu "insert_math_font"
@@ -365,17 +365,17 @@ Menuset
 #
  
 	Menu "tools"
-		Item "Spellchecker...|S" "spellchecker"
+		Item "Spellchecker...|S" "dialog-show spellchecker"
 		OptItem "Thesaurus...|T" "thesaurus-entry"
 		OptItem "Check TeX|h" "buffer-chktex"
-		Item "View Child Processes...|C" "show-forks"
-		Item "TeX Information...|I" "help-Texinfo"
+		Item "View Child Processes...|C" "dialog-show forks"
+		Item "TeX Information...|I" "dialog-show texinfo"
 		Separator
 # A LOT of applications have Tools->Prefs. Remember this
 # should be rarely used - Edit menu is not a good place to
 # have it.
 		Item "Reconfigure|R" "reconfigure"
-		Item "Preferences...|P" "dialog-preferences"
+		Item "Preferences...|P" "dialog-show preferences"
 	End
  
 #
@@ -391,7 +391,7 @@ Menuset
 		Item "Table of Contents|a" "help-open TOC"
 		Item "LaTeX Configuration|L" "help-open LaTeXConfig"
 		Separator
-		Item "About LyX...|X" "help-aboutlyx"
+		Item "About LyX...|X" "dialog-show aboutlyx"
 	End
 
 End
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.454
diff -u -p -r1.454 lyxfunc.C
--- src/lyxfunc.C	17 Jun 2003 13:16:24 -0000	1.454
+++ src/lyxfunc.C	18 Jun 2003 09:56:35 -0000
@@ -291,6 +291,22 @@ FuncStatus LyXFunc::getStatus(FuncReques
 	// the default error message if we disable the command
 	setStatusMessage(N_("Command disabled"));
 
+	// A nasty hack!
+	if (ev.action == LFUN_DIALOG_SHOW) {
+		if (!buf) {
+			if (ev.argument == "preferences" ||
+			    ev.argument == "forks" ||
+			    ev.argument == "aboutlyx" ||
+			    ev.argument == "texinfo") {
+				return flag.disabled(false);
+			}
+			return 
+				flag.disabled(true);
+		}
+		return 
+			flag.disabled(false);
+	}
+
 	// Check whether we need a buffer
 	if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
 		// Yes we need a buffer, do we have one?
@@ -1176,10 +1192,6 @@ void LyXFunc::dispatch(FuncRequest const
 //#warning Find another implementation here (or another lyxfunc)!
 #endif
 #endif
-	case LFUN_HELP_ABOUTLYX:
-		owner->getDialogs().show("about");
-		break;
-
 	case LFUN_HELP_TEXINFO:
 		owner->getDialogs().showTexinfo();
 		break;
@@ -1306,10 +1318,6 @@ void LyXFunc::dispatch(FuncRequest const
 		owner->getMenubar().openByName(argument);
 		break; // RVDK_PATCH_5
 
-	case LFUN_SPELLCHECK:
-		owner->getDialogs().showSpellchecker();
-		break;
-
 	// --- lyxserver commands ----------------------------
 
 
@@ -1404,13 +1412,18 @@ void LyXFunc::dispatch(FuncRequest const
 		dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
 		break;
 
-	case LFUN_MATH_PANEL:
-		owner->getDialogs().show("mathpanel");
-		break;
-
-	case LFUN_DIALOG_SHOW:
-		owner->getDialogs().show(argument);
+	case LFUN_DIALOG_SHOW: {
+		string const & name = argument;
+		if (name == "aboutlyx")
+			owner->getDialogs().show("about");
+		else if (name == "preferences")
+			owner->getDialogs().showPreferences();
+		else if (name == "spellchecker")
+			owner->getDialogs().showSpellchecker();
+		else
+			owner->getDialogs().show(argument);
 		break;
+	}
 
 	case LFUN_DIALOG_SHOW_NEW_INSET: {
 		string const & name = argument;
@@ -1503,10 +1516,6 @@ void LyXFunc::dispatch(FuncRequest const
 		}
 	}
 	break;
-
-	case LFUN_DIALOG_PREFERENCES:
-		owner->getDialogs().showPreferences();
-		break;
 
 	case LFUN_SAVEPREFERENCES:
 	{

Reply via email to