[rhythmbox] transfer-queue: rearrange batch API to be easier to use
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] transfer-queue: rearrange batch API to be easier to use
- Date: Mon, 31 May 2010 10:32:37 +0000 (UTC)
commit d54129f55a37ebbc73c0cb68d22e59a02515058a
Author: Jonathan Matthew <jonathan d14n org>
Date: Mon May 31 20:24:41 2010 +1000
transfer-queue: rearrange batch API to be easier to use
Prefix methods for use by the queue only with underscores,
remove rb_track_transfer_batch_next, since it's only used by the batch
itself, and add a new rb_track_transfer_batch_cancel that just calls
rb_track_transfer_queue_cancel_batch.
bindings/python/rb.defs | 15 --------------
shell/rb-track-transfer-batch.c | 40 ++++++++++++++++++++++----------------
shell/rb-track-transfer-batch.h | 9 +++++--
shell/rb-track-transfer-queue.c | 14 ++++++------
4 files changed, 36 insertions(+), 42 deletions(-)
---
diff --git a/bindings/python/rb.defs b/bindings/python/rb.defs
index 19343a5..6f4bbef 100644
--- a/bindings/python/rb.defs
+++ b/bindings/python/rb.defs
@@ -2979,27 +2979,12 @@
(return-type "guint")
)
-(define-method start
- (of-object "RBTrackTransferBatch")
- (c-name "rb_track_transfer_batch_start")
- (return-type "none")
- (parameters
- '("GObject*" "queue")
- )
-)
-
(define-method cancel
(of-object "RBTrackTransferBatch")
(c-name "rb_track_transfer_batch_cancel")
(return-type "none")
)
-(define-method next
- (of-object "RBTrackTransferBatch")
- (c-name "rb_track_transfer_batch_next")
- (return-type "gboolean")
-)
-
;; From rb-track-transfer-queue.h
diff --git a/shell/rb-track-transfer-batch.c b/shell/rb-track-transfer-batch.c
index 11a02f6..3ded349 100644
--- a/shell/rb-track-transfer-batch.c
+++ b/shell/rb-track-transfer-batch.c
@@ -65,6 +65,8 @@ enum
static void rb_track_transfer_batch_class_init (RBTrackTransferBatchClass *klass);
static void rb_track_transfer_batch_init (RBTrackTransferBatch *batch);
+static gboolean start_next (RBTrackTransferBatch *batch);
+
static guint signals[LAST_SIGNAL] = { 0 };
struct _RBTrackTransferBatchPrivate
@@ -191,14 +193,26 @@ rb_track_transfer_batch_check_media_types (RBTrackTransferBatch *batch)
}
/**
- * rb_track_transfer_batch_start:
+ * rb_track_transfer_batch_cancel:
+ * @batch: a #RBTrackTransferBatch
+ *
+ * Cancels the batch.
+ */
+void
+rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch)
+{
+ rb_track_transfer_queue_cancel_batch (batch->priv->queue, batch);
+}
+
+/**
+ * _rb_track_transfer_batch_start:
* @batch: a #RBTrackTransferBatch
* @queue: the #RBTrackTransferQueue
*
* Starts the batch transfer. Only to be called by the #RBTrackTransferQueue.
*/
void
-rb_track_transfer_batch_start (RBTrackTransferBatch *batch, GObject *queue)
+_rb_track_transfer_batch_start (RBTrackTransferBatch *batch, GObject *queue)
{
gboolean total_duration_valid;
gboolean total_size_valid;
@@ -263,19 +277,20 @@ rb_track_transfer_batch_start (RBTrackTransferBatch *batch, GObject *queue)
g_signal_emit (batch, signals[STARTED], 0);
- rb_track_transfer_batch_next (batch);
+ start_next (batch);
}
/**
- * rb_track_transfer_batch_cancel:
+ * _rb_track_transfer_batch_cancel:
* @batch: a #RBTrackTransferBatch
*
* Cancels a batch transfer. Only to be called by the #RBTrackTransferQueue.
*/
void
-rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch)
+_rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch)
{
batch->priv->cancelled = TRUE;
+ rb_debug ("batch being cancelled");
if (batch->priv->current_encoder != NULL) {
rb_encoder_cancel (batch->priv->current_encoder);
@@ -352,7 +367,7 @@ encoder_completed_cb (RBEncoder *encoder,
mediatype,
error);
- rb_track_transfer_batch_next (batch);
+ start_next (batch);
g_object_unref (batch);
}
@@ -367,17 +382,8 @@ encoder_overwrite_cb (RBEncoder *encoder, GFile *file, RBTrackTransferBatch *bat
return overwrite;
}
-/**
- * rb_track_transfer_batch_next:
- * @batch: a #RBTrackTransferBatch
- *
- * Starts the transfer of the next entry in the batch.
- * Only to be called by the #RBTrackTransferQueue.
- *
- * Return value: %FALSE if there were no more entries to transfer
- */
-gboolean
-rb_track_transfer_batch_next (RBTrackTransferBatch *batch)
+static gboolean
+start_next (RBTrackTransferBatch *batch)
{
GList *n;
char *media_type;
diff --git a/shell/rb-track-transfer-batch.h b/shell/rb-track-transfer-batch.h
index ac5ffab..ef4f637 100644
--- a/shell/rb-track-transfer-batch.h
+++ b/shell/rb-track-transfer-batch.h
@@ -91,10 +91,13 @@ void rb_track_transfer_batch_add (RBTrackTransferBatch *batch,
RhythmDBEntry *entry);
guint rb_track_transfer_batch_check_media_types (RBTrackTransferBatch *batch);
-void rb_track_transfer_batch_start (RBTrackTransferBatch *batch,
- GObject *queue); /* eh */
+
void rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch);
-gboolean rb_track_transfer_batch_next (RBTrackTransferBatch *batch);
+
+/* called by the transfer queue */
+void _rb_track_transfer_batch_start (RBTrackTransferBatch *batch,
+ GObject *queue); /* eh */
+void _rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch);
G_END_DECLS
diff --git a/shell/rb-track-transfer-queue.c b/shell/rb-track-transfer-queue.c
index aa63a69..43882c3 100644
--- a/shell/rb-track-transfer-queue.c
+++ b/shell/rb-track-transfer-queue.c
@@ -240,7 +240,7 @@ batch_progress (RBTrackTransferBatch *batch,
static void
missing_plugins_retry_cb (gpointer inst, gboolean retry, RBTrackTransferQueue *queue)
{
- rb_track_transfer_batch_start (queue->priv->current, G_OBJECT (queue));
+ _rb_track_transfer_batch_start (queue->priv->current, G_OBJECT (queue));
}
#endif
@@ -259,13 +259,13 @@ actually_start_batch (RBTrackTransferQueue *queue)
"track-progress",
G_CALLBACK (batch_progress),
queue, 0);
- rb_track_transfer_batch_start (queue->priv->current, G_OBJECT (queue));
+ _rb_track_transfer_batch_start (queue->priv->current, G_OBJECT (queue));
}
static void
error_response_cb (GtkDialog *dialog, gint response, RBTrackTransferQueue *queue)
{
- rb_track_transfer_batch_cancel (queue->priv->current);
+ _rb_track_transfer_batch_cancel (queue->priv->current);
g_object_unref (queue->priv->current);
queue->priv->current = NULL;
@@ -285,7 +285,7 @@ missing_encoder_response_cb (GtkDialog *dialog, gint response, RBTrackTransferQu
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
/* 'cancel' -> cancel the batch and start the next one */
- rb_track_transfer_batch_cancel (queue->priv->current);
+ _rb_track_transfer_batch_cancel (queue->priv->current);
g_object_unref (queue->priv->current);
queue->priv->current = NULL;
@@ -454,7 +454,7 @@ rb_track_transfer_queue_cancel_batch (RBTrackTransferQueue *queue,
}
if (found) {
- rb_track_transfer_batch_cancel (batch);
+ _rb_track_transfer_batch_cancel (batch);
g_object_unref (batch);
start_next_batch (queue);
@@ -618,13 +618,13 @@ impl_dispose (GObject *object)
RBTrackTransferQueue *queue = RB_TRACK_TRANSFER_QUEUE (object);
if (queue->priv->current != NULL) {
- rb_track_transfer_batch_cancel (queue->priv->current);
+ _rb_track_transfer_batch_cancel (queue->priv->current);
g_object_unref (queue->priv->current);
queue->priv->current = NULL;
}
if (queue->priv->batch_queue != NULL) {
- g_queue_foreach (queue->priv->batch_queue, (GFunc) rb_track_transfer_batch_cancel, NULL);
+ g_queue_foreach (queue->priv->batch_queue, (GFunc) _rb_track_transfer_batch_cancel, NULL);
g_queue_foreach (queue->priv->batch_queue, (GFunc) g_object_unref, NULL);
g_queue_free (queue->priv->batch_queue);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]