diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-10-25 08:43:05 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-10-25 08:43:05 +0000 |
commit | 97fe8bb5863e75e62afcb6c2b6cac10299920e9c (patch) | |
tree | d45a60052e8c56c27edb0670afe3b542b547c207 /libsylph | |
parent | 749d0bd1eb364a5efc52d2f0a0b4b7731c9332ba (diff) |
win32: use ShellExecute() on print.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@680 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/procmsg.c | 21 | ||||
-rw-r--r-- | libsylph/utils.c | 37 | ||||
-rw-r--r-- | libsylph/utils.h | 1 |
3 files changed, 57 insertions, 2 deletions
diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c index 344b43f1..0837d44b 100644 --- a/libsylph/procmsg.c +++ b/libsylph/procmsg.c @@ -1167,7 +1167,7 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline) return; } - prtmp = g_strdup_printf("%s%cprinttmp.%08x", + prtmp = g_strdup_printf("%s%cprinttmp-%08x.txt", get_mime_tmp_dir(), G_DIR_SEPARATOR, id++); if ((prfp = g_fopen(prtmp, "wb")) == NULL) { @@ -1228,14 +1228,31 @@ void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline) fclose(prfp); fclose(tmpfp); +#ifdef G_OS_WIN32 + if (canonicaize_file_replace(prtmp) < 0) { + g_free(prtmp); + return; + } +#endif + if (cmdline && (p = strchr(cmdline, '%')) && *(p + 1) == 's' && !strchr(p + 2, '%')) g_snprintf(buf, sizeof(buf) - 1, cmdline, prtmp); else { - if (cmdline) + if (cmdline) { g_warning(_("Print command line is invalid: `%s'\n"), cmdline); + g_free(prtmp); + return; + } + +#ifdef G_OS_WIN32 + execute_print_file(prtmp); + g_free(prtmp); + return; +#else g_snprintf(buf, sizeof(buf) - 1, def_cmd, prtmp); +#endif } g_free(prtmp); diff --git a/libsylph/utils.c b/libsylph/utils.c index 84b3bf2f..80b6545c 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -3147,6 +3147,43 @@ gint execute_open_file(const gchar *file, const gchar *content_type) return 0; } +gint execute_print_file(const gchar *file) +{ + g_return_val_if_fail(file != NULL, -1); + +#ifdef G_OS_WIN32 + log_print("printing %s\n", file); + + if (G_WIN32_HAVE_WIDECHAR_API()) { + wchar_t *wpath; + + wpath = g_utf8_to_utf16(file, -1, NULL, NULL, NULL); + if (wpath == NULL) + return -1; + + ShellExecuteW(NULL, L"print", wpath, NULL, NULL, SW_SHOWNORMAL); + + g_free(wpath); + + return 0; + } else { + gchar *cp_path; + + cp_path = g_locale_from_utf8(file, -1, NULL, NULL, NULL); + if (cp_path == NULL) + return -1; + + ShellExecuteA(NULL, "print", cp_path, NULL, NULL, + SW_SHOWNORMAL); + + g_free(cp_path); + + return 0; + } +#endif + return 0; +} + gchar *get_command_output(const gchar *cmdline) { gchar *child_stdout; diff --git a/libsylph/utils.h b/libsylph/utils.h index ab898dd0..bc704e8e 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h @@ -437,6 +437,7 @@ gint execute_command_line (const gchar *cmdline, gboolean async); gint execute_open_file (const gchar *file, const gchar *content_type); +gint execute_print_file (const gchar *file); gchar *get_command_output (const gchar *cmdline); /* open URI with external browser */ |