aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-07-04 04:30:16 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2008-07-04 04:30:16 +0000
commita48e2187fd9227ec46cc3f7a77c3ed8c04e3358f (patch)
treef2baab66f9f9d5f7714517a9229db5fb11ad1d57 /src/main.c
parente4fa47016f53e76df6d0ef387d41270b98e5578c (diff)
win32: handle console ctrl events.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2023 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index c799d14b..501560e2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2008 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -99,6 +99,8 @@
gchar *prog_version;
+static gboolean init_console_done = FALSE;
+
static gint lock_socket = -1;
static gint lock_socket_tag = 0;
static GIOChannel *lock_ch = NULL;
@@ -296,8 +298,6 @@ int main(int argc, char *argv[])
set_log_handlers(TRUE);
- register_system_events();
-
account_read_config_all();
account_set_menu();
main_window_reflect_prefs_all();
@@ -317,6 +317,8 @@ int main(int argc, char *argv[])
addressbook_read_file();
+ register_system_events();
+
inc_autocheck_timer_init(mainwin);
remote_command_exec();
@@ -331,7 +333,6 @@ static void init_console(void)
#ifdef G_OS_WIN32
gint fd;
FILE *fp;
- static gboolean init_console_done = FALSE;
if (init_console_done)
return;
@@ -958,6 +959,15 @@ static void set_log_handlers(gboolean enable)
}
#ifdef G_OS_WIN32
+static BOOL WINAPI
+ctrl_handler(DWORD dwctrltype)
+{
+ log_print("ctrl_handler: received %d\n", dwctrltype);
+ app_will_exit(TRUE);
+
+ return TRUE;
+}
+
static LRESULT CALLBACK
wndproc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
@@ -991,11 +1001,24 @@ static void register_system_events(void)
{
WNDCLASS wclass;
static HWND hwnd = NULL;
+ static BOOL ctrl_handler_set = FALSE;
ATOM klass;
HINSTANCE hmodule = GetModuleHandle(NULL);
if (hwnd)
return;
+ if (ctrl_handler_set)
+ return;
+
+ if (init_console_done) {
+ debug_print("register_system_events(): SetConsoleCtrlHandler\n");
+ ctrl_handler_set = SetConsoleCtrlHandler(ctrl_handler, TRUE);
+ if (!ctrl_handler_set)
+ g_warning("SetConsoleCtrlHandler() failed\n");
+ return;
+ }
+
+ debug_print("register_system_events(): RegisterClass\n");
memset(&wclass, 0, sizeof(WNDCLASS));
wclass.lpszClassName = "sylpheed-observer";