New function for an error requester with the correct imagery which doesn't attempt to do Messages lookup.

This commit is contained in:
Chris Young 2014-11-10 21:59:51 +00:00
parent 33eb1f413a
commit e9696b2fa9
3 changed files with 31 additions and 27 deletions

View File

@ -5218,7 +5218,7 @@ int main(int argc, char** argv)
ret = netsurf_register(&amiga_table);
if (ret != NSERROR_OK) {
warn_user("NetSurf operation table failed registration", "");
ami_misc_fatal_error("NetSurf operation table failed registration");
return RETURN_FAIL;
}
@ -5274,20 +5274,20 @@ int main(int argc, char** argv)
/* user options setup */
ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
if (ret != NSERROR_OK) {
warn_user("Options failed to initialise", "");
ami_misc_fatal_error("Options failed to initialise");
return RETURN_FAIL;
}
nsoption_read(current_user_options, NULL);
ami_gui_commandline(&argc, argv); /* calls nsoption_commandline */
if (ami_locate_resource(messages, "Messages") == false) {
warn_user("Cannot open Messages file", "");
ami_misc_fatal_error("Cannot open Messages file");
return RETURN_FAIL;
}
ret = netsurf_init(messages, current_user_cache);
if (ret != NSERROR_OK) {
warn_user("NetSurf failed to initialise", "");
ami_misc_fatal_error("NetSurf failed to initialise");
return RETURN_FAIL;
}
@ -5295,7 +5295,7 @@ int main(int argc, char** argv)
ret = amiga_icon_init();
if (ami_open_resources() == false) { /* alloc ports/asl reqs, open libraries/devices */
warn_user("NoMemory", "");
ami_misc_fatal_error("Unable to allocate resources");
return RETURN_FAIL;
}

View File

@ -47,33 +47,45 @@
#include "amiga/misc.h"
#include "amiga/utf8.h"
void warn_user(const char *warning, const char *detail)
static LONG ami_misc_req(const char *message, int type)
{
Object *req = NULL;
char *utf8warning = ami_utf8_easy(messages_get(warning));
STRPTR bodytext = NULL;
LONG ret = 0;
LOG(("%s %s", warning, detail));
bodytext = ASPrintf("\33b%s\33n\n%s",
utf8warning != NULL ? utf8warning : warning, detail);
LOG(("%s", message));
req = NewObject(REQUESTER_GetClass(), NULL,
REQ_Type, REQTYPE_INFO,
REQ_TitleText, messages_get("NetSurf"),
REQ_BodyText, bodytext,
REQ_BodyText, message,
REQ_GadgetText, messages_get("OK"),
#ifdef __amigaos4__
REQ_Image, (struct Image *)REQIMAGE_WARNING,
REQ_Image, (struct Image *)type,
/* REQ_CharSet, 106, */
#endif
TAG_DONE);
if (req) {
IDoMethod(req, RM_OPENREQ, NULL, NULL, scrn);
ret = IDoMethod(req, RM_OPENREQ, NULL, NULL, scrn);
DisposeObject(req);
}
return ret;
}
void ami_misc_fatal_error(const char *message)
{
ami_misc_req(message, REQIMAGE_ERROR);
}
void warn_user(const char *warning, const char *detail)
{
char *utf8warning = ami_utf8_easy(messages_get(warning));
STRPTR bodytext = ASPrintf("\33b%s\33n\n%s",
utf8warning != NULL ? utf8warning : warning, detail);
ami_misc_req(bodytext, REQIMAGE_WARNING);
if(bodytext) FreeVec(bodytext);
if(utf8warning) free(utf8warning);
}

View File

@ -23,16 +23,8 @@
extern struct gui_file_table *amiga_file_table;
char *translate_escape_chars(const char *s);
int32 ami_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win);
/**
* Cause an abnormal program termination.
*
* \note This never returns and is intended to terminate without any cleanup.
*
* \param error The message to display to the user.
*/
void die(const char * const error) __attribute__ ((noreturn));
void ami_misc_fatal_error(const char *message);
int32 ami_warn_user_multi(const char *body,
const char *opt1, const char *opt2, struct Window *win);
#endif