[evolution] Remove some more unnecessary windows workarounds.



commit 730cf96cd054669364c37bc6967984444f40abbd
Author: Fridrich Strba <fridrich strba bluewin ch>
Date:   Sun Mar 14 23:13:29 2010 +0100

    Remove some more unnecessary windows workarounds.

 capplet/Makefile.am           |    4 +++
 capplet/anjal-settings-main.c |   29 ++++++++++++++++++-----
 shell/main.c                  |   51 +----------------------------------------
 3 files changed, 28 insertions(+), 56 deletions(-)
---
diff --git a/capplet/Makefile.am b/capplet/Makefile.am
index db32e89..f57bbe0 100644
--- a/capplet/Makefile.am
+++ b/capplet/Makefile.am
@@ -44,6 +44,10 @@ evolution_settings_SOURCES  = \
 evolution_settings_LDFLAGS = \
 	-Wl,--export-dynamic
 
+if OS_WIN32
+evolution_settings_LDFLAGS += -mwindows
+endif
+
 evolution_settings_LDADD = 				\
 	$(EVOLUTION_MAIL_LIBS)				\
 	$(CERT_UI_LIBS)					\
diff --git a/capplet/anjal-settings-main.c b/capplet/anjal-settings-main.c
index bdb257a..c9e08d1 100644
--- a/capplet/anjal-settings-main.c
+++ b/capplet/anjal-settings-main.c
@@ -41,9 +41,16 @@
 
 #ifdef G_OS_WIN32
 #define WIN32_LEAN_AND_MEAN
+#ifdef DATADIR
+#undef DATADIR
+#endif
+#include <io.h>
+#include <conio.h>
+#define _WIN32_WINNT 0x0501
 #include <windows.h>
 #endif
 
+
 #include <unique/unique.h>
 
 gboolean windowed = FALSE;
@@ -173,8 +180,22 @@ main (int argc, char *argv[])
 	UniqueApp *app;
 
 #ifdef G_OS_WIN32
-	extern void link_shutdown (void);
-	set_paths ();
+	if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) {
+		/* stdout is fine, presumably redirected to a file or pipe */
+	} else {
+		typedef BOOL (* WINAPI AttachConsole_t) (DWORD);
+
+		AttachConsole_t p_AttachConsole =
+			(AttachConsole_t) GetProcAddress (
+			GetModuleHandle ("kernel32.dll"), "AttachConsole");
+
+		if (p_AttachConsole && p_AttachConsole (ATTACH_PARENT_PROCESS)) {
+			freopen ("CONOUT$", "w", stdout);
+			dup2 (fileno (stdout), 1);
+			freopen ("CONOUT$", "w", stderr);
+			dup2 (fileno (stderr), 2);
+		}
+	}
 #endif
 
 	static GOptionEntry entries[] = {
@@ -245,10 +266,6 @@ main (int argc, char *argv[])
 	
 	gtk_main ();
 
-	
-#ifdef G_OS_WIN32
-	link_shutdown ();
-#endif
 	return 0;
 }
 
diff --git a/shell/main.c b/shell/main.c
index 4848ef9..ecb8e1b 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -349,51 +349,6 @@ static GOptionEntry entries[] = {
 	{ NULL }
 };
 
-#ifdef G_OS_WIN32
-static void
-set_paths (void)
-{
-	/* Set PATH to include the Evolution executable's folder
-	 * and the lib/evolution/$(BASE_VERSION)/components folder. */
-	wchar_t exe_filename[MAX_PATH];
-	wchar_t *p;
-	gchar *exe_folder_utf8;
-	gchar *components_folder_utf8;
-	gchar *top_folder_utf8;
-	gchar *path;
-
-	GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));
-
-	p = wcsrchr (exe_filename, L'\\');
-	g_assert (p != NULL);
-
-	*p = L'\0';
-	exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
-
-	p = wcsrchr (exe_filename, L'\\');
-	g_assert (p != NULL);
-
-	*p = L'\0';
-	top_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
-	components_folder_utf8 = g_strconcat (
-		top_folder_utf8, "/lib/evolution/"
-		BASE_VERSION "/components", NULL);
-
-	path = g_build_path (
-		";", exe_folder_utf8,
-		components_folder_utf8, g_getenv ("PATH"), NULL);
-	if (!g_setenv ("PATH", path, TRUE))
-		g_warning ("Could not set PATH for Evolution "
-			   "and its child processes");
-
-	g_free (path);
-	g_free (exe_folder_utf8);
-	g_free (components_folder_utf8);
-
-	g_free (top_folder_utf8);
-}
-#endif
-
 static void G_GNUC_NORETURN
 shell_force_shutdown (void)
 {
@@ -486,7 +441,7 @@ main (gint argc, gchar **argv)
 			(AttachConsole_t) GetProcAddress (
 			GetModuleHandle ("kernel32.dll"), "AttachConsole");
 
-		if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) {
+		if (p_AttachConsole && p_AttachConsole (ATTACH_PARENT_PROCESS)) {
 			freopen ("CONOUT$", "w", stdout);
 			dup2 (fileno (stdout), 1);
 			freopen ("CONOUT$", "w", stderr);
@@ -502,10 +457,6 @@ main (gint argc, gchar **argv)
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-#ifdef G_OS_WIN32
-	set_paths ();
-#endif
-
 	gtk_init_with_args (
 		&argc, &argv,
 		_("- The Evolution PIM and Email Client"),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]