#ifdef WITH_SMCLIENT
#include "eggsmclient.h"
-#ifndef G_OS_WIN32
+#ifdef GDK_WINDOWING_X11
#include "eggdesktopfile.h"
#endif
#endif /* WITH_SMCLIENT */
+#ifdef G_OS_WIN32
+#ifdef DATADIR
+#undef DATADIR
+#endif
+#include <io.h>
+#include <conio.h>
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#endif
+
static gchar *ev_page_label;
static gchar *ev_find_string;
static gboolean preview_mode = FALSE;
GHashTable *args;
GError *error = NULL;
+#ifdef G_OS_WIN32
+
+ 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 != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
+ {
+ freopen ("CONOUT$", "w", stdout);
+ dup2 (fileno (stdout), 1);
+ freopen ("CONOUT$", "w", stderr);
+ dup2 (fileno (stderr), 2);
+
+ }
+ }
+#endif
+
/* Init glib threads asap */
if (!g_thread_supported ())
g_thread_init (NULL);
ev_stock_icons_init ();
-#if defined(WITH_SMCLIENT) && !defined(G_OS_WIN32)
+#if defined(WITH_SMCLIENT) && defined(GDK_WINDOWING_X11)
egg_set_desktop_file (GNOMEDATADIR "/applications/evince.desktop");
#else
/* Manually set name and icon */
g_set_application_name (_("Document Viewer"));
gtk_window_set_default_icon_name ("evince");
-#endif /* WITH_SMCLIENT && !G_OS_WIN32 */
+#endif /* WITH_SMCLIENT && GDK_WINDOWING_X11 */
ev_application_load_session (EV_APP);
load_files (file_arguments, args);