1 Display the File->Open Previous menu using radio buttons
3 The radio buttons indicate which files are currently open.
5 The rebuilding of the Open Previous menu is also performed when a document
6 is closed, to allow the refresh of "torn-off" copies of this menu. This is
7 why the invalidatePrevOpenMenus() function was made public rather than
12 source/menu.c | 36 ++++++++++++++++++++++++------------
15 3 files changed, 26 insertions(+), 12 deletions(-)
17 diff --quilt old/source/menu.c new/source/menu.c
20 @@ -369,11 +369,10 @@ static Widget createMenuToggle(Widget pa
22 static Widget createMenuRadioToggle(Widget parent, char *name, char *label,
23 char mnemonic, menuCallbackProc callback, void *cbArg, int set,
25 static Widget createMenuSeparator(Widget parent, char *name, int mode);
26 -static void invalidatePrevOpenMenus(void);
27 static void updateWindowMenu(const WindowInfo *window);
28 static void updatePrevOpenMenu(WindowInfo *window);
29 static void updateTagsFileMenu(WindowInfo *window);
30 static void updateTipsFileMenu(WindowInfo *window);
31 static int searchDirection(int ignoreArgs, String *args, Cardinal *nArgs);
32 @@ -4734,11 +4733,11 @@ void InvalidateWindowMenus(void)
34 ** Mark the Previously Opened Files menus of all NEdit windows as invalid.
35 ** Since actually changing the menus is slow, they're just marked and updated
36 ** when the user pulls one down.
38 -static void invalidatePrevOpenMenus(void)
39 +void InvalidatePrevOpenMenus(void)
43 /* Mark the menus invalid (to be updated when the user pulls one
44 down), unless the menu is torn off, meaning it is visible to the user
45 @@ -4798,11 +4797,11 @@ void AddToPrevOpenMenu(const char *filen
46 for (i=0; i<NPrevOpen; i++) {
47 if (!strcmp(filename, PrevOpen[i])) {
48 nameCopy = PrevOpen[i];
49 memmove(&PrevOpen[1], &PrevOpen[0], sizeof(char *) * i);
50 PrevOpen[0] = nameCopy;
51 - invalidatePrevOpenMenus();
52 + InvalidatePrevOpenMenus();
58 @@ -4818,11 +4817,11 @@ void AddToPrevOpenMenu(const char *filen
59 memmove(&PrevOpen[1], &PrevOpen[0], sizeof(char *) * NPrevOpen);
60 PrevOpen[0] = nameCopy;
63 /* Mark the Previously Opened Files menu as invalid in all windows */
64 - invalidatePrevOpenMenus();
65 + InvalidatePrevOpenMenus();
67 /* Undim the menu in all windows if it was previously empty */
69 for (w=WindowList; w!=NULL; w=w->next) {
70 if (!IsTopDocument(w))
71 @@ -4993,16 +4992,19 @@ static void updateWindowMenu(const Windo
72 ** current state of the list as retrieved from FIXME.
73 ** Thanks to Markus Schwarzenberg for the sorting part.
75 static void updatePrevOpenMenu(WindowInfo *window)
77 + char filename[MAXPATHLEN];
78 + char pathname[MAXPATHLEN];
84 char **prevOpenSorted;
85 + Boolean fileIsOpen = False;
87 /* Read history file to get entries written by other sessions. */
90 /* Sort the previously opened file list if requested */
91 @@ -5023,28 +5025,36 @@ static void updatePrevOpenMenu(WindowInf
92 if (index >= NPrevOpen) {
93 /* unmanaging before destroying stops parent from displaying */
94 XtUnmanageChild(items[n]);
95 XtDestroyWidget(items[n]);
97 - XtVaSetValues(items[n], XmNlabelString,
98 - st1=XmStringCreateSimple(prevOpenSorted[index]), NULL);
99 - XtRemoveAllCallbacks(items[n], XmNactivateCallback);
100 - XtAddCallback(items[n], XmNactivateCallback,
101 - (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
102 + ParseFilename(prevOpenSorted[index], filename, pathname);
103 + fileIsOpen = !!FindWindowWithFile(filename, pathname);
104 + XtVaSetValues(items[n],
105 + XmNlabelString, st1=XmStringCreateSimple(prevOpenSorted[index]),
106 + XmNset, fileIsOpen,
108 + XtRemoveAllCallbacks(items[n], XmNvalueChangedCallback);
109 + XtAddCallback(items[n], XmNvalueChangedCallback,
110 + (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
116 /* Add new items for the remaining file names to the menu */
117 for (; index<NPrevOpen; index++) {
118 - btn = XtVaCreateManagedWidget("win", xmPushButtonWidgetClass,
119 + ParseFilename(prevOpenSorted[index], filename, pathname);
120 + fileIsOpen = !!FindWindowWithFile(filename, pathname);
121 + btn = XtVaCreateManagedWidget("win", xmToggleButtonWidgetClass,
122 window->prevOpenMenuPane,
123 XmNlabelString, st1=XmStringCreateSimple(prevOpenSorted[index]),
125 - XmNuserData, TEMPORARY_MENU_ITEM, NULL);
126 - XtAddCallback(btn, XmNactivateCallback, (XtCallbackProc)openPrevCB,
127 + XmNuserData, TEMPORARY_MENU_ITEM,
128 + XmNset, fileIsOpen,
129 + XmNindicatorType, XmONE_OF_MANY, NULL);
130 + XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc)openPrevCB,
131 prevOpenSorted[index]);
135 XtFree((char*)prevOpenSorted);
136 @@ -5531,10 +5541,12 @@ static void raiseCB(Widget w, WindowInfo
137 static void openPrevCB(Widget w, char *name, caddr_t callData)
140 Widget menu = MENU_WIDGET(w);
143 + XmNset, True, NULL);
144 HidePointerOnKeyedEvent(WidgetToWindow(MENU_WIDGET(w))->lastFocus,
145 ((XmAnyCallbackStruct *)callData)->event);
147 XtCallActionProc(WidgetToWindow(menu)->lastFocus, "open",
148 ((XmAnyCallbackStruct *)callData)->event, params, 1);
149 diff --quilt old/source/menu.h new/source/menu.h
150 --- old/source/menu.h
151 +++ new/source/menu.h
154 Widget CreateMenuBar(Widget parent, WindowInfo *window);
155 void InstallMenuActions(XtAppContext context);
156 XtActionsRec *GetMenuActions(int *nActions);
157 void InvalidateWindowMenus(void);
158 +void InvalidatePrevOpenMenus(void);
159 void CheckCloseDim(void);
160 void AddToPrevOpenMenu(const char *filename);
161 void WriteNEditDB(void);
162 void ReadNEditDB(void);
163 Widget CreateBGMenu(WindowInfo *window);
164 diff --quilt old/source/window.c new/source/window.c
165 --- old/source/window.c
166 +++ new/source/window.c
167 @@ -1063,10 +1063,11 @@ void CloseWindow(WindowInfo *window)
170 /* remove the window from the global window list, update window menus */
171 removeFromWindowList(window);
172 InvalidateWindowMenus();
173 + InvalidatePrevOpenMenus(); /* refresh "is opened" radio buttons here */
174 CheckCloseDim(); /* Close of window running a macro may have been disabled. */
176 /* remove the tab of the closing document from tab bar */
177 XtDestroyWidget(window->tab);