~ubuntu-branches/ubuntu/trusty/nautilus/trusty-proposed

« back to all changes in this revision

Viewing changes to libnautilus-private/nautilus-file-operations.c

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-01-02 16:50:06 UTC
  • mfrom: (1.17.43)
  • Revision ID: package-import@ubuntu.com-20140102165006-1ghk9ropzitdc8pp
Tags: 1:3.10.1-0ubuntu1
* New upstream release
* debian/control.in: bump depend on gtk+ 3.9.11
* debian/patches:
  - Dropped git patches, that are included in new version
  - 06_never_exec_nonexec_launchers.patch, refreshed
  - disconnect-extra-location-widgets.patch, dropped included in new version
  - 16_unity_new_documents.patch, refreshed
  - ubuntu_show_titlebar.patch, disable CSD titlebar on non-GNOME sessions
  - ubuntu_titlebar_css.patch, theme fixes (LP: #1272602)

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
        GTimer *time;
76
76
        GtkWindow *parent_window;
77
77
        int screen_num;
78
 
        int inhibit_cookie;
 
78
        guint inhibit_cookie;
79
79
        NautilusProgressInfo *progress;
80
80
        GCancellable *cancellable;
81
81
        GHashTable *skip_files;
184
184
 
185
185
#define IS_IO_ERROR(__error, KIND) (((__error)->domain == G_IO_ERROR && (__error)->code == G_IO_ERROR_ ## KIND))
186
186
 
 
187
#define CANCEL _("_Cancel")
187
188
#define SKIP _("_Skip")
188
189
#define SKIP_ALL _("S_kip All")
189
190
#define RETRY _("_Retry")
 
191
#define DELETE _("_Delete")
190
192
#define DELETE_ALL _("Delete _All")
191
193
#define REPLACE _("_Replace")
192
194
#define REPLACE_ALL _("Replace _All")
1030
1032
        common->progress = nautilus_progress_info_new ();
1031
1033
        common->cancellable = nautilus_progress_info_get_cancellable (common->progress);
1032
1034
        common->time = g_timer_new ();
1033
 
        common->inhibit_cookie = -1;
 
1035
        common->inhibit_cookie = 0;
1034
1036
        common->screen_num = 0;
1035
1037
        if (parent_window) {
1036
1038
                screen = gtk_widget_get_screen (GTK_WIDGET (parent_window));
1045
1047
{
1046
1048
        nautilus_progress_info_finish (common->progress);
1047
1049
 
1048
 
        if (common->inhibit_cookie != -1) {
 
1050
        if (common->inhibit_cookie != 0) {
1049
1051
                gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
1050
1052
                                           common->inhibit_cookie);
1051
1053
        }
1052
1054
 
1053
 
        common->inhibit_cookie = -1;
 
1055
        common->inhibit_cookie = 0;
1054
1056
        g_timer_destroy (common->time);
1055
1057
 
1056
1058
        if (common->parent_window) {
1365
1367
        return res;
1366
1368
}
1367
1369
 
 
1370
static int
 
1371
run_cancel_or_skip_warning (CommonJob *job,
 
1372
                            char *primary_text,
 
1373
                            char *secondary_text,
 
1374
                            const char *details_text,
 
1375
                            int total_operations,
 
1376
                            int operations_remaining)
 
1377
{
 
1378
        int response;
 
1379
 
 
1380
        if (total_operations == 1) {
 
1381
                response = run_warning (job,
 
1382
                                        primary_text,
 
1383
                                        secondary_text,
 
1384
                                        details_text,
 
1385
                                        FALSE,
 
1386
                                        CANCEL,
 
1387
                                        NULL);
 
1388
        } else {
 
1389
                response = run_warning (job,
 
1390
                                        primary_text,
 
1391
                                        secondary_text,
 
1392
                                        details_text,
 
1393
                                        operations_remaining > 1,
 
1394
                                        CANCEL, SKIP_ALL, SKIP,
 
1395
                                        NULL);
 
1396
        }
 
1397
 
 
1398
        return response;
 
1399
}
 
1400
 
1368
1401
static void
1369
1402
inhibit_power_manager (CommonJob *job, const char *message)
1370
1403
{
1436
1469
                                f (_("If you delete an item, it will be permanently lost.")),
1437
1470
                                NULL,
1438
1471
                                FALSE,
1439
 
                                GTK_STOCK_CANCEL, GTK_STOCK_DELETE,
 
1472
                                CANCEL, DELETE,
1440
1473
                                NULL);
1441
1474
        
1442
1475
        return (response == 1);
1460
1493
                                f(_("All items in the Trash will be permanently deleted.")),
1461
1494
                                NULL,
1462
1495
                                FALSE,
1463
 
                                GTK_STOCK_CANCEL, _("Empty _Trash"),
 
1496
                                CANCEL, _("Empty _Trash"),
1464
1497
                                NULL);
1465
1498
 
1466
1499
        return (response == 1);
1502
1535
                                f (_("If you delete an item, it will be permanently lost.")),
1503
1536
                                NULL,
1504
1537
                                FALSE,
1505
 
                                GTK_STOCK_CANCEL, GTK_STOCK_DELETE,
 
1538
                                CANCEL, DELETE,
1506
1539
                                NULL);
1507
1540
 
1508
1541
        return response == 1;
1636
1669
                                                secondary,
1637
1670
                                                details,
1638
1671
                                                FALSE,
1639
 
                                                GTK_STOCK_CANCEL, _("_Skip files"),
 
1672
                                                CANCEL, _("_Skip files"),
1640
1673
                                                NULL);
