use the miscellaneous table warning entry
change all the frontends to provide the warning callback in the miscelaneous table instead of using the warn_user function. Changing all the warn_user callsites still requires completion.
This commit is contained in:
parent
638e07f026
commit
bf3ee089cb
61
amiga/gui.c
61
amiga/gui.c
|
@ -975,7 +975,7 @@ static void gui_init2(int argc, char** argv)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
amiga_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
free(temp_homepage_url);
|
||||
}
|
||||
|
@ -1034,7 +1034,7 @@ static void gui_init2(int argc, char** argv)
|
|||
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
amiga_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
free(temp_homepage_url);
|
||||
temp_homepage_url = NULL;
|
||||
|
@ -1114,7 +1114,7 @@ static void gui_init2(int argc, char** argv)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
amiga_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1424,7 +1424,7 @@ bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
|
|||
|
||||
ami_gui_free_space_box(bbox);
|
||||
} else {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1448,7 +1448,7 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
|
|||
&gwin->gw->scrolly);
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
|
|||
if(ibox == NULL) return NULL;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1590,7 +1590,7 @@ static void gui_window_get_dimensions(struct gui_window *g, int *width, int *hei
|
|||
if(!g) return;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1782,7 +1782,7 @@ static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
|
|||
}
|
||||
|
||||
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_ICON], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1971,7 +1971,7 @@ static void ami_handle_msg(void)
|
|||
drag_y_move = 0;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2034,7 +2034,7 @@ static void ami_handle_msg(void)
|
|||
|
||||
case WMHI_MOUSEBUTTONS:
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2230,7 +2230,7 @@ static void ami_handle_msg(void)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (ret != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(ret), 0);
|
||||
amiga_warn_user(messages_get_errorcode(ret), 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2269,7 +2269,7 @@ static void ami_handle_msg(void)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (ret != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(ret), 0);
|
||||
amiga_warn_user(messages_get_errorcode(ret), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2278,7 +2278,7 @@ static void ami_handle_msg(void)
|
|||
case GID_HOME:
|
||||
{
|
||||
if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
amiga_warn_user("NoMemory", 0);
|
||||
} else {
|
||||
browser_window_navigate(gwin->gw->bw,
|
||||
url,
|
||||
|
@ -2599,7 +2599,7 @@ static void ami_handle_appmsg(void)
|
|||
nsurl *url;
|
||||
|
||||
if (netsurf_path_to_nsurl(filename, &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
amiga_warn_user("NoMemory", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2634,7 +2634,7 @@ static void ami_handle_appmsg(void)
|
|||
nsurl *url;
|
||||
|
||||
if (netsurf_path_to_nsurl(filename, &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
amiga_warn_user("NoMemory", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2701,7 +2701,7 @@ static void ami_handle_applib(void)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
amiga_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2721,7 +2721,7 @@ static void ami_handle_applib(void)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
amiga_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2870,7 +2870,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
|
|||
cur_gw = gwin->gw;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3488,7 +3488,7 @@ nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
amiga_warn_user(messages_get_errorcode(error), 0);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -3618,7 +3618,7 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw
|
|||
if(g != g->shared->gw) return;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3644,7 +3644,7 @@ static void ami_refresh_window(struct gui_window_2 *gwin)
|
|||
ami_set_pointer(gwin, GUI_POINTER_WAIT, false);
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3806,7 +3806,7 @@ gui_window_create(struct browser_window *bw,
|
|||
|
||||
if(!g)
|
||||
{
|
||||
warn_user("NoMemory","");
|
||||
amiga_warn_user("NoMemory","");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -3879,7 +3879,7 @@ gui_window_create(struct browser_window *bw,
|
|||
|
||||
if(!g->shared)
|
||||
{
|
||||
warn_user("NoMemory","");
|
||||
amiga_warn_user("NoMemory","");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -4328,7 +4328,7 @@ gui_window_create(struct browser_window *bw,
|
|||
|
||||
if(!g->shared->win)
|
||||
{
|
||||
warn_user("NoMemory","");
|
||||
amiga_warn_user("NoMemory","");
|
||||
FreeVec(g->shared);
|
||||
FreeVec(g);
|
||||
return NULL;
|
||||
|
@ -4758,7 +4758,7 @@ static void amiga_window_reformat(struct gui_window *gw)
|
|||
|
||||
if (gw != NULL) {
|
||||
if(ami_gui_get_space_box((Object *)gw->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
browser_window_reformat(gw->bw, false, bbox->Width, bbox->Height);
|
||||
|
@ -4783,7 +4783,7 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
|
|||
gwin->gw->scrolly = vcurrent;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4930,7 +4930,7 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
|||
if(!g->bw || browser_window_has_content(g->bw) == false) return;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4985,7 +4985,7 @@ static void gui_window_update_extent(struct gui_window *g)
|
|||
if(g == g->shared->gw) {
|
||||
int width, height;
|
||||
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5170,7 +5170,7 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
|
|||
SetAPen(g->shared->win->RPort,3);
|
||||
|
||||
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5265,7 +5265,7 @@ bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y)
|
|||
struct browser_window_features data;
|
||||
|
||||
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
|
||||
warn_user("NoMemory", "");
|
||||
amiga_warn_user("NoMemory", "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5469,6 +5469,7 @@ static struct gui_search_web_table amiga_search_web_table = {
|
|||
|
||||
static struct gui_misc_table amiga_misc_table = {
|
||||
.schedule = ami_schedule,
|
||||
.warning = amiga_warn_user,
|
||||
|
||||
.quit = gui_quit,
|
||||
.launch_url = gui_launch_url,
|
||||
|
|
|
@ -126,7 +126,8 @@ void ami_misc_fatal_error(const char *message)
|
|||
ami_misc_req(message, TDRIMAGE_ERROR);
|
||||
}
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
/* exported interface documented in amiga/misc.h */
|
||||
nserror amiga_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
char *utf8warning = ami_utf8_easy(messages_get(warning));
|
||||
STRPTR bodytext = ASPrintf("\33b%s\33n\n%s",
|
||||
|
@ -136,6 +137,8 @@ void warn_user(const char *warning, const char *detail)
|
|||
|
||||
if(bodytext) FreeVec(bodytext);
|
||||
if(utf8warning) free(utf8warning);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
int32 ami_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win)
|
||||
|
|
13
amiga/misc.h
13
amiga/misc.h
|
@ -18,11 +18,24 @@
|
|||
|
||||
#ifndef AMIGA_MISC_H
|
||||
#define AMIGA_MISC_H
|
||||
|
||||
#include <exec/types.h>
|
||||
|
||||
#include "utils/errors.h"
|
||||
|
||||
extern struct gui_file_table *amiga_file_table;
|
||||
struct Window;
|
||||
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \param[in] message A warning looked up in the message translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
* \return NSERROR_OK on success or error code if there was a
|
||||
* faliure displaying the message to the user.
|
||||
*/
|
||||
nserror amiga_warn_user(const char *warning, const char *detail);
|
||||
|
||||
void *ami_misc_allocvec_clear(int size, UBYTE value);
|
||||
|
||||
/* Itempool cross-compatibility */
|
||||
|
|
|
@ -1085,6 +1085,7 @@ static struct gui_fetch_table atari_fetch_table = {
|
|||
|
||||
static struct gui_misc_table atari_misc_table = {
|
||||
.schedule = atari_schedule,
|
||||
.warning = atari_warn_user,
|
||||
|
||||
.quit = gui_quit,
|
||||
.cert_verify = gui_cert_verify,
|
||||
|
@ -1193,7 +1194,7 @@ int main(int argc, char** argv)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (ret != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(ret), 0);
|
||||
atari_warn_user(messages_get_errorcode(ret), 0);
|
||||
} else {
|
||||
LOG("Entering Atari event mainloop...");
|
||||
while (!atari_quit) {
|
||||
|
|
|
@ -53,7 +53,8 @@ struct is_process_running_callback_data {
|
|||
bool found;
|
||||
};
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
/* exported function documented in atari/misc/h */
|
||||
nserror atari_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
|
||||
0) + ((detail != 0) ? strlen(detail) : 0);
|
||||
|
@ -62,6 +63,8 @@ void warn_user(const char *warning, const char *detail)
|
|||
|
||||
printf("%s\n", message);
|
||||
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, message);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
void die(const char *error)
|
||||
|
|
10
atari/misc.h
10
atari/misc.h
|
@ -89,4 +89,14 @@ long nkc_to_input_key(short nkc, long * ucs4_out);
|
|||
*/
|
||||
void die(const char * const error) __attribute__ ((noreturn));
|
||||
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \param[in] message A warning looked up in the message translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
* \return NSERROR_OK on success or error code if there was a
|
||||
* faliure displaying the message to the user.
|
||||
*/
|
||||
nserror atari_warn_user(const char *warning, const char *detail);
|
||||
|
||||
#endif
|
||||
|
|
57
beos/gui.cpp
57
beos/gui.cpp
|
@ -113,6 +113,29 @@ static int sEventPipe[2];
|
|||
// #pragma mark - class NSBrowserFrameView
|
||||
|
||||
|
||||
/**
|
||||
* Display a warning for a serious problem (eg memory exhaustion).
|
||||
*
|
||||
* \param warning message key for warning message
|
||||
* \param detail additional message, or 0
|
||||
*/
|
||||
static nserror beos_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
LOG("warn_user: %s (%s)", warning, detail);
|
||||
BAlert *alert;
|
||||
BString text(warning);
|
||||
if (detail)
|
||||
text << ":\n" << detail;
|
||||
|
||||
alert = new BAlert("NetSurf Warning", text.String(), "Debug", "Ok",
|
||||
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
if (alert->Go() < 1) {
|
||||
debugger("warn_user");
|
||||
}
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
NSBrowserApplication::NSBrowserApplication()
|
||||
: BApplication("application/x-vnd.NetSurf")
|
||||
{
|
||||
|
@ -672,7 +695,7 @@ static void gui_init(int argc, char** argv)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
beos_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
|
||||
if (gFirstRefsReceived) {
|
||||
|
@ -804,7 +827,7 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
|
|||
const char *source = content_get_source_data(content, &size);
|
||||
|
||||
if (!content || !source) {
|
||||
warn_user("MiscError", "No document source");
|
||||
beos_warn_user("MiscError", "No document source");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -826,7 +849,7 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
|
|||
* filename. */
|
||||
const char *filename = filename_request();
|
||||
if (!filename) {
|
||||
warn_user("NoMemory", 0);
|
||||
beos_warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
path.SetTo(TEMP_FILENAME_PREFIX);
|
||||
|
@ -834,12 +857,12 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
|
|||
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
|
||||
err = file.InitCheck();
|
||||
if (err < B_OK) {
|
||||
warn_user("IOError", strerror(err));
|
||||
beos_warn_user("IOError", strerror(err));
|
||||
return;
|
||||
}
|
||||
err = file.Write(source, size);
|
||||
if (err < B_OK) {
|
||||
warn_user("IOError", strerror(err));
|
||||
beos_warn_user("IOError", strerror(err));
|
||||
return;
|
||||
}
|
||||
lwc_string *mime = content_get_mime_type(content);
|
||||
|
@ -909,31 +932,11 @@ static nserror gui_launch_url(struct nsurl *url)
|
|||
char *args[2] = { (char *)nsurl_access(url), NULL };
|
||||
status = be_roster->Launch(mimeType.String(), 1, args);
|
||||
if (status < B_OK)
|
||||
warn_user("Cannot launch url", strerror(status));
|
||||
beos_warn_user("Cannot launch url", strerror(status));
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a warning for a serious problem (eg memory exhaustion).
|
||||
*
|
||||
* \param warning message key for warning message
|
||||
* \param detail additional message, or 0
|
||||
*/
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
LOG("warn_user: %s (%s)", warning, detail);
|
||||
BAlert *alert;
|
||||
BString text(warning);
|
||||
if (detail)
|
||||
text << ":\n" << detail;
|
||||
|
||||
alert = new BAlert("NetSurf Warning", text.String(), "Debug", "Ok", NULL,
|
||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
if (alert->Go() < 1)
|
||||
debugger("warn_user");
|
||||
}
|
||||
|
||||
void die(const char * const error)
|
||||
{
|
||||
|
@ -965,11 +968,11 @@ static struct gui_fetch_table beos_fetch_table = {
|
|||
|
||||
static struct gui_misc_table beos_misc_table = {
|
||||
beos_schedule,
|
||||
beos_warn_user,
|
||||
gui_quit,
|
||||
gui_launch_url,
|
||||
NULL, //cert_verify
|
||||
gui_401login_open,
|
||||
NULL, // warning
|
||||
NULL, // pdf_password (if we have Haru support)
|
||||
};
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ S_COCOA := \
|
|||
plotter.m \
|
||||
schedule.m \
|
||||
selection.m \
|
||||
utils.m \
|
||||
ArrowBox.m \
|
||||
ArrowWindow.m \
|
||||
BlackScroller.m \
|
||||
|
|
12
cocoa/gui.m
12
cocoa/gui.m
|
@ -52,6 +52,17 @@ NSString * const kAlwaysCloseMultipleTabs = @"AlwaysCloseMultipleTabs";
|
|||
|
||||
struct browser_window;
|
||||
|
||||
static nserror cocoa_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
NSRunAlertPanel( NSLocalizedString( @"Warning", @"Warning title" ),
|
||||
NSLocalizedString( @"Warning %s%s%s", @"Warning message" ),
|
||||
NSLocalizedString( @"OK", @"" ), nil, nil,
|
||||
warning, detail != NULL ? ": " : "",
|
||||
detail != NULL ? detail : "" );
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
static struct gui_window *
|
||||
gui_window_create(struct browser_window *bw,
|
||||
struct gui_window *existing,
|
||||
|
@ -299,6 +310,7 @@ struct gui_window_table *cocoa_window_table = &window_table;
|
|||
|
||||
static struct gui_misc_table browser_table = {
|
||||
.schedule = cocoa_schedule,
|
||||
.warning = cocoa_warn_user,
|
||||
|
||||
.launch_url = gui_launch_url,
|
||||
.cert_verify = gui_cert_verify,
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "utils/utils.h"
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
NSRunAlertPanel( NSLocalizedString( @"Warning", @"Warning title" ),
|
||||
NSLocalizedString( @"Warning %s%s%s", @"Warning message" ),
|
||||
NSLocalizedString( @"OK", @"" ), nil, nil,
|
||||
warning, detail != NULL ? ": " : "",
|
||||
detail != NULL ? detail : "" );
|
||||
}
|
|
@ -719,6 +719,9 @@ static nserror verify_misc_register(struct gui_misc_table *gmt)
|
|||
if (gmt->schedule == NULL) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
if (gmt->warning == NULL) {
|
||||
return NSERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
/* fill in the optional entries with defaults */
|
||||
if (gmt->quit == NULL) {
|
||||
|
|
|
@ -57,6 +57,18 @@ struct gui_misc_table {
|
|||
*/
|
||||
nserror (*schedule)(int t, void (*callback)(void *p), void *p);
|
||||
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \param[in] message A warning looked up in the message
|
||||
* translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
* \return NSERROR_OK on success or error code if there was a
|
||||
* faliure displaying the message to the user.
|
||||
*/
|
||||
nserror (*warning)(const char *message, const char *detail);
|
||||
|
||||
|
||||
/* Optional entries */
|
||||
|
||||
/**
|
||||
|
@ -86,11 +98,6 @@ struct gui_misc_table {
|
|||
void (*login)(struct nsurl *url, const char *realm,
|
||||
nserror (*cb)(bool proceed, void *pw), void *cbpw);
|
||||
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*/
|
||||
void (*warning)(const char *warning, const char *detail);
|
||||
|
||||
/**
|
||||
* Prompt the user for a password for a PDF.
|
||||
*/
|
||||
|
|
|
@ -174,7 +174,7 @@ $(eval $(foreach V,$(filter FB_FONT_$(NETSURF_FB_FONTLIB)_%,$(.VARIABLES)),$(cal
|
|||
# ----------------------------------------------------------------------------
|
||||
|
||||
# S_FRAMEBUFFER are sources purely for the framebuffer build
|
||||
S_FRAMEBUFFER := gui.c framebuffer.c schedule.c misc.c bitmap.c fetch.c \
|
||||
S_FRAMEBUFFER := gui.c framebuffer.c schedule.c bitmap.c fetch.c \
|
||||
findfile.c localhistory.c clipboard.c
|
||||
|
||||
S_FRAMEBUFFER_FBTK := fbtk.c event.c fill.c bitmap.c user.c window.c \
|
||||
|
|
|
@ -108,6 +108,21 @@ static void die(const char *error)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \param[in] message A warning looked up in the message translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
* \return NSERROR_OK on success or error code if there was a
|
||||
* faliure displaying the message to the user.
|
||||
*/
|
||||
static nserror fb_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
LOG("%s %s", warning, detail);
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* queue a redraw operation, co-ordinates are relative to the window */
|
||||
static void
|
||||
fb_queue_redraw(struct fbtk_widget_s *widget, int x0, int y0, int x1, int y1)
|
||||
|
@ -1103,7 +1118,7 @@ fb_url_enter(void *pw, char *text)
|
|||
|
||||
error = nsurl_create(text, &url);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
fb_warn_user(messages_get_errorcode(error), 0);
|
||||
} else {
|
||||
browser_window_navigate(bw, url, NULL, BW_NAVIGATE_HISTORY,
|
||||
NULL, NULL, NULL);
|
||||
|
@ -2056,6 +2071,7 @@ static struct gui_window_table framebuffer_window_table = {
|
|||
|
||||
static struct gui_misc_table framebuffer_misc_table = {
|
||||
.schedule = framebuffer_schedule,
|
||||
.warning = fb_warn_user,
|
||||
|
||||
.quit = gui_quit,
|
||||
};
|
||||
|
@ -2156,7 +2172,7 @@ main(int argc, char** argv)
|
|||
nsurl_unref(url);
|
||||
}
|
||||
if (ret != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(ret), 0);
|
||||
fb_warn_user(messages_get_errorcode(ret), 0);
|
||||
} else {
|
||||
framebuffer_run();
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
LOG("%s %s", warning, detail);
|
||||
}
|
||||
|
||||
|
13
gtk/gui.c
13
gtk/gui.c
|
@ -480,7 +480,15 @@ static nserror gui_launch_url(struct nsurl *url)
|
|||
return NSERROR_NO_FETCH_HANDLER;
|
||||
}
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \param[in] warning A warning looked up in the message translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
* \return NSERROR_OK on success or error code if there was a
|
||||
* faliure displaying the message to the user.
|
||||
*/
|
||||
static nserror nsgtk_warning(const char *warning, const char *detail)
|
||||
{
|
||||
char buf[300]; /* 300 is the size the RISC OS GUI uses */
|
||||
static GtkWindow *nsgtk_warning_window;
|
||||
|
@ -500,6 +508,8 @@ void warn_user(const char *warning, const char *detail)
|
|||
gtk_label_set_text(WarningLabel, buf);
|
||||
|
||||
gtk_widget_show_all(GTK_WIDGET(nsgtk_warning_window));
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1013,6 +1023,7 @@ static nserror nsgtk_option_init(int *pargc, char** argv)
|
|||
|
||||
static struct gui_misc_table nsgtk_misc_table = {
|
||||
.schedule = nsgtk_schedule,
|
||||
.warning = nsgtk_warning,
|
||||
|
||||
.quit = gui_quit,
|
||||
.launch_url = gui_launch_url,
|
||||
|
|
|
@ -56,7 +56,7 @@ endif
|
|||
# ----------------------------------------------------------------------------
|
||||
|
||||
# S_MONKEY are sources purely for the MONKEY build
|
||||
S_MONKEY := main.c utils.c filetype.c schedule.c bitmap.c plot.c browser.c \
|
||||
S_MONKEY := main.c filetype.c schedule.c bitmap.c plot.c browser.c \
|
||||
download.c 401login.c cert.c layout.c dispatch.c fetch.c
|
||||
|
||||
S_MONKEY := $(addprefix monkey/,$(S_MONKEY))
|
||||
|
|
|
@ -223,6 +223,13 @@ static nserror set_defaults(struct nsoption_s *defaults)
|
|||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static nserror monkey_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
fprintf(stderr, "WARN %s %s\n", warning, detail);
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensures output logging stream is correctly configured
|
||||
*/
|
||||
|
@ -236,6 +243,7 @@ static bool nslog_stream_configure(FILE *fptr)
|
|||
|
||||
static struct gui_misc_table monkey_misc_table = {
|
||||
.schedule = monkey_schedule,
|
||||
.warning = monkey_warn_user,
|
||||
|
||||
.quit = monkey_quit,
|
||||
.launch_url = gui_launch_url,
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
fprintf(stderr, "WARN %s %s\n", warning, detail);
|
||||
}
|
||||
|
79
riscos/gui.c
79
riscos/gui.c
|
@ -529,7 +529,7 @@ static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
|
|||
fp = fopen(file_name, "rb");
|
||||
if (!fp) {
|
||||
LOG("fopen(\"%s\", \"rb\"): %i: %s", file_name, errno, strerror(errno));
|
||||
warn_user("LoadError", strerror(errno));
|
||||
ro_warn_user("LoadError", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
|
|||
|
||||
url = strdup(line);
|
||||
if (!url) {
|
||||
warn_user("NoMemory", 0);
|
||||
ro_warn_user("NoMemory", 0);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
|
|||
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
|
||||
*uri_title = strdup(line);
|
||||
if (!*uri_title) /* non-fatal */
|
||||
warn_user("NoMemory", 0);
|
||||
ro_warn_user("NoMemory", 0);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
|
@ -570,7 +570,7 @@ uri_free:
|
|||
|
||||
uri_syntax_error:
|
||||
fclose(fp);
|
||||
warn_user("URIError", 0);
|
||||
ro_warn_user("URIError", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -590,16 +590,16 @@ static char *ro_gui_url_file_parse(const char *file_name)
|
|||
fp = fopen(file_name, "r");
|
||||
if (!fp) {
|
||||
LOG("fopen(\"%s\", \"r\"): %i: %s", file_name, errno, strerror(errno));
|
||||
warn_user("LoadError", strerror(errno));
|
||||
ro_warn_user("LoadError", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!fgets(line, sizeof line, fp)) {
|
||||
if (ferror(fp)) {
|
||||
LOG("fgets: %i: %s", errno, strerror(errno));
|
||||
warn_user("LoadError", strerror(errno));
|
||||
ro_warn_user("LoadError", strerror(errno));
|
||||
} else
|
||||
warn_user("LoadError", messages_get("EmptyError"));
|
||||
ro_warn_user("LoadError", messages_get("EmptyError"));
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ static char *ro_gui_url_file_parse(const char *file_name)
|
|||
|
||||
url = strdup(line);
|
||||
if (!url) {
|
||||
warn_user("NoMemory", 0);
|
||||
ro_warn_user("NoMemory", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -634,7 +634,7 @@ static char *ro_gui_ieurl_file_parse(const char *file_name)
|
|||
fp = fopen(file_name, "r");
|
||||
if (!fp) {
|
||||
LOG("fopen(\"%s\", \"r\"): %i: %s", file_name, errno, strerror(errno));
|
||||
warn_user("LoadError", strerror(errno));
|
||||
ro_warn_user("LoadError", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -645,7 +645,7 @@ static char *ro_gui_ieurl_file_parse(const char *file_name)
|
|||
url = strdup(line + 4);
|
||||
if (!url) {
|
||||
fclose(fp);
|
||||
warn_user("NoMemory", 0);
|
||||
ro_warn_user("NoMemory", 0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -653,7 +653,7 @@ static char *ro_gui_ieurl_file_parse(const char *file_name)
|
|||
}
|
||||
if (ferror(fp)) {
|
||||
LOG("fgets: %i: %s", errno, strerror(errno));
|
||||
warn_user("LoadError", strerror(errno));
|
||||
ro_warn_user("LoadError", strerror(errno));
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ static char *ro_gui_ieurl_file_parse(const char *file_name)
|
|||
fclose(fp);
|
||||
|
||||
if (!url)
|
||||
warn_user("URIError", 0);
|
||||
ro_warn_user("URIError", 0);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
@ -725,12 +725,12 @@ static void ro_msg_dataopen(wimp_message *message)
|
|||
oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
||||
if (oserror) {
|
||||
LOG("xwimp_send_message: 0x%x: %s", oserror->errnum, oserror->errmess);
|
||||
warn_user("WimpError", oserror->errmess);
|
||||
ro_warn_user("WimpError", oserror->errmess);
|
||||
return;
|
||||
}
|
||||
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
ro_warn_user(messages_get_errorcode(error), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -742,7 +742,7 @@ static void ro_msg_dataopen(wimp_message *message)
|
|||
NULL);
|
||||
nsurl_unref(urlns);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
ro_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -815,7 +815,7 @@ static void ro_msg_dataload(wimp_message *message)
|
|||
|
||||
/* report error to user */
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
ro_warn_user(messages_get_errorcode(error), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -837,7 +837,7 @@ static void ro_msg_dataload(wimp_message *message)
|
|||
}
|
||||
nsurl_unref(url);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
ro_warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -848,7 +848,7 @@ static void ro_msg_dataload(wimp_message *message)
|
|||
message->sender);
|
||||
if (oserror) {
|
||||
LOG("xwimp_send_message: 0x%x: %s", oserror->errnum, oserror->errmess);
|
||||
warn_user("WimpError", oserror->errmess);
|
||||
ro_warn_user("WimpError", oserror->errmess);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -918,7 +918,7 @@ static void ro_msg_datasave(wimp_message *message)
|
|||
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
|
||||
if (error) {
|
||||
LOG("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -970,7 +970,7 @@ static void ro_msg_prequit(wimp_message *message)
|
|||
message, message->sender);
|
||||
if (error) {
|
||||
LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -996,7 +996,7 @@ static void ro_msg_save_desktop(wimp_message *message)
|
|||
|
||||
if (error) {
|
||||
LOG("xosgbpb_writew/xos_bputw: 0x%x:%s", error->errnum, error->errmess);
|
||||
warn_user("SaveError", error->errmess);
|
||||
ro_warn_user("SaveError", error->errmess);
|
||||
|
||||
/* we must cancel the save by acknowledging the message */
|
||||
message->your_ref = message->my_ref;
|
||||
|
@ -1004,7 +1004,7 @@ static void ro_msg_save_desktop(wimp_message *message)
|
|||
message, message->sender);
|
||||
if (error) {
|
||||
LOG("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1055,7 +1055,7 @@ static void ro_gui_get_screen_properties(void)
|
|||
error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals);
|
||||
if (error) {
|
||||
LOG("xos_read_vdu_variables: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("MiscError", error->errmess);
|
||||
ro_warn_user("MiscError", error->errmess);
|
||||
return;
|
||||
}
|
||||
screen_info.width = (vals[0] + 1) << vals[2];
|
||||
|
@ -1074,7 +1074,7 @@ static void ro_gui_check_resolvers(void)
|
|||
LOG("Inet$Resolvers '%s'", resolvers);
|
||||
} else {
|
||||
LOG("Inet$Resolvers not set or empty");
|
||||
warn_user("Resolvers", 0);
|
||||
ro_warn_user("Resolvers", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1414,7 +1414,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
|
|||
error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare);
|
||||
if (error) {
|
||||
LOG("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("PathToURL", error->errmess);
|
||||
ro_warn_user("PathToURL", error->errmess);
|
||||
return NSERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -1427,7 +1427,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
|
|||
error = xosfscontrol_canonicalise_path(path, canonical_path, 0, 0, 1 - spare, 0);
|
||||
if (error) {
|
||||
LOG("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("PathToURL", error->errmess);
|
||||
ro_warn_user("PathToURL", error->errmess);
|
||||
free(canonical_path);
|
||||
return NSERROR_NOT_FOUND;
|
||||
}
|
||||
|
@ -1597,7 +1597,7 @@ static void ro_gui_keypress_cb(void *pw)
|
|||
os_error *error = xwimp_process_key(key->c);
|
||||
if (error) {
|
||||
LOG("xwimp_process_key: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1634,7 +1634,7 @@ static void ro_gui_keypress(wimp_key *key)
|
|||
os_error *error = xwimp_process_key(key->c);
|
||||
if (error) {
|
||||
LOG("xwimp_process_key: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1906,7 +1906,7 @@ void ro_gui_open_window_request(wimp_open *open)
|
|||
error = xwimp_open_window(open);
|
||||
if (error) {
|
||||
LOG("xwimp_open_window: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1927,7 +1927,7 @@ static void ro_gui_view_source_bounce(wimp_message *message)
|
|||
error = xwimp_start_task(command, 0);
|
||||
if (error) {
|
||||
LOG("xwimp_start_task failed: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1947,14 +1947,14 @@ void ro_gui_view_source(hlcache_handle *c)
|
|||
unsigned long source_size;
|
||||
|
||||
if (!c) {
|
||||
warn_user("MiscError", "No document source");
|
||||
ro_warn_user("MiscError", "No document source");
|
||||
return;
|
||||
}
|
||||
|
||||
source_data = content_get_source_data(c, &source_size);
|
||||
|
||||
if (!source_data) {
|
||||
warn_user("MiscError", "No document source");
|
||||
ro_warn_user("MiscError", "No document source");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1979,7 +1979,7 @@ void ro_gui_view_source(hlcache_handle *c)
|
|||
char full_name[256];
|
||||
const char *filename = filename_request();
|
||||
if (!filename) {
|
||||
warn_user("NoMemory", 0);
|
||||
ro_warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2000,7 +2000,7 @@ void ro_gui_view_source(hlcache_handle *c)
|
|||
(byte *) source_data + source_size);
|
||||
if (error) {
|
||||
LOG("xosfile_save_stamped failed: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("MiscError", error->errmess);
|
||||
ro_warn_user("MiscError", error->errmess);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2067,7 +2067,7 @@ static void ro_gui_choose_language(void)
|
|||
* \param warning message key for warning message
|
||||
* \param detail additional message, or 0
|
||||
*/
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
nserror ro_ro_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
LOG("%s %s", warning, detail);
|
||||
|
||||
|
@ -2100,6 +2100,8 @@ void warn_user(const char *warning, const char *detail)
|
|||
"NetSurf", "!netsurf",
|
||||
(osspriteop_area *) 1, 0, 0);
|
||||
}
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2350,7 +2352,7 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
|
|||
FILE *stream = fopen("<Wimp$ScrapDir>.WWW.NetSurf.dump", "w");
|
||||
if (!stream) {
|
||||
LOG("fopen: errno %i", errno);
|
||||
warn_user("SaveError", strerror(errno));
|
||||
ro_warn_user("SaveError", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2363,7 +2365,7 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
|
|||
0);
|
||||
if (error) {
|
||||
LOG("xwimp_start_task failed: 0x%x: %s", error->errnum, error->errmess);
|
||||
warn_user("WimpError", error->errmess);
|
||||
ro_warn_user("WimpError", error->errmess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2385,6 +2387,7 @@ static struct gui_fetch_table riscos_fetch_table = {
|
|||
|
||||
static struct gui_misc_table riscos_misc_table = {
|
||||
.schedule = riscos_schedule,
|
||||
.warning = ro_warn_user,
|
||||
|
||||
.quit = gui_quit,
|
||||
.launch_url = gui_launch_url,
|
||||
|
@ -2507,7 +2510,7 @@ int main(int argc, char** argv)
|
|||
|
||||
ret = gui_init(argc, argv);
|
||||
if (ret != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(ret), 0);
|
||||
ro_warn_user(messages_get_errorcode(ret), 0);
|
||||
}
|
||||
|
||||
while (!riscos_done) {
|
||||
|
|
|
@ -118,6 +118,7 @@ void ro_gui_dump_browser_window(struct browser_window *bw);
|
|||
void ro_gui_drag_box_start(wimp_pointer *pointer);
|
||||
bool ro_gui_prequit(void);
|
||||
const char *ro_gui_default_language(void);
|
||||
nserror ro_warn_user(const char *warning, const char *detail);
|
||||
|
||||
/**
|
||||
* Cause an abnormal program termination.
|
||||
|
|
|
@ -32,6 +32,12 @@
|
|||
#include <errno.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* required for depricated warn_user interface */
|
||||
#include <stdbool.h>
|
||||
#include "utils/errors.h"
|
||||
#include "desktop/gui_misc.h"
|
||||
#include "desktop/gui_internal.h"
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
|
@ -575,3 +581,9 @@ nserror nsc_strntimet(const char *str, size_t size, time_t *timep)
|
|||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported interface documented in utils/utils.h */
|
||||
void warn_user(const char *message, const char *detail)
|
||||
{
|
||||
guit->misc->warning(message, detail);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,15 @@ struct dirent;
|
|||
bool is_dir(const char *path);
|
||||
|
||||
|
||||
/* Platform specific functions */
|
||||
void warn_user(const char *warning, const char *detail);
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \warning depricated interface, this calls the warning entry in the
|
||||
* miscellaneous gui table and discards the return code.
|
||||
*
|
||||
* \param[in] message A warning looked up in the message translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
*/
|
||||
void warn_user(const char *message, const char *detail);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,7 +57,7 @@ S_RESOURCES := windows_resource.o
|
|||
# ----------------------------------------------------------------------------
|
||||
|
||||
# S_WINDOWS are sources purely for the windows build
|
||||
S_WINDOWS := main.c window.c gui.c drawable.c misc.c plot.c findfile.c \
|
||||
S_WINDOWS := main.c window.c gui.c drawable.c plot.c findfile.c \
|
||||
font.c bitmap.c about.c prefs.c download.c filetype.c file.c \
|
||||
localhistory.c schedule.c windbg.c pointers.c
|
||||
S_WINDOWS := $(addprefix windows/,$(S_WINDOWS))
|
||||
|
|
|
@ -64,6 +64,26 @@ static void die(const char *error)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Warn the user of an event.
|
||||
*
|
||||
* \param[in] message A warning looked up in the message translation table
|
||||
* \param[in] detail Additional text to be displayed or NULL.
|
||||
* \return NSERROR_OK on success or error code if there was a
|
||||
* faliure displaying the message to the user.
|
||||
*/
|
||||
static nserror win32_warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
|
||||
0) + ((detail != 0) ? strlen(detail) : 0);
|
||||
char message[len];
|
||||
snprintf(message, len, messages_get(warning), detail);
|
||||
MessageBox(NULL, message, "Warning", MB_ICONWARNING);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static nsurl *gui_get_resource_url(const char *path)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
@ -135,6 +155,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
|
|||
|
||||
static struct gui_misc_table win32_misc_table = {
|
||||
.schedule = win32_schedule,
|
||||
.warning = win32_warn_user,
|
||||
};
|
||||
|
||||
|
||||
|
@ -256,7 +277,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
|
|||
|
||||
}
|
||||
if (ret != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(ret), 0);
|
||||
win32_warn_user(messages_get_errorcode(ret), 0);
|
||||
} else {
|
||||
win32_run();
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void warn_user(const char *warning, const char *detail)
|
||||
{
|
||||
size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
|
||||
0) + ((detail != 0) ? strlen(detail) : 0);
|
||||
char message[len];
|
||||
snprintf(message, len, messages_get(warning), detail);
|
||||
MessageBox(NULL, message, "Warning", MB_ICONWARNING);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue