aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja6
-rw-r--r--libsylph/procmsg.c21
-rw-r--r--libsylph/utils.c37
-rw-r--r--libsylph/utils.h1
5 files changed, 69 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b4d6c79a..a3ba6ece 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2005-10-25
+ * libsylph/utils.[ch]: execute_print_file(): added.
+ * libsylph/procmsg.c: procmsg_print_message(): win32: canonicalize
+ output file, and use ShellExecute() if command is unspecified.
+
+2005-10-25
+
* libsylph/procmsg.c: procmsg_print_message(): match the output
headers to the message view.
* libsylph/procheader.[ch]: procheader_get_header_array_for_display():
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 758def46..c114ae08 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,11 @@
2005-10-25
+ * libsylph/utils.[ch]: execute_print_file(): 追加。
+ * libsylph/procmsg.c: procmsg_print_message(): win32: 出力ファイルを
+ 正規化し、コマンドが指定されていない場合は ShellExecute() を使用。
+
+2005-10-25
+
* libsylph/procmsg.c: procmsg_print_message(): 出力するヘッダを
メッセージビューに合わせた。
* libsylph/procheader.[ch]: procheader_get_header_array_for_display():
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 */