From 8525c857da966580c57aa595ec44ba1c4fc2326a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 13 Mar 2015 14:32:06 +0000 Subject: Clean up more windows frontend issues and split out more functionality --- windows/download.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'windows/download.c') diff --git a/windows/download.c b/windows/download.c index 463a8368c..ed7b10832 100644 --- a/windows/download.c +++ b/windows/download.c @@ -34,6 +34,7 @@ #include "desktop/download.h" #include "windows/download.h" +#include "windows/window.h" #include "windows/gui.h" #include "windows/resourceid.h" #include "windows/schedule.h" @@ -41,13 +42,24 @@ static bool downloading = false; static struct gui_download_window *download1; -static bool nsws_download_window_up(struct gui_download_window *w); BOOL CALLBACK nsws_download_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); static void nsws_download_update_label(void *p); static void nsws_download_update_progress(void *p); static void nsws_download_clear_data(struct gui_download_window *w); +static bool nsws_download_window_up(struct gui_download_window *w) +{ + w->hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DLG_DOWNLOAD), + gui_window_main_window(w->window), + nsws_download_event_callback); + if (w->hwnd == NULL) { + return false; + } + ShowWindow(w->hwnd, SW_SHOW); + return true; +} + static struct gui_download_window * gui_download_window_create(download_context *ctx, struct gui_window *gui) { @@ -142,23 +154,20 @@ gui_download_window_create(download_context *ctx, struct gui_window *gui) } download1 = w; - nsws_download_window_up(w); - return w; -} - -bool nsws_download_window_up(struct gui_download_window *w) -{ - w->hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DLG_DOWNLOAD), - gui_window_main_window(w->window), - nsws_download_event_callback); - if (w->hwnd == NULL) { + if (nsws_download_window_up(w) == false) { warn_user(messages_get("NoMemory"), 0); - return false; + free(destination); + free(domain); + free(filename); + free(w->total_size); + free(w->time_left); + free(w); + return NULL; } - ShowWindow(w->hwnd, SW_SHOW); - return true; + return w; } + BOOL CALLBACK nsws_download_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { -- cgit v1.2.3