[Goodies-commits] r5199 - in xfburn/trunk: . xfburn
David Mohr
squisher at xfce.org
Tue Aug 5 22:12:00 CEST 2008
Author: squisher
Date: 2008-08-05 20:12:00 +0000 (Tue, 05 Aug 2008)
New Revision: 5199
Modified:
xfburn/trunk/NEWS
xfburn/trunk/TODO
xfburn/trunk/xfburn/Makefile.am
xfburn/trunk/xfburn/xfburn-device-box.c
xfburn/trunk/xfburn/xfburn-device-list.c
xfburn/trunk/xfburn/xfburn-device-list.h
xfburn/trunk/xfburn/xfburn-format-dvd-dialog.c
xfburn/trunk/xfburn/xfburn-format-dvd-dialog.h
xfburn/trunk/xfburn/xfburn-hal-manager.c
xfburn/trunk/xfburn/xfburn-hal-manager.h
xfburn/trunk/xfburn/xfburn-main-window.c
xfburn/trunk/xfburn/xfburn-main.c
xfburn/trunk/xfburn/xfburn-preferences-dialog.c
Log:
* Get drives initially from HAL
* Fill in details during refresh from libburn
* Try to unmount inaccessible drives
* Smaller code cleanups / disabling unused code
Modified: xfburn/trunk/NEWS
===================================================================
--- xfburn/trunk/NEWS 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/NEWS 2008-08-05 20:12:00 UTC (rev 5199)
@@ -2,6 +2,10 @@
============-------------
- Allow drags and drop from file managers like Thunar (text/uri-list target)
+- Require HAL if compiled with HAL support
+- Try to unmount a drive if it is not accessible
+- Build list of drives initially from HAL, then fill in details using libburn
+ once the burn dialog shows up
xfburn 0.3.2 (2008-07-15)
============-------------
Modified: xfburn/trunk/TODO
===================================================================
--- xfburn/trunk/TODO 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/TODO 2008-08-05 20:12:00 UTC (rev 5199)
@@ -42,3 +42,5 @@
or invalid size of a composition item
- rework refresh_speed_list, to make it more easily understandable when the
disc status should get refreshed
+- cairo animation for blanking progress
+- allow usage of gtk bookmarks
Modified: xfburn/trunk/xfburn/Makefile.am
===================================================================
--- xfburn/trunk/xfburn/Makefile.am 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/Makefile.am 2008-08-05 20:12:00 UTC (rev 5199)
@@ -20,14 +20,10 @@
xfburn-settings.h \
xfburn-composition.h \
xfburn-compositions-notebook.h \
- xfburn-copy-cd-dialog.h \
- xfburn-copy-cd-progress-dialog.h \
- xfburn-copy-dvd-dialog.h \
xfburn-create-iso-progress-dialog.h \
xfburn-hal-manager.h \
xfburn-device-box.h \
xfburn-device-list.h \
- xfburn-format-dvd-dialog.h \
xfburn-progress-dialog.h \
xfburn-main-window.h \
xfburn-notebook-tab.h \
@@ -54,11 +50,9 @@
xfburn-composition.c \
xfburn-compositions-notebook.c \
xfburn-settings.c \
- xfburn-copy-dvd-dialog.c \
xfburn-hal-manager.c \
xfburn-device-box.c \
xfburn-device-list.c \
- xfburn-format-dvd-dialog.c \
xfburn-progress-dialog.c \
xfburn-main.c \
xfburn-main-window.c \
@@ -104,6 +98,12 @@
missing_files = \
xfburn-copy-cd-dialog.c \
xfburn-copy-cd-progress-dialog.c \
+ xfburn-copy-dvd-dialog.c \
+ xfburn-copy-cd-dialog.h \
+ xfburn-copy-cd-progress-dialog.h \
+ xfburn-copy-dvd-dialog.h \
+ xfburn-format-dvd-dialog.c \
+ xfburn-format-dvd-dialog.h \
xfburn-create-iso-progress-dialog.c
EXTRA_DIST = $(missing_files)
Modified: xfburn/trunk/xfburn/xfburn-device-box.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-box.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-device-box.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -487,12 +487,6 @@
gtk_list_store_clear (GTK_LIST_STORE (model));
- if (!check_disc_validity (priv))
- return;
-
- if (!priv->show_speed_selection)
- return;
-
if (el == NULL) {
/* a valid disc is in the drive, but no speed list is present */
GtkTreeIter iter;
@@ -763,46 +757,66 @@
return device;
}
+static XfburnDevice *
+refresh_drive_info (XfburnDeviceBox *box)
+{
+ XfburnDeviceBoxPrivate *priv = XFBURN_DEVICE_BOX_GET_PRIVATE (box);
+ XfburnDevice *device = NULL;
+
+ device = xfburn_device_box_get_selected_device (box);
+ if (G_UNLIKELY (device == NULL))
+ return NULL;
+
+ if (!xfburn_device_refresh_info (device, priv->show_speed_selection))
+ return NULL;
+
+ if (priv->show_speed_selection)
+ fill_combo_speed (box, device);
+
+ if (priv->show_mode_selection)
+ fill_combo_mode (box,device);
+
+ if (!check_disc_validity (priv))
+ return NULL;
+
+ return device;
+}
+
static void
cb_speed_refresh_clicked (GtkButton *button, XfburnDeviceBox *box)
{
XfburnDeviceBoxPrivate *priv = XFBURN_DEVICE_BOX_GET_PRIVATE (box);
- XfburnDevice *device = NULL;
+ XfburnDevice *device;
xfburn_busy_cursor (priv->combo_device);
- device = xfburn_device_box_get_selected_device (box);
- if (xfburn_device_refresh_supported_speeds (device))
- fill_combo_speed (box, device);
+ device = refresh_drive_info (box);
xfburn_default_cursor (priv->combo_device);
+ if (device == NULL)
+ return;
+
g_signal_emit (G_OBJECT (box), signals[DISC_REFRESHED], 0, device);
}
static void
cb_combo_device_changed (GtkComboBox *combo, XfburnDeviceBox *box)
{
- XfburnDeviceBoxPrivate *priv = XFBURN_DEVICE_BOX_GET_PRIVATE (box);
+ //XfburnDeviceBoxPrivate *priv = XFBURN_DEVICE_BOX_GET_PRIVATE (box);
XfburnDevice *device;
if (GTK_WIDGET_REALIZED (box))
xfburn_busy_cursor (GTK_WIDGET (box));
- device = xfburn_device_box_get_selected_device (box);
- if (device != NULL) {
- //DBG ("Device changed to %s", device->name);
- xfburn_device_refresh_supported_speeds (device);
+ device = refresh_drive_info (box);
- fill_combo_speed (box, device);
-
- if (priv->show_mode_selection)
- fill_combo_mode (box,device);
- }
-
if (GTK_WIDGET_REALIZED (box))
xfburn_default_cursor (GTK_WIDGET (box));
+ if (device == NULL)
+ return;
+
g_signal_emit (G_OBJECT (box), signals[DEVICE_CHANGED], 0, device);
}
Modified: xfburn/trunk/xfburn/xfburn-device-list.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-list.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-device-list.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -33,9 +33,11 @@
#include <libburn.h>
-#include "xfburn-device-list.h"
#include "xfburn-global.h"
+#include "xfburn-hal-manager.h"
+#include "xfburn-device-list.h"
+
static GList *devices = NULL;
static enum burn_disc_status disc_status;
static int profile_no = 0;
@@ -52,7 +54,6 @@
device_content_free (XfburnDevice * device, gpointer user_data)
{
g_free (device->name);
- g_free (device->node_path);
g_slist_free (device->supported_cdr_speeds);
}
@@ -134,6 +135,85 @@
}
}
+void
+fillin_libburn_device_info (XfburnDevice *device, struct burn_drive_info *drives)
+{
+ device->accessible = TRUE;
+
+ device->cdr = drives->write_cdr;
+ device->cdrw = drives->write_cdrw;
+
+ device->dvdr = drives->write_dvdr;
+ device->dvdram = drives->write_dvdram;
+
+ device->buffer_size = drives->buffer_size;
+ device->dummy_write = drives->write_simulate;
+
+ /* write modes */
+ device->tao_block_types = drives->tao_block_types;
+ device->sao_block_types = drives->sao_block_types;
+ device->raw_block_types = drives->raw_block_types;
+ device->packet_block_types = drives->packet_block_types;
+
+ DBG (DEVICE_INFO_PRINTF);
+}
+
+gint
+get_libburn_device_list ()
+{
+ struct burn_drive_info *drives;
+ gint i, ret;
+ gboolean can_burn;
+ guint n_drives = 0;
+ guint n_burners = 0;
+
+ *profile_name = '\0';
+
+ if (!burn_initialize ()) {
+ g_critical ("Unable to initialize libburn");
+ return -1;
+ }
+
+ while ((ret = burn_drive_scan (&drives, &n_drives)) == 0)
+ usleep (1002);
+
+ if (ret < 0)
+ g_warning ("An error occurred while scanning for available drives!");
+
+ if (n_drives < 1) {
+ g_warning ("No drives were found! If this is in error, check the permissions.");
+ }
+
+ for (i = 0; i < n_drives; i++) {
+ XfburnDevice *device = g_new0 (XfburnDevice, 1);
+ gint ret = 0;
+
+ device->name = g_strconcat (drives[i].vendor, " ", drives[i].product, NULL);
+
+ fillin_libburn_device_info (device, &drives[i]);
+
+ can_burn = CAN_BURN_CONDITION;
+
+ ret = burn_drive_get_adr (&(drives[i]), device->addr);
+ if (ret <= 0)
+ g_error ("Unable to get drive %s address (ret=%d). Please report this problem to libburn-hackers at pykix.org", device->name, ret);
+ DBG ("device->addr = %s", device->addr);
+
+ if (can_burn) {
+ devices = g_list_append (devices, device);
+ n_burners++;
+ }
+ }
+
+ burn_drive_info_free (drives);
+ burn_finish ();
+
+ if (n_drives > 0 && n_burners < 1)
+ g_warning ("There are %d drives in your system, but none are capable of burning!", n_drives);
+
+ return n_burners;
+}
+
/**************/
/* public API */
/**************/
@@ -168,10 +248,13 @@
}
gboolean
-xfburn_device_refresh_supported_speeds (XfburnDevice * device)
+xfburn_device_refresh_info (XfburnDevice * device, gboolean get_speed_info)
{
struct burn_drive_info *drive_info = NULL;
gboolean ret;
+#ifdef HAVE_HAL
+ XfburnHalManager *halman = xfburn_hal_manager_get_instance ();
+#endif
if (G_UNLIKELY (device == NULL)) {
DBG ("Hmm, why can we refresh when there is no drive?");
@@ -187,6 +270,15 @@
g_slist_free (device->supported_cdr_speeds);
device->supported_cdr_speeds = NULL;
+ if (!device->accessible) {
+#ifdef HAVE_HAL
+ if (!xfburn_hal_manager_check_ask_umount (halman, device))
+ return FALSE;
+#else
+ return FALSE;
+#endif
+ }
+
if (!burn_initialize ()) {
g_critical ("Unable to initialize libburn");
return FALSE;
@@ -197,9 +289,12 @@
g_warning ("Couldn't grab drive in order to update speed list.");
disc_status = BURN_DISC_UNGRABBED;
} else {
+ if (!device->accessible)
+ fillin_libburn_device_info (device, drive_info);
ret = TRUE;
refresh_disc (device, drive_info);
- refresh_speed_list (device, drive_info);
+ if (get_speed_info)
+ refresh_speed_list (device, drive_info);
burn_drive_release (drive_info->drive, 0);
}
@@ -212,87 +307,21 @@
gint
xfburn_device_list_init ()
{
- struct burn_drive_info *drives;
- gint i, ret;
- gboolean can_burn;
- guint n_drives = 0;
- guint n_burners = 0;
+#ifdef HAVE_HAL
+ XfburnHalManager *halman = xfburn_hal_manager_get_instance ();
+#endif
- *profile_name = '\0';
-
- if (!burn_initialize ()) {
- g_critical ("Unable to initialize libburn");
- return -1;
- }
-
if (devices) {
g_list_foreach (devices, (GFunc) device_content_free, NULL);
g_list_free (devices);
devices = NULL;
}
- while ((ret = burn_drive_scan (&drives, &n_drives)) == 0)
- usleep (1002);
-
- if (ret < 0)
- g_warning ("An error occurred while scanning for available drives!");
-
- if (n_drives < 1) {
- g_warning ("No drives were found! If this is in error, check the permissions.");
- }
-
- for (i = 0; i < n_drives; i++) {
- XfburnDevice *device = g_new0 (XfburnDevice, 1);
- gint ret = 0;
-
- device->name = g_strconcat (drives[i].vendor, " ", drives[i].product, NULL);
- device->node_path = g_strdup (drives[i].location);
-
- device->cdr = drives[i].write_cdr;
- device->cdrw = drives[i].write_cdrw;
-
- device->dvdr = drives[i].write_dvdr;
- device->dvdram = drives[i].write_dvdram;
-
- device->buffer_size = drives[i].buffer_size;
- device->dummy_write = drives[i].write_simulate;
-
- /* write modes */
- device->tao_block_types = drives[i].tao_block_types;
- device->sao_block_types = drives[i].sao_block_types;
- device->raw_block_types = drives[i].raw_block_types;
- device->packet_block_types = drives[i].packet_block_types;
-
- can_burn = CAN_BURN_CONDITION;
-
- DBG (DEVICE_INFO_PRINTF);
-
- ret = burn_drive_get_adr (&(drives[i]), device->addr);
- if (ret <= 0)
- g_error ("Unable to get drive %s address (ret=%d). Please report this problem to libburn-hackers at pykix.org", device->name, ret);
-
- /*
- * refresh_supported_speeds now gets called when the device box gets initialized
- if (burn_drive_grab (drives[i].drive, 1) == 1) {
- refresh_supported_speeds (device, &(drives[i]));
- burn_drive_release (drives[i].drive, 0);
- } else
- g_warning ("Failed to grab drive %s, did not refresh speed list", device->name);
- */
-
- if (can_burn) {
- devices = g_list_append (devices, device);
- n_burners++;
- }
- }
-
- burn_drive_info_free (drives);
- burn_finish ();
-
- if (n_drives > 0 && n_burners < 1)
- g_warning ("There are %d drives in your system, but none are capable of burning!", n_drives);
-
- return n_burners;
+#ifdef HAVE_HAL
+ return xfburn_hal_manager_get_devices (halman, &devices);
+#else
+ return get_libburn_device_list ();
+#endif
}
gboolean
Modified: xfburn/trunk/xfburn/xfburn-device-list.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-device-list.h 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-device-list.h 2008-08-05 20:12:00 UTC (rev 5199)
@@ -57,7 +57,9 @@
typedef struct
{
gchar *name;
- gchar *node_path;
+ gchar addr[BURN_DRIVE_ADR_LEN];
+ gboolean accessible;
+
gint buffer_size;
gboolean dummy_write;
@@ -73,7 +75,6 @@
gboolean dvdr;
gboolean dvdram;
- gchar addr[BURN_DRIVE_ADR_LEN];
} XfburnDevice;
gint xfburn_device_list_init ();
@@ -85,7 +86,7 @@
gboolean xfburn_device_list_disc_is_erasable ();
void xfburn_device_list_free ();
-gboolean xfburn_device_refresh_supported_speeds (XfburnDevice * device);
+gboolean xfburn_device_refresh_info (XfburnDevice * device, gboolean get_speed_info);
gboolean xfburn_device_grab (XfburnDevice * device, struct burn_drive_info **drive_info);
void xfburn_device_free (XfburnDevice * device);
Modified: xfburn/trunk/xfburn/xfburn-format-dvd-dialog.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-format-dvd-dialog.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-format-dvd-dialog.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -17,6 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#if 0
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* !HAVE_CONFIG_H */
@@ -174,3 +176,4 @@
return obj;
}
+#endif
Modified: xfburn/trunk/xfburn/xfburn-format-dvd-dialog.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-format-dvd-dialog.h 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-format-dvd-dialog.h 2008-08-05 20:12:00 UTC (rev 5199)
@@ -16,6 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#if 0
#ifndef __XFBURN_FORMAT_DVD_DIALOG_H__
#define __XFBURN_FORMAT_DVD_DIALOG_H__
@@ -50,3 +51,4 @@
G_END_DECLS
#endif /* XFBURN_FORMAT_DVD_H */
+#endif
Modified: xfburn/trunk/xfburn/xfburn-hal-manager.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-hal-manager.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-hal-manager.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -33,14 +33,17 @@
#include <errno.h>
#include <libxfce4util/libxfce4util.h>
+#include <thunar-vfs/thunar-vfs.h>
+#include <libxfcegui4/libxfcegui4.h>
#include "xfburn-global.h"
#include "xfburn-progress-dialog.h"
+#include "xfburn-device-list.h"
#include "xfburn-hal-manager.h"
static void xfburn_hal_manager_class_init (XfburnHalManagerClass * klass);
-static void xfburn_hal_manager_init (XfburnHalManager * sp);
+static void xfburn_hal_manager_init (XfburnHalManager * obj);
static void xfburn_hal_manager_finalize (GObject * object);
static void hal_finalize (LibHalContext *hal_context);
@@ -59,6 +62,7 @@
typedef struct {
LibHalContext *hal_context;
DBusConnection *dbus_connection;
+ gchar *error;
} XfburnHalManagerPrivate;
static XfburnHalManager *halman = NULL;
@@ -119,6 +123,7 @@
//GError *error = NULL;
DBusConnection *dbus_connection;
+ priv->error = NULL;
//if (halman != NULL)
// g_error ("The HAL context was already there when trying to create a hal-manager!");
@@ -154,16 +159,17 @@
/* drop the allocated HAL context */
hal_finalize (hal_context);
hal_context = NULL;
+ priv->error = "HAL";
+ } else {
+ priv->error = "DBus";
}
- DBG ("Connection to dbus or hal failed!");
+ dbus_error_free (&derror);
} else {
libhal_ctx_set_device_added (hal_context, cb_device_added);
libhal_ctx_set_device_removed (hal_context, cb_device_removed);
libhal_ctx_set_device_property_modified (hal_context, cb_prop_modified);
}
- dbus_error_free (&derror);
-
priv->hal_context = hal_context;
priv->dbus_connection = dbus_connection;
}
@@ -219,10 +225,6 @@
*/
}
-/* */
-/* public */
-/* */
-
GObject *
xfburn_hal_manager_new ()
{
@@ -231,10 +233,24 @@
return g_object_new (XFBURN_TYPE_HAL_MANAGER, NULL);
}
-void
+/* */
+/* public */
+/* */
+
+gchar *
xfburn_hal_manager_create_global ()
{
+ XfburnHalManagerPrivate *priv;
+
halman = XFBURN_HAL_MANAGER (xfburn_hal_manager_new ());
+
+ priv = XFBURN_HAL_MANAGER_GET_PRIVATE (halman);
+
+ if (priv->error) {
+ xfburn_hal_manager_shutdown ();
+ return g_strdup_printf ("Failed to initialize %s!", priv->error);
+ } else
+ return NULL;
}
XfburnHalManager *
@@ -262,4 +278,239 @@
//gdk_threads_leave ();
}
+int
+xfburn_hal_manager_get_devices (XfburnHalManager *halman, GList **device_list)
+{
+ XfburnHalManagerPrivate *priv = XFBURN_HAL_MANAGER_GET_PRIVATE (halman);
+ char **all_devices, **devices;
+ int num;
+ DBusError error;
+ int n_devices = 0;
+
+ dbus_error_init (&error);
+
+ all_devices = libhal_get_all_devices (priv->hal_context, &num, &error);
+
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Could not get list of devices from HAL: %s", error.message);
+ return 0;
+ }
+
+ for (devices = all_devices; *devices != NULL; devices++) {
+ dbus_bool_t exists;
+ char **cap_list, **caps;
+ gboolean writer = FALSE;
+ int write_speed;
+
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error printing HAL device %s: %s", *devices, error.message);
+ return 0;
+ }
+
+ exists = libhal_device_property_exists (priv->hal_context, *devices, "info.capabilities", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error checking HAL property for %s: %s", *devices, error.message);
+ return 0;
+ }
+
+ if (!exists)
+ continue;
+
+ cap_list = libhal_device_get_property_strlist (priv->hal_context, *devices, "info.capabilities", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ return 0;
+ }
+
+ for (caps = cap_list; *caps != NULL; caps++) {
+ if (strcmp (*caps, "storage.cdrom") == 0) {
+ exists = libhal_device_property_exists (priv->hal_context, *devices, "storage.cdrom.write_speed", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error checking HAL property for %s: %s", *devices, error.message);
+ return 0;
+ }
+
+ if (!exists)
+ break;
+
+ write_speed = libhal_device_get_property_int (priv->hal_context, *devices, "storage.cdrom.write_speed", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ return 0;
+ }
+
+ if (write_speed > 0)
+ writer = TRUE;
+ break;
+ }
+ }
+ libhal_free_string_array (cap_list);
+
+ if (writer) {
+ XfburnDevice *device = g_new0 (XfburnDevice, 1);
+ char *str, *str_vendor;
+ gboolean dvdr = FALSE;
+ /*
+ libhal_device_print (priv->hal_context, *devices, &error);
+ printf ("\n");
+ */
+
+ device->accessible = FALSE;
+ str_vendor = libhal_device_get_property_string (priv->hal_context, *devices, "storage.vendor", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ str = libhal_device_get_property_string (priv->hal_context, *devices, "storage.model", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ device->name = g_strconcat (str_vendor, " ", str, NULL);
+ libhal_free_string (str_vendor);
+ libhal_free_string (str);
+
+ str = libhal_device_get_property_string (priv->hal_context, *devices, "block.device", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ g_strlcpy (device->addr, str, BURN_DRIVE_ADR_LEN);
+ libhal_free_string (str);
+
+ device->cdr = libhal_device_get_property_bool (priv->hal_context, *devices, "storage.cdrom.cdr", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ device->cdr = libhal_device_get_property_bool (priv->hal_context, *devices, "storage.cdrom.cdr", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ device->cdrw = libhal_device_get_property_bool (priv->hal_context, *devices, "storage.cdrom.cdrw", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ device->dvdr = libhal_device_get_property_bool (priv->hal_context, *devices, "storage.cdrom.dvdr", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ dvdr = libhal_device_get_property_bool (priv->hal_context, *devices, "storage.cdrom.dvdplusr", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+ device->dvdr |= dvdr;
+
+ device->dvdram = libhal_device_get_property_bool (priv->hal_context, *devices, "storage.cdrom.dvdram", &error);
+ if (dbus_error_is_set (&error)) {
+ g_warning ("Error getting HAL property for %s: %s", *devices, error.message);
+ dbus_error_free (&error);
+ g_free (device);
+ continue;
+ }
+
+ DBG ("Found drive '%s' at '%s'", device->name, device->addr);
+ *device_list = g_list_append (*device_list, device);
+ n_devices++;
+ }
+ }
+
+ libhal_free_string_array (all_devices);
+
+ return n_devices;
+}
+
+gboolean
+xfburn_hal_manager_check_ask_umount (XfburnHalManager *halman, XfburnDevice *device)
+{
+ XfburnHalManagerPrivate *priv = XFBURN_HAL_MANAGER_GET_PRIVATE (halman);
+ LibHalVolume *vol;
+ const char *mp;
+ ThunarVfsInfo *th_info;
+ ThunarVfsVolumeManager *th_volman;
+ ThunarVfsVolume *th_vol;
+ ThunarVfsPath *th_path;
+ gboolean unmounted;
+
+ vol = libhal_volume_from_device_file (priv->hal_context, device->addr);
+ if (vol == NULL) {
+ g_warning ("Could not get HAL volume for %s!", device->addr);
+ return FALSE;
+ }
+
+ if (!libhal_volume_is_mounted (vol))
+ return TRUE;
+
+ mp = libhal_volume_get_mount_point (vol);
+ DBG ("%s is mounted at %s", device->addr, mp);
+
+
+ th_path = thunar_vfs_path_new (mp, NULL);
+ if (!th_path) {
+ g_warning ("Error getting thunar path for %s!", mp);
+ return FALSE;
+ }
+
+ th_info = thunar_vfs_info_new_for_path (th_path, NULL);
+ thunar_vfs_path_unref (th_path);
+ if (!th_info) {
+ g_warning ("Error getting thunar info for %s!", mp);
+ return FALSE;
+ }
+
+ th_volman = thunar_vfs_volume_manager_get_default ();
+ th_vol = thunar_vfs_volume_manager_get_volume_by_info (th_volman, th_info);
+ thunar_vfs_info_unref (th_info);
+
+ if (!th_vol) {
+ g_warning ("Error getting thunar volume for %s!", mp);
+ g_object_unref (th_volman);
+ return FALSE;
+ }
+
+ if (!thunar_vfs_volume_is_mounted (th_vol)) {
+ g_object_unref (th_volman);
+ return FALSE;
+ }
+
+ /* FIXME: ask if we should unmount? */
+ unmounted = thunar_vfs_volume_unmount (th_vol, NULL, NULL);
+ if (unmounted)
+ g_message ("Unmounted %s", mp);
+ else {
+ xfce_err ("Failed to unmount %s. Drive cannot be used for burning.", mp);
+ DBG ("Failed to unmount %s", mp);
+ }
+
+ g_object_unref (th_volman);
+ return unmounted;
+}
+
#endif /* HAVE_HAL */
Modified: xfburn/trunk/xfburn/xfburn-hal-manager.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-hal-manager.h 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-hal-manager.h 2008-08-05 20:12:00 UTC (rev 5199)
@@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include "xfburn-progress-dialog.h"
+#include "xfburn-device-list.h"
G_BEGIN_DECLS
@@ -53,11 +54,13 @@
} XfburnHalManagerClass;
GtkType xfburn_hal_manager_get_type ();
-GObject *xfburn_hal_manager_new ();
-void xfburn_hal_manager_create_global ();
+//GObject *xfburn_hal_manager_new (); /* use _create_global / _get_instance instead */
+gchar *xfburn_hal_manager_create_global ();
XfburnHalManager * xfburn_hal_manager_get_instance ();
void xfburn_hal_manager_shutdown ();
void xfburn_hal_manager_send_volume_changed ();
+int xfburn_hal_manager_get_devices (XfburnHalManager *halman, GList **devices);
+gboolean xfburn_hal_manager_check_ask_umount (XfburnHalManager *halman, XfburnDevice *device);
G_END_DECLS
Modified: xfburn/trunk/xfburn/xfburn-main-window.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-main-window.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-main-window.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -33,7 +33,7 @@
#include "xfburn-file-browser.h"
#include "xfburn-compositions-notebook.h"
#include "xfburn-blank-dialog.h"
-#include "xfburn-format-dvd-dialog.h"
+//#include "xfburn-format-dvd-dialog.h"
#include "xfburn-copy-cd-dialog.h"
#include "xfburn-copy-dvd-dialog.h"
#include "xfburn-burn-image-dialog.h"
@@ -86,8 +86,8 @@
static void action_copy_cd (GtkAction *, XfburnMainWindow *);
static void action_burn_image (GtkAction *, XfburnMainWindow *);
-static void action_format_dvd (GtkAction *, XfburnMainWindow *);
-static void action_copy_dvd (GtkAction *, XfburnMainWindow *);
+//static void action_format_dvd (GtkAction *, XfburnMainWindow *);
+//static void action_copy_dvd (GtkAction *, XfburnMainWindow *);
static void action_burn_dvd_image (GtkAction *, XfburnMainWindow *);
static void action_refresh_directorybrowser (GtkAction *, XfburnMainWindow *);
@@ -131,10 +131,10 @@
{"copy-audio", "xfburn-audio-copy", N_("Copy Audio CD"), NULL, N_("Copy Audio CD"),},
{"burn-image", "xfburn-burn-cd", N_("Burn Image"), NULL, N_("Burn Image"),
G_CALLBACK (action_burn_image),},
- {"format-dvd", "xfburn-format-dvdrw", N_("Format DVD+RW"), NULL, N_("Format DVD+RW"),
+/* {"format-dvd", "xfburn-format-dvdrw", N_("Format DVD+RW"), NULL, N_("Format DVD+RW"),
G_CALLBACK (action_format_dvd),},
{"copy-dvd", "xfburn-data-copy", N_("Copy DVD"), NULL, N_("Copy DVD"),
- G_CALLBACK (action_copy_dvd),},
+ G_CALLBACK (action_copy_dvd),}, */
{"burn-dvd", "xfburn-burn-image", N_("Burn DVD Image"), NULL, N_("Burn DVD Image"),
G_CALLBACK (action_burn_dvd_image),},
};
@@ -155,7 +155,7 @@
"copy-data",
//"copy-audio",
"burn-image",
- "format-dvd",
+ //"format-dvd",
"copy-dvd",
"burn-dvd",
"refresh",
@@ -405,6 +405,7 @@
gtk_widget_destroy (dialog);
}
+/*
static void
action_format_dvd (GtkAction * action, XfburnMainWindow * window)
{
@@ -415,7 +416,9 @@
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+*/
+/*
static void
action_copy_dvd (GtkAction * action, XfburnMainWindow * window)
{
@@ -426,6 +429,7 @@
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+*/
static void
action_burn_dvd_image (GtkAction * action, XfburnMainWindow * window)
Modified: xfburn/trunk/xfburn/xfburn-main.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-main.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-main.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -131,6 +131,7 @@
GtkWidget *mainwin;
gint n_drives;
GError *error = NULL;
+ gchar *error_msg;
#if DEBUG > 0
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
@@ -171,7 +172,13 @@
#endif
#ifdef HAVE_HAL
- xfburn_hal_manager_create_global ();
+ error_msg = xfburn_hal_manager_create_global ();
+ if (error_msg) {
+ xfce_err (error_msg);
+ thunar_vfs_shutdown ();
+ gdk_threads_leave ();
+ return EXIT_FAILURE;
+ }
#endif
xfburn_stock_init ();
Modified: xfburn/trunk/xfburn/xfburn-preferences-dialog.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-preferences-dialog.c 2008-08-05 11:03:17 UTC (rev 5198)
+++ xfburn/trunk/xfburn/xfburn-preferences-dialog.c 2008-08-05 20:12:00 UTC (rev 5199)
@@ -414,7 +414,7 @@
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
DEVICE_LIST_COLUMN_NAME, device_data->name,
- DEVICE_LIST_COLUMN_NODE, device_data->node_path,
+ DEVICE_LIST_COLUMN_NODE, device_data->addr,
DEVICE_LIST_COLUMN_CDR, device_data->cdr,
DEVICE_LIST_COLUMN_CDRW, device_data->cdrw,
DEVICE_LIST_COLUMN_DVDR, device_data->dvdr, DEVICE_LIST_COLUMN_DVDRAM, device_data->dvdram, -1);
More information about the Goodies-commits
mailing list