1641
1674
                        
1642
1675
                        g_error_free (error);
1669
1702
                                        secondary,
1670
1703
                                        details,
1671
1704
                                        FALSE,
1672
 
                                        GTK_STOCK_CANCEL, SKIP, RETRY,
 
1705
                                        CANCEL, SKIP, RETRY,
1673
1706
                                        NULL);
1674
1707
 
1675
1708
                g_error_free (error);
1696
1729
                        primary = f (_("Error while deleting."));
1697
1730
                        secondary = f (_("Could not remove the folder %B."), dir);
1698
1731
                        details = error->message;
1699
 
                        
1700
 
                        response = run_warning (job,
1701
 
                                                primary,
1702
 
                                                secondary,
1703
 
                                                details,
1704
 
                                                (source_info->num_files - transfer_info->num_files) > 1,
1705
 
                                                GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
1706
 
                                                NULL);
 
1732
 
 
1733
                        response = run_cancel_or_skip_warning (job,
 
1734
                                                               primary,
 
1735
                                                               secondary,
 
1736
                                                               details,
 
1737
                                                               source_info->num_files,
 
1738
                                                               source_info->num_files - transfer_info->num_files);
1707
1739
                        
1708
1740
                        if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
1709
1741
                                abort_job (job);
1774
1806
                secondary = f (_("There was an error deleting %B."), file);
1775
1807
                details = error->message;
1776
1808
                
1777
 
                response = run_warning (job,
1778
 
                                        primary,
1779
 
                                        secondary,
1780
 
                                        details,
1781
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
1782
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
1783
 
                                        NULL);
 
1809
                response = run_cancel_or_skip_warning (job,
 
1810
                                                       primary,
 
1811
                                                       secondary,
 
1812
                                                       details,
 
1813
                                                       source_info->num_files,
 
1814
                                                       source_info->num_files - transfer_info->num_files);
1784
1815
 
1785
1816
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
1786
1817
                        abort_job (job);
1919
1950
                                                 secondary,
1920
1951
                                                 details,
1921
1952
                                                 (total_files - files_trashed) > 1,
1922
 
                                                 GTK_STOCK_CANCEL, SKIP_ALL, SKIP, DELETE_ALL, GTK_STOCK_DELETE,
 
1953
                                                 CANCEL, SKIP_ALL, SKIP, DELETE_ALL, DELETE,
1923
1954
                                                 NULL);
1924
1955
 
1925
1956
                        if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
2366
2397
                                                    "will be permanently lost."));
