summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-05-07 19:14:54 +0000
committerJames Bursa <james@netsurf-browser.org>2004-05-07 19:14:54 +0000
commit24fb50b120a1d56e033b53d455fcc3e877b3eea4 (patch)
tree2c7aebb7557766b190ecf47a76dda403ed56c10a /riscos
parent9d9f208d7e7a9f8d8ef3dc8b481f21e5db428471 (diff)
downloadnetsurf-24fb50b120a1d56e033b53d455fcc3e877b3eea4.tar.gz
netsurf-24fb50b120a1d56e033b53d455fcc3e877b3eea4.tar.bz2
[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
Diffstat (limited to 'riscos')
-rw-r--r--riscos/dialog.c20
-rw-r--r--riscos/download.c2
-rw-r--r--riscos/gui.c60
-rw-r--r--riscos/gui.h13
-rw-r--r--riscos/history.c4
-rw-r--r--riscos/menus.c6
-rw-r--r--riscos/save.c60
-rw-r--r--riscos/save_complete.c6
-rw-r--r--riscos/toolbar.c2
-rw-r--r--riscos/window.c2
10 files changed, 98 insertions, 77 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 3e530bdf2..1b74ceefb 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -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);
}
@@ -401,6 +406,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.
*/
diff --git a/riscos/download.c b/riscos/download.c
index bd161321e..6dedaa59e 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -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;
}
diff --git a/riscos/gui.c b/riscos/gui.c
index cc3dfe747..ecc8f9665 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -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);
@@ -445,6 +447,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);
}
diff --git a/riscos/gui.h b/riscos/gui.h
index 61e6bf664..9ca0c37d6 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -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
diff --git a/riscos/history.c b/riscos/history.c
index f29dd8ad4..93d07557a 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -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);
diff --git a/riscos/menus.c b/riscos/menus.c
index 7eab07e45..a7d49a140 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -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);
}
}
diff --git a/riscos/save.c b/riscos/save.c
index 8a9034178..62a577bd0 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -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;
}
diff --git a/riscos/save_complete.c b/riscos/save_complete.c
index a343ff6c8..bdf8682db 100644
--- a/riscos/save_complete.c
+++ b/riscos/save_complete.c
@@ -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;
}
diff --git a/riscos/toolbar.c b/riscos/toolbar.c
index 9a42851f1..795d0880d 100644
--- a/riscos/toolbar.c
+++ b/riscos/toolbar.c
@@ -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;
}
diff --git a/riscos/window.c b/riscos/window.c
index 83680cc7a..0bc4109b4 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -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;
}