262
259
_rb_track_transfer_batch_start (queue->priv->current, G_OBJECT (queue));
263
get_missing_plugin_strings (GList *profiles, gboolean get_descriptions)
269
encoder = rb_encoder_new ();
270
strings = g_ptr_array_new_with_free_func (g_free);
271
for (l = profiles; l != NULL; l = l->next) {
272
GstEncodingProfile *profile = GST_ENCODING_PROFILE (l->data);
273
char **details, **descriptions;
277
rb_encoder_get_missing_plugins (encoder, profile, &details, &descriptions);
278
d = get_descriptions ? descriptions : details;
279
for (i = 0; d[i] != NULL; i++) {
280
g_ptr_array_add (strings, g_strdup (d[i]));
282
g_strfreev (details);
283
g_strfreev (descriptions);
285
g_ptr_array_add (strings, NULL);
286
g_object_unref (encoder);
266
error_response_cb (GtkDialog *dialog, gint response, RBTrackTransferQueue *queue)
292
missing_plugins_retry_cb (gpointer inst, gboolean retry, RBTrackTransferQueue *queue)
268
_rb_track_transfer_batch_cancel (queue->priv->current);
269
g_object_unref (queue->priv->current);
294
rb_debug ("plugin install finished (retry %d), checking media types again", retry);
295
g_queue_push_head (queue->priv->batch_queue, queue->priv->current);
270
296
queue->priv->current = NULL;
272
297
start_next_batch (queue);
273
gtk_widget_destroy (GTK_WIDGET (dialog));
277
301
missing_encoder_response_cb (GtkDialog *dialog, gint response, RBTrackTransferQueue *queue)
304
GstEncodingTarget *target;
279
310
switch (response) {
280
311
case GTK_RESPONSE_YES:
281
312
/* 'continue' -> start the batch */
313
rb_debug ("starting batch regardless of missing plugins");
282
314
actually_start_batch (queue);
285
317
case GTK_RESPONSE_CANCEL:
286
318
case GTK_RESPONSE_DELETE_EVENT:
287
319
/* 'cancel' -> cancel the batch and start the next one */
320
rb_debug ("cancelling batch");
288
321
_rb_track_transfer_batch_cancel (queue->priv->current);
289
322
g_object_unref (queue->priv->current);
290
323
queue->priv->current = NULL;
292
325
start_next_batch (queue);
296
328
case GTK_RESPONSE_ACCEPT:
297
/* 'install an encoder' -> try to install an encoder */
299
* probably need RBEncoder API to get missing plugin installer details
300
* for a specific pipeline or profile or something.
301
* since gnome-media profiles use specific element names, installing by
302
* caps won't necessarily install something that works. guh.
329
/* 'install plugins' -> try to install encoder/muxer */
331
/* get profiles that need plugins installed */
333
encoder = rb_encoder_new ();
334
g_object_get (queue->priv->current, "encoding-target", &target, NULL);
335
for (l = gst_encoding_target_get_profiles (target); l != NULL; l = l->next) {
336
GstEncodingProfile *profile = GST_ENCODING_PROFILE (l->data);
337
char *profile_media_type;
338
profile_media_type = rb_gst_encoding_profile_get_media_type (profile);
339
if ((rb_gst_media_type_is_lossless (profile_media_type) == FALSE) &&
340
rb_encoder_get_missing_plugins (encoder, profile, NULL, NULL)) {
341
profiles = g_list_append (profiles, profile);
343
g_free (profile_media_type);
345
g_object_unref (encoder);
346
g_object_unref (target);
348
if (profiles == NULL) {
349
rb_debug ("apparently we don't need any plugins any more");
350
actually_start_batch (queue);
354
rb_debug ("attempting plugin installation");
355
details = get_missing_plugin_strings (profiles, FALSE);
305
356
retry = g_cclosure_new ((GCallback) missing_plugins_retry_cb,
306
357
g_object_ref (queue),
307
358
(GClosureNotify) g_object_unref);
308
359
g_closure_set_marshal (retry, g_cclosure_marshal_VOID__BOOLEAN);
309
g_signal_emit (queue,
310
signals[MISSING_PLUGINS], 0,
311
details, descriptions, retry,
360
if (rb_missing_plugins_install ((const char **)details->pdata, FALSE, retry)) {
314
361
rb_debug ("attempting to install missing plugins for transcoding");
316
363
rb_debug ("proceeding without the missing plugins for transcoding");
364
actually_start_batch (queue);
319
367
g_closure_sink (retry);
368
g_ptr_array_free (details, TRUE);
369
g_list_free (profiles);
324
373
g_assert_not_reached ();
327
376
gtk_widget_destroy (GTK_WIDGET (dialog));
328
g_object_unref (dialog);
350
403
queue->priv->overwrite_decision = OVERWRITE_PROMPT;
351
404
g_object_get (queue->priv->current, "total-entries", &total, NULL);
353
count = rb_track_transfer_batch_check_media_types (queue->priv->current);
354
rb_debug ("%d tracks in the batch, %d of which cannot be transferred", total, count);
356
rb_debug ("what is this batch doing here anyway");
357
} else if (count == total) {
360
g_object_get (queue->priv->shell, "window", &window, NULL);
361
/* once we do encoder installation this should turn into a
362
* normal confirmation dialog with no 'continue' option.
364
dialog = rb_alert_dialog_new (window,
368
_("Unable to transfer tracks"),
369
_("None of the tracks to be transferred "
370
"are in a format supported by the target "
371
"device, and no encoders are available "
372
"for the supported formats."));
373
rb_alert_dialog_set_details_label (RB_ALERT_DIALOG (dialog), NULL);
374
g_object_unref (window);
375
g_signal_connect_object (dialog, "response", G_CALLBACK (error_response_cb), queue, 0);
376
gtk_widget_show (dialog);
379
} else if (count > 0) {
385
rb_debug ("can't find a supported media type for %d/%d files, prompting", count, total);
386
text = g_strdup_printf (_("%d of the %d files to be transferred are not in a format supported"
387
" by the target device, and no encoders are available for the"
388
" supported formats."),
390
g_object_get (queue->priv->shell, "window", &window, NULL);
391
dialog = rb_alert_dialog_new (window,
395
_("Unable to transfer all tracks. Do you want to continue?"),
397
g_object_unref (window);
400
rb_alert_dialog_set_details_label (RB_ALERT_DIALOG (dialog), NULL);
401
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
402
_("_Cancel"), GTK_RESPONSE_CANCEL,
403
_("C_ontinue"), GTK_RESPONSE_YES,
404
/*_("_Install an encoder"), GTK_RESPONSE_ACCEPT,*/
407
g_signal_connect_object (dialog, "response", G_CALLBACK (missing_encoder_response_cb), queue, 0);
408
gtk_widget_show (dialog);
412
actually_start_batch (queue);
407
can_continue = rb_track_transfer_batch_check_profiles (queue->priv->current,
411
if (can_continue && count == 0 && profiles == NULL) {
412
/* no problems, go ahead */
413
actually_start_batch (queue);
417
if (profiles == NULL) {
419
message = g_strdup (_("This file cannot be transferred as it is not in a "
420
"format supported by the target device and no suitable "
421
"encoding profiles are available."));
423
message = g_strdup_printf (_("%d of the %d files cannot be transferred as "
424
"they must be converted into a format supported "
425
"by the target device but no suitable encoding "
426
"profiles are available."), count, total);
429
GPtrArray *descriptions;
430
GstEncodingTarget *target;
434
descriptions = get_missing_plugin_strings (profiles, TRUE);
435
plugins = g_strjoinv ("\n", (char **)descriptions->pdata);
437
/* this is a tiny bit hackish */
438
g_object_get (queue->priv->current, "encoding-target", &target, NULL);
439
is_library = (g_strcmp0 (gst_encoding_target_get_name (target), "rhythmbox-library") == 0);
440
gst_encoding_target_unref (target);
443
/* XXX should provide the option of picking a different format? */
444
message = g_strdup_printf (_("Additional software is required to encode media "
445
"in your preferred format:\n%s"), plugins);
446
} else if (total == 1) {
447
message = g_strdup_printf (_("Additional software is required to convert this "
448
"file into a format supported by the target "
449
"device:\n%s"), plugins);
451
message = g_strdup_printf (_("Additional software is required to convert %d "
452
"of the %d files to be transferred into a format "
453
"supported by the target device:\n%s"),
454
count, total, plugins);
458
g_ptr_array_free (descriptions, TRUE);
461
g_object_get (queue->priv->shell, "window", &window, NULL);
462
dialog = rb_alert_dialog_new (window,
466
_("Unable to transfer tracks"),
468
g_object_unref (window);
471
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel the transfer"), GTK_RESPONSE_CANCEL);
473
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Skip these files"), GTK_RESPONSE_YES);
475
if (profiles != NULL && gst_install_plugins_supported ()) {
476
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Install"), GTK_RESPONSE_ACCEPT);
479
rb_alert_dialog_set_details_label (RB_ALERT_DIALOG (dialog), NULL);
480
g_signal_connect_object (dialog, "response", G_CALLBACK (missing_encoder_response_cb), queue, 0);
481
gtk_widget_show (dialog);
483
if (profiles != NULL) {
484
g_list_free (profiles);