~cjcurran/gnome-control-center/expose-card-ports

« back to all changes in this revision

Viewing changes to capplets/common/file-transfer-dialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* file-transfer-dialog.c
2
 
 * Copyright (C) 2002 Ximian, Inc.
3
 
 *
4
 
 * Written by Rachel Hestilow <hestilow@ximian.com>
5
 
 *            Jens Granseuer <jensgr@gmx.net>
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2, or (at your option)
10
 
 * any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
 
 * 02111-1307, USA.
21
 
 */
22
 
 
23
 
#ifdef HAVE_CONFIG_H
24
 
# include "config.h"
25
 
#endif
26
 
 
27
 
#include <glib.h>
28
 
#include <glib/gi18n.h>
29
 
#include <gtk/gtk.h>
30
 
#include <gio/gio.h>
31
 
#include <limits.h>
32
 
 
33
 
#include "file-transfer-dialog.h"
34
 
 
35
 
enum
36
 
{
37
 
        PROP_0,
38
 
        PROP_FROM_URI,
39
 
        PROP_TO_URI,
40
 
        PROP_FRACTION_COMPLETE,
41
 
        PROP_NTH_URI,
42
 
        PROP_TOTAL_URIS,
43
 
        PROP_PARENT
44
 
};
45
 
 
46
 
enum
47
 
{
48
 
        CANCEL,
49
 
        DONE,
50
 
        LAST_SIGNAL
51
 
};
52
 
 
53
 
guint file_transfer_dialog_signals[LAST_SIGNAL] = {0, };
54
 
 
55
 
struct _FileTransferDialogPrivate
56
 
{
57
 
        GtkWidget *progress;
58
 
        GtkWidget *status;
59
 
        guint nth;
60
 
        guint total;
61
 
        GCancellable *cancellable;
62
 
};
63
 
 
64
 
#define FILE_TRANSFER_DIALOG_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), file_transfer_dialog_get_type (), FileTransferDialogPrivate))
65
 
 
66
 
typedef struct _FileTransferJob
67
 
{
68
 
        FileTransferDialog *dialog;
69
 
        GtkDialog *overwrite_dialog;
70
 
        GSList *source_files;
71
 
        GSList *target_files;
72
 
        FileTransferDialogOptions options;
73
 
} FileTransferJob;
74
 
 
75
 
/* structure passed to the various callbacks */
76
 
typedef struct {
77
 
        FileTransferDialog *dialog;
78
 
        gchar *source;
79
 
        gchar *target;
80
 
        guint current_file;
81
 
        guint total_files;
82
 
        goffset current_bytes;
83
 
        goffset total_bytes;
84
 
        gint response;
85
 
        GtkDialog *overwrite_dialog;
86
 
} FileTransferData;
87
 
 
88
 
G_DEFINE_TYPE (FileTransferDialog, file_transfer_dialog, GTK_TYPE_DIALOG)
89
 
 
90
 
static void
91
 
file_transfer_dialog_update_num_files (FileTransferDialog *dlg)
92
 
{
93
 
        gchar *str;
94
 
 
95
 
        if (dlg->priv->total <= 1)
96
 
                return;
97
 
 
98
 
        str = g_strdup_printf (_("Copying file: %u of %u"),
99
 
                              dlg->priv->nth, dlg->priv->total);
100
 
        gtk_progress_bar_set_text (GTK_PROGRESS_BAR (dlg->priv->progress), str);
101
 
        g_free (str);
102
 
}
103
 
 
104
 
static void
105
 
file_transfer_dialog_response (GtkDialog *dlg, gint response_id)
106
 
{
107
 
        FileTransferDialog *dialog = FILE_TRANSFER_DIALOG (dlg);
108
 
 
109
 
        g_cancellable_cancel (dialog->priv->cancellable);
110
 
}
111
 
 
112
 
static void
113
 
file_transfer_dialog_finalize (GObject *object)
114
 
{
115
 
        FileTransferDialog *dlg = FILE_TRANSFER_DIALOG (object);
116
 
 
117
 
        if (dlg->priv->cancellable)
118
 
        {
119
 
                g_object_unref (dlg->priv->cancellable);
120
 
                dlg->priv->cancellable = NULL;
121
 
        }
122
 
 
123
 
        G_OBJECT_CLASS (file_transfer_dialog_parent_class)->finalize (object);
124
 
}
125
 
 
126
 
