[Xfce4-commits] <thunar-volman:master> Implement video CD/DVD autoplaying.
Jannis Pohlmann
noreply at xfce.org
Sun Jul 25 19:44:38 CEST 2010
Updating branch refs/heads/master
to 4fee95888fe46deab053be73b121323467168ede (commit)
from 86b67e880310d214507a29c2a0e98a751a120c91 (commit)
commit 4fee95888fe46deab053be73b121323467168ede
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Mon Jul 19 19:22:17 2010 +0200
Implement video CD/DVD autoplaying.
.gitignore | 1 -
thunar-volman/tvm-block-device.c | 92 +++++++++++++++++++++++++++++++++++---
2 files changed, 86 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 689645c..53a839c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,4 +37,3 @@ stamp-h1
thunar-volman-settings
thunar-volman-settings.desktop
texput.log
-thunar-volman
diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c
index 26c9483..118e383 100644
--- a/thunar-volman/tvm-block-device.c
+++ b/thunar-volman/tvm-block-device.c
@@ -44,9 +44,15 @@ typedef gboolean (*TvmBlockDeviceHandler) (TvmContext *context,
-static gboolean tvm_block_device_autobrowse (TvmContext *context,
- GMount *mount,
- GError **error);
+static gboolean tvm_file_test (GMount *mount,
+ const gchar *filename,
+ GFileTest test);
+static gboolean tvm_block_device_autorun (TvmContext *context,
+ GMount *mount,
+ GError **error);
+static gboolean tvm_block_device_autobrowse (TvmContext *context,
+ GMount *mount,
+ GError **error);
@@ -55,14 +61,90 @@ static TvmBlockDeviceHandler block_device_handlers[] =
#if 0
tvm_block_device_autoipod,
tvm_block_device_autophoto,
- tvm_block_device_autorun,
#endif
+ tvm_block_device_autorun,
tvm_block_device_autobrowse,
};
static gboolean
+tvm_file_test (GMount *mount,
+ const gchar *filename,
+ GFileTest test)
+{
+ gboolean result = FALSE;
+ GFile *mount_point;
+ gchar *mount_path;
+ gchar *absolute_path;
+
+ g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
+ g_return_val_if_fail (filename != NULL && *filename != '\0', FALSE);
+
+ mount_point = g_mount_get_root (mount);
+ mount_path = g_file_get_path (mount_point);
+ g_object_unref (mount_point);
+
+ absolute_path = g_build_filename (mount_path, filename, NULL);
+ g_free (mount_path);
+
+ result = g_file_test (absolute_path, test);
+ g_free (absolute_path);
+
+ return result;
+}
+
+
+
+static gboolean
+tvm_block_device_autorun (TvmContext *context,
+ GMount *mount,
+ GError **error)
+{
+ gboolean autoplay;
+ gboolean result = FALSE;
+ GError *err = NULL;
+ gchar *autoplay_command;
+
+ g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ /* check if autoplaying video CDs and DVDs is enabled */
+ autoplay = xfconf_channel_get_bool (context->channel,
+ "/autoplay-video-cds/enabled", FALSE);
+ if (autoplay)
+ {
+ /* check if we have a video CD or video DVD here */
+ if (tvm_file_test (mount, "vcd", G_FILE_TEST_IS_DIR)
+ || tvm_file_test (mount, "video_ts", G_FILE_TEST_IS_DIR))
+ {
+ /* determine the autoplay command for video CDs/DVDs */
+ autoplay_command = xfconf_channel_get_string (context->channel,
+ "/autoplay-video-cds/command",
+ "parole");
+
+ /* try to spawn the preferred video CD/DVD player */
+ result = tvm_run_command (context, mount, autoplay_command, &err);
+
+ /* free the command string */
+ g_free (autoplay_command);
+
+ /* forward errors to the caller */
+ if (err != NULL)
+ g_propagate_error (error, err);
+
+ /* return success/failure to the caller */
+ return result;
+ }
+ }
+
+ return TRUE;
+}
+
+
+
+static gboolean
tvm_block_device_autobrowse (TvmContext *context,
GMount *mount,
GError **error)
@@ -128,8 +210,6 @@ tvm_block_device_mount_finish (GVolume *volume,
g_return_if_fail (G_IS_ASYNC_RESULT (result));
g_return_if_fail (context != NULL);
- g_debug ("finish");
-
/* finish mounting the volume */
if (g_volume_mount_finish (volume, result, &error))
{
More information about the Xfce4-commits
mailing list