[Xfce4-commits] <thunar-volman:jannis/port-to-udev> Add function to run the default audio CD player.

Jannis Pohlmann noreply at xfce.org
Wed Jul 21 12:28:01 CEST 2010


Updating branch refs/heads/jannis/port-to-udev
         to 874384f79c70d2ca3f710c6a544460fd2694de89 (commit)
       from 6c536e3f624854eba11ba314a154cb1d3f493ebc (commit)

commit 874384f79c70d2ca3f710c6a544460fd2694de89
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Wed Jul 21 12:25:46 2010 +0200

    Add function to run the default audio CD player.

 thunar-volman/tvm-run.c |   42 +++++++++++++++++++++++++++++++++++++++---
 thunar-volman/tvm-run.h |    2 ++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/thunar-volman/tvm-run.c b/thunar-volman/tvm-run.c
index 112dfa1..a4bc67b 100644
--- a/thunar-volman/tvm-run.c
+++ b/thunar-volman/tvm-run.c
@@ -155,7 +155,6 @@ tvm_run_burn_software (TvmContext *context,
     "ID_CDROM_MEDIA_DVD_PLUS_R",
     "ID_CDROM_MEDIA_DVD_PLUS_RW",
   };
-  gboolean            autoburn;
   gboolean            is_cd = FALSE;
   gboolean            is_dvd = FALSE;
   gboolean            result = FALSE;
@@ -168,8 +167,7 @@ tvm_run_burn_software (TvmContext *context,
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
   /* abort without error if autoburning is turned off */
-  autoburn = xfconf_channel_get_bool (context->channel, "/autoburn/enabled", FALSE);
-  if (!autoburn)
+  if (!xfconf_channel_get_bool (context->channel, "/autoburn/enabled", FALSE))
     {
       g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, 
                    _("Autoburning of blank CDs and DVDs is disabled"));
@@ -242,3 +240,41 @@ tvm_run_burn_software (TvmContext *context,
   return result;
 }
 
+
+
+gboolean 
+tvm_run_cd_player (TvmContext *context,
+                   GError    **error)
+{
+  gboolean result = FALSE;
+  gchar   *command;
+
+  g_return_val_if_fail (context != NULL, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  /* check whether autoplaying audio CDs is enabled */
+  if (xfconf_channel_get_bool (context->channel, "/autoplay-audio-cds/enabled", FALSE))
+    {
+      /* determine the audio CD player command */
+      command = xfconf_channel_get_string (context->channel, 
+                                           "/autoplay-audio-cds/command", NULL);
+
+      /* check whether the command is set and non-empty */
+      if (command != NULL && *command != '\0')
+        {
+          /* try to lanuch the audio CD player */
+          result = tvm_run_command (context, NULL, command, error);
+        }
+      else
+        {
+          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+                       _("The CD player command is undefined"));
+        }
+      
+      /* free the command string */
+      g_free (command);
+    }
+
+  return result;
+}
diff --git a/thunar-volman/tvm-run.h b/thunar-volman/tvm-run.h
index dc67d13..c3b472a 100644
--- a/thunar-volman/tvm-run.h
+++ b/thunar-volman/tvm-run.h
@@ -33,6 +33,8 @@ gboolean tvm_run_command        (TvmContext  *context,
                                  GError     **error);
 gboolean  tvm_run_burn_software (TvmContext  *context,
                                  GError     **error);
+gboolean  tvm_run_cd_player     (TvmContext  *context,
+                                 GError     **error);
 
 G_END_DECLS
 



More information about the Xfce4-commits mailing list