~ubuntu-branches/ubuntu/utopic/nautilus/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/zg_activity_logging.patch/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:
73
73
        GTimer *time;
74
74
        GtkWindow *parent_window;
75
75
        int screen_num;
76
 
        int inhibit_cookie;
 
76
        guint inhibit_cookie;
77
77
        NautilusProgressInfo *progress;
78
78
        GCancellable *cancellable;
79
79
        GHashTable *skip_files;
182
182
 
183
183
#define IS_IO_ERROR(__error, KIND) (((__error)->domain == G_IO_ERROR && (__error)->code == G_IO_ERROR_ ## KIND))
184
184
 
 
185
#define CANCEL _("_Cancel")
185
186
#define SKIP _("_Skip")
186
187
#define SKIP_ALL _("S_kip All")
187
188
#define RETRY _("_Retry")
 
189
#define DELETE _("_Delete")
188
190
#define DELETE_ALL _("Delete _All")
189
191
#define REPLACE _("_Replace")
190
192
#define REPLACE_ALL _("Replace _All")
930
932
        common->progress = nautilus_progress_info_new ();
931
933
        common->cancellable = nautilus_progress_info_get_cancellable (common->progress);
932
934
        common->time = g_timer_new ();
933
 
        common->inhibit_cookie = -1;
 
935
        common->inhibit_cookie = 0;
934
936
        common->screen_num = 0;
935
937
        if (parent_window) {
936
938
                screen = gtk_widget_get_screen (GTK_WIDGET (parent_window));
945
947
{
946
948
        nautilus_progress_info_finish (common->progress);
947
949
 
948
 
        if (common->inhibit_cookie != -1) {
 
950
        if (common->inhibit_cookie != 0) {
949
951
                gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
950
952
                                           common->inhibit_cookie);
951
953
        }
952
954
 
953
 
        common->inhibit_cookie = -1;
 
955
        common->inhibit_cookie = 0;
954
956
        g_timer_destroy (common->time);
955
957
 
956
958
        if (common->parent_window) {
1265
1267
        return res;
1266
1268
}
1267
1269
 
 
1270
static int
 
1271
run_cancel_or_skip_warning (CommonJob *job,
 
1272
                            char *primary_text,
 
1273
                            char *secondary_text,
 
1274
                            const char *details_text,
 
1275
                            int total_operations,
 
1276
                            int operations_remaining)
 
1277
{
 
1278
        int response;
 
1279
 
 
1280
        if (total_operations == 1) {
 
1281
                response = run_warning (job,
 
1282
                                        primary_text,
 
1283
                                        secondary_text,
 
1284
                                        details_text,
 
1285
                                        FALSE,
 
1286
                                        CANCEL,
 
1287
                                        NULL);
 
1288
        } else {
 
1289
                response = run_warning (job,
 
1290
                                        primary_text,
 
1291
                                        secondary_text,
 
1292
                                        details_text,
 
1293
                                        operations_remaining > 1,
 
1294
                                        CANCEL, SKIP_ALL, SKIP,
 
1295
                                        NULL);
 
1296
        }
 
1297
 
 
1298
        return response;
 
1299
}
 
1300
 
1268
1301
static void
1269
1302
inhibit_power_manager (CommonJob *job, const char *message)
1270
1303
{
1336
1369
                                f (_("If you delete an item, it will be permanently lost.")),
1337
1370
                                NULL,
1338
1371
                                FALSE,
1339
 
                                GTK_STOCK_CANCEL, GTK_STOCK_DELETE,
 
1372
                                CANCEL, DELETE,
1340
1373
                                NULL);
1341
1374
        
1342
1375
        return (response == 1);
1360
1393
                                f(_("All items in the Trash will be permanently deleted.")),
1361
1394
                                NULL,
1362
1395
                                FALSE,
1363
 
                                GTK_STOCK_CANCEL, _("Empty _Trash"),
 
1396
                                CANCEL, _("Empty _Trash"),
1364
1397
                                NULL);
1365
1398
 
1366
1399
        return (response == 1);
1402
1435
                                f (_("If you delete an item, it will be permanently lost.")),
1403
1436
                                NULL,
1404
1437
                                FALSE,
1405
 
                                GTK_STOCK_CANCEL, GTK_STOCK_DELETE,
 
1438
                                CANCEL, DELETE,
1406
1439
                                NULL);
1407
1440
 
1408
1441
        return response == 1;
1536
1569
                                                secondary,
1537
1570
                                                details,
1538
1571
                                                FALSE,
1539
 
                                                GTK_STOCK_CANCEL, _("_Skip files"),
 
1572
                                                CANCEL, _("_Skip files"),
1540
1573
                                                NULL);
1541
1574
                        
1542
1575
                        g_error_free (error);
1569
1602
                                        secondary,
1570
1603
                                        details,
1571
1604
                                        FALSE,
1572
 
                                        GTK_STOCK_CANCEL, SKIP, RETRY,
 
1605
                                        CANCEL, SKIP, RETRY,
1573
1606
                                        NULL);
1574
1607
 
1575
1608
                g_error_free (error);
1596
1629
                        primary = f (_("Error while deleting."));
1597
1630
                        secondary = f (_("Could not remove the folder %B."), dir);
1598
1631
                        details = error->message;
1599
 
                        
1600
 
                        response = run_warning (job,
1601
 
                                                primary,
1602
 
                                                secondary,
1603
 
                                                details,
1604
 
                                                (source_info->num_files - transfer_info->num_files) > 1,
1605
 
                                                GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
1606
 
                                                NULL);
 
1632
 
 
1633
                        response = run_cancel_or_skip_warning (job,
 
1634
                                                               primary,
 
1635
                                                               secondary,
 
1636
                                                               details,
 
1637
                                                               source_info->num_files,
 
1638
                                                               source_info->num_files - transfer_info->num_files);
1607
1639
                        
1608
1640
                        if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
1609
1641
                                abort_job (job);
1674
1706
                secondary = f (_("There was an error deleting %B."), file);
1675
1707
                details = error->message;
1676
1708
                
1677
 
                response = run_warning (job,
1678
 
                                        primary,
1679
 
                                        secondary,
1680
 
                                        details,
1681
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
1682
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
1683
 
                                        NULL);
 
1709
                response = run_cancel_or_skip_warning (job,
 
1710
                                                       primary,
 
1711
                                                       secondary,
 
1712
                                                       details,
 
1713
                                                       source_info->num_files,
 
1714
                                                       source_info->num_files - transfer_info->num_files);
1684
1715
 
1685
1716
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
1686
1717
                        abort_job (job);
1819
1850
                                                 secondary,
1820
1851
                                                 details,
1821
1852
                                                 (total_files - files_trashed) > 1,
1822
 
                                                 GTK_STOCK_CANCEL, SKIP_ALL, SKIP, DELETE_ALL, GTK_STOCK_DELETE,
 
1853
                                                 CANCEL, SKIP_ALL, SKIP, DELETE_ALL, DELETE,
1823
1854
                                                 NULL);
1824
1855
 
1825
1856
                        if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
2237
2268
                                                    "will be permanently lost."));
2238
2269
        gtk_dialog_add_buttons (GTK_DIALOG (dialog), 
2239
2270
                                _("Do _not Empty Trash"), GTK_RESPONSE_REJECT, 
2240
 
                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 
 
2271
                                CANCEL, GTK_RESPONSE_CANCEL, 
2241
2272
                                _("Empty _Trash"), GTK_RESPONSE_ACCEPT, NULL);
2242
2273
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
2243
2274
        gtk_window_set_title (GTK_WINDOW (dialog), ""); /* as per HIG */
2566
2597
                                                secondary,
2567
2598
                                                details,
2568
2599
                                                FALSE,
