X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=previewer%2Fev-previewer.c;h=5c1980a062d4d9be484470293e8890fe69784a57;hb=3d3c4a5a08f1b8b536542735110c1376fb3e30bf;hp=e66a043811328e1109ab03300825302ffbe22466;hpb=faace27fc6850ac153a41d47e51dfbd589dc1411;p=evince.git diff --git a/previewer/ev-previewer.c b/previewer/ev-previewer.c index e66a0438..5c1980a0 100644 --- a/previewer/ev-previewer.c +++ b/previewer/ev-previewer.c @@ -24,10 +24,19 @@ #include #include #include -#include "ev-stock-icons.h" #include "ev-previewer-window.h" +#ifdef G_OS_WIN32 +#ifdef DATADIR +#undef DATADIR +#endif +#include +#include +#define _WIN32_WINNT 0x0500 +#include +#endif + static gboolean unlink_temp_file = FALSE; static const gchar *print_settings; static const gchar **filenames; @@ -43,9 +52,6 @@ static void ev_previewer_unlink_tempfile (const gchar *filename) { GFile *file, *tempdir; - - if (!unlink_temp_file) - return; file = g_file_new_for_path (filename); tempdir = g_file_new_for_path (g_get_tmp_dir ()); @@ -97,6 +103,30 @@ main (gint argc, gchar **argv) const gchar *filename; 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); @@ -158,7 +188,10 @@ main (gint argc, gchar **argv) gtk_main (); - ev_previewer_unlink_tempfile (filename); + if (unlink_temp_file) + ev_previewer_unlink_tempfile (filename); + if (print_settings) + ev_previewer_unlink_tempfile (print_settings); ev_shutdown (); ev_stock_icons_shutdown ();