1/* 2 * $XConsortium: viewfuncs.c,v 2.23 92/04/08 12:18:41 rws 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/* $XFree86$ */ 28 29/* view.c -- action procedures to handle viewing of a message */ 30 31#include "xmh.h" 32#include "actions.h" 33 34/*ARGSUSED*/ 35void DoCloseView( 36 Widget widget, /* unused */ 37 XtPointer client_data, 38 XtPointer call_data) /* unused */ 39{ 40 Scrn scrn = (Scrn) client_data; 41 XtCallbackRec confirms[2]; 42 43 confirms[0].callback = DoCloseView; 44 confirms[0].closure = (XtPointer) scrn; 45 confirms[1].callback = (XtCallbackProc) NULL; 46 confirms[1].closure = (XtPointer) NULL; 47 48 if (MsgSetScrn((Msg) NULL, scrn, confirms, (XtCallbackList) NULL) == 49 NEEDS_CONFIRMATION) 50 return; 51 DestroyScrn(scrn); 52} 53 54 55/*ARGSUSED*/ 56void XmhCloseView( 57 Widget w, 58 XEvent *event, 59 String *params, 60 Cardinal *num_params) 61{ 62 Scrn scrn = ScrnFromWidget(w); 63 DoCloseView(w, (XtPointer) scrn, (XtPointer) NULL); 64} 65 66 67static void DoViewReplyMsg( 68 Scrn scrn, 69 String *params, 70 Cardinal num_params) 71{ 72 Msg msg; 73 Scrn nscrn; 74 75 if (scrn->msg == NULL) return; 76 nscrn = NewCompScrn(); 77 ScreenSetAssocMsg(nscrn, scrn->msg); 78 msg = TocMakeNewMsg(DraftsFolder); 79 MsgSetTemporary(msg); 80 MsgLoadReply(msg, scrn->msg, params, num_params); 81 MsgSetScrnForComp(msg, nscrn); 82 MapScrn(nscrn); 83} 84 85/*ARGSUSED*/ 86void DoViewReply( 87 Widget w, 88 XtPointer client_data, 89 XtPointer call_data) 90{ 91 DoViewReplyMsg((Scrn) client_data, (String *)NULL, (Cardinal)0); 92} 93 94 95 96/*ARGSUSED*/ 97void XmhViewReply( 98 Widget w, 99 XEvent *event, 100 String *params, 101 Cardinal *num_params) 102{ 103 Scrn scrn = ScrnFromWidget(w); 104 DoViewReplyMsg(scrn, params, *num_params); 105} 106 107 108/*ARGSUSED*/ 109static void DoViewForwardMsg( 110 Scrn scrn, 111 String *params, 112 Cardinal num_params) 113{ 114 MsgList mlist; 115 116 if (scrn->msg == NULL) return; 117 mlist = MakeSingleMsgList(scrn->msg); 118 CreateForward(mlist, params, num_params); 119 FreeMsgList(mlist); 120} 121 122/*ARGSUSED*/ 123void DoViewForward( 124 Widget w, 125 XtPointer client_data, 126 XtPointer call_data) 127{ 128 DoViewForwardMsg((Scrn) client_data, (String *)NULL, (Cardinal)0); 129} 130 131/*ARGSUSED*/ 132void XmhViewForward( 133 Widget w, 134 XEvent *event, 135 String *params, 136 Cardinal *num_params) 137{ 138 DoViewForwardMsg(ScrnFromWidget(w), params, *num_params); 139} 140 141 142/*ARGSUSED*/ 143void DoViewUseAsComposition( 144 Widget w, 145 XtPointer client_data, 146 XtPointer call_data) 147{ 148 Scrn scrn = (Scrn) client_data; 149 Msg msg; 150 Scrn nscrn; 151 152 if (scrn->msg == NULL) return; 153 nscrn = NewCompScrn(); 154 if (MsgGetToc(scrn->msg) == DraftsFolder) 155 msg = scrn->msg; 156 else { 157 msg = TocMakeNewMsg(DraftsFolder); 158 MsgLoadCopy(msg, scrn->msg); 159 MsgSetTemporary(msg); 160 } 161 MsgSetScrnForComp(msg, nscrn); 162 MapScrn(nscrn); 163} 164 165 166/*ARGSUSED*/ 167void XmhViewUseAsComposition( 168 Widget w, 169 XEvent *event, 170 String *params, 171 Cardinal *num_params) 172{ 173 Scrn scrn = ScrnFromWidget(w); 174 DoViewUseAsComposition(w, (XtPointer) scrn, (XtPointer) NULL); 175} 176 177 178/*ARGSUSED*/ 179void DoEditView( 180 Widget w, 181 XtPointer client_data, 182 XtPointer call_data) 183{ 184 Scrn scrn = (Scrn) client_data; 185 Arg args[1]; 186 XtTranslations editTranslations = scrn->edit_translations; 187 188 if (scrn->msg == NULL) return; 189 XtSetArg(args[0], XtNtranslations, editTranslations); 190 XtSetValues(scrn->viewwidget, args, (Cardinal) 1); 191 MsgSetEditable(scrn->msg); 192} 193 194 195/*ARGSUSED*/ 196void XmhEditView( 197 Widget w, 198 XEvent *event, 199 String *params, 200 Cardinal *num_params) 201{ 202 Scrn scrn = ScrnFromWidget(w); 203 if (scrn->msg != NULL && ! MsgGetEditable(scrn->msg)) 204 DoEditView(w, (XtPointer) scrn, (XtPointer) NULL); 205} 206 207 208/*ARGSUSED*/ 209void DoSaveView( 210 Widget w, 211 XtPointer client_data, 212 XtPointer call_data) 213{ 214 Scrn scrn = (Scrn) client_data; 215 Arg args[2]; 216 217 if (scrn->msg == NULL) return; 218 if (MsgSaveChanges(scrn->msg)) { 219 XtSetArg(args[0], XtNtranslations, scrn->read_translations); 220 XtSetValues(scrn->viewwidget, args, (Cardinal) 1); 221 MsgClearEditable(scrn->msg); 222 } 223} 224 225 226/*ARGSUSED*/ 227void XmhSaveView( 228 Widget w, 229 XEvent *event, 230 String *params, 231 Cardinal *num_params) 232{ 233 Scrn scrn = ScrnFromWidget(w); 234 if (MsgChanged(scrn->msg) || MsgGetReapable(scrn->msg)) 235 DoSaveView(w, (XtPointer) scrn, (XtPointer) NULL); 236} 237 238 239/*ARGSUSED*/ 240void DoPrintView( 241 Widget w, 242 XtPointer client_data, 243 XtPointer call_data) 244{ 245 Scrn scrn = (Scrn) client_data; 246 char **argv; 247 char str[200]; 248 249 if (! scrn->msg) return; 250 snprintf(str, sizeof(str), "%s %s", app_resources.print_command, 251 MsgFileName(scrn->msg)); 252 argv = MakeArgv(3); 253 argv[0] = "/bin/sh"; 254 argv[1] = "-c"; /* commands are read from the next argument */ 255 argv[2] = str; 256 (void) DoCommand(argv, (char*)NULL, (char*)NULL); 257 /* a "notice" popup should appear with any stderr output */ 258 XtFree((char*)argv); 259} 260 261 262/*ARGSUSED*/ 263void XmhPrintView( 264 Widget w, 265 XEvent *event, 266 String *params, 267 Cardinal *num_params) 268{ 269 Scrn scrn = ScrnFromWidget(w); 270 DoPrintView(w, (XtPointer) scrn, (XtPointer) NULL); 271} 272 273 274/*ARGSUSED*/ 275void XmhViewMarkDelete( 276 Widget w, 277 XEvent *event, 278 String *params, 279 Cardinal *num_params) 280{ 281 Scrn scrn = ScrnFromWidget(w); 282 if (scrn->msg == NULL) return; 283 MsgSetFate(scrn->msg, Fdelete, (Toc)NULL); 284} 285 286 287