[project @ 2004-05-07 19:14:54 by bursa]

Implement multitasking warning dialog. Warn user if resolvers not set.

svn path=/import/netsurf/; revision=841
This commit is contained in:
James Bursa 2004-05-07 19:14:54 +00:00
parent 9d9f208d7e
commit 24fb50b120
16 changed files with 114 additions and 79 deletions

View File

@ -78,6 +78,13 @@ InvalidURL:The address <em>%s</em> could not be understood.
NoMemory:NetSurf is running out of memory. Please free some memory and try again.
FontBadInst:An error occurred when initialising fonts due to the presence of obsolete copies of the ROM fonts on disc. NetSurf will exit and launch a program which will attempt to fix this.
FontError:Failed to open font "Homerton.Medium" (%s).
Resolvers:No domain name servers are configured, so only browsing local files will be possible. Use Configure to set your name server(s).
PathToURL:An error occurred converting the file path to an URL:
SaveError:The file could not be saved due to an error:
MenuError:An error occurred when opening the menu:
DragError:An error occurred when dragging the icon:
TbarError:An error occurred when constructing the toolbar:
WimpError:An unexpected Window Manager error occurred:
# Some general purpose words and phrases
Bytes: B

Binary file not shown.

View File

@ -78,6 +78,13 @@ InvalidURL:L'adresse <em>%s</em> est incomprise.
NoMemory:NetSurf a besoin de plus de mémoire. Veuillez libérer de la mémoire et réessayer.
FontBadInst:Une erreur s'est produite lors de l'initialisation des fontes à cause de la présence de copies obsolètes de fontes ROM sur disque. NetSurf va sortir et lancer un programme qui va tenter de réparer cela.
FontError:Échec d'ouverture de la fonte "Homerton.Medium" (%s).
Resolvers:No domain name servers are configured, so only browsing local files will be possible. Use Configure to set your name server(s).
PathToURL:An error occurred converting the file path to an URL:
SaveError:The file could not be saved due to an error:
MenuError:An error occurred when opening the menu:
DragError:An error occurred when dragging the icon:
TbarError:An error occurred when constructing the toolbar:
WimpError:An unexpected Window Manager error occurred:
Bytes: O
kBytes: kO

Binary file not shown.

View File

@ -95,7 +95,7 @@ void browser_window_create(const char *url, struct browser_window *clone)
bw = malloc(sizeof *bw);
if (!bw) {
warn_user("NoMemory");
warn_user("NoMemory", 0);
return;
}

View File

@ -62,6 +62,6 @@ void gui_window_place_caret(gui_window *g, int x, int y, int height);
void gui_launch_url(char *url);
void warn_user(const char *warning);
void warn_user(const char *warning, const char *detail);
#endif

View File

@ -31,7 +31,8 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
#ifdef WITH_AUTH
dialog_401li,
#endif
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip;
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
dialog_warning;
wimp_menu* theme_menu = NULL;
static int font_size;
@ -45,6 +46,7 @@ static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
static void ro_gui_dialog_reset_zoom(void);
static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
static void set_browser_choices(void);
static void get_browser_choices(void);
static void set_proxy_choices(void);
@ -77,6 +79,7 @@ void ro_gui_dialog_init(void)
dialog_pageinfo = ro_gui_dialog_create("pageinfo");
dialog_objinfo = ro_gui_dialog_create("objectinfo");
dialog_tooltip = ro_gui_dialog_create("tooltip");
dialog_warning = ro_gui_dialog_create("warning");
set_browser_choices();
set_proxy_choices();
@ -181,7 +184,9 @@ void ro_gui_dialog_click(wimp_pointer *pointer)
ro_gui_401login_click(pointer);
#endif
else if (pointer->w == dialog_zoom)
ro_gui_dialog_click_zoom(pointer);
ro_gui_dialog_click_zoom(pointer);
else if (pointer->w == dialog_warning)
ro_gui_dialog_click_warning(pointer);
}
@ -400,6 +405,17 @@ void ro_gui_dialog_reset_zoom(void) {
}
/**
* Handle clicks in the warning dialog.
*/
void ro_gui_dialog_click_warning(wimp_pointer *pointer)
{
if (pointer->i == ICON_WARNING_CONTINUE)
ro_gui_dialog_close(dialog_warning);
}
/**
* Close a dialog box.
*/

