~ubuntu-branches/ubuntu/natty/shotwell/natty

« back to all changes in this revision

Viewing changes to .pc/01_lpi.patch/src/ImportPage.vala

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-08-16 16:58:02 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100816165802-j6t0o788sk21djtr
Tags: 0.6.91-0ubuntu1
* New upstream release
* debian/control:
  - Build-depend on valac >= 0.9.5
  - Build-depend on libgexiv2-dev >= 0.1.91

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
    
196
196
    public bool is_already_imported() {
197
197
        string? preview_md5 = get_import_source().get_preview_md5();
198
 
        
199
 
                // ignore trashed duplicates
200
 
        return (preview_md5 != null) 
201
 
            ? LibraryPhoto.has_nontrash_duplicate(null, preview_md5, null, 
202
 
            get_import_source().get_file_format()) : false;
 
198
        PhotoFileFormat file_format = get_import_source().get_file_format();
 
199
        
 
200
        // ignore trashed duplicates
 
201
        if (!is_string_empty(preview_md5)
 
202
            && LibraryPhoto.has_nontrash_duplicate(null, preview_md5, null, file_format)) {
 
203
            return true;
 
204
        }
 
205
        
 
206
        // Because gPhoto doesn't reliably return thumbnails for RAW files, and because we want
 
207
        // to avoid downloading huge RAW files during an "import all" only to determine they're
 
208
        // duplicates, use the image's basename and filesize to do duplicate detection
 
209
        if (file_format == PhotoFileFormat.RAW) {
 
210
            uint64 filesize = get_import_source().get_filesize();
 
211
            // unlikely to be a problem, but what the hay
 
212
            if (filesize <= int64.MAX) {
 
213
                if (LibraryPhoto.global.has_basename_filesize_duplicate(
 
214
                    get_import_source().get_filename(), (int64) filesize)) {
 
215
                    return true;
 
216
                }
 
217
            }
 
218
        }
 
219
        
 
220
        return false;
203
221
    }
204
222
    
205
223
    public ImportSource get_import_source() {
344
362
        get_view().monitor_source_collection(import_sources, new ImportViewManager(this));
345
363
        
346
364
        // sort by exposure time
347
 
        get_view().set_comparator(preview_comparator);
 
365
        get_view().set_comparator(preview_comparator, preview_comparator_predicate);
348
366
        
349
367
        // monitor selection for UI
350
368
        get_view().items_state_changed.connect(on_view_changed);
432
450
        return Resources.ICON_SINGLE_PHOTO;
433
451
    }
434
452
 
435
 
    private int64 preview_comparator(void *a, void *b) {
 
453
    private static int64 preview_comparator(void *a, void *b) {
436
454
        return ((ImportPreview *) a)->get_import_source().get_exposure_time()
437
455
            - ((ImportPreview *) b)->get_import_source().get_exposure_time();
438
456
    }
439
457
    
 
458
    private static bool preview_comparator_predicate(DataObject object, Alteration alteration) {
 
459
        return alteration.has_detail("metadata", "exposure-time");
 
460
    }
 
461
    
440
462
    private int64 import_job_comparator(void *a, void *b) {
441
463
        return ((CameraImportJob *) a)->get_exposure_time() - ((CameraImportJob *) b)->get_exposure_time();
442
464
    }
533
555
    
534
556
    public override CheckerboardItem? get_fullscreen_photo() {
535
557
        error("No fullscreen support for import pages");
536
 
        
537
 
        return null;
538
558
    }
539
559
    
540
560
    public override void switched_to() {
616
636
            
617
637
            default:
618
638
                error("Unknown result type %d", (int) res);
619
 
            break;
620
639
        }
621
640
    }
622
641
    
1049
1068
            jobs.add(new CameraImportJob(null_context, import_file));
1050
1069
        }
1051
1070
        
 
1071
        debug("Importing %d files from %s", jobs.size, camera_name);
 
1072
        
1052
1073
        if (jobs.size > 0) {
1053
1074
            // see import_reporter() to see why this is held during the duration of the import
1054
1075
            assert(local_ref == null);
1351
1372
    private void on_fatal_error(ImportResult result, string message) {
1352
1373
        AppWindow.error_message(message);
1353
1374
    }
 
1375
    
 
1376
    public override string? get_icon_name() {
 
1377
        return Resources.ICON_IMPORTING;
 
1378
    }
1354
1379
}
1355
1380