332
335
/* Put that to 0 for now so that a new idle call will be scheduled while
333
336
* we are in the loop. That way if we block the other one will be able
334
* to deliver the results. */
337
* to deliver results. */
335
338
results_id = priv->results_id;
336
339
priv->results_id = 0;
338
341
/* Return several results at a time that can be a huge speed gain.
339
342
* What should be the value that provides speed and responsiveness? */
340
for (i = 0, iter = priv->results; iter && i < NUMBER_OF_RESULTS; iter = next) {
343
for (i = 0; priv->results && i < NUMBER_OF_RESULTS;) {
341
344
BraseroIOJobBase *base;
347
/* Find the next result that can be returned */
349
for (iter = priv->results; iter; iter = iter->next) {
350
BraseroIOJobResult *tmp_result;
352
tmp_result = iter->data;
353
if (!tmp_result->base->methods->in_use) {
346
362
/* Make sure another result is not returned for this base. This
347
363
* is to avoid BraseroDataDisc showing multiple dialogs for
348
364
* various problems; like one dialog for joliet, one for deep,
349
365
* and one for name collision. */
350
if (result->base->in_use)
366
base = (BraseroIOJobBase *) result->base;
367
base->methods->in_use = TRUE;
353
369
priv->results = g_slist_remove (priv->results, result);
355
base = (BraseroIOJobBase *) result->base;
371
/* This is to make sure the object
372
* lives as long as we need it. */
373
g_object_ref (base->object);
358
375
g_mutex_unlock (priv->lock);
360
377
data = result->callback_data;
362
/* This is to make sure the object lives
363
* as long as we need it. */
364
g_object_ref (base->object);
366
379
if (result->uri || result->info || result->error)
367
result->base->callback (base->object,
371
data? data->callback_data:NULL);
380
base->methods->callback (base->object,
384
data? data->callback_data:NULL);
373
386
/* call destroy () for callback data */
374
387
brasero_io_unref_result_callback_data (data,
389
base->methods->destroy,
379
g_object_unref (base->object);
381
392
brasero_io_job_result_free (result);
383
394
g_mutex_lock (priv->lock);
386
base->in_use = FALSE;
398
g_object_unref (base->object);
399
base->methods->in_use = FALSE;
389
if (!priv->results_id && iter && i >= NUMBER_OF_RESULTS) {
402
if (!priv->results_id && priv->results && i >= NUMBER_OF_RESULTS) {
390
403
/* There are still results and no idle call is scheduled so we
391
404
* have to restart ourselves to make sure we empty the queue */
392
405
priv->results_id = results_id;
514
527
* add a dummy result to destroy callback_data. */
515
528
if (g_atomic_int_dec_and_test (&job->callback_data->ref)) {
517
if (job->base->destroy)
518
job->base->destroy (job->base->object,
520
job->callback_data->callback_data);
530
if (job->base->methods->destroy)
531
job->base->methods->destroy (job->base->object,
533
job->callback_data->callback_data);
522
535
g_free (job->callback_data);
604
BraseroIOPrivate *priv;
590
605
GMountOperation *operation;
591
606
BraseroIOMount mount = { NULL, };
593
/* FIXME: need a way to get a parent window for the operation */
594
operation = gtk_mount_operation_new (NULL);
608
priv = BRASERO_IO_PRIVATE (self);
610
if (priv->win_callback)
611
parent = priv->win_callback (priv->win_user_data);
614
operation = gtk_mount_operation_new (parent);
595
616
g_file_mount_enclosing_volume (file,
596
617
G_MOUNT_MOUNT_NONE,
2323
BraseroIOJobCallbacks *
2324
brasero_io_register_job_methods (BraseroIOResultCallback callback,
2325
BraseroIODestroyCallback destroy,
2326
BraseroIOProgressCallback progress)
2328
BraseroIOJobCallbacks *methods;
2330
methods = g_new0 (BraseroIOJobCallbacks, 1);
2331
methods->callback = callback;
2332
methods->destroy = destroy;
2333
methods->progress = progress;
2339
brasero_io_register_with_methods (GObject *object,
2340
BraseroIOJobCallbacks *methods)
2342
BraseroIOJobBase *base;
2344
base = g_new0 (BraseroIOJobBase, 1);
2345
base->object = object;
2346
base->methods = methods;
2302
2352
BraseroIOJobBase *
2303
2353
brasero_io_register (GObject *object,
2304
2354
BraseroIOResultCallback callback,
2305
2355
BraseroIODestroyCallback destroy,
2306
2356
BraseroIOProgressCallback progress)
2308
BraseroIOJobBase *base;
2310
base = g_new0 (BraseroIOJobBase, 1);
2311
base->object = object;
2312
base->callback = callback;
2313
base->destroy = destroy;
2314
base->progress = progress;
2358
return brasero_io_register_with_methods (object, brasero_io_register_job_methods (callback, destroy, progress));
2362
brasero_io_job_base_free (BraseroIOJobBase *base)
2364
BraseroIOJobCallbacks *methods;
2369
methods = base->methods;
2373
if (methods->ref <= 0)
2378
brasero_io_xid_for_metadata (gpointer user_data)
2380
BraseroIOPrivate *priv;
2382
priv = BRASERO_IO_PRIVATE (user_data);
2383
if (priv->win_callback) {
2387
parent = priv->win_callback (priv->win_user_data);
2388
xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (GTK_WIDGET (parent)->window));
2333
2409
metadata = brasero_metadata_new ();
2334
2410
priv->metadatas = g_slist_prepend (priv->metadatas, metadata);
2411
brasero_metadata_set_get_xid_callback (metadata, brasero_io_xid_for_metadata, object);
2335
2412
metadata = brasero_metadata_new ();
2336
2413
priv->metadatas = g_slist_prepend (priv->metadatas, metadata);
2414
brasero_metadata_set_get_xid_callback (metadata, brasero_io_xid_for_metadata, object);
2339
2417
static gboolean