Updating branch refs/heads/master to 269de460833d282df34812bbaffc7f8b0dbe67bf (commit) from ccafc02e8cce0bc104af60012d8c2c493ed5327e (commit)
commit 269de460833d282df34812bbaffc7f8b0dbe67bf Author: Jannis Pohlmann <jan...@xfce.org> Date: Tue Jul 20 11:42:45 2010 +0200 Add support for blank CDs and DVDs by launching the burn software. configure.in.in | 1 + thunar-volman/Makefile.am | 6 + thunar-volman/tvm-block-device.c | 11 +- thunar-volman/tvm-pango-extensions.c | 178 ++++++++++++++++++++ .../{tvm-run.h => tvm-pango-extensions.h} | 22 ++-- thunar-volman/tvm-prompt.c | 175 +++++++++++++++++++ thunar-volman/{tvm-block-device.h => tvm-prompt.h} | 28 +++- thunar-volman/tvm-run.c | 138 ++++++++++++++- thunar-volman/tvm-run.h | 10 +- 9 files changed, 536 insertions(+), 33 deletions(-) diff --git a/configure.in.in b/configure.in.in index 439e9ad..1a40559 100644 --- a/configure.in.in +++ b/configure.in.in @@ -86,6 +86,7 @@ XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.18.0]) XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.18.0]) XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0]) XDT_CHECK_PACKAGE([GUDEV], [gudev-1.0], [145]) +XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.7.0]) XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.7.0]) XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.7.0]) diff --git a/thunar-volman/Makefile.am b/thunar-volman/Makefile.am index 66aa8e9..72d6a5f 100644 --- a/thunar-volman/Makefile.am +++ b/thunar-volman/Makefile.am @@ -40,6 +40,10 @@ thunar_volman_SOURCES = \ tvm-device.h \ tvm-gio-extensions.c \ tvm-gio-extensions.h \ + tvm-pango-extensions.c \ + tvm-pango-extensions.h \ + tvm-prompt.c \ + tvm-prompt.h \ tvm-run.c \ tvm-run.h @@ -50,6 +54,7 @@ thunar_volman_CFLAGS = \ $(GTHREAD_CFLAGS) \ $(GTK_CFLAGS) \ $(GUDEV_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ $(XFCONF_CFLAGS) \ $(PLATFORM_CFLAGS) @@ -65,5 +70,6 @@ thunar_volman_LDADD = \ $(GTHREAD_LIBS) \ $(GTK_LIBS) \ $(GUDEV_LIBS) \ + $(LIBXFCE4UI_LIBS) \ $(LIBXFCE4UTIL_LIBS) \ $(XFCONF_LIBS) diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c index d111884..42ed5f4 100644 --- a/thunar-volman/tvm-block-device.c +++ b/thunar-volman/tvm-block-device.c @@ -326,6 +326,7 @@ tvm_block_device_added (TvmContext *context) gboolean is_partition; gboolean is_volume; guint64 audio_tracks; + GError *error = NULL; g_return_if_fail (context != NULL); @@ -352,11 +353,15 @@ tvm_block_device_added (TvmContext *context) g_udev_device_get_property_as_uint64 (context->device, "ID_CDROM_MEDIA_TRACK_COUNT_AUDIO"); + /* check if we have a blank CD/DVD here */ if (g_strcmp0 (media_state, "blank") == 0) { -#if 0 - tvm_run_burn_software (client, device, channel, &error); -#endif + /* try to run the burn program */ + if (!tvm_run_burn_software (context, &error)) + g_propagate_error (context->error, error); + + /* finish processing the device */ + tvm_device_handler_finished (context); } else if (audio_tracks > 0) { diff --git a/thunar-volman/tvm-pango-extensions.c b/thunar-volman/tvm-pango-extensions.c new file mode 100644 index 0000000..d7f68fb --- /dev/null +++ b/thunar-volman/tvm-pango-extensions.c @@ -0,0 +1,178 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2006-2007 Benedikt Meurer <be...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_STDARG_H +#include <stdarg.h> +#endif + +#include <thunar-volman/tvm-pango-extensions.h> + + + +static PangoAttrList *tvm_pango_attr_list_wrap (PangoAttribute *attribute, ...) G_GNUC_MALLOC; + + + +static PangoAttrList* +tvm_pango_attr_list_wrap (PangoAttribute *attribute, ...) +{ + PangoAttrList *attr_list; + va_list args; + + /* allocate a new attribute list */ + attr_list = pango_attr_list_new (); + + /* add all specified attributes */ + va_start (args, attribute); + while (attribute != NULL) + { + attribute->start_index = 0; + attribute->end_index = -1; + pango_attr_list_insert (attr_list, attribute); + attribute = va_arg (args, PangoAttribute *); + } + va_end (args); + + return attr_list; +} + + + +/** + * tvm_pango_attr_list_big: + * + * Returns a #PangoAttrList for rendering big text. + * The returned list is owned by the callee and must + * not be freed or modified by the caller. + * + * Return value: a #PangoAttrList for rendering big text. + **/ +PangoAttrList* +tvm_pango_attr_list_big (void) +{ + static PangoAttrList *attr_list = NULL; + if (G_UNLIKELY (attr_list == NULL)) + attr_list = tvm_pango_attr_list_wrap (pango_attr_scale_new (PANGO_SCALE_LARGE), NULL); + return attr_list; +} + + + +/** + * tvm_pango_attr_list_big_bold: + * + * Returns a #PangoAttrList for rendering big bold text. + * The returned list is owned by the callee and must + * not be freed or modified by the caller. + * + * Return value: a #PangoAttrList for rendering big bold text. + **/ +PangoAttrList* +tvm_pango_attr_list_big_bold (void) +{ + static PangoAttrList *attr_list = NULL; + if (G_UNLIKELY (attr_list == NULL)) + attr_list = tvm_pango_attr_list_wrap (pango_attr_scale_new (PANGO_SCALE_LARGE), pango_attr_weight_new (PANGO_WEIGHT_BOLD), NULL); + return attr_list; +} + + + +/** + * tvm_pango_attr_list_bold: + * + * Returns a #PangoAttrList for rendering bold text. + * The returned list is owned by the callee and must + * not be freed or modified by the caller. + * + * Return value: a #PangoAttrList for rendering bold text. + **/ +PangoAttrList* +tvm_pango_attr_list_bold (void) +{ + static PangoAttrList *attr_list = NULL; + if (G_UNLIKELY (attr_list == NULL)) + attr_list = tvm_pango_attr_list_wrap (pango_attr_weight_new (PANGO_WEIGHT_BOLD), NULL); + return attr_list; +} + + + +/** + * tvm_pango_attr_list_italic: + * + * Returns a #PangoAttrList for rendering italic text. + * The returned list is owned by the callee and must + * not be freed or modified by the caller. + * + * Return value: a #PangoAttrList for rendering italic text. + **/ +PangoAttrList* +tvm_pango_attr_list_italic (void) +{ + static PangoAttrList *attr_list = NULL; + if (G_UNLIKELY (attr_list == NULL)) + attr_list = tvm_pango_attr_list_wrap (pango_attr_style_new (PANGO_STYLE_ITALIC), NULL); + return attr_list; +} + + + +/** + * tvm_pango_attr_list_small_italic: + * + * Returns a #PangoAttrList for rendering small italic text. + * The returned list is owned by the callee and must + * not be freed or modified by the caller. + * + * Return value: a #PangoAttrList for rendering small italic text. + **/ +PangoAttrList* +tvm_pango_attr_list_small_italic (void) +{ + static PangoAttrList *attr_list = NULL; + if (G_UNLIKELY (attr_list == NULL)) + attr_list = tvm_pango_attr_list_wrap (pango_attr_scale_new (PANGO_SCALE_SMALL), pango_attr_style_new (PANGO_STYLE_ITALIC), NULL); + return attr_list; +} + + + +/** + * tvm_pango_attr_list_underline_single: + * + * Returns a #PangoAttrList for underlining text using a single line. + * The returned list is owned by the callee and must not be freed + * or modified by the caller. + * + * Return value: a #PangoAttrList for underlining text using a single line. + **/ +PangoAttrList* +tvm_pango_attr_list_underline_single (void) +{ + static PangoAttrList *attr_list = NULL; + if (G_UNLIKELY (attr_list == NULL)) + attr_list = tvm_pango_attr_list_wrap (pango_attr_underline_new (PANGO_UNDERLINE_SINGLE), NULL); + return attr_list; +} diff --git a/thunar-volman/tvm-run.h b/thunar-volman/tvm-pango-extensions.h similarity index 52% copy from thunar-volman/tvm-run.h copy to thunar-volman/tvm-pango-extensions.h index cd450db..01446df 100644 --- a/thunar-volman/tvm-run.h +++ b/thunar-volman/tvm-pango-extensions.h @@ -1,6 +1,6 @@ /* vi:set et ai sw=2 sts=2 ts=2: */ /*- - * Copyright (c) 2010 Jannis Pohlmann <jan...@xfce.org> + * Copyright (c) 2006-2007 Benedikt Meurer <be...@xfce.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,20 +18,20 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __TVM_RUN_H__ -#define __TVM_RUN_H__ +#ifndef __TVM_PANGO_EXTENSIONS_H__ +#define __TVM_PANGO_EXTENSIONS_H__ -#include <gio/gio.h> - -#include <thunar-volman/tvm-context.h> +#include <pango/pango.h> G_BEGIN_DECLS -gboolean tvm_run_command (TvmContext *context, - GMount *mount, - const gchar *command, - GError **error); +PangoAttrList *tvm_pango_attr_list_big (void) G_GNUC_CONST G_GNUC_INTERNAL; +PangoAttrList *tvm_pango_attr_list_big_bold (void) G_GNUC_CONST G_GNUC_INTERNAL; +PangoAttrList *tvm_pango_attr_list_bold (void) G_GNUC_CONST G_GNUC_INTERNAL; +PangoAttrList *tvm_pango_attr_list_italic (void) G_GNUC_CONST G_GNUC_INTERNAL; +PangoAttrList *tvm_pango_attr_list_small_italic (void) G_GNUC_CONST G_GNUC_INTERNAL; +PangoAttrList *tvm_pango_attr_list_underline_single (void) G_GNUC_CONST G_GNUC_INTERNAL; G_END_DECLS -#endif /* !__TVM_RUN_H__ */ +#endif /* !__TVM_PANGO_EXTENSIONS_H__ */ diff --git a/thunar-volman/tvm-prompt.c b/thunar-volman/tvm-prompt.c new file mode 100644 index 0000000..985cf0c --- /dev/null +++ b/thunar-volman/tvm-prompt.c @@ -0,0 +1,175 @@ +/* vi:set et ai sw=2 sts=2 ts=2: */ +/*- + * Copyright (c) 2007 Benedikt Meurer <be...@xfce.org> + * Copyright (c) 2010 Jannis Pohlmann <jan...@xfce.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifdef HAVE_STDARG_H +#include <stdarg.h> +#endif + +#include <gudev/gudev.h> + +#include <gtk/gtk.h> + +#include <libxfce4ui/libxfce4ui.h> + +#include <thunar-volman/tvm-context.h> +#include <thunar-volman/tvm-pango-extensions.h> +#include <thunar-volman/tvm-prompt.h> + + + +static void +tvm_prompt_uevent (GUdevClient *client, + const gchar *action, + GUdevDevice *device, + GtkWidget *dialog) +{ + GUdevDevice *dialog_device; + + g_return_if_fail (G_UDEV_IS_CLIENT (client)); + g_return_if_fail (action != NULL && *action != '\0'); + g_return_if_fail (G_UDEV_IS_DEVICE (device)); + g_return_if_fail (GTK_IS_DIALOG (dialog)); + + /* ignore "move" and "add" actions, "change" might only be correct + * for CDs/DVDs though */ + if (g_strcmp0 (action, "remove") != 0 && g_strcmp0 (action, "change") != 0) + return; + + /* determine the device belonging to the dialog */ + dialog_device = g_object_get_data (G_OBJECT (dialog), "device"); + + /* the device should be set, otherwise it's a bug in the application */ + g_assert (dialog_device != NULL); + + /* check if the removed/changed device belongs to the dialog */ + if (g_strcmp0 (g_udev_device_get_sysfs_path (device), + g_udev_device_get_sysfs_path (dialog_device)) == 0) + { + /* cancel the dialog */ + gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); + } +} + + + +gint +tvm_prompt (TvmContext *context, + const gchar *icon, + const gchar *title, + const gchar *primary_text, + const gchar *secondary_text, + const gchar *first_button_text, + ...) +{ + GtkWidget *dialog; + GtkWidget *hbox; + GtkWidget *image; + GtkWidget *label; + GtkWidget *vbox; + va_list args; + gint response; + + g_return_val_if_fail (context != NULL, GTK_RESPONSE_CANCEL); + + /* create a new dialog */ + dialog = gtk_dialog_new (); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + g_object_set_data_full (G_OBJECT (dialog), "device", g_object_ref (context->device), + g_object_unref); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 6); + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12); + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + + /* apply the specified title */ + if (title != NULL && *title != '\0') + gtk_window_set_title (GTK_WINDOW (dialog), title); + + /* create the specified buttons */ + if (first_button_text != NULL) + { + va_start (args, first_button_text); + for (response = va_arg (args, gint); first_button_text != NULL; ) + { + /* insert the button */ + gtk_dialog_add_button (GTK_DIALOG (dialog), first_button_text, response); + first_button_text = va_arg (args, const gchar *); + if (first_button_text == NULL) + break; + response = va_arg (args, gint); + } + va_end (args); + } + + /* create the hbox */ + hbox = gtk_hbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0); + gtk_widget_show (hbox); + + /* apply the specified icon */ + if (G_LIKELY (icon != NULL)) + { + gtk_window_set_icon_name (GTK_WINDOW (dialog), icon); + + /* setup an image for the icon */ + image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment (GTK_MISC (image), 0.0f, 0.0f); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + gtk_widget_show (image); + } + + /* setup the vbox */ + vbox = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); + + /* setup the primary text */ + label = gtk_label_new (primary_text); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); + gtk_label_set_attributes (GTK_LABEL (label), tvm_pango_attr_list_big_bold ()); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + /* setup the secondary text */ + if (G_LIKELY (secondary_text != NULL)) + { + label = gtk_label_new (secondary_text); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + } + + g_signal_connect (context->client, "uevent", G_CALLBACK (tvm_prompt_uevent), dialog); + + /* run the dialog */ + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + /* clean up */ + gtk_widget_destroy (dialog); + + return response; +} diff --git a/thunar-volman/tvm-block-device.h b/thunar-volman/tvm-prompt.h similarity index 59% copy from thunar-volman/tvm-block-device.h copy to thunar-volman/tvm-prompt.h index 5f6f1d7..886a3e4 100644 --- a/thunar-volman/tvm-block-device.h +++ b/thunar-volman/tvm-prompt.h @@ -1,5 +1,6 @@ /* vi:set et ai sw=2 sts=2 ts=2: */ /*- + * Copyright (c) 2007 Benedikt Meurer <be...@xfce.org> * Copyright (c) 2010 Jannis Pohlmann <jan...@xfce.org> * * This program is free software; you can redistribute it and/or @@ -18,18 +19,35 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __TVM_BLOCK_DEVICE_H__ -#define __TVM_BLOCK_DEVICE_H__ +#ifndef __TVM_PROMPT_H__ +#define __TVM_PROMPT_H__ #include <glib.h> #include <thunar-volman/tvm-context.h> -#include <thunar-volman/tvm-device.h> G_BEGIN_DECLS -void tvm_block_device_added (TvmContext *context); +enum +{ + TVM_RESPONSE_NONE, + TVM_RESPONSE_PLAY, + TVM_RESPONSE_MUSIC, + TVM_RESPONSE_BROWSE, + TVM_RESPONSE_PHOTOS, + TVM_RESPONSE_AUTORUN, + TVM_RESPONSE_BURN_DATA_CD, + TVM_RESPONSE_BURN_AUDIO_CD, +}; + +gint tvm_prompt (TvmContext *context, + const gchar *icon, + const gchar *title, + const gchar *primary_text, + const gchar *secondary_text, + const gchar *first_button_text, + ...) G_GNUC_NULL_TERMINATED; G_END_DECLS -#endif /* !__TVM_BLOCK_DEVICE_H__ */ +#endif /* !__TVM_PROMPT_H__ */ diff --git a/thunar-volman/tvm-run.c b/thunar-volman/tvm-run.c index 23ea8aa..571047d 100644 --- a/thunar-volman/tvm-run.c +++ b/thunar-volman/tvm-run.c @@ -24,7 +24,12 @@ #include <gio/gio.h> +#include <gtk/gtk.h> + +#include <libxfce4util/libxfce4util.h> + #include <thunar-volman/tvm-context.h> +#include <thunar-volman/tvm-prompt.h> #include <thunar-volman/tvm-run.h> @@ -46,7 +51,7 @@ tvm_run_command (TvmContext *context, gchar *quoted; g_return_val_if_fail (context != NULL, FALSE); - g_return_val_if_fail (G_IS_MOUNT (mount), FALSE); + g_return_val_if_fail (mount == NULL || G_IS_MOUNT (mount), FALSE); g_return_val_if_fail (command != NULL && *command != '\0', FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -67,22 +72,30 @@ tvm_run_command (TvmContext *context, break; case 'm': /* mount point */ - mount_point = g_mount_get_root (mount); - mount_path = g_file_get_path (mount_point); - if (G_LIKELY (mount_path != NULL)) + if (mount != NULL) { - /* substitute mount point quoted */ - quoted = g_shell_quote (mount_path); - g_string_append (command_line, quoted); - g_free (quoted); + mount_point = g_mount_get_root (mount); + mount_path = g_file_get_path (mount_point); + if (G_LIKELY (mount_path != NULL)) + { + /* substitute mount point quoted */ + quoted = g_shell_quote (mount_path); + g_string_append (command_line, quoted); + g_free (quoted); + } + else + { + /* %m must always be substituted */ + g_string_append (command_line, "\"\""); + } + g_free (mount_path); + g_object_unref (mount_point); } else { /* %m must always be substituted */ g_string_append (command_line, "\"\""); } - g_free (mount_path); - g_object_unref (mount_point); break; case '%': @@ -124,3 +137,108 @@ tvm_run_command (TvmContext *context, return result; } + + + +gboolean +tvm_run_burn_software (TvmContext *context, + GError **error) +{ + static const gchar *cd_criteria[] = { + "ID_CDROM_MEDIA_CD_R", + "ID_CDROM_MEDIA_CD_RW", + }; + + static const gchar *dvd_criteria[] = { + "ID_CDROM_MEDIA_DVD_R", + "ID_CDROM_MEDIA_DVD_RW", + "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; + const gchar *command_property; + gchar *command; + guint n; + gint response; + + g_return_val_if_fail (context != NULL, FALSE); + 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) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Autoburning of blank CDs/DVDs is disabled")); + return FALSE; + } + + /* check if the disc is a CD */ + for (n = 0; !is_cd && n < G_N_ELEMENTS (cd_criteria); ++n) + if (g_udev_device_get_property_as_boolean (context->device, cd_criteria[n])) + is_cd = TRUE; + + /* check if the disc is a DVD */ + for (n = 0; !is_cd && !is_dvd && n < G_N_ELEMENTS (dvd_criteria); ++n) + if (g_udev_device_get_property_as_boolean (context->device, dvd_criteria[n])) + is_dvd = TRUE; + + g_debug ("is_cd = %i, is_dvd = %i", is_cd, is_dvd); + + if (is_dvd) + { + /* ask what to do with the empty DVD */ + response = tvm_prompt (context, "gnome-dev-disc-dvdr", + _("Blank DVD inserted"), + _("You have inserted a blank DVD."), + _("What would you like to do?"), + _("Ig_nore"), GTK_RESPONSE_CANCEL, + _("Burn _DVD"), TVM_RESPONSE_BURN_DATA_CD, + NULL); + } + else + { + /* ask whether to burn data or audio CD */ + response = tvm_prompt (context, "gnome-dev-disc-cdr", + _("Blank CD inserted"), + _("You have inserted a blank CD."), + _("What would you like to do?"), + _("Ig_nore"), GTK_RESPONSE_CANCEL, + _("Burn _Data CD"), TVM_RESPONSE_BURN_DATA_CD, + _("Burn _Audio CD"), TVM_RESPONSE_BURN_AUDIO_CD, + NULL); + } + + /* determine the autoburn command property */ + if (response == TVM_RESPONSE_BURN_DATA_CD) + command_property = "/autoburn/data-cd-command"; + else if (response == TVM_RESPONSE_BURN_AUDIO_CD) + command_property = "/autoburn/audio-cd-command"; + else + return TRUE; + + /* determine the command to launch */ + command = xfconf_channel_get_string (context->channel, command_property, NULL); + + /* only try to launch the command if it is set and non-empty */ + if (command != NULL && *command != '\0') + { + /* try to execute the preferred burn software */ + result = tvm_run_command (context, NULL, command, error); + } + else + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("The burn command may not be empty")); + result = FALSE; + } + + /* free the burn command */ + g_free (command); + + return result; +} + diff --git a/thunar-volman/tvm-run.h b/thunar-volman/tvm-run.h index cd450db..dc67d13 100644 --- a/thunar-volman/tvm-run.h +++ b/thunar-volman/tvm-run.h @@ -27,10 +27,12 @@ G_BEGIN_DECLS -gboolean tvm_run_command (TvmContext *context, - GMount *mount, - const gchar *command, - GError **error); +gboolean tvm_run_command (TvmContext *context, + GMount *mount, + const gchar *command, + GError **error); +gboolean tvm_run_burn_software (TvmContext *context, + GError **error); G_END_DECLS _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits