* don't insist on using xdg-open; use "open" on MacOS or what MU_PLAY_PROGRAM sets
This commit is contained in:
13
configure.ac
13
configure.ac
@ -248,18 +248,6 @@ AM_CONDITIONAL(HAVE_MAKEINFO, [test "x$have_makeinfo" = "xyes"])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# check for xdg-open
|
|
||||||
AS_IF([test "x$buildgui"="xyes"],[
|
|
||||||
AC_PATH_PROG(XDGOPEN, [xdg-open], [], [$PATH])
|
|
||||||
AS_IF([test "x$XDGOPEN" != "x"],[
|
|
||||||
AC_DEFINE_UNQUOTED([XDGOPEN], ["$XDGOPEN"],[Path to xdg-open])],[
|
|
||||||
AC_MSG_WARN([xdg-open not found, mu cannot open attachments])])
|
|
||||||
])
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# check for pmccabe
|
# check for pmccabe
|
||||||
AC_PATH_PROG([PMCCABE],[pmccabe],[pmccabe],[no])
|
AC_PATH_PROG([PMCCABE],[pmccabe],[pmccabe],[no])
|
||||||
@ -326,7 +314,6 @@ echo
|
|||||||
echo "Build unit tests (glib >= 2.22) : $have_gtest"
|
echo "Build unit tests (glib >= 2.22) : $have_gtest"
|
||||||
echo "Build 'mug' toy-ui (requires GTK+) : $buildgui"
|
echo "Build 'mug' toy-ui (requires GTK+) : $buildgui"
|
||||||
echo "McCabe's Cyclomatic Complexity tool : $have_pmccabe"
|
echo "McCabe's Cyclomatic Complexity tool : $have_pmccabe"
|
||||||
echo "xdg-open : $XDGOPEN"
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Have direntry->d_ino : $use_dirent_d_ino"
|
echo "Have direntry->d_ino : $use_dirent_d_ino"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
.TH MU EXTRACT 1 "May 2011" "User Manuals"
|
.TH MU EXTRACT 1 "May 2011" "User Manuals"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
|
|
||||||
mu extract\- display and save message parts (attachments), and open them with
|
mu extract\- display and save message parts (attachments), and open them with
|
||||||
other tools.
|
other tools.
|
||||||
@ -57,8 +57,9 @@ allowed.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-play\fR Try to 'play' (open) the attachment with the default
|
\fB\-\-play\fR Try to 'play' (open) the attachment with the default
|
||||||
application for the particular file type. Depends on the \fBxdg-open\fR
|
application for the particular file type. On MacOS, this uses the \fBopen\fR
|
||||||
utility.
|
program, on other platforms is uses \fBxdg-open\fR. You can choose a different
|
||||||
|
program by setting the \fBMU_PLAY_PROGRAM\fR environment variable.
|
||||||
|
|
||||||
.SH EXAMPLES
|
.SH EXAMPLES
|
||||||
|
|
||||||
@ -78,8 +79,7 @@ To extract all files ending in '.jpg' (case-insensitive):
|
|||||||
$ mu extract msgfile '.*\.jpg'
|
$ mu extract msgfile '.*\.jpg'
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
To extract an mp3-file, and play it in the the default mp3-playing application
|
To extract an mp3-file, and play it in the the default mp3-playing application.
|
||||||
(requires \fIxdg-open\fR):
|
|
||||||
.nf
|
.nf
|
||||||
$ mu extract --play msgfile 'whoopsididitagain.mp3'
|
$ mu extract --play msgfile 'whoopsididitagain.mp3'
|
||||||
.fi
|
.fi
|
||||||
@ -95,4 +95,4 @@ Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|||||||
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
|
|
||||||
.BR mu(1) xdg-open(1)
|
.BR mu(1)
|
||||||
|
|||||||
@ -114,9 +114,7 @@ Using the \fBsave\fR command, we can save an attachment from a message to disk.
|
|||||||
.TP
|
.TP
|
||||||
.B open
|
.B open
|
||||||
|
|
||||||
Using the \fBsave\fR command, we can open an attachment file (using the
|
Using the \fBopen\fR command, we can open an attachment file.
|
||||||
\fBxdg-open\fR program).
|
|
||||||
|
|
||||||
.nf
|
.nf
|
||||||
-> open <docid> <partindex>
|
-> open <docid> <partindex>
|
||||||
<- (:info open :message "<filename> has been opened")
|
<- (:info open :message "<filename> has been opened")
|
||||||
|
|||||||
@ -324,38 +324,42 @@ mu_util_is_local_file (const char* path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote)
|
mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote)
|
||||||
{
|
{
|
||||||
#ifndef XDGOPEN
|
|
||||||
g_warning ("opening files not supported (xdg-open missing)");
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
GError *err;
|
GError *err;
|
||||||
const gchar *argv[3];
|
const gchar *prog;
|
||||||
|
char *cmdline;
|
||||||
|
|
||||||
g_return_val_if_fail (path, FALSE);
|
g_return_val_if_fail (path, FALSE);
|
||||||
g_return_val_if_fail (mu_util_is_local_file (path) || allow_remote,
|
g_return_val_if_fail (mu_util_is_local_file (path) || allow_remote,
|
||||||
FALSE);
|
FALSE);
|
||||||
g_return_val_if_fail (!mu_util_is_local_file (path) || allow_local,
|
g_return_val_if_fail (!mu_util_is_local_file (path) || allow_local,
|
||||||
FALSE);
|
FALSE);
|
||||||
argv[0] = XDGOPEN;
|
|
||||||
argv[1] = path;
|
|
||||||
argv[2] = NULL;
|
|
||||||
|
|
||||||
|
prog = g_getenv ("MU_PLAY_PROGRAM");
|
||||||
|
if (!prog) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
prog = "open";
|
||||||
|
#else
|
||||||
|
prog = "xdg-open";
|
||||||
|
#endif /*!__APPLE__*/
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdline = g_strconcat (prog, " ", path, NULL);
|
||||||
err = NULL;
|
err = NULL;
|
||||||
rv = g_spawn_async (NULL, (gchar**)&argv, NULL, 0,
|
rv = g_spawn_command_line_async (cmdline, &err);
|
||||||
NULL, NULL, NULL, &err);
|
|
||||||
|
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
g_warning ("failed to spawn xdg-open: %s",
|
g_warning ("failed to spawn %s: %s",
|
||||||
err->message ? err->message : "error");
|
cmdline, err->message ? err->message : "error");
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (cmdline);
|
||||||
return rv;
|
return rv;
|
||||||
#endif /*XDGOPEN*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -179,8 +179,10 @@ gboolean mu_util_printerr_encoded (const char *frm, ...) G_GNUC_PRINTF(1,2);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* try to 'play' (ie., open with it's associated program) a
|
* Try to 'play' (ie., open with it's associated program) a file. On
|
||||||
* file. depends on xdg-open to do the actual opening
|
* MacOS, the the program 'open' is used for this; on other platforms
|
||||||
|
* 'xdg-open' to do the actual opening. In addition you can set it to another program
|
||||||
|
* by setting the MU_PLAY_PROGRAM environment variable
|
||||||
*
|
*
|
||||||
* @param path full path of the file to open
|
* @param path full path of the file to open
|
||||||
* @param allow_local allow local files (ie. with file:// prefix or fs paths)
|
* @param allow_local allow local files (ie. with file:// prefix or fs paths)
|
||||||
|
|||||||
Reference in New Issue
Block a user