aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp55
1 files changed, 3 insertions, 52 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 771b323..8916860 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -1,6 +1,5 @@
#include <exception>
#include <stdexcept>
-#include <thread>
#include <windows.h>
#include <commctrl.h>
#include <SWI-Prolog.h>
@@ -77,8 +76,6 @@ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK HandleMsg(HWND, UINT, WPARAM, LPARAM);
/* Process main menu commands. */
static void HandleMainMenu(HWND, WORD);
-/* Wait for thread. */
-void WaitFor(void (*f)(bool*));
/* Handle messages to Help > About dialog. */
static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
/* Try to style application according to current Windows theme. */
@@ -353,7 +350,7 @@ LRESULT CALLBACK HandleMsg(const HWND hWnd, const UINT uMsg, const WPARAM wParam
const wchar_t** const vTip = group == IDG_MENU? vTipMenu: vTipCtx;
tip = vTip[ID_INDEX(command)];
}
- SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(0,0), reinterpret_cast<LPARAM>(tip));
+ Status(tip, 0);
return 0;
}
@@ -390,12 +387,12 @@ void HandleMainMenu(const HWND hWnd, const WORD command)
case IDM_FILE_FETCH_DATA:
{
- WaitFor(WaitFetchData);
+ WaitFor(FetchData);
break;
}
case IDM_FILE_FETCH_SCREENWRITERS:
- //WaitFor("episode_data","update_screenwriters");
+ WaitFor(FetchScreenwriters);
break;
case IDM_FILE_ABOUT:
@@ -442,52 +439,6 @@ void HandleMainMenu(const HWND hWnd, const WORD command)
}
}
-void WaitFor(void (*f)(bool*))
-{
- static bool bActive = false;
- static bool bDone = false;
- static UINT_PTR iTimer;
-
- /* Ensure that only a single thread is waited on. */
- if (bActive) {
- if (EBMessageBox(L"Another task is active. "
- L"Do you want to cancel the existing task and start a new one?",
- L"Error", MB_YESNO|MB_ICONWARNING) == IDYES) {
- KillTimer(nullptr, iTimer);
- bActive = false;
- g_elv->Update();
- } else
- return;
- }
-
- /* The timer procedure animates an ellipsis in the status bar
- * while the thread is running. */
- static auto proc = [](HWND, UINT, UINT_PTR, DWORD) -> void
- {
- static int i = 0;
- static const wchar_t* text[] = {L".", L"..", L"...", L""};
-
- if (bDone) {
- KillTimer(nullptr, iTimer);
- i = 0;
- bActive = 0;
- g_elv->Update();
- } else {
- i = (i+1)%(sizeof(text)/sizeof(*text));
- SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0),
- reinterpret_cast<LPARAM>(text[i]));
- }
- };
-
- /* The waited-on function signals its completion by setting a
- * shared boolean value to true. */
- bDone = false;
- bActive = true;
- std::thread(f, &bDone).detach();
- SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), reinterpret_cast<LPARAM>(L"."));
- Prefer(iTimer = SetTimer(nullptr, -1, 500, proc));
-}
-
INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM)
{
switch (uMsg) {