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

« back to all changes in this revision

Viewing changes to libnautilus-private/nautilus-file.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:
4265
4265
NautilusIconInfo *
4266
4266
nautilus_file_get_icon (NautilusFile *file,
4267
4267
                        int size,
 
4268
                        int scale,
4268
4269
                        NautilusFileIconFlags flags)
4269
4270
{
4270
4271
        NautilusIconInfo *icon;
4282
4283
        }
4283
4284
 
4284
4285
        if (gicon != NULL) {
4285
 
                icon = nautilus_icon_info_lookup (gicon, size);
 
4286
                icon = nautilus_icon_info_lookup (gicon, size, scale);
4286
4287
                g_object_unref (gicon);
4287
4288
 
4288
4289
                return icon;
4292
4293
               flags & NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE);
4293
4294
        
4294
4295
        if (flags & NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE) {
4295
 
                modified_size = size;
 
4296
                modified_size = size * scale;
4296
4297
        } else {
4297
 
                modified_size = size * cached_thumbnail_size / NAUTILUS_ICON_SIZE_STANDARD;
 
4298
                modified_size = size * scale * cached_thumbnail_size / NAUTILUS_ICON_SIZE_STANDARD;
4298
4299
                DEBUG ("Modifying icon size to %d, as our cached thumbnail size is %d",
4299
4300
                       modified_size, cached_thumbnail_size);
4300
4301
        }
4303
4304
            nautilus_file_should_show_thumbnail (file)) {
4304
4305
                if (file->details->thumbnail) {
4305
4306
                        int w, h, s;
4306
 
                        double scale;
 
4307
                        double thumb_scale;
4307
4308
 
4308
4309
                        raw_pixbuf = g_object_ref (file->details->thumbnail);
4309
4310
 
4313
4314
                        s = MAX (w, h);                 
4314
4315
                        /* Don't scale up small thumbnails in the standard view */
4315
4316
                        if (s <= cached_thumbnail_size) {
4316
 
                                scale = (double)size / NAUTILUS_ICON_SIZE_STANDARD;
 
4317
                                thumb_scale = (double)size / NAUTILUS_ICON_SIZE_STANDARD;
4317
4318
                        }
4318
4319
                        else {
4319
 
                                scale = (double)modified_size / s;
 
4320
                                thumb_scale = (double)modified_size / s;
4320
4321
                        }
4321
4322
                        /* Make sure that icons don't get smaller than NAUTILUS_ICON_SIZE_SMALLEST */
4322
 
                        if (s*scale <= NAUTILUS_ICON_SIZE_SMALLEST) {
4323
 
                                scale = (double) NAUTILUS_ICON_SIZE_SMALLEST / s;
 
4323
                        if (s*thumb_scale <= NAUTILUS_ICON_SIZE_SMALLEST) {
 
4324
                                thumb_scale = (double) NAUTILUS_ICON_SIZE_SMALLEST / s;
4324
4325
                        }
4325
4326
 
4326
4327
                        scaled_pixbuf = gdk_pixbuf_scale_simple (raw_pixbuf,
4327
 
                                                                 MAX (w * scale, 1),
4328
 
                                                                 MAX (h * scale, 1),
 
4328
                                                                 MAX (w * thumb_scale, 1),
 
4329
                                                                 MAX (h * thumb_scale, 1),
4329
4330
                                                                 GDK_INTERP_BILINEAR);
4330
4331
 
4331
4332
                        /* We don't want frames around small icons */
4332
 
                        if (!gdk_pixbuf_get_has_alpha (raw_pixbuf) || s >= 128) {
 
4333
                        if (!gdk_pixbuf_get_has_alpha (raw_pixbuf) || s >= 128 * scale) {
4333
4334
                                nautilus_ui_frame_image (&scaled_pixbuf);
4334
4335
                        }
4335
4336
 
4339
4340
                           image instead. We don't want to compare to exactly 100%,
4340
4341
                           since the zoom level 150% gives thumbnails at 144, which is
4341
4342
                           ok to scale up from 128. */
4342
 
                        if (modified_size > 128*1.25 &&
 
4343
                        if (modified_size > 128 * 1.25 * scale &&
4343
4344
                            !file->details->thumbnail_wants_original &&
4344
4345
                            nautilus_can_thumbnail_internally (file)) {
4345
4346
                                /* Invalidate if we resize upward */
4348
4349
                        }
4349
4350
 
4350
4351
                        DEBUG ("Returning thumbnailed image, at size %d %d",
4351
 
                               (int) (w * scale), (int) (h * scale));
 
4352
                               (int) (w * thumb_scale), (int) (h * thumb_scale));
4352
4353
                        
4353
 
                        icon = nautilus_icon_info_new_for_pixbuf (scaled_pixbuf);
 
4354
                        icon = nautilus_icon_info_new_for_pixbuf (scaled_pixbuf, scale);
4354
4355
                        g_object_unref (scaled_pixbuf);
4355
4356
                        return icon;
4356
4357
                } else if (file->details->thumbnail_path == NULL &&
4370
4371
                gicon = nautilus_file_get_gicon (file, flags);
4371
4372
        
4372
4373
        if (gicon) {
4373
 
                icon = nautilus_icon_info_lookup (gicon, size);
 
4374
                icon = nautilus_icon_info_lookup (gicon, size, scale);
4374
4375
                if (nautilus_icon_info_is_fallback (icon)) {
4375
4376
                        g_object_unref (icon);
4376
 
                        icon = nautilus_icon_info_lookup (get_default_file_icon (flags), size);
 
4377
                        icon = nautilus_icon_info_lookup (get_default_file_icon (flags), size, scale);
4377
4378
                }
4378
4379
                g_object_unref (gicon);
4379
4380
                return icon;
4380
4381
        } else {
4381
 
                return nautilus_icon_info_lookup (get_default_file_icon (flags), size);
 
4382
                return nautilus_icon_info_lookup (get_default_file_icon (flags), size, scale);
4382
4383
        }
4383
4384
}
4384
4385
 
4386
4387
nautilus_file_get_icon_pixbuf (NautilusFile *file,
4387
4388
                               int size,
4388
4389
                               gboolean force_size,
 
4390
                               int scale,
4389
4391
                               NautilusFileIconFlags flags)
4390
4392
{
4391
4393
        NautilusIconInfo *info;
4392
4394
        GdkPixbuf *pixbuf;
4393
4395
 
4394
 
        info = nautilus_file_get_icon (file, size, flags);
 
4396
        info = nautilus_file_get_icon (file, size, scale, flags);
4395
4397
        if (force_size) {
4396
4398
                pixbuf =  nautilus_icon_info_get_pixbuf_at_size (info, size);
4397
4399
        } else {
7682
7684
        res = get_attributes_for_default_sort_type (file, &is_recent, &is_download, &is_trash, &is_search);
7683
7685
 
7684
7686
        if (res) {
7685
 
                if (is_recent || is_download) {
 
7687
                if (is_recent) {
 
7688
                        retval = NAUTILUS_FILE_SORT_BY_ATIME;
 
7689
                } else if (is_download) {
7686
7690
                        retval = NAUTILUS_FILE_SORT_BY_MTIME;
7687
7691
                } else if (is_trash) {
7688
7692
                        retval = NAUTILUS_FILE_SORT_BY_TRASHED_TIME;