2569
 
                                                GTK_STOCK_CANCEL, RETRY, SKIP,
 
2600
                                                CANCEL, RETRY, SKIP,
2570
2601
                                                NULL);
2571
2602
 
2572
2603
                        g_error_free (error);
2607
2638
                                        secondary,
2608
2639
                                        details,
2609
2640
                                        TRUE,
2610
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP, RETRY,
 
2641
                                        CANCEL, SKIP_ALL, SKIP, RETRY,
2611
2642
                                        NULL);
2612
2643
                
2613
2644
                g_error_free (error);
2684
2715
                                        secondary,
2685
2716
                                        details,
2686
2717
                                        TRUE,
2687
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP, RETRY,
 
2718
                                        CANCEL, SKIP_ALL, SKIP, RETRY,
2688
2719
                                        NULL);
2689
2720
                
2690
2721
                g_error_free (error);
2790
2821
                                      secondary,
2791
2822
                                      details,
2792
2823
                                      FALSE,
2793
 
                                      GTK_STOCK_CANCEL, RETRY,
 
2824
                                      CANCEL, RETRY,
2794
2825
                                      NULL);
2795
2826
                
2796
2827
                g_error_free (error);
2831
2862
                           secondary,
2832
2863
                           NULL,
2833
2864
                           FALSE,
2834
 
                           GTK_STOCK_CANCEL,
 
2865
                           CANCEL,
2835
2866
                           NULL);
2836
2867
                
2837
2868
                abort_job (job);
2872
2903
                                                secondary,
2873
2904
                                                details,
2874
2905
                                                FALSE,
2875
 
                                                GTK_STOCK_CANCEL,
 
2906
                                                CANCEL,
2876
2907
                                                COPY_FORCE,
2877
2908
                                                RETRY,
2878
2909
                                                NULL);
2900
2931
                           secondary,
2901
2932
                           NULL,
2902
2933
                           FALSE,
2903
 
                           GTK_STOCK_CANCEL,
 
2934
                           CANCEL,
2904
2935
                           NULL);
2905
2936
                
2906
2937
                g_error_free (error);
3078
3109
#define FAT_FORBIDDEN_CHARACTERS "/:;*?\"<>"
3079
3110
 
3080
3111
static gboolean
3081
 
str_replace (char *str,
3082
 
             const char *chars_to_replace,
3083
 
             char replacement)
 
3112
fat_str_replace (char *str,
 
3113
                 char replacement)
