[Goodies-commits] r6049 - xfburn/trunk/xfburn
David Mohr
squisher at xfce.org
Mon Nov 10 07:29:00 CET 2008
Author: squisher
Date: 2008-11-10 06:29:00 +0000 (Mon, 10 Nov 2008)
New Revision: 6049
Modified:
xfburn/trunk/xfburn/xfburn-global.h
xfburn/trunk/xfburn/xfburn-perform-burn.c
xfburn/trunk/xfburn/xfburn-progress-dialog.c
xfburn/trunk/xfburn/xfburn-progress-dialog.h
Log:
Giving the stop button some life
Modified: xfburn/trunk/xfburn/xfburn-global.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-global.h 2008-11-10 05:36:10 UTC (rev 6048)
+++ xfburn/trunk/xfburn/xfburn-global.h 2008-11-10 06:29:00 UTC (rev 6049)
@@ -55,6 +55,6 @@
* Note that this special device only supports one track! */
//#define DEBUG_NULL_DEVICE
-#define DEBUG_LIBBURN 1
+//#define DEBUG_LIBBURN 1
#endif
Modified: xfburn/trunk/xfburn/xfburn-perform-burn.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-perform-burn.c 2008-11-10 05:36:10 UTC (rev 6048)
+++ xfburn/trunk/xfburn/xfburn-perform-burn.c 2008-11-10 06:29:00 UTC (rev 6049)
@@ -69,6 +69,7 @@
int dbg_no;
int total_sectors, burned_sectors;
off_t disc_size;
+ gboolean stopping = FALSE;
while (burn_drive_get_status (drive, NULL) != BURN_DRIVE_IDLE)
usleep(100001);
@@ -129,16 +130,28 @@
burned_sectors = 0;
while ((status = burn_drive_get_status (drive, &progress)) != BURN_DRIVE_IDLE) {
time_t time_now = time (NULL);
+ gboolean stop;
dbg_no++;
switch (status) {
case BURN_DRIVE_WRITING:
+ /* Is this really thread safe? It would seems so, but it's not verified */
+ g_object_get (G_OBJECT (dialog_progress), "stop", &stop, NULL);
+
+ if (stop && !stopping) {
+ DBG ("cancelling...");
+ burn_drive_cancel (drive);
+ stopping = TRUE;
+ }
+
if (progress.sectors > 0 && progress.sector >= 0) {
gdouble cur_speed = 0.0;
int fifo_status, fifo_size, fifo_free;
char *fifo_text;
- if (progress.tracks > 1) {
+ if (stopping) {
+ xfburn_progress_dialog_set_status (XFBURN_PROGRESS_DIALOG (dialog_progress), XFBURN_PROGRESS_DIALOG_STATUS_STOPPING);
+ } else if (progress.tracks > 1) {
gchar *str;
str = g_strdup_printf (_("Burning track %2d/%d..."), progress.track+1, progress.tracks);
@@ -256,8 +269,12 @@
usleep (500000);
}
- /* default message in case the burn failed but we didn't get any burn_msgs */
- strcpy (msg_text, "unknown");
+ /* no error message by default */
+#ifdef DEBUG_LIBBURN
+ strcpy (msg_text, _("see console"));
+#else
+ msg_text[0] = '\0';
+#endif
/* check the libburn message queue for errors */
while ((ret = burn_msgs_obtain ("FAILURE", &error_code, msg_text, &os_errno, severity)) == 1) {
@@ -281,9 +298,15 @@
final_message = g_strdup (_("Done"));
final_status = XFBURN_PROGRESS_DIALOG_STATUS_COMPLETED;
} else {
- final_status_text = _("Failure");
+ if (stopping)
+ final_status_text = _("User Aborted");
+ else
+ final_status_text = _("Failure");
final_status = XFBURN_PROGRESS_DIALOG_STATUS_FAILED;
- final_message = g_strdup_printf ("%s: %s", final_status_text, msg_text);
+ if (msg_text[0] != '\0')
+ final_message = g_strdup_printf ("%s: %s", final_status_text, msg_text);
+ else
+ final_message = g_strdup (final_status_text);
}
/* output it to console in case the program crashes */
Modified: xfburn/trunk/xfburn/xfburn-progress-dialog.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-progress-dialog.c 2008-11-10 05:36:10 UTC (rev 6048)
+++ xfburn/trunk/xfburn/xfburn-progress-dialog.c 2008-11-10 06:29:00 UTC (rev 6049)
@@ -46,6 +46,7 @@
int fd_stdin;
gboolean animate;
int ani_index;
+ gboolean stop;
GtkWidget *label_action;
GtkWidget *progress_bar;
@@ -68,7 +69,9 @@
static void set_writing_speed (XfburnProgressDialog * dialog, gfloat speed);
static void set_action_text (XfburnProgressDialog * dialog, XfburnProgressDialogStatus status, const gchar * text);
+static void stop (XfburnProgressDialog *dialog);
+static void cb_button_stop_clicked (GtkWidget *button, XfburnProgressDialog * dialog);
static void cb_button_close_clicked (GtkWidget *button, XfburnProgressDialog * dialog);
static gboolean cb_dialog_delete (XfburnProgressDialog * dialog, GdkEvent * event, XfburnProgressDialogPrivate * priv);
@@ -78,6 +81,7 @@
PROP_STATUS,
PROP_SHOW_BUFFERS,
PROP_ANIMATE,
+ PROP_STOP,
};
static gchar animation[] = { '-', '\\', '|', '/' };
@@ -154,6 +158,9 @@
g_object_class_install_property (object_class, PROP_ANIMATE,
g_param_spec_boolean ("animate", "Show an animation", "Show an animation",
FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_STOP,
+ g_param_spec_boolean ("stop", "Stop the burning process", "Stop the burning process",
+ FALSE, G_PARAM_READABLE));
}
static void
@@ -225,6 +232,7 @@
priv->button_stop = gtk_button_new_from_stock (GTK_STOCK_STOP);
gtk_widget_show (priv->button_stop);
gtk_dialog_add_action_widget (GTK_DIALOG (obj), priv->button_stop, GTK_RESPONSE_CANCEL);
+ g_signal_connect (G_OBJECT (priv->button_stop), "clicked", G_CALLBACK (cb_button_stop_clicked), obj);
priv->button_close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_widget_show (priv->button_close);
@@ -255,6 +263,9 @@
case PROP_ANIMATE:
g_value_set_boolean (value, priv->animate);
break;
+ case PROP_STOP:
+ g_value_set_boolean (value, priv->stop);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -279,6 +290,10 @@
priv->ani_index = 0;
//DBG ("Set animate to %d", priv->animate);
break;
+ case PROP_STOP:
+ DBG ("this should not be allowed...");
+ priv->stop = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -317,8 +332,23 @@
g_free (temp);
}
+static void
+stop (XfburnProgressDialog *dialog)
+{
+ XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
+
+ //DBG ("setting stop");
+ priv->stop = TRUE;
+}
+
/* callbacks */
static void
+cb_button_stop_clicked (GtkWidget *button, XfburnProgressDialog *dialog)
+{
+ stop (dialog);
+}
+
+static void
cb_button_close_clicked (GtkWidget *button, XfburnProgressDialog *dialog)
{
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -330,6 +360,8 @@
{
xfburn_main_leave_window ();
if (!GTK_WIDGET_SENSITIVE (priv->button_close)) {
+ /* burn process is still ongoing, we need to stop first */
+ stop (dialog);
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
return TRUE;
} else {
@@ -491,6 +523,9 @@
if (fraction >= 1.0) {
fraction = 1.0;
switch (priv->status) {
+ case XFBURN_PROGRESS_DIALOG_STATUS_STOPPING:
+ text = g_strdup (_("Aborted"));
+ break;
case XFBURN_PROGRESS_DIALOG_STATUS_RUNNING:
text = g_strdup ("100%");
break;
@@ -536,8 +571,12 @@
priv->status = status;
- if (status != XFBURN_PROGRESS_DIALOG_STATUS_RUNNING) {
+ if (status == XFBURN_PROGRESS_DIALOG_STATUS_STOPPING) {
gdk_threads_enter ();
+ set_action_text (dialog, status, _("Aborting..."));
+ gdk_threads_leave ();
+ } else if (status != XFBURN_PROGRESS_DIALOG_STATUS_RUNNING) {
+ gdk_threads_enter ();
gtk_widget_set_sensitive (priv->button_stop, FALSE);
gtk_widget_set_sensitive (priv->button_close, TRUE);
gdk_threads_leave ();
Modified: xfburn/trunk/xfburn/xfburn-progress-dialog.h
===================================================================
--- xfburn/trunk/xfburn/xfburn-progress-dialog.h 2008-11-10 05:36:10 UTC (rev 6048)
+++ xfburn/trunk/xfburn/xfburn-progress-dialog.h 2008-11-10 06:29:00 UTC (rev 6049)
@@ -33,6 +33,7 @@
#define XFBURN_TYPE_PROGRESS_DIALOG_STATUS (xfburn_progress_dialog_status_get_type ())
typedef enum
{
+ XFBURN_PROGRESS_DIALOG_STATUS_STOPPING,
XFBURN_PROGRESS_DIALOG_STATUS_RUNNING,
XFBURN_PROGRESS_DIALOG_STATUS_FAILED,
XFBURN_PROGRESS_DIALOG_STATUS_CANCELLED,
More information about the Goodies-commits
mailing list