1 | /* |
---|
2 | * $XConsortium: viewfuncs.c,v 2.22 91/07/17 21:25:48 converse Exp $ |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT 1987, 1989 |
---|
6 | * DIGITAL EQUIPMENT CORPORATION |
---|
7 | * MAYNARD, MASSACHUSETTS |
---|
8 | * ALL RIGHTS RESERVED. |
---|
9 | * |
---|
10 | * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND |
---|
11 | * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION. |
---|
12 | * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR |
---|
13 | * ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. |
---|
14 | * |
---|
15 | * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT |
---|
16 | * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN |
---|
17 | * ADDITION TO THAT SET FORTH ABOVE. |
---|
18 | * |
---|
19 | * Permission to use, copy, modify, and distribute this software and its |
---|
20 | * documentation for any purpose and without fee is hereby granted, provided |
---|
21 | * that the above copyright notice appear in all copies and that both that |
---|
22 | * copyright notice and this permission notice appear in supporting |
---|
23 | * documentation, and that the name of Digital Equipment Corporation not be |
---|
24 | * used in advertising or publicity pertaining to distribution of the software |
---|
25 | * without specific, written prior permission. |
---|
26 | */ |
---|
27 | |
---|
28 | /* view.c -- action procedures to handle viewing of a message */ |
---|
29 | |
---|
30 | #include "xmh.h" |
---|
31 | |
---|
32 | |
---|
33 | /*ARGSUSED*/ |
---|
34 | void DoCloseView(widget, client_data, call_data) |
---|
35 | Widget widget; /* unused */ |
---|
36 | XtPointer client_data; |
---|
37 | XtPointer call_data; /* unused */ |
---|
38 | { |
---|
39 | Scrn scrn = (Scrn) client_data; |
---|
40 | XtCallbackRec confirms[2]; |
---|
41 | |
---|
42 | confirms[0].callback = DoCloseView; |
---|
43 | confirms[0].closure = (XtPointer) scrn; |
---|
44 | confirms[1].callback = (XtCallbackProc) NULL; |
---|
45 | confirms[1].closure = (XtPointer) NULL; |
---|
46 | |
---|
47 | if (MsgSetScrn((Msg) NULL, scrn, confirms, (XtCallbackList) NULL) == |
---|
48 | NEEDS_CONFIRMATION) |
---|
49 | return; |
---|
50 | DestroyScrn(scrn); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | /*ARGSUSED*/ |
---|
55 | void XmhCloseView(w, event, params, num_params) |
---|
56 | Widget w; |
---|
57 | XEvent *event; |
---|
58 | String *params; |
---|
59 | Cardinal *num_params; |
---|
60 | { |
---|
61 | Scrn scrn = ScrnFromWidget(w); |
---|
62 | DoCloseView(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | /*ARGSUSED*/ |
---|
67 | void DoViewReply(w, client_data, call_data) |
---|
68 | Widget w; |
---|
69 | XtPointer client_data; |
---|
70 | XtPointer call_data; |
---|
71 | { |
---|
72 | Scrn scrn = (Scrn) client_data; |
---|
73 | Msg msg; |
---|
74 | Scrn nscrn; |
---|
75 | |
---|
76 | if (scrn->msg == NULL) return; |
---|
77 | nscrn = NewCompScrn(); |
---|
78 | ScreenSetAssocMsg(nscrn, scrn->msg); |
---|
79 | msg = TocMakeNewMsg(DraftsFolder); |
---|
80 | MsgSetTemporary(msg); |
---|
81 | MsgLoadReply(msg, scrn->msg); |
---|
82 | MsgSetScrnForComp(msg, nscrn); |
---|
83 | MapScrn(nscrn); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | /*ARGSUSED*/ |
---|
89 | void XmhViewReply(w, event, params, num_params) |
---|
90 | Widget w; |
---|
91 | XEvent *event; |
---|
92 | String *params; |
---|
93 | Cardinal *num_params; |
---|
94 | { |
---|
95 | Scrn scrn = ScrnFromWidget(w); |
---|
96 | DoViewReply(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | /*ARGSUSED*/ |
---|
101 | void DoViewForward(w, client_data, call_data) |
---|
102 | Widget w; |
---|
103 | XtPointer client_data; |
---|
104 | XtPointer call_data; |
---|
105 | { |
---|
106 | Scrn scrn = (Scrn) client_data; |
---|
107 | MsgList mlist; |
---|
108 | |
---|
109 | if (scrn->msg == NULL) return; |
---|
110 | mlist = MakeSingleMsgList(scrn->msg); |
---|
111 | CreateForward(mlist); |
---|
112 | FreeMsgList(mlist); |
---|
113 | } |
---|
114 | |
---|
115 | /*ARGSUSED*/ |
---|
116 | void XmhViewForward(w, event, params, num_params) |
---|
117 | Widget w; |
---|
118 | XEvent *event; |
---|
119 | String *params; |
---|
120 | Cardinal *num_params; |
---|
121 | { |
---|
122 | Scrn scrn = ScrnFromWidget(w); |
---|
123 | DoViewForward(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | /*ARGSUSED*/ |
---|
128 | void DoViewUseAsComposition(w, client_data, call_data) |
---|
129 | Widget w; |
---|
130 | XtPointer client_data; |
---|
131 | XtPointer call_data; |
---|
132 | { |
---|
133 | Scrn scrn = (Scrn) client_data; |
---|
134 | Msg msg; |
---|
135 | Scrn nscrn; |
---|
136 | |
---|
137 | if (scrn->msg == NULL) return; |
---|
138 | nscrn = NewCompScrn(); |
---|
139 | if (MsgGetToc(scrn->msg) == DraftsFolder) |
---|
140 | msg = scrn->msg; |
---|
141 | else { |
---|
142 | msg = TocMakeNewMsg(DraftsFolder); |
---|
143 | MsgLoadCopy(msg, scrn->msg); |
---|
144 | MsgSetTemporary(msg); |
---|
145 | } |
---|
146 | MsgSetScrnForComp(msg, nscrn); |
---|
147 | MapScrn(nscrn); |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | /*ARGSUSED*/ |
---|
152 | void XmhViewUseAsComposition(w, event, params, num_params) |
---|
153 | Widget w; |
---|
154 | XEvent *event; |
---|
155 | String *params; |
---|
156 | Cardinal *num_params; |
---|
157 | { |
---|
158 | Scrn scrn = ScrnFromWidget(w); |
---|
159 | DoViewUseAsComposition(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
160 | } |
---|
161 | |
---|
162 | |
---|
163 | /*ARGSUSED*/ |
---|
164 | void DoEditView(w, client_data, call_data) |
---|
165 | Widget w; |
---|
166 | XtPointer client_data; |
---|
167 | XtPointer call_data; |
---|
168 | { |
---|
169 | Scrn scrn = (Scrn) client_data; |
---|
170 | Arg args[1]; |
---|
171 | XtTranslations editTranslations = scrn->edit_translations; |
---|
172 | |
---|
173 | if (scrn->msg == NULL) return; |
---|
174 | XtSetArg(args[0], XtNtranslations, editTranslations); |
---|
175 | XtSetValues(scrn->viewwidget, args, (Cardinal) 1); |
---|
176 | MsgSetEditable(scrn->msg); |
---|
177 | } |
---|
178 | |
---|
179 | |
---|
180 | /*ARGSUSED*/ |
---|
181 | void XmhEditView(w, event, params, num_params) |
---|
182 | Widget w; |
---|
183 | XEvent *event; |
---|
184 | String *params; |
---|
185 | Cardinal *num_params; |
---|
186 | { |
---|
187 | Scrn scrn = ScrnFromWidget(w); |
---|
188 | if (scrn->msg != NULL && ! MsgGetEditable(scrn->msg)) |
---|
189 | DoEditView(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
190 | } |
---|
191 | |
---|
192 | |
---|
193 | /*ARGSUSED*/ |
---|
194 | void DoSaveView(w, client_data, call_data) |
---|
195 | Widget w; |
---|
196 | XtPointer client_data; |
---|
197 | XtPointer call_data; |
---|
198 | { |
---|
199 | Scrn scrn = (Scrn) client_data; |
---|
200 | Arg args[2]; |
---|
201 | |
---|
202 | if (scrn->msg == NULL) return; |
---|
203 | if (MsgSaveChanges(scrn->msg, 1)) { |
---|
204 | XtSetArg(args[0], XtNtranslations, scrn->read_translations); |
---|
205 | XtSetValues(scrn->viewwidget, args, (Cardinal) 1); |
---|
206 | MsgClearEditable(scrn->msg); |
---|
207 | } |
---|
208 | } |
---|
209 | |
---|
210 | |
---|
211 | /*ARGSUSED*/ |
---|
212 | void XmhSaveView(w, event, params, num_params) |
---|
213 | Widget w; |
---|
214 | XEvent *event; |
---|
215 | String *params; |
---|
216 | Cardinal *num_params; |
---|
217 | { |
---|
218 | Scrn scrn = ScrnFromWidget(w); |
---|
219 | if (MsgChanged(scrn->msg) || MsgGetReapable(scrn->msg)) |
---|
220 | DoSaveView(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
221 | } |
---|
222 | |
---|
223 | |
---|
224 | /*ARGSUSED*/ |
---|
225 | void DoPrintView(w, client_data, call_data) |
---|
226 | Widget w; |
---|
227 | XtPointer client_data; |
---|
228 | XtPointer call_data; |
---|
229 | { |
---|
230 | Scrn scrn = (Scrn) client_data; |
---|
231 | char **argv; |
---|
232 | char str[200]; |
---|
233 | |
---|
234 | if (! scrn->msg) return; |
---|
235 | (void) sprintf(str, "%s %s", app_resources.print_command, |
---|
236 | MsgFileName(scrn->msg)); |
---|
237 | argv = MakeArgv(3); |
---|
238 | argv[0] = "/bin/sh"; |
---|
239 | argv[1] = "-c"; /* commands are read from the next argument */ |
---|
240 | argv[2] = str; |
---|
241 | (void) DoCommand(argv, (char*)NULL, (char*)NULL); |
---|
242 | /* a "notice" popup should appear with any stderr output */ |
---|
243 | XtFree((char*)argv); |
---|
244 | } |
---|
245 | |
---|
246 | |
---|
247 | /*ARGSUSED*/ |
---|
248 | void XmhPrintView(w, event, params, num_params) |
---|
249 | Widget w; |
---|
250 | XEvent *event; |
---|
251 | String *params; |
---|
252 | Cardinal *num_params; |
---|
253 | { |
---|
254 | Scrn scrn = ScrnFromWidget(w); |
---|
255 | DoPrintView(w, (XtPointer) scrn, (XtPointer) NULL); |
---|
256 | } |
---|
257 | |
---|
258 | |
---|
259 | /*ARGSUSED*/ |
---|
260 | void XmhViewMarkDelete(w, event, params, num_params) |
---|
261 | Widget w; |
---|
262 | XEvent *event; |
---|
263 | String *params; |
---|
264 | Cardinal *num_params; |
---|
265 | { |
---|
266 | Scrn scrn = ScrnFromWidget(w); |
---|
267 | if (scrn->msg == NULL) return; |
---|
268 | MsgSetFate(scrn->msg, Fdelete, (Toc)NULL); |
---|
269 | } |
---|
270 | |
---|
271 | |
---|