3084
3114
{
3085
3115
        gboolean success;
3086
3116
        int i;
3087
3117
 
3088
3118
        success = FALSE;
3089
3119
        for (i = 0; str[i] != '\0'; i++) {
3090
 
                if (strchr (chars_to_replace, str[i])) {
 
3120
                if (strchr (FAT_FORBIDDEN_CHARACTERS, str[i]) ||
 
3121
                    str[i] < 32) {
3091
3122
                        success = TRUE;
3092
3123
                        str[i] = replacement;
3093
3124
                }
3108
3139
                        gboolean ret;
3109
3140
                        int i, old_len;
3110
3141
 
3111
 
                        ret = str_replace (filename, FAT_FORBIDDEN_CHARACTERS, '_');
 
3142
                        ret = fat_str_replace (filename, '_');
3112
3143
 
3113
3144
                        old_len = strlen (filename);
3114
3145
                        for (i = 0; i < old_len; i++) {
3443
3474
                                        secondary,
3444
3475
                                        details,
3445
3476
                                        FALSE,
3446
 
                                        GTK_STOCK_CANCEL, SKIP, RETRY,
 
3477
                                        CANCEL, SKIP, RETRY,
3447
3478
                                        NULL);
3448
3479
 
3449
3480
                g_error_free (error);
3576
3607
                                                secondary,
3577
3608
                                                details,
3578
3609
                                                FALSE,
3579
 
                                                GTK_STOCK_CANCEL, _("_Skip files"),
 
3610
                                                CANCEL, _("_Skip files"),
3580
3611
                                                NULL);
3581
3612
                        
3582
3613
                        g_error_free (error);
3621
3652
                                        secondary,
3622
3653
                                        details,
3623
3654
                                        FALSE,
3624
 
                                        GTK_STOCK_CANCEL, SKIP, RETRY,
 
3655
                                        CANCEL, SKIP, RETRY,
3625
3656
                                        NULL);
3626
3657
 
3627
3658
                g_error_free (error);
3658
3689
                        secondary = f (_("Could not remove the source folder."));
3659
3690
                        details = error->message;
3660
3691
                        
3661
 
                        response = run_warning (job,
3662
 
                                                primary,
3663
 
                                                secondary,
3664
 
                                                details,
3665
 
                                                (source_info->num_files - transfer_info->num_files) > 1,
3666
 
                                                GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
3667
 
                                                NULL);
3668
 
                        
 
3692
                        response = run_cancel_or_skip_warning (job,
 
3693
                                                               primary,
 
3694
                                                               secondary,
 
3695
                                                               details,
 
3696
                                                               source_info->num_files,
 
3697
                                                               source_info->num_files - transfer_info->num_files);
 
3698
 
3669
3699
                        if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
3670
3700
                                abort_job (job);
3671
3701
                        } else if (response == 1) { /* skip all */
3752
3782
                                        secondary,
3753
3783
                                        details,
3754
3784
                                        TRUE,
3755
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
3785
                                        CANCEL, SKIP_ALL, SKIP,
3756
3786
                                        NULL);
3757
3787
                
3758
3788
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
3793
3823
                                        secondary,
3794
3824
                                        details,
3795
3825
                                        TRUE,
3796
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
3826
                                        CANCEL, SKIP_ALL, SKIP,
3797
3827
                                        NULL);
3798
3828
                
3799
3829
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4106
4136
                                            : g_strdup (_("You cannot copy a folder into itself."));
4107
4137
                secondary = g_strdup (_("The destination folder is inside the source folder."));
4108
4138
                
4109
 
                response = run_warning (job,
4110
 
                                        primary,
4111
 
                                        secondary,
4112
 
                                        NULL,
4113
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
4114
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
4115
 
                                        NULL);
 
4139
                response = run_cancel_or_skip_warning (job,
 
4140
                                                       primary,
 
4141
                                                       secondary,
 
4142
                                                       NULL,
 
4143
                                                       source_info->num_files,
 
4144
                                                       source_info->num_files - transfer_info->num_files);
4116
4145
 
4117
4146
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4118
4147
                        abort_job (job);
4139
4168
                                            : g_strdup (_("You cannot copy a file over itself."));
4140
4169
                secondary = g_strdup (_("The source file would be overwritten by the destination."));
4141
4170
                
4142
 
                response = run_warning (job,
4143
 
                                        primary,
4144
 
                                        secondary,
4145
 
                                        NULL,
4146
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
4147
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
4148
 
                                        NULL);
 
4171
                response = run_cancel_or_skip_warning (job,
 
4172
                                                       primary,
 
4173
                                                       secondary,
 
4174
                                                       NULL,
 
4175
                                                       source_info->num_files,
 
4176
                                                       source_info->num_files - transfer_info->num_files);
4149
4177
 
4150
4178
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4151
4179
                        abort_job (job);
4362
4390
                                                        secondary,
4363
4391
                                                        details,
4364
4392
                                                        TRUE,
4365
 
                                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
4393
                                                        CANCEL, SKIP_ALL, SKIP,
4366
4394
                                                        NULL);
4367
4395
                                
4368
4396
                                g_error_free (error);
4424
4452
                secondary = f (_("There was an error copying the file into %F."), dest_dir);
4425
4453
                details = error->message;
4426
4454
                
