[rhythmbox] track-transfer-batch: set queue on construction, rather than start
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] track-transfer-batch: set queue on construction, rather than start
- Date: Sun, 21 Aug 2016 04:41:51 +0000 (UTC)
commit 6c3e06d0c19c801d3fcc58144862cd2b441c6f4b
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Aug 21 14:40:09 2016 +1000
track-transfer-batch: set queue on construction, rather than start
This makes it possible to cancel a batch before it starts, among
other things.
https://bugzilla.gnome.org/show_bug.cgi?id=770148
shell/rb-track-transfer-batch.c | 30 +++++++++++++++++++++++++-----
shell/rb-track-transfer-batch.h | 7 ++++---
shell/rb-track-transfer-queue.c | 2 +-
sources/rb-library-source.c | 2 +-
sources/rb-transfer-target.c | 2 +-
5 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/shell/rb-track-transfer-batch.c b/shell/rb-track-transfer-batch.c
index d068bdf..5918a04 100644
--- a/shell/rb-track-transfer-batch.c
+++ b/shell/rb-track-transfer-batch.c
@@ -60,6 +60,7 @@ enum
PROP_0,
PROP_ENCODING_TARGET,
PROP_SETTINGS,
+ PROP_QUEUE,
PROP_SOURCE,
PROP_DESTINATION,
PROP_TOTAL_ENTRIES,
@@ -137,6 +138,7 @@ G_DEFINE_TYPE_EXTENDED (RBTrackTransferBatch,
* @target: a #GstEncodingTarget describing allowable encodings (or NULL for defaults)
* @source: the #RBSource from which the entries are to be transferred
* @destination: the #RBSource to which the entries are to be transferred
+ * @queue: the #RBTrackTransferQueue instance
*
* Creates a new transfer batch with the specified encoding target. If no target
* is specified, the default target will be used with the user's preferred
@@ -151,7 +153,8 @@ RBTrackTransferBatch *
rb_track_transfer_batch_new (GstEncodingTarget *target,
GSettings *settings,
GObject *source,
- GObject *destination)
+ GObject *destination,
+ GObject *queue)
{
GObject *obj;
@@ -160,6 +163,7 @@ rb_track_transfer_batch_new (GstEncodingTarget *target,
"settings", settings,
"source", source,
"destination", destination,
+ "queue", queue,
NULL);
return RB_TRACK_TRANSFER_BATCH (obj);
}
@@ -357,12 +361,11 @@ task_progress_cancel (RBTaskProgress *progress)
/**
* _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)
{
gboolean total_duration_valid;
gboolean total_size_valid;
@@ -373,7 +376,7 @@ _rb_track_transfer_batch_start (RBTrackTransferBatch *batch, GObject *queue)
RBShell *shell;
GList *l;
- g_object_get (queue, "shell", &shell, NULL);
+ g_object_get (batch->priv->queue, "shell", &shell, NULL);
/* calculate total duration and file size and figure out the
* origin source if we weren't given one to start with.
@@ -421,7 +424,6 @@ _rb_track_transfer_batch_start (RBTrackTransferBatch *batch, GObject *queue)
batch->priv->source = origin;
}
- batch->priv->queue = RB_TRACK_TRANSFER_QUEUE (queue);
batch->priv->cancelled = FALSE;
batch->priv->total_fraction = 0.0;
@@ -754,6 +756,9 @@ impl_set_property (GObject *object,
case PROP_SETTINGS:
batch->priv->settings = g_value_dup_object (value);
break;
+ case PROP_QUEUE:
+ batch->priv->queue = g_value_get_object (value);
+ break;
case PROP_SOURCE:
batch->priv->source = g_value_dup_object (value);
break;
@@ -798,6 +803,9 @@ impl_get_property (GObject *object,
case PROP_SETTINGS:
g_value_set_object (value, batch->priv->settings);
break;
+ case PROP_QUEUE:
+ g_value_set_object (value, batch->priv->queue);
+ break;
case PROP_SOURCE:
g_value_set_object (value, batch->priv->source);
break;
@@ -953,6 +961,18 @@ rb_track_transfer_batch_class_init (RBTrackTransferBatchClass *klass)
G_TYPE_SETTINGS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
+ * RBTrackTransferBatch:queue
+ *
+ * The #RBTrackTransferQueue instance
+ */
+ g_object_class_install_property (object_class,
+ PROP_QUEUE,
+ g_param_spec_object ("queue",
+ "transfer queue",
+ "RBTrackTransferQueue instance",
+ RB_TYPE_TRACK_TRANSFER_QUEUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ /**
* RBTrackTransferBatch:source:
*
* The RBSource from which the tracks are being transferred.
diff --git a/shell/rb-track-transfer-batch.h b/shell/rb-track-transfer-batch.h
index cc15868..7df99b0 100644
--- a/shell/rb-track-transfer-batch.h
+++ b/shell/rb-track-transfer-batch.h
@@ -88,7 +88,8 @@ GType rb_track_transfer_batch_get_type (void);
RBTrackTransferBatch * rb_track_transfer_batch_new (GstEncodingTarget *target,
GSettings *settings,
GObject *source,
- GObject *destination);
+ GObject *destination,
+ GObject *queue);
void rb_track_transfer_batch_add (RBTrackTransferBatch *batch,
RhythmDBEntry *entry);
@@ -99,8 +100,8 @@ gboolean rb_track_transfer_batch_check_profiles (RBTrackTransferBatch *batch,
void rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch);
/* called by the transfer queue */
-void _rb_track_transfer_batch_start (RBTrackTransferBatch *batch,
- GObject *queue); /* eh */
+void _rb_track_transfer_batch_start (RBTrackTransferBatch *batch);
+
void _rb_track_transfer_batch_cancel (RBTrackTransferBatch *batch);
void _rb_track_transfer_batch_continue (RBTrackTransferBatch *batch,
diff --git a/shell/rb-track-transfer-queue.c b/shell/rb-track-transfer-queue.c
index 5768cce..75a87cc 100644
--- a/shell/rb-track-transfer-queue.c
+++ b/shell/rb-track-transfer-queue.c
@@ -275,7 +275,7 @@ 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);
}
static GPtrArray *
diff --git a/sources/rb-library-source.c b/sources/rb-library-source.c
index 9839c60..15ba523 100644
--- a/sources/rb-library-source.c
+++ b/sources/rb-library-source.c
@@ -1248,7 +1248,7 @@ impl_paste (RBSource *asource, GList *entries)
gst_encoding_profile_set_name (profile, "copy");
gst_encoding_target_add_profile (target, profile);
- batch = rb_track_transfer_batch_new (target, source->priv->encoding_settings, NULL, G_OBJECT
(source));
+ batch = rb_track_transfer_batch_new (target, source->priv->encoding_settings, NULL, G_OBJECT
(source), G_OBJECT (xferq));
g_signal_connect_object (batch, "get-dest-uri", G_CALLBACK (get_dest_uri_cb), source, 0);
g_signal_connect_object (batch, "track-done", G_CALLBACK (track_done_cb), source, 0);
diff --git a/sources/rb-transfer-target.c b/sources/rb-transfer-target.c
index b9f8077..cfd303f 100644
--- a/sources/rb-transfer-target.c
+++ b/sources/rb-transfer-target.c
@@ -410,7 +410,7 @@ rb_transfer_target_transfer (RBTransferTarget *target, GSettings *settings, GLis
batch = g_object_steal_data (G_OBJECT (target), "transfer-target-batch");
if (batch == NULL) {
- batch = rb_track_transfer_batch_new (NULL, settings, NULL, G_OBJECT (target));
+ batch = rb_track_transfer_batch_new (NULL, settings, NULL, G_OBJECT (target), G_OBJECT
(xferq));
g_signal_connect_object (batch, "get-dest-uri", G_CALLBACK (get_dest_uri_cb), target, 0);
g_signal_connect_object (batch, "track-done", G_CALLBACK (track_done_cb), target, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]