3 * Handler for a save dbox under new dbox system
5 * v. 1.00 (9 August 1993)
7 * © 1993-1998 Straylight
10 /*----- Licensing note ----------------------------------------------------*
12 * This file is part of Straylight's Steel library.
14 * Steel is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * Steel is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Steel. If not, write to the Free Software Foundation,
26 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
41 static dbox saveas__db;
42 static int saveas__filetype;
43 static xfersend_saveproc saveas__saveproc;
44 static xfersend_sendproc saveas__sendproc;
45 static xfersend_printproc saveas__printproc;
46 static void *saveas__handle;
47 static int saveas__estsize;
48 static char *saveas__title;
49 static BOOL saveas__xfer;
51 #define saveas__FILEICON 1
52 #define saveas__FILENAME 2
56 * BOOL saveas__raw(dbox d,wimp_eventstr *e,void *handle)
59 * Raw event handler for the save as dialogue box.
62 * dbox d == the saveas dialogue box
63 * wimp_eventstr *e == the current wimp event
64 * void *handle == the caller's handle
67 static BOOL saveas__raw(dbox d,wimp_eventstr *e,void *handle)
74 if (e->data.but.m.bbits==wimp_BDRAGLEFT)
76 dbox_getfield(d,saveas__FILENAME,name,256);
103 * xfersend_saveproc saveproc,
104 * xfersend_sendproc sendproc,
105 * xfersend_printproc printproc,
110 * Creates and handles a save as dialogue box (even saving your data for
114 * char *title == the title of the dialogue box.
115 * char *name == the default filename for the box.
116 * int filetype == the filetype of the data to be sent.
117 * int estsize == the estimated file size.
118 * xfersend_saveproc saveproc == function to save the data.
119 * xfersend_sendproc sendproc == function to export data to another
120 * application (RAM transfer).
121 * xfersend_printproc printproc == function to print data.
122 * void *handle == your handle to the data (or anything else!)
131 xfersend_saveproc saveproc,
132 xfersend_sendproc sendproc,
133 xfersend_printproc printproc,
142 saveas__filetype=filetype;
143 saveas__estsize=estsize;
144 saveas__saveproc=saveproc;
145 saveas__sendproc=sendproc;
146 saveas__printproc=printproc;
147 saveas__handle=handle;
148 if (template_exists("save"))
150 if (saveas__db=dbox_create("save"),saveas__db==0)
155 if (saveas__db=dbox_create("xfer_send"),saveas__db==0)
158 xfersend_close_on_xfer(TRUE,dbox_syshandle(saveas__db));
159 win_settitle(dbox_syshandle(saveas__db),"%s",saveas__title);
160 dbox_setfield(saveas__db,saveas__FILENAME,"%s",name);
161 fileicon(dbox_syshandle(saveas__db),
165 dbox_rawEventHandler(saveas__db,saveas__raw,saveas__handle);
166 dbox_display(saveas__db,FALSE);
169 switch (dbox_fillin(saveas__db))
180 msgs_lookup("saveasHM:This is the %s dialogue box."),
183 switch (dbox_helpField())
185 case saveas__FILEICON:
186 help_addLine(msgs_lookup
188 "saveasFIH:Drag this icon to a Filer window or "
189 "another application to save the file."
198 if (wimpt_options() & 7)
199 dbox_clickicon(saveas__db,saveas__OK);
200 dbox_getfield(saveas__db,saveas__FILENAME,fname,256);
202 for (index=0;fname[index]!=0;index++)
204 if (fname[index]=='.')
209 if (wimpt_options() & 7)
211 note(msgs_lookup("saveasDI:To save, drag icon to a "
212 "directory viewer."));
217 werr(FALSE,msgs_lookup("saveasDI:To save, drag icon to a "
218 "directory viewer."));
224 stop=saveas__saveproc(fname,saveas__handle);
225 if (dbox_wasAdjustClick() || !stop)
227 if (wimpt_options() & 7)
233 dbox_hide(saveas__db);
234 if (wimpt_options() & 7)
241 xfersend_close_on_xfer(FALSE,0);
242 dbox_delete(saveas__db);
246 * BOOL saveas_file_is_safe(void)
249 * Informs caller if the file is going to a safe home.
252 * TRUE if the file is 'safe' - i.e. on disk
255 BOOL saveas_file_is_safe(void)
258 return (xfersend_file_is_safe());