/* check if we have a volume */
if (volume != NULL)
{
/* check if we can mount the volume */
if (g_volume_can_mount (volume))
{
/* try to mount the volume asynchronously */ mount_operation = gtk_mount_operation_new (NULL); g_volume_mount (volume, G_MOUNT_MOUNT_NONE, mount_operation, NULL, (GAsyncReadyCallback) tvm_block_device_mount_finish, context); g_object_unref (mount_operation);
}
else
{ g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Unable to mount the device"));
/* finish processing the device */ tvm_device_handler_finished (context);
}
}
else
{
g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Could not detect the volume corresponding to the device"));
/* determine the GVolume corresponding to the udev device */
volume =
tvm_g_volume_monitor_get_volume_for_kind (context->monitor, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE, g_udev_device_get_device_file (context->device));
if (volume != NULL)
{
tvm_block_device_mount_volume(context,volume);
}
else
{
/* clean up and try again in one second */
g_object_unref (context->monitor);
context->monitor = g_volume_monitor_get ();
g_timeout_add_seconds(1, (GSourceFunc) tvm_block_device_mount_retry, context);
}
return FALSE;
}
What's the best way to get this put into thunar-volman?
I see that 0.8.1 has your patch.
I think that better than waiting 1 second would be to try immediately and only then wait for a bit. I modified the code accordingly, ending up with
static gboolean device_ mount_volume (TvmContext *context, GVolume *volume)
tvm_block_
{
GMountOperation *mount_operation;
/* check if we have a volume */
mount_ operation = gtk_mount_ operation_ new (NULL);
g_volume_ mount (volume, G_MOUNT_MOUNT_NONE, mount_operation,
NULL, (GAsyncReadyCal lback) tvm_block_ device_ mount_finish, context);
g_object_ unref (mount_operation);
g_set_ error (context->error, G_FILE_ERROR, G_FILE_ ERROR_FAILED,
_("Unable to mount the device"));
if (volume != NULL)
{
/* check if we can mount the volume */
if (g_volume_can_mount (volume))
{
/* try to mount the volume asynchronously */
}
else
{
/* finish processing the device */
tvm_ device_ handler_ finished (context); ERROR_FAILED,
_( "Could not detect the volume corresponding to the device"));
}
}
else
{
g_set_error (context->error, G_FILE_ERROR, G_FILE_
/* finish processing the device */ device_ handler_ finished (context);
tvm_
}
return FALSE;
}
static gboolean device_ mount_retry (TvmContext *context)
tvm_block_
{
GVolume *volume;
volume = g_volume_ monitor_ get_volume_ for_kind (context->monitor,
G_VOLUME_ IDENTIFIER_ KIND_UNIX_ DEVICE,
g_udev_ device_ get_device_ file (context->device));
tvm_
/* if no volume then call anyway to do not-found processing */ device_ mount_volume (context,volume);
tvm_block_
return FALSE;
}
static gboolean device_ mount (TvmContext *context)
tvm_block_
{
GVolume *volume;
g_return_if_fail (context != NULL);
/* determine the GVolume corresponding to the udev device */ g_volume_ monitor_ get_volume_ for_kind (context->monitor,
G_VOLUME_ IDENTIFIER_ KIND_UNIX_ DEVICE,
g_udev_ device_ get_device_ file (context->device)); block_device_ mount_volume( context, volume) ; object_ unref (context->monitor); >monitor = g_volume_ monitor_ get (); timeout_ add_seconds( 1, (GSourceFunc) tvm_block_ device_ mount_retry, context);
volume =
tvm_
if (volume != NULL)
{
tvm_
}
else
{
/* clean up and try again in one second */
g_
context-
g_
}
return FALSE;
}
What's the best way to get this put into thunar-volman?