2367
2398
        gtk_dialog_add_buttons (GTK_DIALOG (dialog), 
2368
2399
                                _("Do _not Empty Trash"), GTK_RESPONSE_REJECT, 
2369
 
                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 
 
2400
                                CANCEL, GTK_RESPONSE_CANCEL, 
2370
2401
                                _("Empty _Trash"), GTK_RESPONSE_ACCEPT, NULL);
2371
2402
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
2372
2403
        gtk_window_set_title (GTK_WINDOW (dialog), ""); /* as per HIG */
2695
2726
                                                secondary,
2696
2727
                                                details,
2697
2728
                                                FALSE,
2698
 
                                                GTK_STOCK_CANCEL, RETRY, SKIP,
 
2729
                                                CANCEL, RETRY, SKIP,
2699
2730
                                                NULL);
2700
2731
 
2701
2732
                        g_error_free (error);
2736
2767
                                        secondary,
2737
2768
                                        details,
2738
2769
                                        TRUE,
2739
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP, RETRY,
 
2770
                                        CANCEL, SKIP_ALL, SKIP, RETRY,
2740
2771
                                        NULL);
2741
2772
                
2742
2773
                g_error_free (error);
2813
2844
                                        secondary,
2814
2845
                                        details,
2815
2846
                                        TRUE,
2816
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP, RETRY,
 
2847
                                        CANCEL, SKIP_ALL, SKIP, RETRY,
2817
2848
                                        NULL);
2818
2849
                
2819
2850
                g_error_free (error);
2919
2950
                                      secondary,
2920
2951
                                      details,
2921
2952
                                      FALSE,
2922
 
                                      GTK_STOCK_CANCEL, RETRY,
 
2953
                                      CANCEL, RETRY,
2923
2954
                                      NULL);
2924
2955
                
2925
2956
                g_error_free (error);
2960
2991
                           secondary,
2961
2992
                           NULL,
2962
2993
                           FALSE,
2963
 
                           GTK_STOCK_CANCEL,
 
2994
                           CANCEL,
2964
2995
                           NULL);
2965
2996
                
2966
2997
                abort_job (job);
3001
3032
                                                secondary,
3002
3033
                                                details,
3003
3034
                                                FALSE,
3004
 
                                                GTK_STOCK_CANCEL,
 
3035
                                                CANCEL,
3005
3036
                                                COPY_FORCE,
3006
3037
                                                RETRY,
3007
3038
                                                NULL);
3029
3060
                           secondary,
3030
3061
                           NULL,
3031
3062
                           FALSE,
3032
 
                           GTK_STOCK_CANCEL,
 
3063
                           CANCEL,
3033
3064
                           NULL);
3034
3065
                
3035
3066
                g_error_free (error);
3207
3238
#define FAT_FORBIDDEN_CHARACTERS "/:;*?\"<>"
3208
3239
 
3209
3240
static gboolean
3210
 
str_replace (char *str,
3211
 
             const char *chars_to_replace,
3212
 
             char replacement)
 
3241
fat_str_replace (char *str,
 
3242
                 char replacement)