View File

@ -271,7 +271,7 @@ void ro_download_datasave_ack(wimp_message *message)
data, data_end);
if (error) {
LOG(("0x%x: %s\n", error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("SaveError", error->errmess);
return;
}

View File

@ -48,6 +48,7 @@
#ifdef WITH_URL
#include "netsurf/riscos/url_protocol.h"
#endif
#include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
@ -124,6 +125,7 @@ static void ro_gui_open_window_request(wimp_open *open);
static void ro_gui_close_window_request(wimp_close *close);
static void ro_gui_mouse_click(wimp_pointer *pointer);
static void ro_gui_icon_bar_click(wimp_pointer* pointer);
static void ro_gui_check_resolvers(void);
static void ro_gui_drag_end(wimp_dragged *drag);
static void ro_gui_keypress(wimp_key* key);
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
@ -203,6 +205,7 @@ void gui_init(int argc, char** argv)
wimp_close_template();
ro_gui_pointers_init();
ro_gui_icon_bar_create();
ro_gui_check_resolvers();
}
@ -369,10 +372,9 @@ void ro_gui_check_fonts(void)
160, 160, 0, 0, &font, 0, 0);
if (error) {
if (error->errnum == error_FILE_NOT_FOUND) {
warn_user("FontBadInst");
xwimp_start_task("TaskWindow -wimpslot 200K -quit "
"<NetSurf$Dir>.FixFonts", 0);
exit(EXIT_FAILURE);
die("FontBadInst");
} else {
snprintf(s, sizeof s, messages_get("FontError"),
error->errmess);
@ -444,6 +446,17 @@ void ro_gui_icon_bar_create(void)
}
/**
* Warn the user if Inet$Resolvers is not set.
*/
void ro_gui_check_resolvers(void)
{
if (!getenv("Inet$Resolvers"))
warn_user("Resolvers", 0);
}
/**
* Close down the gui (RISC OS).
*/
@ -1348,7 +1361,7 @@ char *ro_path_to_url(const char *path)
if (error) {
LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("PathToURL", error->errmess);
return 0;
}
@ -1356,7 +1369,7 @@ char *ro_path_to_url(const char *path)
url = malloc(1 - spare + 10);
if (!buffer || !url) {
LOG(("malloc failed"));
warn_user("NoMemory");
warn_user("NoMemory", 0);
free(buffer);
free(url);
return 0;
@ -1367,7 +1380,7 @@ char *ro_path_to_url(const char *path)
if (error) {
LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("PathToURL", error->errmess);
free(buffer);
free(url);
return 0;
@ -1421,28 +1434,34 @@ void ro_gui_view_source(struct content *content)
}
static os_error warn_error = { 1, "" };
static char warn_buffer[300];
/**
* 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)
void warn_user(const char *warning, const char *detail)
{
strncpy(warn_error.errmess, messages_get(warning), 252);
xwimp_report_error_by_category(&warn_error,
wimp_ERROR_BOX_OK_ICON |
wimp_ERROR_BOX_GIVEN_CATEGORY |
wimp_ERROR_BOX_CATEGORY_ERROR <<
wimp_ERROR_BOX_CATEGORY_SHIFT,
"NetSurf", "!netsurf",
(osspriteop_area *) 1, 0, 0);
LOG(("%s %s", warning, detail));
snprintf(warn_buffer, sizeof warn_buffer, "%s %s",
messages_get(warning),
detail ? detail : "");
warn_buffer[sizeof warn_buffer - 1] = 0;
ro_gui_set_icon_string(dialog_warning, ICON_WARNING_MESSAGE,
warn_buffer);
xwimp_set_icon_state(dialog_warning, ICON_WARNING_HELP,
wimp_ICON_DELETED, wimp_ICON_DELETED);
ro_gui_dialog_open(dialog_warning);
xos_bell();
}
static os_error warn_error = { 1, "" };
/**
* Display an error and exit.
*
@ -1451,6 +1470,13 @@ void warn_user(const char *warning)
void die(const char *error)
{
warn_user(error);
strncpy(warn_error.errmess, messages_get(error), 252);
xwimp_report_error_by_category(&warn_error,
wimp_ERROR_BOX_OK_ICON |
wimp_ERROR_BOX_GIVEN_CATEGORY |
wimp_ERROR_BOX_CATEGORY_ERROR <<
wimp_ERROR_BOX_CATEGORY_SHIFT,
"NetSurf", "!netsurf",
(osspriteop_area *) 1, 0, 0);
exit(EXIT_FAILURE);
}

View File

@ -22,7 +22,7 @@
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
dialog_objinfo, dialog_tooltip;
dialog_objinfo, dialog_tooltip, dialog_warning;
extern wimp_w history_window;
extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *theme_menu;
extern int iconbar_menu_height;
@ -231,10 +231,9 @@ void schedule_run(void);
#define ICON_CONFIG_PROX_OK 0
#define ICON_CONFIG_PROX_CANCEL 1
#define ICON_CONFIG_PROX_DEFAULT 2
#define ICON_CONFIG_PROX_HTTP 3
#define ICON_CONFIG_PROX_HTTPHOST 4
#define ICON_CONFIG_PROX_HTTPPORT 5
#define ICON_CONFIG_PROX_HTTP 2
#define ICON_CONFIG_PROX_HTTPHOST 3
#define ICON_CONFIG_PROX_HTTPPORT 4
#define ICON_CONFIG_TH_OK 0
#define ICON_CONFIG_TH_CANCEL 1
@ -284,4 +283,8 @@ void schedule_run(void);
#define ICON_OBJINFO_TYPE 2
#define ICON_OBJINFO_ICON 3
#define ICON_WARNING_MESSAGE 0
#define ICON_WARNING_CONTINUE 1
#define ICON_WARNING_HELP 2
#endif

View File

@ -81,7 +81,7 @@ struct history *history_create(void)
history = malloc(sizeof *history);
if (!history) {
warn_user("NoMemory");
warn_user("NoMemory", 0);
return 0;
}
@ -119,7 +119,7 @@ void history_add(struct history *history, struct content *content)
url = strdup(content->url);
title = strdup(content->title ? content->title : url);
if (!entry || !url || !title) {
warn_user("NoMemory");
warn_user("NoMemory", 0);
free(entry);
free(url);
free(title);

View File

@ -683,7 +683,7 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
if (error) {
LOG(("0x%x: %s\n", error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("MenuError", error->errmess);
}
}
@ -846,7 +846,7 @@ void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning)
warning->pos.x, warning->pos.y);
if (error) {
LOG(("0x%x: %s\n", error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("MenuError", error->errmess);
}
}
@ -885,7 +885,7 @@ void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning)
warning->pos.x, warning->pos.y);
if (error) {
LOG(("0x%x: %s\n", error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("MenuError", error->errmess);
}
}

View File

@ -81,7 +81,7 @@ void ro_gui_drag_icon(wimp_pointer *pointer)
if (error) {
LOG(("xdragasprite_start: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("DragError", error->errmess);
}
}
@ -160,7 +160,7 @@ void ro_gui_save_datasave_ack(wimp_message *message)
if (error) {
LOG(("xosfile_save_stamped: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("SaveError", error->errmess);
return;
}
break;
@ -186,7 +186,7 @@ void ro_gui_save_datasave_ack(wimp_message *message)
if (error) {
LOG(("xosfile_save_stamped: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("SaveError", error->errmess);
return;
}
break;
@ -219,14 +219,14 @@ void ro_gui_save_datasave_ack(wimp_message *message)
if (error) {
LOG(("xwimp_send_message_to_window: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("SaveError", error->errmess);
}
error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
if (error) {
LOG(("xwimp_create_menu: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("MenuError", error->errmess);
}
save_content = 0;
@ -256,7 +256,7 @@ void ro_gui_save_complete(struct content *c, char *path)
if (error) {
LOG(("xosfile_create_dir: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("SaveError", error->errmess);
return;
}
@ -265,7 +265,7 @@ void ro_gui_save_complete(struct content *c, char *path)
fp = fopen(buf, "w");
if (!fp) {
LOG(("fopen(): errno = %i", errno));
warn_user(strerror(errno));
warn_user("SaveError", strerror(errno));
return;
}
fprintf(fp, "Filer_Run <Obey$Dir>.index\n");
@ -274,61 +274,37 @@ void ro_gui_save_complete(struct content *c, char *path)
if (error) {
LOG(("xosfile_set_type: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("SaveError", error->errmess);
return;
}
/* Create !Sprites */
/* Create !Sprites */
snprintf(buf, sizeof buf, "%s.!Sprites", path);
appname = strrchr(path, '.');
if (!appname) {
LOG(("Couldn't get appname"));
warn_user("Failed to acquire dirname");
return;
}
if (!appname)
appname = path;
area = thumbnail_initialise(34, 34, os_MODE8BPP90X90);
if (!area) {
LOG(("Iconsprite initialisation failed."));
warn_user("NoMemory", 0);
return;
}
sprite_header = (osspriteop_header *)(area + 1);
strncpy(sprite_header->name, appname + 1, 12);
/* !Paint gets confused with uppercase characters
*/
for (index = 0; index < 12; index++) {
/* Paint gets confused with uppercase characters */
for (index = 0; index < 12; index++)
sprite_header->name[index] = tolower(sprite_header->name[index]);
}
thumbnail_create(c, area,
(osspriteop_header *) ((char *) area + 16),
34, 34);
error = xosspriteop_save_sprite_file(osspriteop_NAME, area, buf);
if (error) {
LOG(("Failed to save iconsprite"));
warn_user("Failed to save iconsprite");
free(area);
return;
}
free(area);
/* Create !Boot file */
snprintf(buf, sizeof buf, "%s.!Boot", path);
fp = fopen(buf, "w");
if (!fp) {
LOG(("fopen(): errno = %i", errno));
warn_user(strerror(errno));
return;
}
fprintf(fp, "IconSprites <Obey$Dir>.!Sprites\n");
fclose(fp);
error = xosfile_set_type(buf, 0xfeb);
if (error) {
LOG(("xosfile_set_type: 0x%x: %s",
LOG(("xosspriteop_save_sprite_file: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
return;
warn_user("SaveError", error->errmess);
return;
}
save_complete(c, path);
@ -382,7 +358,7 @@ bool ro_gui_save_link(struct content *c, link_format format, char *path)
FILE *fp = fopen(path, "w");
if (!fp) {
warn_user(strerror(errno));
warn_user("SaveError", strerror(errno));
return false;
}

View File

@ -277,7 +277,7 @@ char * rewrite_stylesheet_urls(const char *source, unsigned int size,
res = malloc(size + imports * 20);
if (!res) {
warn_user("NoMemory");
warn_user("NoMemory", 0);
return 0;
}
*osize = 0;
@ -317,14 +317,14 @@ char * rewrite_stylesheet_urls(const char *source, unsigned int size,
url2 = strndup(url, url_len);
if (!url2) {
warn_user("NoMemory");
warn_user("NoMemory", 0);
free(res);
return 0;
}
url = url_join(url2, base);
free(url2);
if (!url) {
warn_user("NoMemory");
warn_user("NoMemory", 0);
free(res);
return 0;
}

View File

@ -358,7 +358,7 @@ struct toolbar_icon *ro_toolbar_initialise_icon(osspriteop_area *sprite_area,
} else if (error) {
LOG(("xosspriteop_read_sprite_info: 0x%x: %s",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("TbarError", error->errmess);
return NULL;
}

View File

@ -748,7 +748,7 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
if (error) {
LOG(("xwimp_get_pointer_info: 0x%x: %s\n",
error->errnum, error->errmess));
warn_user(error->errmess);
warn_user("WimpError", error->errmess);
return false;
}