Skip to content

Commit 5d46dc3

Browse files
committed
refactor
1 parent 4620188 commit 5d46dc3

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

libnemo-private/nemo-preview-image.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,29 @@ scale_current_pixbuf_to_size (NemoPreviewImage *widget,
465465
}
466466
}
467467

468+
static void
469+
reload_at_size (NemoPreviewImage *widget,
470+
gint width,
471+
gint height)
472+
{
473+
NemoPreviewImagePrivate *priv;
474+
475+
priv = nemo_preview_image_get_instance_private (widget);
476+
477+
if (priv->file == NULL) {
478+
return;
479+
}
480+
481+
/* Determine whether to show image/thumbnail or generic icon */
482+
if (nemo_can_thumbnail_internally (priv->file) || nemo_file_has_loaded_thumbnail (priv->file)) {
483+
priv->showing_icon = FALSE;
484+
load_image_at_size (widget, width, height);
485+
} else {
486+
priv->showing_icon = TRUE;
487+
load_icon_at_size (widget, width, height);
488+
}
489+
}
490+
468491
static gboolean
469492
on_resize_timeout (gpointer user_data)
470493
{
@@ -476,12 +499,7 @@ on_resize_timeout (gpointer user_data)
476499
priv->resize_timeout_id = 0;
477500

478501
gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
479-
480-
if (priv->showing_icon) {
481-
load_icon_at_size (widget, allocation.width, allocation.height);
482-
} else {
483-
load_image_at_size (widget, allocation.width, allocation.height);
484-
}
502+
reload_at_size (widget, allocation.width, allocation.height);
485503

486504
return G_SOURCE_REMOVE;
487505
}
@@ -570,16 +588,8 @@ nemo_preview_image_set_file (NemoPreviewImage *widget,
570588

571589
if (file != NULL) {
572590
nemo_file_ref (file);
573-
if (nemo_can_thumbnail_internally (file) || nemo_file_has_loaded_thumbnail (file)) {
574-
priv->showing_icon = FALSE;
575-
gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
576-
load_image_at_size (widget, allocation.width, allocation.height);
577-
} else {
578-
/* Load folder or file icon at current widget size */
579-
priv->showing_icon = TRUE;
580-
gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
581-
load_icon_at_size (widget, allocation.width, allocation.height);
582-
}
591+
gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
592+
reload_at_size (widget, allocation.width, allocation.height);
583593
}
584594
}
585595

0 commit comments

Comments
 (0)