3213
3243
{
3214
3244
        gboolean success;
3215
3245
        int i;
3216
3246
 
3217
3247
        success = FALSE;
3218
3248
        for (i = 0; str[i] != '\0'; i++) {
3219
 
                if (strchr (chars_to_replace, str[i])) {
 
3249
                if (strchr (FAT_FORBIDDEN_CHARACTERS, str[i]) ||
 
3250
                    str[i] < 32) {
3220
3251
                        success = TRUE;
3221
3252
                        str[i] = replacement;
3222
3253
                }
3237
3268
                        gboolean ret;
3238
3269
                        int i, old_len;
3239
3270
 
3240
 
                        ret = str_replace (filename, FAT_FORBIDDEN_CHARACTERS, '_');
 
3271
                        ret = fat_str_replace (filename, '_');
3241
3272
 
3242
3273
                        old_len = strlen (filename);
3243
3274
                        for (i = 0; i < old_len; i++) {
3572
3603
                                        secondary,
3573
3604
                                        details,
3574
3605
                                        FALSE,
3575
 
                                        GTK_STOCK_CANCEL, SKIP, RETRY,
 
3606
                                        CANCEL, SKIP, RETRY,
3576
3607
                                        NULL);
3577
3608
 
3578
3609
                g_error_free (error);
3705
3736
                                                secondary,
3706
3737
                                                details,
3707
3738
                                                FALSE,
3708
 
                                                GTK_STOCK_CANCEL, _("_Skip files"),
 
3739
                                                CANCEL, _("_Skip files"),
3709
3740
                                                NULL);
3710
3741
                        
3711
3742
                        g_error_free (error);
3750
3781
                                        secondary,
3751
3782
                                        details,
3752
3783
                                        FALSE,
3753
 
                                        GTK_STOCK_CANCEL, SKIP, RETRY,
 
3784
                                        CANCEL, SKIP, RETRY,
3754
3785
                                        NULL);
3755
3786
 
3756
3787
                g_error_free (error);
3787
3818
                        secondary = f (_("Could not remove the source folder."));
3788
3819
                        details = error->message;
3789
3820
                        
3790
 
                        response = run_warning (job,
3791
 
                                                primary,
3792
 
                                                secondary,
3793
 
                                                details,
3794
 
                                                (source_info->num_files - transfer_info->num_files) > 1,
3795
 
                                                GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
3796
 
                                                NULL);
3797
 
                        
 
3821
                        response = run_cancel_or_skip_warning (job,
 
3822
                                                               primary,
 
3823
                                                               secondary,
 
3824
                                                               details,
 
3825
                                                               source_info->num_files,
 
3826
                                                               source_info->num_files - transfer_info->num_files);
 
3827
 
3798
3828
                        if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
3799
3829
                                abort_job (job);
3800
3830
                        } else if (response == 1) { /* skip all */
3881
3911
                                        secondary,
3882
3912
                                        details,
3883
3913
                                        TRUE,
3884
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
3914
                                        CANCEL, SKIP_ALL, SKIP,
3885
3915
                                        NULL);
3886
3916
                
3887
3917
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
3922
3952
                                        secondary,
3923
3953
                                        details,
3924
3954
                                        TRUE,
3925
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
3955
                                        CANCEL, SKIP_ALL, SKIP,
3926
3956
                                        NULL);
3927
3957
                
3928
3958
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4235
4265
                                            : g_strdup (_("You cannot copy a folder into itself."));
4236
4266
                secondary = g_strdup (_("The destination folder is inside the source folder."));
4237
4267
                
4238
 
                response = run_warning (job,
4239
 
                                        primary,
4240
 
                                        secondary,
4241
 
                                        NULL,
4242
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
4243
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
4244
 
                                        NULL);
 
4268
                response = run_cancel_or_skip_warning (job,
 
4269
                                                       primary,
 
4270
                                                       secondary,
 
4271
                                                       NULL,
 
4272
                                                       source_info->num_files,
 
4273
                                                       source_info->num_files - transfer_info->num_files);
4245
4274
 
4246
4275
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4247
4276
                        abort_job (job);
4268
4297
                                            : g_strdup (_("You cannot copy a file over itself."));
4269
4298
                secondary = g_strdup (_("The source file would be overwritten by the destination."));
4270
4299
                
4271
 
                response = run_warning (job,
4272
 
                                        primary,
4273
 
                                        secondary,
4274
 
                                        NULL,
4275
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
4276
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
4277
 
                                        NULL);
 
4300
                response = run_cancel_or_skip_warning (job,
 
4301
                                                       primary,
 
4302
                                                       secondary,
 
4303
                                                       NULL,
 
4304
                                                       source_info->num_files,
 
4305
                                                       source_info->num_files - transfer_info->num_files);
4278
4306
 
4279
4307
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4280
4308
                        abort_job (job);
4491
4519
                                                        secondary,
4492
4520
                                                        details,
4493
4521
                                                        TRUE,
4494
 
                                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
4522
                                                        CANCEL, SKIP_ALL, SKIP,
4495
4523
                                                        NULL);
4496
4524
                                
