    Display the File->Open Previous menu using radio buttons

    The radio buttons indicate which files are currently open.

    The rebuilding of the Open Previous menu is also performed when a document
    is closed, to allow the refresh of "torn-off" copies of this menu. This is
    why the invalidatePrevOpenMenus() function was made public rather than
    static.

diff -ar -U5 nedit_official nedit_mod
diff -ar -U5 nedit_official/source/menu.c nedit_mod/source/menu.c
--- nedit_official/source/menu.c	2006-01-03 00:10:21.000000000 +0100
+++ nedit_mod/source/menu.c	2006-01-12 16:30:40.810125000 +0100
@@ -352,11 +352,10 @@
 	int mode);
 static Widget createMenuRadioToggle(Widget parent, char *name, char *label,
 	char mnemonic, menuCallbackProc callback, void *cbArg, int set,
 	int mode);
 static Widget createMenuSeparator(Widget parent, char *name, int mode);
-static void invalidatePrevOpenMenus(void);
 static void updateWindowMenu(const WindowInfo *window);
 static void updatePrevOpenMenu(WindowInfo *window);
 static void updateTagsFileMenu(WindowInfo *window);
 static void updateTipsFileMenu(WindowInfo *window);
 static int searchDirection(int ignoreArgs, String *args, Cardinal *nArgs);
@@ -4474,11 +4473,11 @@
 /*
 ** Mark the Previously Opened Files menus of all NEdit windows as invalid.
 ** Since actually changing the menus is slow, they're just marked and updated
 ** when the user pulls one down.
 */
