summaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-04-27 22:41:59 +0100
committerVincent Sanders <vince@kyllikki.org>2016-04-27 22:41:59 +0100
commite44bd09ac3a28823d9947c54949d115619003fe4 (patch)
tree66e3efcd35046d44c161fddabf5f7cb880b16424 /windows
parent68938664411ac2ee82e39e11fe855a6cd1b32c7c (diff)
downloadnetsurf-e44bd09ac3a28823d9947c54949d115619003fe4.tar.gz
netsurf-e44bd09ac3a28823d9947c54949d115619003fe4.tar.bz2
update windows frontend to not use depricated warn_user API
Diffstat (limited to 'windows')
-rw-r--r--windows/about.c5
-rw-r--r--windows/download.c16
-rw-r--r--windows/gui.c12
-rw-r--r--windows/gui.h23
-rw-r--r--windows/main.c23
-rw-r--r--windows/prefs.c4
-rw-r--r--windows/window.c12
7 files changed, 47 insertions, 48 deletions
diff --git a/windows/about.c b/windows/about.c
index 686d350f0..4716a5c91 100644
--- a/windows/about.c
+++ b/windows/about.c
@@ -27,11 +27,12 @@
#include <windows.h>
+#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
#include "desktop/version.h"
-#include "utils/log.h"
+#include "windows/gui.h"
#include "windows/window.h"
#include "windows/about.h"
#include "windows/resourceid.h"
@@ -144,7 +145,7 @@ void nsws_about_dialog_init(HINSTANCE hinst, HWND parent)
int ret = DialogBox(hinst, MAKEINTRESOURCE(IDD_DLG_ABOUT), parent,
nsws_about_event_callback);
if (ret == -1) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
return;
}
}
diff --git a/windows/download.c b/windows/download.c
index c2cda8fb8..b281ea76a 100644
--- a/windows/download.c
+++ b/windows/download.c
@@ -86,14 +86,14 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
{
if (downloading) {
/* initial implementation */
- warn_user("1 download at a time please", 0);
+ win32_warning("1 download at a time please", 0);
return NULL;
}
downloading = true;
struct gui_download_window *w =
malloc(sizeof(struct gui_download_window));
if (w == NULL) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
return NULL;
}
int total_size = download_context_get_total_length(ctx);
@@ -108,7 +108,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
filename = strdup(messages_get("UnknownFile"));
}
if (filename == NULL) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
free(w);
return NULL;
}
@@ -119,14 +119,14 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
domain = strdup(messages_get("UnknownHost"));
}
if (domain == NULL) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
free(filename);
free(w);
return NULL;
}
destination = malloc(PATH_MAX);
if (destination == NULL) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
free(domain);
free(filename);
free(w);
@@ -144,7 +144,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
w->size = total_size;
w->total_size = strdup(size);
if (w->total_size == NULL) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
free(destination);
free(domain);
free(filename);
@@ -163,7 +163,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
w->window = gui;
w->file = fopen(destination, "wb");
if (w->file == NULL) {
- warn_user(messages_get("FileOpenWriteError"), destination);
+ win32_warning(messages_get("FileOpenWriteError"), destination);
free(destination);
free(domain);
free(filename);
@@ -175,7 +175,7 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui)
download1 = w;
if (nsws_download_window_up(w) == false) {
- warn_user(messages_get("NoMemory"), 0);
+ win32_warning(messages_get("NoMemory"), 0);
free(destination);
free(domain);
free(filename);
diff --git a/windows/gui.c b/windows/gui.c
index f9aca5a9c..9923ecfaa 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -30,6 +30,7 @@
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/file.h"
+#include "utils/messages.h"
#include "desktop/browser.h"
#include "desktop/gui_clipboard.h"
@@ -90,8 +91,17 @@ void win32_run(void)
}
+/* exported function documented in windows/gui.h */
+nserror win32_warning(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;
+}
/**
diff --git a/windows/gui.h b/windows/gui.h
index f72cb2cc2..4c3f360b1 100644
--- a/windows/gui.h
+++ b/windows/gui.h
@@ -25,6 +25,8 @@ struct gui_clipboard_table *win32_clipboard_table;
extern HINSTANCE hInstance;
+extern char *options_file_location;
+
/* bounding box */
typedef struct bbox_s {
int x0;
@@ -33,19 +35,24 @@ typedef struct bbox_s {
int y1;
} bbox_t;
-
-
-extern char *options_file_location;
-
-
-
-
/**
* Run the win32 message loop with scheduling
*/
void win32_run(void);
-/** cause the main message loop to exit */
+/**
+ * cause the main message loop to exit
+ */
void win32_set_quit(bool q);
+/**
+ * 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 win32_warning(const char *warning, const char *detail);
+
#endif
diff --git a/windows/main.c b/windows/main.c
index 869907d11..df64e487d 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -65,25 +65,6 @@ static void die(const char *error)
}
-/**
- * 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];
@@ -155,7 +136,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
static struct gui_misc_table win32_misc_table = {
.schedule = win32_schedule,
- .warning = win32_warn_user,
+ .warning = win32_warning,
};
@@ -277,7 +258,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
}
if (ret != NSERROR_OK) {
- win32_warn_user(messages_get_errorcode(ret), 0);
+ win32_warning(messages_get_errorcode(ret), 0);
} else {
win32_run();
}
diff --git a/windows/prefs.c b/windows/prefs.c
index 1f8dfc95e..adc0101a7 100644
--- a/windows/prefs.c
+++ b/windows/prefs.c
@@ -37,12 +37,12 @@ static CHOOSEFONT *nsws_prefs_font_prepare(int fontfamily, HWND parent)
{
CHOOSEFONT *cf = malloc(sizeof(CHOOSEFONT));
if (cf == NULL) {
- warn_user(messages_get("NoMemory"),0);
+ win32_warning(messages_get("NoMemory"),0);
return NULL;
}
LOGFONT *lf = malloc(sizeof(LOGFONT));
if (lf == NULL) {
- warn_user(messages_get("NoMemory"),0);
+ win32_warning(messages_get("NoMemory"),0);
free(cf);
return NULL;
}
diff --git a/windows/window.c b/windows/window.c
index 1dd2bfdc9..f5f13fe24 100644
--- a/windows/window.c
+++ b/windows/window.c
@@ -921,7 +921,7 @@ nsws_window_command(HWND hwnd,
case IDM_FILE_OPEN_WINDOW:
ret = win32_open_new_window(gw);
if (ret != NSERROR_OK) {
- warn_user(messages_get_errorcode(ret), 0);
+ win32_warning(messages_get_errorcode(ret), 0);
}
break;
@@ -1027,7 +1027,7 @@ nsws_window_command(HWND hwnd,
nsurl *url;
if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
+ win32_warning("NoMemory", 0);
} else {
browser_window_navigate(gw->bw,
url,
@@ -1110,7 +1110,7 @@ nsws_window_command(HWND hwnd,
gw->fullscreen = malloc(sizeof(RECT));
if ((desktop == NULL) ||
(gw->fullscreen == NULL)) {
- warn_user("NoMemory", 0);
+ win32_warning("NoMemory", 0);
break;
}
GetWindowRect(desktop, &rdesk);
@@ -1191,7 +1191,7 @@ nsws_window_command(HWND hwnd,
LOG("launching %s\n", addr);
if (nsurl_create(addr, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
+ win32_warning("NoMemory", 0);
} else {
browser_window_navigate(gw->bw,
url,
@@ -1522,7 +1522,7 @@ static void win32_window_set_title(struct gui_window *w, const char *title)
char *fulltitle = malloc(strlen(title) +
SLEN(" - NetSurf") + 1);
if (fulltitle == NULL) {
- warn_user("NoMemory", 0);
+ win32_warning("NoMemory", 0);
return;
}
strcpy(fulltitle, title);
@@ -1707,7 +1707,7 @@ bool nsws_window_go(HWND hwnd, const char *urltxt)
return false;
if (nsurl_create(urltxt, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
+ win32_warning("NoMemory", 0);
} else {
browser_window_navigate(gw->bw,
url,