4427
 
                response = run_warning (job,
4428
 
                                        primary,
4429
 
                                        secondary,
4430
 
                                        details,
4431
 
                                        (source_info->num_files - transfer_info->num_files) > 1,
4432
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
4433
 
                                        NULL);
 
4455
                response = run_cancel_or_skip_warning (job,
 
4456
                                                       primary,
 
4457
                                                       secondary,
 
4458
                                                       details,
 
4459
                                                       source_info->num_files,
 
4460
                                                       source_info->num_files - transfer_info->num_files);
4434
4461
 
4435
4462
                g_error_free (error);
4436
4463
                
4814
4841
                                        secondary,
4815
4842
                                        NULL,
4816
4843
                                        files_left > 1,
4817
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
4844
                                        CANCEL, SKIP_ALL, SKIP,
4818
4845
                                        NULL);
4819
4846
                
4820
4847
                if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
4971
4998
                                        secondary,
4972
4999
                                        details,
4973
5000
                                        files_left > 1,
4974
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
5001
                                        CANCEL, SKIP_ALL, SKIP,
4975
5002
                                        NULL);
4976
5003
 
4977
5004
                g_error_free (error);
5416
5443
                                        secondary,
5417
5444
                                        details,
5418
5445
                                        files_left > 1,
5419
 
                                        GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
 
5446
                                        CANCEL, SKIP_ALL, SKIP,
5420
5447
                                        NULL);
5421
5448
 
5422
5449
                if (error) {
6105
6132
                        g_assert (dest_fs_type == NULL);
6106
6133
                        dest_fs_type = query_fs_type (job->dest_dir, common->cancellable);
6107
6134
 
6108
 
                        g_object_unref (dest);
6109
 
 
6110
6135
                        if (count == 1) {
6111
6136
                                new_filename = g_strdup (filename);
6112
6137
                        } else {
6144
6169
                                goto retry;
6145
6170
                        }
6146
6171
                        g_free (new_filename);
6147
 
                } else if (IS_IO_ERROR (error, EXISTS)) {
 
6172
                }
 
6173
 
 
6174
                if (IS_IO_ERROR (error, EXISTS)) {
6148
6175
                        g_object_unref (dest);
6149
6176
                        dest = NULL;
6150
6177
                        filename_base = eel_filename_strip_extension (filename);
6193
6220
                                                secondary,
6194
6221
                                                details,
6195
6222
                                                FALSE,
6196
 
                                                GTK_STOCK_CANCEL, SKIP,
 
6223
                                                CANCEL, SKIP,
6197
6224
                                                NULL);
6198
6225
                        
6199
6226
                        g_error_free (error);
6506
6533
                                              error->message,
6507
6534
                                              NULL,
6508
6535
                                              FALSE,
6509
 
                                              GTK_STOCK_CANCEL, RETRY,
 
6536
                                              CANCEL, RETRY,
6510
6537
                                              NULL);
6511
6538
                } else {
6512
6539
                        response = 0;
6547
6574
                                                      error->message,
6548
6575
                                                      NULL,
6549
6576
                                                      FALSE,
6550
 
                                                      GTK_STOCK_CANCEL, RETRY,
 
6577
                                                      CANCEL, RETRY,
6551
6578
                                                      NULL);
6552
6579
                        } else {
6553
6580
                                response = 0;
6582
6609
                                              error->message,
6583
6610
                                              NULL,
6584
6611
                                              FALSE,
6585
 
                                              GTK_STOCK_CANCEL, RETRY,
 
6612
                                              CANCEL, RETRY,
6586
6613
                                              NULL);
6587
6614
                } else {
6588
6615
                        response = 0;
6617
6644
                                                              error->message,
6618
6645
                                                              NULL,
6619
6646
                                                              FALSE,
6620
 
                                                              GTK_STOCK_CANCEL, RETRY,
 
6647
                                                              CANCEL, RETRY,
6621
6648
                                                              NULL);
6622
6649
                                } else {
6623
6650
                                        response = 0;