4497
4525
                                g_error_free (error);
4553
4581
                secondary = f (_("There was an error copying the file into %F."), dest_dir);
4554
4582
                details = error->message;
4555
4583
                
4556
 
                response = run_warning (job,
4557
 
                                        primary,
4558
 
                                        secondary,
4559
 
                                        details,
4560
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
4561
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
4562
 
                                        NULL);
 
4584
                response = run_cancel_or_skip_warning (job,
 
4585
                                                       primary,
 
4586
                                                       secondary,
 
4587
                                                       details,
 
4588
                                                       source_info->num_files,
 
4589
                                                       source_info->num_files - transfer_info->num_files);
4563
4590
 
4564
4591
                g_error_free (error);
4565
4592
                
4960
4987
                                        secondary,
4961
4988
                                        NULL,
4962
4989
                                        files_left > 1,
4963
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
4990
                                        CANCEL, SKIP_ALL, SKIP,
4964
4991
                                        NULL);
4965
4992
                
4966
4993
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
5117
5144
                                        secondary,
5118
5145
                                        details,
5119
5146
                                        files_left > 1,
5120
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
5147
                                        CANCEL, SKIP_ALL, SKIP,
5121
5148
                                        NULL);
5122
5149
 
5123
5150
                g_error_free (error);
5575
5602
                                        secondary,
5576
5603
                                        details,
5577
5604
                                        files_left > 1,
5578
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
5605
                                        CANCEL, SKIP_ALL, SKIP,
5579
5606
                                        NULL);
5580
5607
 
5581
5608
                if (error) {
6289
6316
                        g_assert (dest_fs_type == NULL);
6290
6317
                        dest_fs_type = query_fs_type (job->dest_dir, common->cancellable);
6291
6318
 
6292
 
                        g_object_unref (dest);
6293
 
 
6294
6319
                        if (count == 1) {
6295
6320
                                new_filename = g_strdup (filename);
6296
6321
                        } else {
6328
6353
                                goto retry;
6329
6354
                        }
6330
6355
                        g_free (new_filename);
6331
 
                } else if (IS_IO_ERROR (error, EXISTS)) {
 
6356
                }
 
6357
 
 
6358
                if (IS_IO_ERROR (error, EXISTS)) {
6332
6359
                        g_object_unref (dest);
6333
6360
                        dest = NULL;
6334
6361
                        filename_base = eel_filename_strip_extension (filename);
6377
6404
                                                secondary,
6378
6405
                                                details,
6379
6406
                                                FALSE,
6380
 
                                                GTK_STOCK_CANCEL, SKIP,
 
6407
                                                CANCEL, SKIP,
6381
6408
                                                NULL);
6382
6409
                        
6383
6410
                        g_error_free (error);
6690
6717
                                              error->message,
6691
6718
                                              NULL,
6692
6719
                                              FALSE,
6693
 
                                              GTK_STOCK_CANCEL, RETRY,
 
6720
                                              CANCEL, RETRY,
6694
6721
                                              NULL);
6695
6722
                } else {
6696
6723
                        response = 0;
6731
6758
                                                      error->message,
6732
6759
                                                      NULL,
6733
6760
                                                      FALSE,
6734
 
                                                      GTK_STOCK_CANCEL, RETRY,
 
6761
                                                      CANCEL, RETRY,
6735
6762
                                                      NULL);
6736
6763
                        } else {
6737
6764
                                response = 0;
6766
6793
                                              error->message,
6767
6794
                                              NULL,
6768
6795
                                              FALSE,
6769
 
                                              GTK_STOCK_CANCEL, RETRY,
 
6796
                                              CANCEL, RETRY,
6770
6797
                                              NULL);
6771
6798
                } else {
6772
6799
                        response = 0;
6801
6828
                                                              error->message,
6802
6829
                                                              NULL,
6803
6830
                                                              FALSE,
6804
 
                                                              GTK_STOCK_CANCEL, RETRY,
 
6831
                                                              CANCEL, RETRY,
6805
6832
                                                              NULL);
6806
6833
                                } else {
6807
6834
                                        response = 0;