[brasero] Instead of merely failing tell user when the disc can't be ejected and ask him to do it manually
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Instead of merely failing tell user when the disc can't be ejected and ask him to do it manually
- Date: Wed, 14 Oct 2009 20:32:09 +0000 (UTC)
commit 94be70c61a5a13a3aad886992dc84127a1d36f24
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Tue Oct 13 20:48:31 2009 +0200
Instead of merely failing tell user when the disc can't be ejected and ask him to do it manually
libbrasero-burn/brasero-burn-dialog.c | 77 +++++++++++++++++++++++++++++++
libbrasero-burn/brasero-burn.c | 58 ++++++++++++++++++-----
libbrasero-burn/brasero-burn.h | 3 +
libbrasero-burn/libbrasero-marshal.list | 1 +
4 files changed, 127 insertions(+), 12 deletions(-)
---
diff --git a/libbrasero-burn/brasero-burn-dialog.c b/libbrasero-burn/brasero-burn-dialog.c
index 65fbf74..63e1e70 100644
--- a/libbrasero-burn/brasero-burn-dialog.c
+++ b/libbrasero-burn/brasero-burn-dialog.c
@@ -946,6 +946,79 @@ brasero_burn_dialog_rewritable_cb (BraseroBurn *burn,
return result;
}
+static void
+brasero_burn_dialog_wait_for_ejection_cb (BraseroDrive *drive,
+ BraseroMedium *medium,
+ GtkDialog *message)
+{
+ /* we might have a dialog waiting for the
+ * insertion of a disc if so close it */
+ gtk_dialog_response (GTK_DIALOG (message), GTK_RESPONSE_OK);
+}
+
+static BraseroBurnResult
+brasero_burn_dialog_eject_failure_cb (BraseroBurn *burn,
+ BraseroDrive *drive,
+ GtkDialog *dialog)
+{
+ gint result;
+ gchar *name;
+ gint removal_id;
+ GtkWindow *window;
+ GtkWidget *message;
+ gboolean hide = FALSE;
+ BraseroBurnDialogPrivate *priv;
+
+ priv = BRASERO_BURN_DIALOG_PRIVATE (dialog);
+
+ if (!GTK_WIDGET_VISIBLE (dialog)) {
+ gtk_widget_show (GTK_WIDGET (dialog));
+ hide = TRUE;
+ }
+
+ g_timer_stop (priv->total_time);
+
+ window = GTK_WINDOW (dialog);
+
+ name = brasero_drive_get_display_name (drive);
+ message = gtk_message_dialog_new (window,
+ GTK_DIALOG_DESTROY_WITH_PARENT|
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ /* Translators: %s is the name of a drive */
+ _("Please remove the disc from \"%s\" manually."),
+ name);
+ g_free (name);
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
+ _("The disc needs to be removed for operation to continue but it cannot be ejected."));
+
+ gtk_dialog_add_button (GTK_DIALOG (message),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
+ /* connect to signals to be warned when media is removed */
+ removal_id = g_signal_connect_after (drive,
+ "medium-removed",
+ G_CALLBACK (brasero_burn_dialog_wait_for_ejection_cb),
+ message);
+
+ result = gtk_dialog_run (GTK_DIALOG (message));
+
+ g_signal_handler_disconnect (drive, removal_id);
+ gtk_widget_destroy (message);
+
+ if (hide)
+ gtk_widget_hide (GTK_WIDGET (dialog));
+
+ g_timer_start (priv->total_time);
+
+ if (result == GTK_RESPONSE_ACCEPT)
+ return BRASERO_BURN_OK;
+
+ return BRASERO_BURN_CANCEL;
+}
+
static BraseroBurnResult
brasero_burn_dialog_disable_joliet_cb (BraseroBurn *burn,
GtkDialog *dialog)
@@ -1521,6 +1594,10 @@ brasero_burn_dialog_setup_session (BraseroBurnDialog *dialog,
G_CALLBACK (brasero_burn_dialog_insert_disc_cb),
dialog);
g_signal_connect (priv->burn,
+ "eject-failure",
+ G_CALLBACK (brasero_burn_dialog_eject_failure_cb),
+ dialog);
+ g_signal_connect (priv->burn,
"location-request",
G_CALLBACK (brasero_burn_dialog_image_error),
dialog);
diff --git a/libbrasero-burn/brasero-burn.c b/libbrasero-burn/brasero-burn.c
index 80262f2..11d3fd9 100644
--- a/libbrasero-burn/brasero-burn.c
+++ b/libbrasero-burn/brasero-burn.c
@@ -138,6 +138,7 @@ typedef enum {
PROGRESS_CHANGED_SIGNAL,
ACTION_CHANGED_SIGNAL,
DUMMY_SUCCESS_SIGNAL,
+ EJECT_FAILURE_SIGNAL,
LAST_SIGNAL
} BraseroBurnSignalType;
@@ -323,6 +324,35 @@ brasero_burn_unmount (BraseroBurn *self,
}
static BraseroBurnResult
+brasero_burn_emit_eject_failure_signal (BraseroBurn *burn,
+ BraseroDrive *drive)
+{
+ GValue instance_and_params [4];
+ GValue return_value;
+
+ instance_and_params [0].g_type = 0;
+ g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (burn));
+ g_value_set_instance (instance_and_params, burn);
+
+ instance_and_params [1].g_type = 0;
+ g_value_init (instance_and_params + 1, G_TYPE_FROM_INSTANCE (drive));
+ g_value_set_instance (instance_and_params + 1, drive);
+
+ return_value.g_type = 0;
+ g_value_init (&return_value, G_TYPE_INT);
+ g_value_set_int (&return_value, BRASERO_BURN_CANCEL);
+
+ g_signal_emitv (instance_and_params,
+ brasero_burn_signals [EJECT_FAILURE_SIGNAL],
+ 0,
+ &return_value);
+
+ g_value_unset (instance_and_params);
+
+ return g_value_get_int (&return_value);
+}
+
+static BraseroBurnResult
brasero_burn_eject (BraseroBurn *self,
BraseroDrive *drive,
GError **error)
@@ -337,21 +367,15 @@ brasero_burn_eject (BraseroBurn *self,
counter ++;
if (counter > MAX_EJECT_ATTEMPTS) {
- gchar *name;
+ BraseroBurnResult result;
BRASERO_BURN_LOG ("Max attempts reached at ejecting");
- /* FIXME: it'd be better if we asked the user to do it
- * manually */
- name = brasero_drive_get_display_name (drive);
- if (error && !(*error))
- g_set_error (error,
- BRASERO_BURN_ERROR,
- BRASERO_BURN_ERROR_GENERAL,
- _("The disc in \"%s\" cannot be ejected"),
- name);
- g_free (name);
- return BRASERO_BURN_ERR;
+ result = brasero_burn_emit_eject_failure_signal (self, drive);
+ if (result != BRASERO_BURN_OK)
+ return result;
+
+ continue;
}
BRASERO_BURN_LOG ("Retrying ejection");
@@ -3021,6 +3045,16 @@ brasero_burn_class_init (BraseroBurnClass *klass)
NULL, NULL,
brasero_marshal_INT__VOID,
G_TYPE_INT, 0);
+ brasero_burn_signals [EJECT_FAILURE_SIGNAL] =
+ g_signal_new ("eject_failure",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BraseroBurnClass,
+ eject_failure),
+ NULL, NULL,
+ brasero_marshal_INT__OBJECT,
+ G_TYPE_INT, 1,
+ BRASERO_TYPE_DRIVE);
}
static void
diff --git a/libbrasero-burn/brasero-burn.h b/libbrasero-burn/brasero-burn.h
index 741b47c..9f1ccf9 100644
--- a/libbrasero-burn/brasero-burn.h
+++ b/libbrasero-burn/brasero-burn.h
@@ -62,6 +62,9 @@ typedef struct {
BraseroBurnError error,
BraseroMedia required_media);
+ BraseroBurnResult (*eject_failure) (BraseroBurn *obj,
+ BraseroDrive *drive);
+
BraseroBurnResult (*location_request) (BraseroBurn *obj,
GError *error,
gboolean is_temporary);
diff --git a/libbrasero-burn/libbrasero-marshal.list b/libbrasero-burn/libbrasero-marshal.list
index 3641719..c682022 100644
--- a/libbrasero-burn/libbrasero-marshal.list
+++ b/libbrasero-burn/libbrasero-marshal.list
@@ -1,6 +1,7 @@
INT:VOID
INT:INT
INT:STRING
+INT:OBJECT
INT:OBJECT,INT,INT
INT:POINTER,BOOLEAN
BOOLEAN:VOID
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]