Move download overwrite warning requester to misc.c

This commit is contained in:
Chris Young 2012-12-08 17:25:25 +00:00
parent 69647cc6a4
commit ffac64fcea
3 changed files with 25 additions and 18 deletions

View File

@ -37,9 +37,10 @@
#include "desktop/options.h"
#include "amiga/bitmap.h"
#include "amiga/iff_dr2d.h"
#include "amiga/file.h"
#include "amiga/misc.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
#include "amiga/file.h"
#include "desktop/download.h"
#include "desktop/selection.h"
@ -415,24 +416,8 @@ BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG si
overwritetext = ASPrintf(messages_get("OverwriteFile"));
}
char *utf8text = ami_utf8_easy(overwritetext);
res = ami_warn_user_multi(overwritetext, "DontReplace", "Replace", win);
FreeVec(overwritetext);
char *utf8gadget1 = ami_utf8_easy(messages_get("DontReplace"));
char *utf8gadget2 = ami_utf8_easy(messages_get("Replace"));
char *utf8gadgets = ASPrintf("%s|%s", utf8gadget1, utf8gadget2);
free(utf8gadget1);
free(utf8gadget2);
res = TimedDosRequesterTags(TDR_ImageType, TDRIMAGE_WARNING,
TDR_TitleString, messages_get("NetSurf"),
TDR_FormatString, utf8text,
TDR_GadgetString, utf8gadgets,
TDR_Window, win,
TAG_DONE);
if(utf8text) free(utf8text);
if(utf8gadgets) FreeVec(utf8gadgets);
}
else return TRUE;

View File

@ -71,6 +71,27 @@ void warn_user(const char *warning, const char *detail)
if(utf8warning) free(utf8warning);
}
int ami_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win)
{
int res = 0;
char *utf8text = ami_utf8_easy(body);
char *utf8gadget1 = ami_utf8_easy(messages_get(opt1));
char *utf8gadget2 = ami_utf8_easy(messages_get(opt2));
char *utf8gadgets = ASPrintf("%s|%s", utf8gadget1, utf8gadget2);
free(utf8gadget1);
free(utf8gadget2);
res = TimedDosRequesterTags(TDR_ImageType, TDRIMAGE_WARNING,
TDR_TitleString, messages_get("NetSurf"),
TDR_FormatString, utf8text,
TDR_GadgetString, utf8gadgets,
TDR_Window, win,
TAG_DONE);
if(utf8text) free(utf8text);
if(utf8gadgets) FreeVec(utf8gadgets);
}
void die(const char *error)
{
TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_ERROR,

View File

@ -19,4 +19,5 @@
#ifndef AMIGA_MISC_H
#define AMIGA_MISC_H
char *translate_escape_chars(const char *s);
int ami_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win);
#endif