static void
127
 
file_transfer_dialog_set_prop (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
128
 
{
129
 
        FileTransferDialog *dlg = FILE_TRANSFER_DIALOG (object);
130
 
        GFile *file;
131
 
        gchar *str;
132
 
        gchar *str2;
133
 
        gchar *base;
134
 
        gchar *escaped;
135
 
        GtkWindow *parent;
136
 
        guint n;
137
 
 
138
 
        switch (prop_id)
139
 
        {
140
 
        case PROP_FROM_URI:
141
 
                file = g_file_new_for_uri (g_value_get_string (value));
142
 
                base = g_file_get_basename (file);
143
 
                escaped = g_uri_escape_string (base, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
144
 
 
145
 
                str = g_strdup_printf (_("Copying '%s'"), escaped);
146
 
                str2 = g_strdup_printf ("<big><b>%s</b></big>", str);
147
 
                gtk_label_set_markup (GTK_LABEL (dlg->priv->status), str2);
148
 
 
149
 
                g_free (base);
150
 
                g_free (escaped);
151
 
                g_free (str);
152
 
                g_free (str2);
153
 
                g_object_unref (file);
154
 
                break;
155
 
        case PROP_TO_URI:
156
 
                break;
157
 
        case PROP_FRACTION_COMPLETE:
158
 
                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (dlg->priv->progress), g_value_get_double (value));
159
 
                break;
160
 
        case PROP_NTH_URI:
161
 
                n = g_value_get_uint (value);
162
 
                if (n != dlg->priv->nth)
163
 
                {
164
 
                        dlg->priv->nth = g_value_get_uint (value);
165
 
                        file_transfer_dialog_update_num_files (dlg);
166
 
                }
167
 
                break;
168
 
        case PROP_TOTAL_URIS:
169
 
                n = g_value_get_uint (value);
170
 
                if (n != dlg->priv->nth)
171
 
                {
172
 
                        dlg->priv->total = g_value_get_uint (value);
173
 
                        file_transfer_dialog_update_num_files (dlg);
174
 
                }
175
 
                break;
176
 
        case PROP_PARENT:
177
 
                parent = g_value_get_pointer (value);
178
 
                if (parent)
179
 
                {
180
 
                        gtk_window_set_title (GTK_WINDOW (dlg), gtk_window_get_title (parent));
181
 
                        gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
182
 
                }
183
 
                else
184
 
                        gtk_window_set_title (GTK_WINDOW (dlg),
185
 
                                              _("Copying files"));
186
 
                break;
187
 
        default:
188
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
189
 
        }
190
 
}
191
 
 
192
 
static void
193
 
file_transfer_dialog_get_prop (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
194
 
{
195
 
        FileTransferDialog *dlg = FILE_TRANSFER_DIALOG (object);
196
 
 
197
 
        switch (prop_id)
198
 
        {
199
 
        case PROP_NTH_URI:
200
 
                g_value_set_uint (value, dlg->priv->nth);
201
 
                break;
202
 
        case PROP_TOTAL_URIS:
203
 
                g_value_set_uint (value, dlg->priv->total);
204
 
                break;
205
 
        default:
206
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
207
 
        }
208
 
}
209
 
 
210
 
static void
211
 
file_transfer_dialog_class_init (FileTransferDialogClass *klass)
212
 
{
213
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
214
 
 
215
 
        object_class->finalize = file_transfer_dialog_finalize;
216
 
        object_class->get_property = file_transfer_dialog_get_prop;
217
 
        object_class->set_property = file_transfer_dialog_set_prop;
218
 
 
219
 
        GTK_DIALOG_CLASS (klass)->response = file_transfer_dialog_response;
220
 
 
221
 
        g_object_class_install_property
222
 
                (object_class, PROP_PARENT,
223
 
                 g_param_spec_pointer ("parent",
224
 
                                      _("Parent Window"),
225
 
                                      _("Parent window of the dialog"),
226
 
                                      G_PARAM_READWRITE));
227
 
 
228
 
        g_object_class_install_property
229
 
                (object_class, PROP_FROM_URI,
230
 
                 g_param_spec_string ("from_uri",
231
 
                                      _("From URI"),
232
 
                                      _("URI currently transferring from"),
233
 
                                      NULL,
234
 
                                      G_PARAM_READWRITE));
235
 
 
236
 
        g_object_class_install_property
237
 
                (object_class, PROP_TO_URI,
238
 
                 g_param_spec_string ("to_uri",
239
 
                                      _("To URI"),
240
 
                                      _("URI currently transferring to"),
241
 
                                      NULL,
242
 
                                      G_PARAM_WRITABLE));
243
 
 
244
 
        g_object_class_install_property
245
 
                (object_class, PROP_FRACTION_COMPLETE,
246
 
                 g_param_spec_double ("fraction_complete",
247
 
                                      _("Fraction completed"),
248
 
                                      _("Fraction of transfer currently completed"),
249
 
                                      0, 1, 0,
250
 
                                      G_PARAM_WRITABLE));
251
 
 
252
 
        g_object_class_install_property
253
 
                (object_class, PROP_NTH_URI,
254
 
                 g_param_spec_uint ("nth_uri",
255
 
                                    _("Current URI index"),
256
 
                                    _("Current URI index - starts from 1"),
257
 
                                    1, INT_MAX, 1,
258
 
                                    G_PARAM_READWRITE));
259
 
 
260
 
        g_object_class_install_property
261
 
                (object_class, PROP_TOTAL_URIS,
262
 
                 g_param_spec_uint ("total_uris",
263
 
                                    _("Total URIs"),
264
 
                                    _("Total number of URIs"),
265
 
                                    1, INT_MAX, 1,
266
 
                                    G_PARAM_READWRITE));
267
 
 
268
 
        file_transfer_dialog_signals[CANCEL] =
269
 
                g_signal_new ("cancel",
270
 
                              G_TYPE_FROM_CLASS (object_class),
271
 
                              G_SIGNAL_RUN_FIRST,
272
 
                              0,
273
 
                              NULL, NULL,
274
 
                              g_cclosure_marshal_VOID__VOID,
275
 
                              G_TYPE_NONE, 0);
276
 
 
277
 
        file_transfer_dialog_signals[DONE] =
278
 
                g_signal_new ("done",
279
 
                              G_TYPE_FROM_CLASS (object_class),
280
 
                              G_SIGNAL_RUN_LAST,
281
 
                              0,
282
 
                              NULL, NULL,
283
 
                              g_cclosure_marshal_VOID__VOID,
284
 
                              G_TYPE_NONE, 0);
285
 
 
286
 
        g_type_class_add_private (klass, sizeof (FileTransferDialogPrivate));
287
 
}
288
 
 
289
 
static void
290
 
file_transfer_dialog_init (FileTransferDialog *dlg)
291
 
{
292
 
        GtkWidget *vbox;
293
 
        GtkWidget *hbox;
294
 
        GtkWidget *progress_vbox;
295
 
        GtkWidget *table;
296
 
        char      *markup;
297
 
        GtkWidget *content_area;
298
 
 
299
 
        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
300
 
        dlg->priv = FILE_TRANSFER_DIALOG_GET_PRIVATE (dlg);
301
 
        dlg->priv->cancellable = g_cancellable_new ();
302
 
 
303
 
        gtk_container_set_border_width (GTK_CONTAINER (content_area), 4);
304
 
        gtk_box_set_spacing (GTK_BOX (content_area), 4);
305
 
 
306
 
        gtk_widget_set_size_request (GTK_WIDGET (dlg), 350, -1);
307
 
 
308
 
        vbox = gtk_vbox_new (FALSE, 6);
309
 
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
310
 
        gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
311
 
 
312
 
        dlg->priv->status = gtk_label_new (NULL);
313
 
        markup = g_strconcat ("<big><b>", _("Copying files"), "</b></big>", NULL);
314
 
        gtk_label_set_markup (GTK_LABEL (dlg->priv->status), markup);
315
 
        g_free (markup);
316
 
 
317
 
        gtk_misc_set_alignment (GTK_MISC (dlg->priv->status), 0.0, 0.0);
318
 
 
319
 
        gtk_box_pack_start (GTK_BOX (vbox), dlg->priv->status, FALSE, FALSE, 0);
320
 
 
321
 
        hbox = gtk_hbox_new (FALSE, 0);
322
 
        gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
323
 
 
324
 
        table = gtk_table_new (2, 2, FALSE);
325
 
        gtk_table_set_row_spacings (GTK_TABLE (table), 4);
326
 
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
327
 
 
328
 
        gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), FALSE, FALSE, 0);
329
 
 
330
 
        progress_vbox = gtk_vbox_new (TRUE, 0);
331
 
        gtk_box_pack_start (GTK_BOX (vbox), progress_vbox, FALSE, FALSE, 0);
332
 
 
333
 
        dlg->priv->progress = gtk_progress_bar_new ();
334
 
        gtk_box_pack_start (GTK_BOX (progress_vbox),
335
 
                            dlg->priv->progress, FALSE, FALSE, 0);
336
 
 
337
 
        gtk_dialog_add_button (GTK_DIALOG (dlg),
338
 
                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
339
 
 
340
 
        gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
341
 
        gtk_container_set_border_width (GTK_CONTAINER (dlg), 6);
342
 
 
343
 
        gtk_widget_show_all (content_area);
344
 
}
345
 
 
346
 
GtkWidget*
347
 
file_transfer_dialog_new (void)
348
 
{
349
 
        return GTK_WIDGET (g_object_new (file_transfer_dialog_get_type (),
350
 
                                         NULL));
351
 
}
352
 
 
353
 
GtkWidget*
354
 
file_transfer_dialog_new_with_parent (GtkWindow *parent)
355
 
{
356
 
        return GTK_WIDGET (g_object_new (file_transfer_dialog_get_type (),
357
 
                                         "parent", parent, NULL));
358
 
}
359
 
 
360
 
static gboolean
361
 
file_transfer_job_update (gpointer user_data)
362
 
{
363
 
        FileTransferData *data = user_data;
364
 
        gdouble fraction;
365
 
        gdouble current_fraction;
366
 
 
367
 
        if (data->total_bytes == 0)
368
 
                current_fraction = 0.0;
369
 
        else
370
 
                current_fraction = ((gdouble) data->current_bytes) / data->total_bytes;
371
 
 
372
 
        fraction = ((gdouble) data->current_file - 1) / data->total_files +
373
 
                   (1.0 / data->total_files) * current_fraction;
374
 
 
375
 
        g_object_set (data->dialog,
376
 
                      "from_uri", data->source,
377
 
                      "to_uri", data->target,
378
 
                      "nth_uri", data->current_file,
379
 
                      "fraction_complete", fraction,
380
 
                      NULL);
381
 
        return FALSE;
382
 
}
383
 
 
384
 
static void
385
 
file_transfer_job_progress (goffset current_bytes,
386
 
                            goffset total_bytes,
387
 
                            gpointer user_data)
388
 
{
389
 
        FileTransferData *data = user_data;
390
 
 
391
 
        data->current_bytes = current_bytes;
392
 
        data->total_bytes = total_bytes;
393
 
 
394
 
        gdk_threads_enter ();
395
 
        file_transfer_job_update (data);
396
 
        gdk_threads_leave ();
397
 
}
398
 
 
399
 
static void
400
 
file_transfer_job_destroy (FileTransferJob *job)
401
 
{
402
 
        g_object_unref (job->dialog);
403
 
        g_slist_foreach (job->source_files, (GFunc) g_object_unref, NULL);
404
 
        g_slist_foreach (job->target_files, (GFunc) g_object_unref, NULL);
405
 
        g_slist_free (job->source_files);
406
 
        g_slist_free (job->target_files);
407
 
        if (job->overwrite_dialog != NULL)
408
 
                gtk_widget_destroy (GTK_WIDGET (job->overwrite_dialog));
409
 
        g_free (job);
410
 
}
411
 
 
412
 
static gboolean
413
 
file_transfer_dialog_done (FileTransferDialog *dialog)
414
 
{
415
 
        g_signal_emit (dialog,
416
 
                       file_transfer_dialog_signals[DONE],
417
 
                       0, NULL);
418
 
        return FALSE;
419
 
}
420
 
 
421
 
static gboolean
422
 
file_transfer_dialog_cancel (FileTransferDialog *dialog)
423
 
{
424
 
        g_signal_emit (dialog,
425
 
                       file_transfer_dialog_signals[CANCEL],
426
 
                       0, NULL);
427
 
        return FALSE;
428
 
}
429
 
 
430
 
static gboolean
431
 
file_transfer_dialog_overwrite (gpointer user_data)
432
 
{
433
 
        FileTransferData *data = user_data;
434
 
        GtkDialog *dialog;
435
 
 
436
 
        dialog = data->overwrite_dialog;
437
 
 
438
 
        if (dialog != NULL) {
439
 
        } else {
440
 
                GtkWidget *button;
441
 
 
442
 
                dialog = GTK_DIALOG (gtk_message_dialog_new (GTK_WINDOW (data->dialog),
443
 
                                                             GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
444
 
                                                             GTK_BUTTONS_NONE,
445
 
                                                             _("File '%s' already exists. Do you want to overwrite it?"),
446
 
                                                             data->target));
447
 
 
448
 
                gtk_dialog_add_button (dialog, _("_Skip"), GTK_RESPONSE_NO);
449
 
                gtk_dialog_add_button (dialog, _("Overwrite _All"), GTK_RESPONSE_APPLY);
450
 
 
451
 
                button = gtk_button_new_with_label (_("_Overwrite"));
452
 
                gtk_button_set_image (GTK_BUTTON (button),
453
 
                                      gtk_image_new_from_stock (GTK_STOCK_APPLY,
454
 
                                                                GTK_ICON_SIZE_BUTTON));
455
 
                gtk_dialog_add_action_widget (dialog, button, GTK_RESPONSE_YES);
456
 
                gtk_widget_show (button);
457
 
 
458
 
                data->overwrite_dialog = dialog;
459
 
        }
460
 
 
461
 
        data->response = gtk_dialog_run (dialog);
462
 
 
463
 
        gtk_widget_hide (GTK_WIDGET (dialog));
464
 
        return FALSE;
465
 
}
466
 
 
467
 
/* TODO: support transferring directories recursively? */
468
 
static gboolean
469
 
file_transfer_job_schedule (GIOSchedulerJob *io_job,
470
 
                            GCancellable *cancellable,
471
 
                            FileTransferJob *job)
472
 
{
473
 
        GFile *source, *target;
474
 
        gboolean success;
475
 
        GFileCopyFlags copy_flags = G_FILE_COPY_NONE;
476
 
        FileTransferData data;
477
 
        GError *error;
478
 
        gboolean retry;
479
 
 
480
 
        /* take the first file from the list and copy it */
481
 
        source = job->source_files->data;
482
 
        job->source_files = g_slist_delete_link (job->source_files, job->source_files);
483
 
 
484
 
        target = job->target_files->data;
485
 
        job->target_files = g_slist_delete_link (job->target_files, job->target_files);
486
 
 
487
 
        data.dialog = job->dialog;
488
 
        data.overwrite_dialog = job->overwrite_dialog;
489
 
        data.current_file = job->dialog->priv->nth + 1;
490
 
        data.total_files = job->dialog->priv->total;
491
 
        data.current_bytes = data.total_bytes = 0;
492
 
        data.source = g_file_get_basename (source);
493
 
        data.target = g_file_get_basename (target);
494
 
 
495
 
        g_io_scheduler_job_send_to_mainloop (io_job,
496
 
                                             file_transfer_job_update,
497
 
                                             &data,
498
 
                                             NULL);
499
 
 
500
 
        if (job->options & FILE_TRANSFER_DIALOG_OVERWRITE)
501
 
                copy_flags |= G_FILE_COPY_OVERWRITE;
502
 
 
503
 
        do {
504
 
                retry = FALSE;
505
 
                error = NULL;
506
 
                success = g_file_copy (source, target,
507
 
                                       copy_flags,
508
 
                                       job->dialog->priv->cancellable,
509
 
                                       file_transfer_job_progress,
510
 
                                       &data,
511
 
                                       &error);
512
 
 
513
 
                if (error != NULL)
514
 
                {
515
 
                        if (error->domain == G_IO_ERROR &&
516
 
                            error->code == G_IO_ERROR_EXISTS)
517
 
                        {
518
 
                                /* since the job is run in a thread, we cannot simply run
519
 
                                 * a dialog here and need to defer it to the mainloop */
520
 
                                data.response = GTK_RESPONSE_NONE;
521
 
                                g_io_scheduler_job_send_to_mainloop (io_job,
522
 
                                                                     file_transfer_dialog_overwrite,
523
 
                                                                     &data,
524
 
                                                                     NULL);
525
 
 
526
 
                                if (data.response == GTK_RESPONSE_YES) {
527
 
                                        retry = TRUE;
528
 
                                        copy_flags |= G_FILE_COPY_OVERWRITE;
529
 
                                } else if (data.response == GTK_RESPONSE_APPLY) {
530
 
                                        retry = TRUE;
531
 
                                        job->options |= FILE_TRANSFER_DIALOG_OVERWRITE;
532
 
                                        copy_flags |= G_FILE_COPY_OVERWRITE;
533
 
                                } else {
534
 
                                        success = TRUE;
535
 
                                }
536
 
 
537
 
                                job->overwrite_dialog = data.overwrite_dialog;
538
 
                        }
539
 
                        g_error_free (error);
540
 
                }
541
 
        } while (retry);
542
 
 
543
 
        g_object_unref (source);
544
 
        g_object_unref (target);
545
 
 
546
 
        g_free (data.source);
547
 
        g_free (data.target);
548
 
 
549
 
        if (success)
550
 
        {
551
 
                if (job->source_files == NULL)
552
 
                {
553
 
                        g_io_scheduler_job_send_to_mainloop_async (io_job,
554
 
                                                                   (GSourceFunc) file_transfer_dialog_done,
555
 
                                                                   g_object_ref (job->dialog),
556
 
                                                                   g_object_unref);
557
 
                        return FALSE;
558
 
                }
559
 
        }
560
 
        else /* error on copy or cancelled */
561
 
        {
562
 
                g_io_scheduler_job_send_to_mainloop_async (io_job,
563
 
                                                           (GSourceFunc) file_transfer_dialog_cancel,
564
 
                                                           g_object_ref (job->dialog),
565
 
                                                           g_object_unref);
566
 
                return FALSE;
567
 
        }
568
 
 
569
 
        /* more work to do... */
570
 
        return TRUE;
571
 
}
572
 
 
573
 
void
574
 
file_transfer_dialog_copy_async (FileTransferDialog *dlg,
575
 
                                 GList *source_files,
576
 
                                 GList *target_files,
577
 
                                 FileTransferDialogOptions options,
578
 
                                 int priority)
579
 
{
580
 
        FileTransferJob *job;
581
 
        GList *l;
582
 
        guint n;
583
 
 
584
 
        job = g_new0 (FileTransferJob, 1);
585
 
        job->dialog = g_object_ref (dlg);
586
 
        job->options = options;
587
 
 
588
 
        /* we need to copy the list contents for private use */
589
 
        n = 0;
590
 
        for (l = g_list_last (source_files); l; l = l->prev, ++n)
591
 
        {
592
 
                job->source_files = g_slist_prepend (job->source_files,
593
 
                                                     g_object_ref (l->data));
594
 
        }
595
 
        for (l = g_list_last (target_files); l; l = l->prev)
596
 
        {
597
 
                job->target_files = g_slist_prepend (job->target_files,
598
 
                                                     g_object_ref (l->data));
599
 
        }
600
 
 
601
 
        g_object_set (dlg, "total_uris", n, NULL);
602
 
 
603
 
        g_io_scheduler_push_job ((GIOSchedulerJobFunc) file_transfer_job_schedule,
604
 
                                 job,
605
 
                                 (GDestroyNotify) file_transfer_job_destroy,
606
 
                                 priority,
607
 
                                 dlg->priv->cancellable);
608
 
}