diff options
author | Vincent Sanders <vince@kyllikki.org> | 2016-04-25 23:11:55 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2016-04-25 23:11:55 +0100 |
commit | bf3ee089cb57765c48065423027eb4fffbe297f1 (patch) | |
tree | 2432a7705866c0773bc70ea3287f45534ec085e1 /windows | |
parent | 638e07f026d85de0c01630217570d4148aaaced5 (diff) | |
download | netsurf-bf3ee089cb57765c48065423027eb4fffbe297f1.tar.gz netsurf-bf3ee089cb57765c48065423027eb4fffbe297f1.tar.bz2 |
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.
Diffstat (limited to 'windows')
-rw-r--r-- | windows/Makefile.target | 2 | ||||
-rw-r--r-- | windows/main.c | 23 | ||||
-rw-r--r-- | windows/misc.c | 40 |
3 files changed, 23 insertions, 42 deletions
diff --git a/windows/Makefile.target b/windows/Makefile.target index 6b8ce6a8c..1f2dcba24 100644 --- a/windows/Makefile.target +++ b/windows/Makefile.target @@ -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)) diff --git a/windows/main.c b/windows/main.c index d2d054414..869907d11 100644 --- a/windows/main.c +++ b/windows/main.c @@ -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(); } diff --git a/windows/misc.c b/windows/misc.c deleted file mode 100644 index ad7ce0d84..000000000 --- a/windows/misc.c +++ /dev/null @@ -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); -} - - |