| @@ -1,741 +1,741 @@ | | | @@ -1,741 +1,741 @@ |
1 | /* | | 1 | /* |
2 | | | 2 | |
3 | Copyright (c) 1987, 1988 X Consortium | | 3 | Copyright (c) 1987, 1988 X Consortium |
4 | | | 4 | |
5 | Permission is hereby granted, free of charge, to any person obtaining | | 5 | Permission is hereby granted, free of charge, to any person obtaining |
6 | a copy of this software and associated documentation files (the | | 6 | a copy of this software and associated documentation files (the |
7 | "Software"), to deal in the Software without restriction, including | | 7 | "Software"), to deal in the Software without restriction, including |
8 | without limitation the rights to use, copy, modify, merge, publish, | | 8 | without limitation the rights to use, copy, modify, merge, publish, |
9 | distribute, sublicense, and/or sell copies of the Software, and to | | 9 | distribute, sublicense, and/or sell copies of the Software, and to |
10 | permit persons to whom the Software is furnished to do so, subject to | | 10 | permit persons to whom the Software is furnished to do so, subject to |
11 | the following conditions: | | 11 | the following conditions: |
12 | | | 12 | |
13 | The above copyright notice and this permission notice shall be included | | 13 | The above copyright notice and this permission notice shall be included |
14 | in all copies or substantial portions of the Software. | | 14 | in all copies or substantial portions of the Software. |
15 | | | 15 | |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | | 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | | 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
19 | IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR | | 19 | IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR |
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | | 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | | 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
22 | OTHER DEALINGS IN THE SOFTWARE. | | 22 | OTHER DEALINGS IN THE SOFTWARE. |
23 | | | 23 | |
24 | Except as contained in this notice, the name of the X Consortium shall | | 24 | Except as contained in this notice, the name of the X Consortium shall |
25 | not be used in advertising or otherwise to promote the sale, use or | | 25 | not be used in advertising or otherwise to promote the sale, use or |
26 | other dealings in this Software without prior written authorization | | 26 | other dealings in this Software without prior written authorization |
27 | from the X Consortium. | | 27 | from the X Consortium. |
28 | | | 28 | |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | /* | | 31 | /* |
32 | * xman - X window system manual page display program. | | 32 | * xman - X window system manual page display program. |
33 | * Author: Chris D. Peterson, MIT Project Athena | | 33 | * Author: Chris D. Peterson, MIT Project Athena |
34 | * Created: October 29, 1987 | | 34 | * Created: October 29, 1987 |
35 | */ | | 35 | */ |
36 | #ifdef HAVE_CONFIG_H | | 36 | #ifdef HAVE_CONFIG_H |
37 | # include "config.h" | | 37 | # include "config.h" |
38 | #endif | | 38 | #endif |
39 | | | 39 | |
40 | #include <sys/types.h> | | 40 | #include <sys/types.h> |
41 | #include <sys/stat.h> | | 41 | #include <sys/stat.h> |
42 | #include "globals.h" | | 42 | #include "globals.h" |
43 | #include "vendor.h" | | 43 | #include "vendor.h" |
44 | #ifdef INCLUDE_XPRINT_SUPPORT | | 44 | #ifdef INCLUDE_XPRINT_SUPPORT |
45 | #include "printdialog.h" | | 45 | #include "printdialog.h" |
46 | #include "print.h" | | 46 | #include "print.h" |
47 | #endif /* INCLUDE_XPRINT_SUPPORT */ | | 47 | #endif /* INCLUDE_XPRINT_SUPPORT */ |
48 | | | 48 | |
49 | #ifdef RELEASE_VERSION | | 49 | #ifdef RELEASE_VERSION |
50 | #define XMAN_VERSION "Xman Version " PACKAGE_VERSION " - X11R" RELEASE_VERSION | | 50 | #define XMAN_VERSION "Xman Version " PACKAGE_VERSION " - X11R" RELEASE_VERSION |
51 | #else | | 51 | #else |
52 | #define XMAN_VERSION "Xman Version " PACKAGE_VERSION | | 52 | #define XMAN_VERSION "Xman Version " PACKAGE_VERSION |
53 | #endif | | 53 | #endif |
54 | | | 54 | |
55 | static void PutUpManpage(ManpageGlobals * man_globals, FILE * file); | | 55 | static void PutUpManpage(ManpageGlobals * man_globals, FILE * file); |
56 | static void ToggleBothShownState(ManpageGlobals * man_globals); | | 56 | static void ToggleBothShownState(ManpageGlobals * man_globals); |
57 | | | 57 | |
58 | /* Function Name: OptionCallback | | 58 | /* Function Name: OptionCallback |
59 | * Description: This is the callback function for the callback menu. | | 59 | * Description: This is the callback function for the callback menu. |
60 | * Arguments: w - the widget we are calling back from. | | 60 | * Arguments: w - the widget we are calling back from. |
61 | * globals_pointer - a pointer to the pseudo globals structure | | 61 | * globals_pointer - a pointer to the pseudo globals structure |
62 | * for this manpage. | | 62 | * for this manpage. |
63 | * junk - (call data) not used. | | 63 | * junk - (call data) not used. |
64 | * Returns: none. | | 64 | * Returns: none. |
65 | */ | | 65 | */ |
66 | | | 66 | |
67 | /*ARGSUSED*/ | | 67 | /*ARGSUSED*/ |
68 | void | | 68 | void |
69 | OptionCallback(Widget w, XtPointer pointer, XtPointer junk) | | 69 | OptionCallback(Widget w, XtPointer pointer, XtPointer junk) |
70 | { | | 70 | { |
71 | ManpageGlobals *man_globals = (ManpageGlobals *) pointer; | | 71 | ManpageGlobals *man_globals = (ManpageGlobals *) pointer; |
72 | String params; | | 72 | String params; |
73 | Cardinal num_params = 1; | | 73 | Cardinal num_params = 1; |
74 | | | 74 | |
75 | if (w == man_globals->search_entry) | | 75 | if (w == man_globals->search_entry) |
76 | PopupSearch(XtParent(w), NULL, NULL, NULL); | | 76 | PopupSearch(XtParent(w), NULL, NULL, NULL); |
77 | else if (w == man_globals->dir_entry) { /* Put Up Directory */ | | 77 | else if (w == man_globals->dir_entry) { /* Put Up Directory */ |
78 | params = "Directory"; | | 78 | params = "Directory"; |
79 | GotoPage(XtParent(w), NULL, ¶ms, &num_params); | | 79 | GotoPage(XtParent(w), NULL, ¶ms, &num_params); |
80 | } | | 80 | } |
81 | else if (w == man_globals->manpage_entry) { /* Put Up Man Page */ | | 81 | else if (w == man_globals->manpage_entry) { /* Put Up Man Page */ |
82 | params = "ManualPage"; | | 82 | params = "ManualPage"; |
83 | GotoPage(XtParent(w), NULL, ¶ms, &num_params); | | 83 | GotoPage(XtParent(w), NULL, ¶ms, &num_params); |
84 | } | | 84 | } |
85 | else if (w == man_globals->help_entry) /* Help */ | | 85 | else if (w == man_globals->help_entry) /* Help */ |
86 | PopupHelp(XtParent(w), NULL, NULL, NULL); | | 86 | PopupHelp(XtParent(w), NULL, NULL, NULL); |
87 | else if (w == man_globals->both_screens_entry) /*Toggle Both_Shown State. */ | | 87 | else if (w == man_globals->both_screens_entry) /*Toggle Both_Shown State. */ |
88 | ToggleBothShownState(man_globals); | | 88 | ToggleBothShownState(man_globals); |
89 | else if (w == man_globals->remove_entry) /* Kill the manpage */ | | 89 | else if (w == man_globals->remove_entry) /* Kill the manpage */ |
90 | RemoveThisManpage(XtParent(w), NULL, NULL, NULL); | | 90 | RemoveThisManpage(XtParent(w), NULL, NULL, NULL); |
91 | else if (w == man_globals->open_entry) /* Open new manpage */ | | 91 | else if (w == man_globals->open_entry) /* Open new manpage */ |
92 | CreateNewManpage(XtParent(w), NULL, NULL, NULL); | | 92 | CreateNewManpage(XtParent(w), NULL, NULL, NULL); |
93 | #ifdef INCLUDE_XPRINT_SUPPORT | | 93 | #ifdef INCLUDE_XPRINT_SUPPORT |
94 | else if (w == man_globals->print_entry) /* Print current manpage */ | | 94 | else if (w == man_globals->print_entry) /* Print current manpage */ |
95 | PrintThisManpage(XtParent(w), NULL, NULL, NULL); | | 95 | PrintThisManpage(XtParent(w), NULL, NULL, NULL); |
96 | #endif /* INCLUDE_XPRINT_SUPPORT */ | | 96 | #endif /* INCLUDE_XPRINT_SUPPORT */ |
97 | else if (w == man_globals->version_entry) /* Get version */ | | 97 | else if (w == man_globals->version_entry) /* Get version */ |
98 | ShowVersion(XtParent(w), NULL, NULL, NULL); | | 98 | ShowVersion(XtParent(w), NULL, NULL, NULL); |
99 | else if (w == man_globals->quit_entry) /* Quit. */ | | 99 | else if (w == man_globals->quit_entry) /* Quit. */ |
100 | Quit(XtParent(w), NULL, NULL, NULL); | | 100 | Quit(XtParent(w), NULL, NULL, NULL); |
101 | } | | 101 | } |
102 | | | 102 | |
103 | /* Function Name: ToggleBothShownState; | | 103 | /* Function Name: ToggleBothShownState; |
104 | * Description: toggles the state of the both shown feature. | | 104 | * Description: toggles the state of the both shown feature. |
105 | * Arguments: man_globals - the man globals structure. | | 105 | * Arguments: man_globals - the man globals structure. |
106 | * Returns: none. | | 106 | * Returns: none. |
107 | */ | | 107 | */ |
108 | | | 108 | |
109 | /* | | 109 | /* |
110 | * I did not have a two state widget, which is the way this | | 110 | * I did not have a two state widget, which is the way this |
111 | * should really be done. 1/22/88 - CDP. | | 111 | * should really be done. 1/22/88 - CDP. |
112 | */ | | 112 | */ |
113 | | | 113 | |
114 | static void | | 114 | static void |
115 | ToggleBothShownState(ManpageGlobals * man_globals) | | 115 | ToggleBothShownState(ManpageGlobals * man_globals) |
116 | { | | 116 | { |
117 | const char *label_str; | | 117 | const char *label_str; |
118 | Arg arglist[1]; | | 118 | Arg arglist[1]; |
119 | | | 119 | |
120 | if (man_globals->both_shown == TRUE) { | | 120 | if (man_globals->both_shown == TRUE) { |
121 | label_str = SHOW_BOTH; | | 121 | label_str = SHOW_BOTH; |
122 | if (man_globals->dir_shown) | | 122 | if (man_globals->dir_shown) |
123 | XtUnmanageChild(man_globals->manpagewidgets.manpage); | | 123 | XtUnmanageChild(man_globals->manpagewidgets.manpage); |
124 | else | | 124 | else |
125 | XtUnmanageChild(man_globals->manpagewidgets.directory); | | 125 | XtUnmanageChild(man_globals->manpagewidgets.directory); |
126 | } | | 126 | } |
127 | else { | | 127 | else { |
128 | Widget manpage = man_globals->manpagewidgets.manpage; | | 128 | Widget manpage = man_globals->manpagewidgets.manpage; |
129 | Widget dir = man_globals->manpagewidgets.directory; | | 129 | Widget dir = man_globals->manpagewidgets.directory; |
130 | | | 130 | |
131 | label_str = SHOW_ONE; | | 131 | label_str = SHOW_ONE; |
132 | | | 132 | |
133 | XtSetArg(arglist[0], XtNpreferredPaneSize, resources.directory_height); | | 133 | XtSetArg(arglist[0], XtNpreferredPaneSize, resources.directory_height); |
134 | XtSetValues(dir, arglist, (Cardinal) 1); | | 134 | XtSetValues(dir, arglist, (Cardinal) 1); |
135 | | | 135 | |
136 | if (!man_globals->dir_shown) { | | 136 | if (!man_globals->dir_shown) { |
137 | XtUnmanageChild(manpage); | | 137 | XtUnmanageChild(manpage); |
138 | XtManageChild(dir); | | 138 | XtManageChild(dir); |
139 | } | | 139 | } |
140 | XtManageChild(manpage); | | 140 | XtManageChild(manpage); |
141 | } | | 141 | } |
142 | man_globals->both_shown = !man_globals->both_shown; | | 142 | man_globals->both_shown = !man_globals->both_shown; |
143 | | | 143 | |
144 | if (man_globals->dir_shown) | | 144 | if (man_globals->dir_shown) |
145 | ChangeLabel(man_globals->label, | | 145 | ChangeLabel(man_globals->label, |
146 | man_globals->section_name[man_globals->current_directory]); | | 146 | man_globals->section_name[man_globals->current_directory]); |
147 | else | | 147 | else |
148 | ChangeLabel(man_globals->label, man_globals->manpage_title); | | 148 | ChangeLabel(man_globals->label, man_globals->manpage_title); |
149 | | | 149 | |
150 | XtSetArg(arglist[0], XtNlabel, label_str); | | 150 | XtSetArg(arglist[0], XtNlabel, label_str); |
151 | XtSetValues(man_globals->both_screens_entry, arglist, ONE); | | 151 | XtSetValues(man_globals->both_screens_entry, arglist, ONE); |
152 | | | 152 | |
153 | /* if both are shown there is no need to switch between the two. */ | | 153 | /* if both are shown there is no need to switch between the two. */ |
154 | | | 154 | |
155 | XtSetArg(arglist[0], XtNsensitive, !man_globals->both_shown); | | 155 | XtSetArg(arglist[0], XtNsensitive, !man_globals->both_shown); |
156 | XtSetValues(man_globals->manpage_entry, arglist, ONE); | | 156 | XtSetValues(man_globals->manpage_entry, arglist, ONE); |
157 | XtSetValues(man_globals->dir_entry, arglist, ONE); | | 157 | XtSetValues(man_globals->dir_entry, arglist, ONE); |
158 | } | | 158 | } |
159 | | | 159 | |
160 | /* Function Name: Popup | | 160 | /* Function Name: Popup |
161 | * Description: This function pops up the given widget under the cursor. | | 161 | * Description: This function pops up the given widget under the cursor. |
162 | * Arguments: w - the widget to popup. | | 162 | * Arguments: w - the widget to popup. |
163 | * grab_kind - the kind of grab to register. | | 163 | * grab_kind - the kind of grab to register. |
164 | * Returns: none | | 164 | * Returns: none |
165 | */ | | 165 | */ |
166 | | | 166 | |
167 | /* How far off the top of the widget to have the initial cursor position. */ | | 167 | /* How far off the top of the widget to have the initial cursor position. */ |
168 | | | 168 | |
169 | #define OFF_OF_TOP 25 | | 169 | #define OFF_OF_TOP 25 |
170 | | | 170 | |
171 | void | | 171 | void |
172 | Popup(Widget w, XtGrabKind grab_kind) | | 172 | Popup(Widget w, XtGrabKind grab_kind) |
173 | { | | 173 | { |
174 | int x_root, y_root, y_pos, garbage; | | 174 | int x_root, y_root, y_pos, garbage; |
175 | unsigned int mask; | | 175 | unsigned int mask; |
176 | Window junk_window; | | 176 | Window junk_window; |
177 | | | 177 | |
178 | XQueryPointer(XtDisplay(w), XtWindow(w), &junk_window, &junk_window, | | 178 | XQueryPointer(XtDisplay(w), XtWindow(w), &junk_window, &junk_window, |
179 | &x_root, &y_root, &garbage, &garbage, &mask); | | 179 | &x_root, &y_root, &garbage, &garbage, &mask); |
180 | | | 180 | |
181 | y_pos = OFF_OF_TOP - Height(w) / 2 - BorderWidth(w); | | 181 | y_pos = OFF_OF_TOP - Height(w) / 2 - BorderWidth(w); |
182 | PositionCenter(w, x_root, y_root, y_pos, 0, 2, 2); | | 182 | PositionCenter(w, x_root, y_root, y_pos, 0, 2, 2); |
183 | XtPopup(w, grab_kind); | | 183 | XtPopup(w, grab_kind); |
184 | } | | 184 | } |
185 | | | 185 | |
186 | /* Function Name: PutUpManpage | | 186 | /* Function Name: PutUpManpage |
187 | * Description: Puts the manpage on the display. | | 187 | * Description: Puts the manpage on the display. |
188 | * Arguments: man_globals - a pointer to the pseudo globals structure | | 188 | * Arguments: man_globals - a pointer to the pseudo globals structure |
189 | * for this manpage. | | 189 | * for this manpage. |
190 | * file - the file to display. | | 190 | * file - the file to display. |
191 | * Returns: none. | | 191 | * Returns: none. |
192 | */ | | 192 | */ |
193 | | | 193 | |
194 | static void | | 194 | static void |
195 | PutUpManpage(ManpageGlobals * man_globals, FILE * file) | | 195 | PutUpManpage(ManpageGlobals * man_globals, FILE * file) |
196 | { | | 196 | { |
197 | String params = "ManualPage"; | | 197 | String params = "ManualPage"; |
198 | Cardinal num_params = 1; | | 198 | Cardinal num_params = 1; |
199 | | | 199 | |
200 | if (file == NULL) | | 200 | if (file == NULL) |
201 | return; | | 201 | return; |
202 | | | 202 | |
203 | OpenFile(man_globals, file); | | 203 | OpenFile(man_globals, file); |
204 | | | 204 | |
205 | if (!man_globals->both_shown) { | | 205 | if (!man_globals->both_shown) { |
206 | Arg arglist[1]; | | 206 | Arg arglist[1]; |
207 | | | 207 | |
208 | XtSetArg(arglist[0], XtNsensitive, TRUE); | | 208 | XtSetArg(arglist[0], XtNsensitive, TRUE); |
209 | XtSetValues(man_globals->manpage_entry, arglist, ONE); | | 209 | XtSetValues(man_globals->manpage_entry, arglist, ONE); |
210 | XtSetValues(man_globals->both_screens_entry, arglist, ONE); | | 210 | XtSetValues(man_globals->both_screens_entry, arglist, ONE); |
211 | } | | 211 | } |
212 | GotoPage(man_globals->manpagewidgets.manpage, NULL, ¶ms, &num_params); | | 212 | GotoPage(man_globals->manpagewidgets.manpage, NULL, ¶ms, &num_params); |
213 | } | | 213 | } |
214 | | | 214 | |
215 | /* Function Name: DirectoryHandler | | 215 | /* Function Name: DirectoryHandler |
216 | * Description: This is the callback function for the directory listings. | | 216 | * Description: This is the callback function for the directory listings. |
217 | * Arguments: w - the widget we are calling back from. | | 217 | * Arguments: w - the widget we are calling back from. |
218 | * global_pointer - the pointer to the pseudo global structure | | 218 | * global_pointer - the pointer to the pseudo global structure |
219 | * associated with this manpage. | | 219 | * associated with this manpage. |
220 | * ret_val - return value from the list widget. | | 220 | * ret_val - return value from the list widget. |
221 | * Returns: none. | | 221 | * Returns: none. |
222 | */ | | 222 | */ |
223 | | | 223 | |
224 | void | | 224 | void |
225 | DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val) | | 225 | DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val) |
226 | { | | 226 | { |
227 | FILE *file; /* The manpage file. */ | | 227 | FILE *file; /* The manpage file. */ |
228 | ManpageGlobals *man_globals = (ManpageGlobals *) global_pointer; | | 228 | ManpageGlobals *man_globals = (ManpageGlobals *) global_pointer; |
229 | XawListReturnStruct *ret_struct = (XawListReturnStruct *) ret_val; | | 229 | XawListReturnStruct *ret_struct = (XawListReturnStruct *) ret_val; |
230 | | | 230 | |
231 | file = FindManualFile(man_globals, man_globals->current_directory, | | 231 | file = FindManualFile(man_globals, man_globals->current_directory, |
232 | ret_struct->list_index); | | 232 | ret_struct->list_index); |
233 | PutUpManpage(man_globals, file); | | 233 | PutUpManpage(man_globals, file); |
234 | if ((file != NULL) && (file != man_globals->curr_file)) { | | 234 | if ((file != NULL) && (file != man_globals->curr_file)) { |
235 | fclose(file); | | 235 | fclose(file); |
236 | } | | 236 | } |
237 | } | | 237 | } |
238 | | | 238 | |
239 | /* Function Name: DirPopupCallback | | 239 | /* Function Name: DirPopupCallback |
240 | * Description: This is the callback function for the callback menu. | | 240 | * Description: This is the callback function for the callback menu. |
241 | * Arguments: w - the widget we are calling back from. | | 241 | * Arguments: w - the widget we are calling back from. |
242 | * pointer - a pointer to the pseudo globals structure | | 242 | * pointer - a pointer to the pseudo globals structure |
243 | * for this manpage. | | 243 | * for this manpage. |
244 | * junk - (call data) not used. | | 244 | * junk - (call data) not used. |
245 | * Returns: none. | | 245 | * Returns: none. |
246 | */ | | 246 | */ |
247 | | | 247 | |
248 | /*ARGSUSED*/ | | 248 | /*ARGSUSED*/ |
249 | void | | 249 | void |
250 | DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk) | | 250 | DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk) |
251 | { | | 251 | { |
252 | ManpageGlobals *man_globals; | | 252 | ManpageGlobals *man_globals; |
253 | MenuStruct *menu_struct; | | 253 | MenuStruct *menu_struct; |
254 | Widget parent; | | 254 | Widget parent; |
255 | int number; | | 255 | int number; |
256 | int current_box; | | 256 | int current_box; |
257 | | | 257 | |
258 | menu_struct = (MenuStruct *) pointer; | | 258 | menu_struct = (MenuStruct *) pointer; |
259 | man_globals = (ManpageGlobals *) menu_struct->data; | | 259 | man_globals = (ManpageGlobals *) menu_struct->data; |
260 | | | 260 | |
261 | number = menu_struct->number; | | 261 | number = menu_struct->number; |
262 | current_box = man_globals->current_directory; | | 262 | current_box = man_globals->current_directory; |
263 | | | 263 | |
264 | /* We have used this guy, pop down the menu. */ | | 264 | /* We have used this guy, pop down the menu. */ |
265 | | | 265 | |
266 | if (number != current_box) { | | 266 | if (number != current_box) { |
267 | /* This is the only one that we know has a parent. */ | | 267 | /* This is the only one that we know has a parent. */ |
268 | parent = XtParent(man_globals->manpagewidgets.box[INITIAL_DIR]); | | 268 | parent = XtParent(man_globals->manpagewidgets.box[INITIAL_DIR]); |
269 | | | 269 | |
270 | MakeDirectoryBox(man_globals, parent, | | 270 | MakeDirectoryBox(man_globals, parent, |
271 | man_globals->manpagewidgets.box + number, number); | | 271 | man_globals->manpagewidgets.box + number, number); |
272 | XtUnmanageChild(man_globals->manpagewidgets.box[current_box]); | | 272 | XtUnmanageChild(man_globals->manpagewidgets.box[current_box]); |
273 | XtManageChild(man_globals->manpagewidgets.box[number]); | | 273 | XtManageChild(man_globals->manpagewidgets.box[number]); |
274 | | | 274 | |
275 | XawListUnhighlight(man_globals->manpagewidgets.box[current_box]); | | 275 | XawListUnhighlight(man_globals->manpagewidgets.box[current_box]); |
276 | ChangeLabel(man_globals->label, man_globals->section_name[number]); | | 276 | ChangeLabel(man_globals->label, man_globals->section_name[number]); |
277 | man_globals->current_directory = number; | | 277 | man_globals->current_directory = number; |
278 | } | | 278 | } |
279 | | | 279 | |
280 | /* put up directory. */ | | 280 | /* put up directory. */ |
281 | if (!man_globals->both_shown) { | | 281 | if (!man_globals->both_shown) { |
282 | XtUnmanageChild(man_globals->manpagewidgets.manpage); | | 282 | XtUnmanageChild(man_globals->manpagewidgets.manpage); |
283 | XtManageChild(man_globals->manpagewidgets.directory); | | 283 | XtManageChild(man_globals->manpagewidgets.directory); |
284 | } | | 284 | } |
285 | } | | 285 | } |
286 | | | 286 | |
287 | /************************************************************ | | 287 | /************************************************************ |
288 | * | | 288 | * |
289 | * Action Routines. | | 289 | * Action Routines. |
290 | * | | 290 | * |
291 | ************************************************************/ | | 291 | ************************************************************/ |
292 | | | 292 | |
293 | /* Function Name: SaveFormattedPage | | 293 | /* Function Name: SaveFormattedPage |
294 | * Description: This is the action routine may save the manpage. | | 294 | * Description: This is the action routine may save the manpage. |
295 | * Arguments: w - any widget in the widget tree. | | 295 | * Arguments: w - any widget in the widget tree. |
296 | * event - NOT USED. | | 296 | * event - NOT USED. |
297 | * params, num_params - the parameters passed to the action | | 297 | * params, num_params - the parameters passed to the action |
298 | * routine, can be either Manpage or | | 298 | * routine, can be either Manpage or |
299 | * Directory. | | 299 | * Directory. |
300 | * Returns: none. | | 300 | * Returns: none. |
301 | */ | | 301 | */ |
302 | | | 302 | |
303 | /*ARGSUSED*/ | | 303 | /*ARGSUSED*/ |
304 | void | | 304 | void |
305 | SaveFormattedPage(Widget w, XEvent * event, String * params, | | 305 | SaveFormattedPage(Widget w, XEvent * event, String * params, |
306 | Cardinal * num_params) | | 306 | Cardinal * num_params) |
307 | { | | 307 | { |
308 | ManpageGlobals *man_globals; | | 308 | ManpageGlobals *man_globals; |
309 | char cmdbuf[BUFSIZ], error_buf[BUFSIZ]; | | 309 | char cmdbuf[BUFSIZ], error_buf[BUFSIZ]; |
310 | | | 310 | |
311 | if (*num_params != 1) { | | 311 | if (*num_params != 1) { |
312 | XtAppWarning(XtWidgetToApplicationContext(w), | | 312 | XtAppWarning(XtWidgetToApplicationContext(w), |
313 | "Xman - SaveFormattedPage: This action routine requires one argument."); | | 313 | "Xman - SaveFormattedPage: This action routine requires one argument."); |
314 | return; | | 314 | return; |
315 | } | | 315 | } |
316 | | | 316 | |
317 | man_globals = GetGlobals(w); | | 317 | man_globals = GetGlobals(w); |
318 | | | 318 | |
319 | /* | | 319 | /* |
320 | * If we are not active then take no action. | | 320 | * If we are not active then take no action. |
321 | */ | | 321 | */ |
322 | | | 322 | |
323 | if (man_globals->tempfile == NULL || man_globals->tempfile[0] == '\0') | | 323 | if (man_globals->tempfile[0] == '\0') |
324 | return; | | 324 | return; |
325 | | | 325 | |
326 | switch (params[0][0]) { | | 326 | switch (params[0][0]) { |
327 | case 'S': | | 327 | case 'S': |
328 | case 's': | | 328 | case 's': |
329 | | | 329 | |
330 | #ifndef NO_COMPRESS | | 330 | #ifndef NO_COMPRESS |
331 | if (!man_globals->compress) | | 331 | if (!man_globals->compress) |
332 | #endif | | 332 | #endif |
333 | | | 333 | |
334 | snprintf(cmdbuf, sizeof(cmdbuf), "%s %s %s", COPY, | | 334 | snprintf(cmdbuf, sizeof(cmdbuf), "%s %s %s", COPY, |
335 | man_globals->tempfile, man_globals->save_file); | | 335 | man_globals->tempfile, man_globals->save_file); |
336 | | | 336 | |
337 | #ifndef NO_COMPRESS | | 337 | #ifndef NO_COMPRESS |
338 | else if (man_globals->gzip) | | 338 | else if (man_globals->gzip) |
339 | snprintf(cmdbuf, sizeof(cmdbuf), "%s < %s > %s", GZIP_COMPRESS, | | 339 | snprintf(cmdbuf, sizeof(cmdbuf), "%s < %s > %s", GZIP_COMPRESS, |
340 | man_globals->tempfile, man_globals->save_file); | | 340 | man_globals->tempfile, man_globals->save_file); |
341 | else | | 341 | else |
342 | snprintf(cmdbuf, sizeof(cmdbuf), "%s < %s > %s", COMPRESS, | | 342 | snprintf(cmdbuf, sizeof(cmdbuf), "%s < %s > %s", COMPRESS, |
343 | man_globals->tempfile, man_globals->save_file); | | 343 | man_globals->tempfile, man_globals->save_file); |
344 | #endif | | 344 | #endif |
345 | | | 345 | |
346 | if (!system(cmdbuf)) { | | 346 | if (!system(cmdbuf)) { |
347 | /* make sure the formatted man page is fully accessible by the world */ | | 347 | /* make sure the formatted man page is fully accessible by the world */ |
348 | if (chmod(man_globals->save_file, CHMOD_MODE) != 0) { | | 348 | if (chmod(man_globals->save_file, CHMOD_MODE) != 0) { |
349 | snprintf(error_buf, sizeof(error_buf), | | 349 | snprintf(error_buf, sizeof(error_buf), |
350 | "Couldn't set permissions on formatted man page '%s'.\n", | | 350 | "Couldn't set permissions on formatted man page '%s'.\n", |
351 | man_globals->save_file); | | 351 | man_globals->save_file); |
352 | PopupWarning(man_globals, error_buf); | | 352 | PopupWarning(man_globals, error_buf); |
353 | } | | 353 | } |
354 | } | | 354 | } |
355 | else { | | 355 | else { |
356 | snprintf(error_buf, sizeof(error_buf), | | 356 | snprintf(error_buf, sizeof(error_buf), |
357 | "Error while executing the command '%s'.\n", cmdbuf); | | 357 | "Error while executing the command '%s'.\n", cmdbuf); |
358 | PopupWarning(man_globals, error_buf); | | 358 | PopupWarning(man_globals, error_buf); |
359 | } | | 359 | } |
360 | break; | | 360 | break; |
361 | case 'C': | | 361 | case 'C': |
362 | case 'c': | | 362 | case 'c': |
363 | break; | | 363 | break; |
364 | default: | | 364 | default: |
365 | PopupWarning(man_globals, "Xman - SaveFormattedPage: " | | 365 | PopupWarning(man_globals, "Xman - SaveFormattedPage: " |
366 | "Unknown argument must be either 'Save' or 'Cancel'."); | | 366 | "Unknown argument must be either 'Save' or 'Cancel'."); |
367 | return; | | 367 | return; |
368 | } | | 368 | } |
369 | | | 369 | |
370 | /* | | 370 | /* |
371 | * We do not need the filename anymore, and have the fd open. | | 371 | * We do not need the filename anymore, and have the fd open. |
372 | * We will remove it. | | 372 | * We will remove it. |
373 | */ | | 373 | */ |
374 | | | 374 | |
375 | remove(man_globals->tempfile); | | 375 | remove(man_globals->tempfile); |
376 | XtPopdown(XtParent(XtParent(w))); | | 376 | XtPopdown(XtParent(XtParent(w))); |
377 | } | | 377 | } |
378 | | | 378 | |
379 | /* Function Name: GotoPage | | 379 | /* Function Name: GotoPage |
380 | * Description: The Action routine that switches over to the manpage | | 380 | * Description: The Action routine that switches over to the manpage |
381 | * or directory. | | 381 | * or directory. |
382 | * Arguments: w - any widget in the widget tree. | | 382 | * Arguments: w - any widget in the widget tree. |
383 | * event - NOT USED. | | 383 | * event - NOT USED. |
384 | * params, num_params - the parameters passed to the action | | 384 | * params, num_params - the parameters passed to the action |
385 | * routine, can be either Manpage or | | 385 | * routine, can be either Manpage or |
386 | * Directory. | | 386 | * Directory. |
387 | * Returns: none. | | 387 | * Returns: none. |
388 | */ | | 388 | */ |
389 | | | 389 | |
390 | /*ARGSUSED*/ | | 390 | /*ARGSUSED*/ |
391 | void | | 391 | void |
392 | GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params) | | 392 | GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params) |
393 | { | | 393 | { |
394 | ManpageGlobals *man_globals; | | 394 | ManpageGlobals *man_globals; |
395 | Arg arglist[1]; | | 395 | Arg arglist[1]; |
396 | Boolean sensitive; | | 396 | Boolean sensitive; |
397 | | | 397 | |
398 | if (*num_params != 1) { | | 398 | if (*num_params != 1) { |
399 | XtAppWarning(XtWidgetToApplicationContext(w), | | 399 | XtAppWarning(XtWidgetToApplicationContext(w), |
400 | "Xman - GotoPage: This action routine requires one argument."); | | 400 | "Xman - GotoPage: This action routine requires one argument."); |
401 | return; | | 401 | return; |
402 | } | | 402 | } |
403 | | | 403 | |
404 | man_globals = GetGlobals(w); | | 404 | man_globals = GetGlobals(w); |
405 | | | 405 | |
406 | if (man_globals->both_shown) { | | 406 | if (man_globals->both_shown) { |
407 | ChangeLabel(man_globals->label, | | 407 | ChangeLabel(man_globals->label, |
408 | man_globals->section_name[man_globals->current_directory]); | | 408 | man_globals->section_name[man_globals->current_directory]); |
409 | return; | | 409 | return; |
410 | } | | 410 | } |
411 | | | 411 | |
412 | switch (params[0][0]) { | | 412 | switch (params[0][0]) { |
413 | case 'M': | | 413 | case 'M': |
414 | case 'm': | | 414 | case 'm': |
415 | XtSetArg(arglist[0], XtNsensitive, &sensitive); | | 415 | XtSetArg(arglist[0], XtNsensitive, &sensitive); |
416 | XtGetValues(man_globals->manpage_entry, arglist, ONE); | | 416 | XtGetValues(man_globals->manpage_entry, arglist, ONE); |
417 | if (sensitive) { | | 417 | if (sensitive) { |
418 | ChangeLabel(man_globals->label, man_globals->manpage_title); | | 418 | ChangeLabel(man_globals->label, man_globals->manpage_title); |
419 | XtUnmanageChild(man_globals->manpagewidgets.directory); | | 419 | XtUnmanageChild(man_globals->manpagewidgets.directory); |
420 | XtManageChild(man_globals->manpagewidgets.manpage); | | 420 | XtManageChild(man_globals->manpagewidgets.manpage); |
421 | man_globals->dir_shown = FALSE; | | 421 | man_globals->dir_shown = FALSE; |
422 | } | | 422 | } |
423 | break; | | 423 | break; |
424 | case 'D': | | 424 | case 'D': |
425 | case 'd': | | 425 | case 'd': |
426 | ChangeLabel(man_globals->label, | | 426 | ChangeLabel(man_globals->label, |
427 | man_globals->section_name[man_globals->current_directory]); | | 427 | man_globals->section_name[man_globals->current_directory]); |
428 | XtUnmanageChild(man_globals->manpagewidgets.manpage); | | 428 | XtUnmanageChild(man_globals->manpagewidgets.manpage); |
429 | XtManageChild(man_globals->manpagewidgets.directory); | | 429 | XtManageChild(man_globals->manpagewidgets.directory); |
430 | man_globals->dir_shown = TRUE; | | 430 | man_globals->dir_shown = TRUE; |
431 | break; | | 431 | break; |
432 | default: | | 432 | default: |
433 | XtAppWarning(XtWidgetToApplicationContext(w), | | 433 | XtAppWarning(XtWidgetToApplicationContext(w), |
434 | "Xman - GotoPage: Unknown argument must be " | | 434 | "Xman - GotoPage: Unknown argument must be " |
435 | "either Manpage or Directory."); | | 435 | "either Manpage or Directory."); |
436 | return; | | 436 | return; |
437 | } | | 437 | } |
438 | } | | 438 | } |
439 | | | 439 | |
440 | /* Function Name: Quit. | | 440 | /* Function Name: Quit. |
441 | * Description: Quits Xman. | | 441 | * Description: Quits Xman. |
442 | * Arguments: w - any widget. | | 442 | * Arguments: w - any widget. |
443 | * event - NOT USED. | | 443 | * event - NOT USED. |
444 | * params, num_params - NOT USED. | | 444 | * params, num_params - NOT USED. |
445 | * Returns: none. | | 445 | * Returns: none. |
446 | */ | | 446 | */ |
447 | | | 447 | |
448 | /*ARGSUSED*/ | | 448 | /*ARGSUSED*/ |
449 | void | | 449 | void |
450 | Quit(Widget w, XEvent * event, String * params, Cardinal * num_params) | | 450 | Quit(Widget w, XEvent * event, String * params, Cardinal * num_params) |
451 | { | | 451 | { |
452 | XtAppSetExitFlag(XtWidgetToApplicationContext(w)); | | 452 | XtAppSetExitFlag(XtWidgetToApplicationContext(w)); |
453 | } | | 453 | } |
454 | | | 454 | |
455 | /* Function Name: PopupHelp | | 455 | /* Function Name: PopupHelp |
456 | * Description: Pops up xman's help. | | 456 | * Description: Pops up xman's help. |
457 | * Arguments: w - NOT USED. | | 457 | * Arguments: w - NOT USED. |
458 | * event - NOT USED. | | 458 | * event - NOT USED. |
459 | * params, num_params - NOT USED. | | 459 | * params, num_params - NOT USED. |
460 | * Returns: none. | | 460 | * Returns: none. |
461 | */ | | 461 | */ |
462 | | | 462 | |
463 | /*ARGSUSED*/ | | 463 | /*ARGSUSED*/ |
464 | void | | 464 | void |
465 | PopupHelp(Widget w, XEvent * event, String * params, Cardinal * num_params) | | 465 | PopupHelp(Widget w, XEvent * event, String * params, Cardinal * num_params) |
466 | { | | 466 | { |
467 | if (MakeHelpWidget()) | | 467 | if (MakeHelpWidget()) |
468 | XtPopup(help_widget, XtGrabNone); | | 468 | XtPopup(help_widget, XtGrabNone); |
469 | } | | 469 | } |
470 | | | 470 | |
471 | /* Function Name: PopupSearch | | 471 | /* Function Name: PopupSearch |
472 | * Description: Pops up this manual pages search widget. | | 472 | * Description: Pops up this manual pages search widget. |
473 | * Arguments: w - any widget in this manpage. | | 473 | * Arguments: w - any widget in this manpage. |
474 | * event - NOT USED. | | 474 | * event - NOT USED. |
475 | * params, num_params - NOT USED. | | 475 | * params, num_params - NOT USED. |
476 | * Returns: none. | | 476 | * Returns: none. |
477 | */ | | 477 | */ |
478 | | | 478 | |
479 | /*ARGSUSED*/ | | 479 | /*ARGSUSED*/ |
480 | void | | 480 | void |
481 | PopupSearch(Widget w, XEvent * event, String * params, Cardinal * num_params) | | 481 | PopupSearch(Widget w, XEvent * event, String * params, Cardinal * num_params) |
482 | { | | 482 | { |
483 | ManpageGlobals *man_globals = GetGlobals(w); | | 483 | ManpageGlobals *man_globals = GetGlobals(w); |
484 | | | 484 | |
485 | if (man_globals->search_widget) { | | 485 | if (man_globals->search_widget) { |
486 | if (!XtIsRealized(man_globals->search_widget)) { | | 486 | if (!XtIsRealized(man_globals->search_widget)) { |
487 | XtRealizeWidget(man_globals->search_widget); | | 487 | XtRealizeWidget(man_globals->search_widget); |
488 | AddCursor(man_globals->search_widget, | | 488 | AddCursor(man_globals->search_widget, |
489 | resources.cursors.search_entry); | | 489 | resources.cursors.search_entry); |
490 | } | | 490 | } |
491 | Popup(man_globals->search_widget, XtGrabNone); | | 491 | Popup(man_globals->search_widget, XtGrabNone); |
492 | } | | 492 | } |
493 | } | | 493 | } |
494 | | | 494 | |
495 | /* Function Name: CreateNewManpage | | 495 | /* Function Name: CreateNewManpage |
496 | * Description: Creates A New Manual Page. | | 496 | * Description: Creates A New Manual Page. |
497 | * Arguments: w - NOT USED. | | 497 | * Arguments: w - NOT USED. |
498 | * event - NOT USED. | | 498 | * event - NOT USED. |
499 | * params, num_params - NOT USED. | | 499 | * params, num_params - NOT USED. |
500 | * Returns: none. | | 500 | * Returns: none. |
501 | */ | | 501 | */ |
502 | | | 502 | |
503 | /*ARGSUSED*/ | | 503 | /*ARGSUSED*/ |
504 | void | | 504 | void |
505 | CreateNewManpage(Widget w, XEvent * event, String * params, | | 505 | CreateNewManpage(Widget w, XEvent * event, String * params, |
506 | Cardinal * num_params) | | 506 | Cardinal * num_params) |
507 | { | | 507 | { |
508 | if (CreateManpage(NULL)) | | 508 | if (CreateManpage(NULL)) |
509 | man_pages_shown++; | | 509 | man_pages_shown++; |
510 | } | | 510 | } |
511 | | | 511 | |
512 | /* Function Name: RemoveThisManpage | | 512 | /* Function Name: RemoveThisManpage |
513 | * Description: Removes a manual page. | | 513 | * Description: Removes a manual page. |
514 | * Arguments: w - any widget in the manpage. | | 514 | * Arguments: w - any widget in the manpage. |
515 | * event - NOT USED. | | 515 | * event - NOT USED. |
516 | * params, num_params - NOT USED. | | 516 | * params, num_params - NOT USED. |
517 | * Returns: none. | | 517 | * Returns: none. |
518 | */ | | 518 | */ |
519 | | | 519 | |
520 | /*ARGSUSED*/ | | 520 | /*ARGSUSED*/ |
521 | void | | 521 | void |
522 | RemoveThisManpage(Widget w, XEvent * event, String * params, | | 522 | RemoveThisManpage(Widget w, XEvent * event, String * params, |
523 | Cardinal * num_params) | | 523 | Cardinal * num_params) |
524 | { | | 524 | { |
525 | ManpageGlobals *man_globals = GetGlobals(w); | | 525 | ManpageGlobals *man_globals = GetGlobals(w); |
526 | | | 526 | |
527 | if (man_globals->This_Manpage != help_widget) { | | 527 | if (man_globals->This_Manpage != help_widget) { |
528 | RemoveGlobals(man_globals->This_Manpage); | | 528 | RemoveGlobals(man_globals->This_Manpage); |
529 | XtDestroyWidget(man_globals->This_Manpage); | | 529 | XtDestroyWidget(man_globals->This_Manpage); |
530 | | | 530 | |
531 | XtFree((char *) man_globals->section_name); | | 531 | XtFree((char *) man_globals->section_name); |
532 | XtFree((char *) man_globals->manpagewidgets.box); | | 532 | XtFree((char *) man_globals->manpagewidgets.box); |
533 | XtFree((char *) man_globals); | | 533 | XtFree((char *) man_globals); |
534 | | | 534 | |
535 | if ((--man_pages_shown) == 0) | | 535 | if ((--man_pages_shown) == 0) |
536 | Quit(w, NULL, NULL, NULL); | | 536 | Quit(w, NULL, NULL, NULL); |
537 | } | | 537 | } |
538 | else | | 538 | else |
539 | XtPopdown(help_widget); | | 539 | XtPopdown(help_widget); |
540 | } | | 540 | } |
541 | | | 541 | |
542 | /* Function Name: Search | | 542 | /* Function Name: Search |
543 | * Description: Actually performs a search. | | 543 | * Description: Actually performs a search. |
544 | * Arguments: w - any widget in the manpage. | | 544 | * Arguments: w - any widget in the manpage. |
545 | * event - NOT USED. | | 545 | * event - NOT USED. |
546 | * params, num_params - NOT USED. | | 546 | * params, num_params - NOT USED. |
547 | * Returns: none. | | 547 | * Returns: none. |
548 | */ | | 548 | */ |
549 | | | 549 | |
550 | /*ARGSUSED*/ | | 550 | /*ARGSUSED*/ |
551 | void | | 551 | void |
552 | Search(Widget w, XEvent * event, String * params, Cardinal * num_params) | | 552 | Search(Widget w, XEvent * event, String * params, Cardinal * num_params) |
553 | { | | 553 | { |
554 | ManpageGlobals *man_globals = GetGlobals(w); | | 554 | ManpageGlobals *man_globals = GetGlobals(w); |
555 | FILE *file = NULL; | | 555 | FILE *file = NULL; |
556 | | | 556 | |
557 | XtPopdown(XtParent(XtParent(w))); /* popdown the search widget */ | | 557 | XtPopdown(XtParent(XtParent(w))); /* popdown the search widget */ |
558 | | | 558 | |
559 | if ((*num_params < 1) || (*num_params > 2)) { | | 559 | if ((*num_params < 1) || (*num_params > 2)) { |
560 | XtAppWarning(XtWidgetToApplicationContext(w), | | 560 | XtAppWarning(XtWidgetToApplicationContext(w), |
561 | "Xman - Search: This action routine requires one or two arguments."); | | 561 | "Xman - Search: This action routine requires one or two arguments."); |
562 | return; | | 562 | return; |
563 | } | | 563 | } |
564 | | | 564 | |
565 | switch (params[0][0]) { | | 565 | switch (params[0][0]) { |
566 | case 'a': | | 566 | case 'a': |
567 | case 'A': | | 567 | case 'A': |
568 | file = DoSearch(man_globals, APROPOS); | | 568 | file = DoSearch(man_globals, APROPOS); |
569 | break; | | 569 | break; |
570 | case 'm': | | 570 | case 'm': |
571 | case 'M': | | 571 | case 'M': |
572 | file = DoSearch(man_globals, MANUAL); | | 572 | file = DoSearch(man_globals, MANUAL); |
573 | break; | | 573 | break; |
574 | case 'c': | | 574 | case 'c': |
575 | case 'C': | | 575 | case 'C': |
576 | file = NULL; | | 576 | file = NULL; |
577 | break; | | 577 | break; |
578 | default: | | 578 | default: |
579 | XtAppWarning(XtWidgetToApplicationContext(w), | | 579 | XtAppWarning(XtWidgetToApplicationContext(w), |
580 | "Xman - Search: First parameter unknown."); | | 580 | "Xman - Search: First parameter unknown."); |
581 | file = NULL; | | 581 | file = NULL; |
582 | break; | | 582 | break; |
583 | } | | 583 | } |
584 | | | 584 | |
585 | if (*num_params == 2) | | 585 | if (*num_params == 2) |
586 | switch (params[1][0]) { | | 586 | switch (params[1][0]) { |
587 | case 'O': | | 587 | case 'O': |
588 | case 'o': | | 588 | case 'o': |
589 | if (file != NULL) { | | 589 | if (file != NULL) { |
590 | Widget w2; | | 590 | Widget w2; |
591 | char *label; | | 591 | char *label; |
592 | | | 592 | |
593 | w2 = CreateManpage(file); | | 593 | w2 = CreateManpage(file); |
594 | if (w2) { | | 594 | if (w2) { |
595 | man_pages_shown++; | | 595 | man_pages_shown++; |
596 | | | 596 | |
597 | /* Put title into new manual page. */ | | 597 | /* Put title into new manual page. */ |
598 | | | 598 | |
599 | label = man_globals->manpage_title; | | 599 | label = man_globals->manpage_title; |
600 | man_globals = GetGlobals(w2); | | 600 | man_globals = GetGlobals(w2); |
601 | strcpy(man_globals->manpage_title, label); | | 601 | strcpy(man_globals->manpage_title, label); |
602 | ChangeLabel(man_globals->label, label); | | 602 | ChangeLabel(man_globals->label, label); |
603 | } | | 603 | } |
604 | } | | 604 | } |
605 | break; | | 605 | break; |
606 | default: | | 606 | default: |
607 | XtAppWarning(XtWidgetToApplicationContext(w), | | 607 | XtAppWarning(XtWidgetToApplicationContext(w), |
608 | "Xman - Search: Second parameter unknown."); | | 608 | "Xman - Search: Second parameter unknown."); |
609 | break; | | 609 | break; |
610 | } | | 610 | } |
611 | else { | | 611 | else { |
612 | PutUpManpage(man_globals, file); | | 612 | PutUpManpage(man_globals, file); |
613 | } | | 613 | } |
614 | if ((file != NULL) && (file != man_globals->curr_file)) { | | 614 | if ((file != NULL) && (file != man_globals->curr_file)) { |
615 | fclose(file); | | 615 | fclose(file); |
616 | } | | 616 | } |
617 | } | | 617 | } |
618 | | | 618 | |
619 | #ifdef INCLUDE_XPRINT_SUPPORT | | 619 | #ifdef INCLUDE_XPRINT_SUPPORT |
620 | static void | | 620 | static void |
621 | printshellDestroyXtProc(Widget w, XtPointer client_data, XtPointer callData) | | 621 | printshellDestroyXtProc(Widget w, XtPointer client_data, XtPointer callData) |
622 | { | | 622 | { |
623 | ManpageGlobals *mg = GetGlobals(w); | | 623 | ManpageGlobals *mg = GetGlobals(w); |
624 | | | 624 | |
625 | XawPrintDialogClosePrinterConnection(mg->printdialog, False); | | 625 | XawPrintDialogClosePrinterConnection(mg->printdialog, False); |
626 | } | | 626 | } |
627 | | | 627 | |
628 | static void | | 628 | static void |
629 | printOKXtProc(Widget w, XtPointer client_data, XtPointer callData) | | 629 | printOKXtProc(Widget w, XtPointer client_data, XtPointer callData) |
630 | { | | 630 | { |
631 | XawPrintDialogCallbackStruct *pdcs = | | 631 | XawPrintDialogCallbackStruct *pdcs = |
632 | (XawPrintDialogCallbackStruct *) callData; | | 632 | (XawPrintDialogCallbackStruct *) callData; |
633 | Cardinal n; | | 633 | Cardinal n; |
634 | Arg args[2]; | | 634 | Arg args[2]; |
635 | ManpageGlobals *mg = GetGlobals(w); | | 635 | ManpageGlobals *mg = GetGlobals(w); |
636 | Widget topwindow = mg->This_Manpage; | | 636 | Widget topwindow = mg->This_Manpage; |
637 | FILE *file; | | 637 | FILE *file; |
638 | | | 638 | |
639 | Log(("printOKXtProc: OK.\n")); | | 639 | Log(("printOKXtProc: OK.\n")); |
640 | | | 640 | |
641 | /* Get file object */ | | 641 | /* Get file object */ |
642 | n = 0; | | 642 | n = 0; |
643 | XtSetArg(args[n], XtNfile, &file); | | 643 | XtSetArg(args[n], XtNfile, &file); |
644 | n++; | | 644 | n++; |
645 | XtGetValues(mg->manpagewidgets.manpage, args, n); | | 645 | XtGetValues(mg->manpagewidgets.manpage, args, n); |
646 | Assertion(file != NULL, (("printOKXtProc: file == NULL.\n"))); | | 646 | Assertion(file != NULL, (("printOKXtProc: file == NULL.\n"))); |
647 | | | 647 | |
648 | DoPrintManpage("Xman", | | 648 | DoPrintManpage("Xman", |
649 | file, topwindow, | | 649 | file, topwindow, |
650 | pdcs->pdpy, pdcs->pcontext, pdcs->colorspace, | | 650 | pdcs->pdpy, pdcs->pcontext, pdcs->colorspace, |
651 | printshellDestroyXtProc, | | 651 | printshellDestroyXtProc, |
652 | mg->manpage_title, | | 652 | mg->manpage_title, |
653 | pdcs->printToFile ? pdcs->printToFileName : NULL); | | 653 | pdcs->printToFile ? pdcs->printToFileName : NULL); |
654 | | | 654 | |
655 | XtPopdown(mg->printdialog_shell); | | 655 | XtPopdown(mg->printdialog_shell); |
656 | } | | 656 | } |
657 | | | 657 | |
658 | static void | | 658 | static void |
659 | printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) | | 659 | printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) |
660 | { | | 660 | { |
661 | ManpageGlobals *mg = GetGlobals(w); | | 661 | ManpageGlobals *mg = GetGlobals(w); |
662 | | | 662 | |
663 | Log(("printCancelXtProc: cancel.\n")); | | 663 | Log(("printCancelXtProc: cancel.\n")); |
664 | XtPopdown(mg->printdialog_shell); | | 664 | XtPopdown(mg->printdialog_shell); |
665 | | | 665 | |
666 | Log(("destroying print dialog shell...\n")); | | 666 | Log(("destroying print dialog shell...\n")); |
667 | XtDestroyWidget(mg->printdialog_shell); | | 667 | XtDestroyWidget(mg->printdialog_shell); |
668 | mg->printdialog_shell = NULL; | | 668 | mg->printdialog_shell = NULL; |
669 | mg->printdialog = NULL; | | 669 | mg->printdialog = NULL; |
670 | Log(("... done\n")); | | 670 | Log(("... done\n")); |
671 | } | | 671 | } |
672 | | | 672 | |
673 | /* Function Name: PrintThisManpage | | 673 | /* Function Name: PrintThisManpage |
674 | * Description: Print the current manual page. | | 674 | * Description: Print the current manual page. |
675 | * Arguments: mg - manpage globals | | 675 | * Arguments: mg - manpage globals |
676 | * Returns: none. | | 676 | * Returns: none. |
677 | */ | | 677 | */ |
678 | | | 678 | |
679 | /*ARGSUSED*/ | | 679 | /*ARGSUSED*/ |
680 | void | | 680 | void |
681 | PrintThisManpage(Widget w, XEvent * event, String * params, | | 681 | PrintThisManpage(Widget w, XEvent * event, String * params, |
682 | Cardinal * num_params) | | 682 | Cardinal * num_params) |
683 | { | | 683 | { |
684 | ManpageGlobals *mg = GetGlobals(w); | | 684 | ManpageGlobals *mg = GetGlobals(w); |
685 | Dimension width, height; | | 685 | Dimension width, height; |
686 | Position x, y; | | 686 | Position x, y; |
687 | Widget parent = mg->This_Manpage; | | 687 | Widget parent = mg->This_Manpage; |
688 | Widget topwindow = mg->This_Manpage; | | 688 | Widget topwindow = mg->This_Manpage; |
689 | | | 689 | |
690 | Log(("print!\n")); | | 690 | Log(("print!\n")); |
691 | | | 691 | |
692 | if (!mg->printdialog) { | | 692 | if (!mg->printdialog) { |
693 | int n; | | 693 | int n; |
694 | Arg args[20]; | | 694 | Arg args[20]; |
695 | | | 695 | |
696 | n = 0; | | 696 | n = 0; |
697 | XtSetArg(args[n], XtNallowShellResize, True); | | 697 | XtSetArg(args[n], XtNallowShellResize, True); |
698 | n++; | | 698 | n++; |
699 | mg->printdialog_shell = XtCreatePopupShell("printdialogshell", | | 699 | mg->printdialog_shell = XtCreatePopupShell("printdialogshell", |
700 | transientShellWidgetClass, | | 700 | transientShellWidgetClass, |
701 | topwindow, args, n); | | 701 | topwindow, args, n); |
702 | n = 0; | | 702 | n = 0; |
703 | mg->printdialog = | | 703 | mg->printdialog = |
704 | XtCreateManagedWidget("printdialog", printDialogWidgetClass, | | 704 | XtCreateManagedWidget("printdialog", printDialogWidgetClass, |
705 | mg->printdialog_shell, args, n); | | 705 | mg->printdialog_shell, args, n); |
706 | XtAddCallback(mg->printdialog, XawNOkCallback, printOKXtProc, NULL); | | 706 | XtAddCallback(mg->printdialog, XawNOkCallback, printOKXtProc, NULL); |
707 | XtAddCallback(mg->printdialog, XawNCancelCallback, printCancelXtProc, | | 707 | XtAddCallback(mg->printdialog, XawNCancelCallback, printCancelXtProc, |
708 | NULL); | | 708 | NULL); |
709 | | | 709 | |
710 | XtRealizeWidget(mg->printdialog_shell); | | 710 | XtRealizeWidget(mg->printdialog_shell); |
711 | } | | 711 | } |
712 | | | 712 | |
713 | /* Center dialog */ | | 713 | /* Center dialog */ |
714 | XtVaGetValues(mg->printdialog_shell, | | 714 | XtVaGetValues(mg->printdialog_shell, |
715 | XtNwidth, &width, XtNheight, &height, NULL); | | 715 | XtNwidth, &width, XtNheight, &height, NULL); |
716 | | | 716 | |
717 | x = (Position) (XWidthOfScreen(XtScreen(parent)) - width) / 2; | | 717 | x = (Position) (XWidthOfScreen(XtScreen(parent)) - width) / 2; |
718 | y = (Position) (XHeightOfScreen(XtScreen(parent)) - height) / 3; | | 718 | y = (Position) (XHeightOfScreen(XtScreen(parent)) - height) / 3; |
719 | | | 719 | |
720 | XtVaSetValues(mg->printdialog_shell, XtNx, x, XtNy, y, NULL); | | 720 | XtVaSetValues(mg->printdialog_shell, XtNx, x, XtNy, y, NULL); |
721 | | | 721 | |
722 | XtPopup(mg->printdialog_shell, XtGrabNonexclusive); | | 722 | XtPopup(mg->printdialog_shell, XtGrabNonexclusive); |
723 | } | | 723 | } |
724 | #endif /* INCLUDE_XPRINT_SUPPORT */ | | 724 | #endif /* INCLUDE_XPRINT_SUPPORT */ |
725 | | | 725 | |
726 | /* Function Name: ShowVersion | | 726 | /* Function Name: ShowVersion |
727 | * Description: Show current version. | | 727 | * Description: Show current version. |
728 | * Arguments: w - any widget in the manpage. | | 728 | * Arguments: w - any widget in the manpage. |
729 | * event - NOT USED. | | 729 | * event - NOT USED. |
730 | * params, num_params - NOT USED. | | 730 | * params, num_params - NOT USED. |
731 | * Returns: none. | | 731 | * Returns: none. |
732 | */ | | 732 | */ |
733 | | | 733 | |
734 | /*ARGSUSED*/ | | 734 | /*ARGSUSED*/ |
735 | void | | 735 | void |
736 | ShowVersion(Widget w, XEvent * event, String * params, Cardinal * num_params) | | 736 | ShowVersion(Widget w, XEvent * event, String * params, Cardinal * num_params) |
737 | { | | 737 | { |
738 | ManpageGlobals *man_globals = GetGlobals(w); | | 738 | ManpageGlobals *man_globals = GetGlobals(w); |
739 | | | 739 | |
740 | ChangeLabel(man_globals->label, XMAN_VERSION); | | 740 | ChangeLabel(man_globals->label, XMAN_VERSION); |
741 | } | | 741 | } |