From 39683eb5ab1e51c69ddf12a9da1ce0402f78380f Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 9 Mar 2006 06:37:55 +0000 Subject: added a hidden option "mime_command" for backward compatibility. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1035 ee746299-78ed-0310-b773-934348b2243d --- src/mimeview.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/mimeview.c') diff --git a/src/mimeview.c b/src/mimeview.c index 5f4774bd..3a79811a 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -1126,8 +1126,7 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, const gchar *cmdline) { const gchar *cmd = NULL; - const gchar *p; - gchar *cmdbuf; + gchar buf[BUFFSIZE]; if (!cmdline) { #ifdef G_OS_WIN32 @@ -1155,16 +1154,28 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, else if (MIME_TEXT_HTML == partinfo->mime_type) cmd = prefs_common.uri_cmd; if (!cmd) { - procmime_execute_open_file - (filename, partinfo->content_type); - return; + if (prefs_common.mime_cmd) { + if (str_find_format_times + (prefs_common.mime_cmd, 's') == 2) { + g_snprintf(buf, sizeof(buf), + prefs_common.mime_cmd, + partinfo->content_type, + "%s"); + cmd = buf; + } else + cmd = prefs_common.mime_cmd; + } else { + procmime_execute_open_file + (filename, partinfo->content_type); + return; + } } #endif } else cmd = cmdline; - if (cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's' && - !strchr(p + 2, '%')) { + if (cmd && str_find_format_times(cmd, 's') == 1) { + gchar *cmdbuf; cmdbuf = g_strdup_printf(cmd, filename); execute_command_line(cmdbuf, TRUE); g_free(cmdbuf); -- cgit v1.2.3