-static void invalidatePrevOpenMenus(void)
+void InvalidatePrevOpenMenus(void)
 {
     WindowInfo *w;
 
     /* Mark the menus invalid (to be updated when the user pulls one
        down), unless the menu is torn off, meaning it is visible to the user
@@ -4516,11 +4515,11 @@
     for (i=0; i<NPrevOpen; i++) {
     	if (!strcmp(filename, PrevOpen[i])) {
     	    nameCopy = PrevOpen[i];
     	    memmove(&PrevOpen[1], &PrevOpen[0], sizeof(char *) * i);
     	    PrevOpen[0] = nameCopy;
-    	    invalidatePrevOpenMenus();
+    	    InvalidatePrevOpenMenus();
 	    WriteNEditDB();
     	    return;
     	}
     }
     
@@ -4536,11 +4535,11 @@
     memmove(&PrevOpen[1], &PrevOpen[0], sizeof(char *) * NPrevOpen);
     PrevOpen[0] = nameCopy;
     NPrevOpen++;
     
     /* Mark the Previously Opened Files menu as invalid in all windows */
-    invalidatePrevOpenMenus();
+    InvalidatePrevOpenMenus();
 
     /* Undim the menu in all windows if it was previously empty */
     if (NPrevOpen > 0) {
     	for (w=WindowList; w!=NULL; w=w->next) {
     	    if (!IsTopDocument(w))
@@ -4669,16 +4668,19 @@
 ** current state of the list as retrieved from FIXME.
 ** Thanks to Markus Schwarzenberg for the sorting part.
 */
 static void updatePrevOpenMenu(WindowInfo *window)
 {
+    char filename[MAXPATHLEN];
+    char pathname[MAXPATHLEN];
     Widget btn;
     WidgetList items;
     Cardinal nItems;
     int n, index;
     XmString st1;
     char **prevOpenSorted;
+    Boolean fileIsOpen = False;
 
     /*  Read history file to get entries written by other sessions.  */
     ReadNEditDB();
                 
     /* Sort the previously opened file list if requested */
@@ -4699,28 +4701,36 @@
         if (index >= NPrevOpen) {
             /* unmanaging before destroying stops parent from displaying */
             XtUnmanageChild(items[n]);
             XtDestroyWidget(items[n]);          
         } else {
-            XtVaSetValues(items[n], XmNlabelString,
-                    st1=XmStringCreateSimple(prevOpenSorted[index]), NULL);
-            XtRemoveAllCallbacks(items[n], XmNactivateCallback);
-            XtAddCallback(items[n], XmNactivateCallback,
-                    (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
+            ParseFilename(prevOpenSorted[index], filename, pathname);
+            fileIsOpen = !!FindWindowWithFile(filename, pathname);
+            XtVaSetValues(items[n],
+                XmNlabelString, st1=XmStringCreateSimple(prevOpenSorted[index]),
+                XmNset, fileIsOpen,
+                NULL);
+            XtRemoveAllCallbacks(items[n], XmNvalueChangedCallback);
+            XtAddCallback(items[n], XmNvalueChangedCallback,
+                (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
             XmStringFree(st1);
             index++;
         }
     }
     
     /* Add new items for the remaining file names to the menu */
     for (; index<NPrevOpen; index++) {
-        btn = XtVaCreateManagedWidget("win", xmPushButtonWidgetClass,
+        ParseFilename(prevOpenSorted[index], filename, pathname);
+        fileIsOpen = !!FindWindowWithFile(filename, pathname);
+        btn = XtVaCreateManagedWidget("win", xmToggleButtonWidgetClass,
                 window->prevOpenMenuPane, 
                 XmNlabelString, st1=XmStringCreateSimple(prevOpenSorted[index]),
                 XmNmarginHeight, 0,
-                XmNuserData, TEMPORARY_MENU_ITEM, NULL);
-        XtAddCallback(btn, XmNactivateCallback, (XtCallbackProc)openPrevCB, 
+                XmNuserData, TEMPORARY_MENU_ITEM,
+                XmNset, fileIsOpen,
+                XmNindicatorType, XmONE_OF_MANY, NULL);
+        XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc)openPrevCB, 
                 prevOpenSorted[index]);
         XmStringFree(st1);
     }
                 
     XtFree((char*)prevOpenSorted);
@@ -5162,10 +5172,12 @@
 static void openPrevCB(Widget w, char *name, caddr_t callData)
 {
     char *params[1];
     Widget menu = MENU_WIDGET(w);
     
+    XtVaSetValues(w,
+                  XmNset, True, NULL);
     HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w))->lastFocus,
             ((XmAnyCallbackStruct *)callData)->event);
     params[0] = name;
     XtCallActionProc(WidgetToWindow(menu)->lastFocus, "open",
     	    ((XmAnyCallbackStruct *)callData)->event, params, 1);
diff -ar -U5 nedit_official/source/menu.h nedit_mod/source/menu.h
--- nedit_official/source/menu.h	2004-11-09 22:58:44.000000000 +0100
+++ nedit_mod/source/menu.h	2006-01-12 16:24:05.919500000 +0100
@@ -38,10 +38,11 @@
 
 Widget CreateMenuBar(Widget parent, WindowInfo *window);
 void InstallMenuActions(XtAppContext context);
 XtActionsRec *GetMenuActions(int *nActions);
 void InvalidateWindowMenus(void);
+void InvalidatePrevOpenMenus(void);
 void CheckCloseDim(void);
 void AddToPrevOpenMenu(const char *filename);
 void WriteNEditDB(void);
 void ReadNEditDB(void);
 Widget CreateBGMenu(WindowInfo *window);
diff -ar -U5 nedit_official/source/window.c nedit_mod/source/window.c
--- nedit_official/source/window.c	2005-12-17 20:23:32.000000000 +0100
+++ nedit_mod/source/window.c	2006-01-12 16:24:05.950750000 +0100
@@ -1021,10 +1021,11 @@
     }
     
     /* remove the window from the global window list, update window menus */
     removeFromWindowList(window);
     InvalidateWindowMenus();
+    InvalidatePrevOpenMenus(); /* refresh "is opened" radio buttons here */
     CheckCloseDim(); /* Close of window running a macro may have been disabled. */
 
     /* remove the tab of the closing document from tab bar */
     XtDestroyWidget(window->tab);
 
