[gthumb/ext: 75/79] use a special style when the image is smaller than the thumbnail
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 75/79] use a special style when the image is smaller than the thumbnail
- Date: Sun, 2 Aug 2009 20:32:29 +0000 (UTC)
commit 549468b3ea0b07248ef4ec1eef014028e11a7c97
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Jul 30 00:47:41 2009 +0200
use a special style when the image is smaller than the thumbnail
when an image is smaller than the thumbnail size, do not use the
frame and the dropshadow, use the same style used by the icons
instead
gthumb/gth-cell-renderer-thumbnail.c | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/gthumb/gth-cell-renderer-thumbnail.c b/gthumb/gth-cell-renderer-thumbnail.c
index f09ad23..965b550 100644
--- a/gthumb/gth-cell-renderer-thumbnail.c
+++ b/gthumb/gth-cell-renderer-thumbnail.c
@@ -143,18 +143,23 @@ gth_cell_renderer_thumbnail_get_size (GtkCellRenderer *cell,
int *height)
{
GthCellRendererThumbnail *self;
+ int image_width;
+ int image_height;
int calc_width;
int calc_height;
- self = GTH_CELL_RENDERER_THUMBNAIL (cell);
+ self = GTH_CELL_RENDERER_THUMBNAIL (cell);
+
+ image_width = gdk_pixbuf_get_width (self->priv->thumbnail);
+ image_height = gdk_pixbuf_get_height (self->priv->thumbnail);
- if (self->priv->is_icon || (self->priv->thumbnail == NULL)) {
+ if (self->priv->is_icon || (self->priv->thumbnail == NULL) || ((image_width < self->priv->size) && (image_height < self->priv->size))) {
calc_width = (int) (cell->xpad * 2) + (THUMBNAIL_X_BORDER * 2) + self->priv->size;
calc_height = (int) (cell->ypad * 2) + (THUMBNAIL_Y_BORDER * 2) + self->priv->size;
}
else {
- calc_width = (int) (cell->xpad * 2) + (THUMBNAIL_X_BORDER * 2) + gdk_pixbuf_get_width (self->priv->thumbnail);
- calc_height = (int) (cell->ypad * 2) + (THUMBNAIL_Y_BORDER * 2) + gdk_pixbuf_get_height (self->priv->thumbnail);
+ calc_width = (int) (cell->xpad * 2) + (THUMBNAIL_X_BORDER * 2) + image_width;
+ calc_height = (int) (cell->ypad * 2) + (THUMBNAIL_Y_BORDER * 2) + image_height;
}
if (width != NULL)
@@ -407,6 +412,11 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
return;
}
+ image_rect.width = gdk_pixbuf_get_width (pixbuf);
+ image_rect.height = gdk_pixbuf_get_height (pixbuf);
+ image_rect.x = thumb_rect.x + (thumb_rect.width - image_rect.width) * .5;
+ image_rect.y = thumb_rect.y + (thumb_rect.height - image_rect.height) * .5;
+
style = gtk_widget_get_style (widget);
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
@@ -414,7 +424,7 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
else
state = ((flags & GTK_CELL_RENDERER_FOCUSED) == GTK_CELL_RENDERER_FOCUSED) ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL;
- if (self->priv->is_icon || (state != GTK_STATE_NORMAL)) {
+ if (self->priv->is_icon || (state != GTK_STATE_NORMAL) || ((image_rect.width < self->priv->size) && (image_rect.height < self->priv->size))) {
int R = 7;
cr = gdk_cairo_create (window);
@@ -439,12 +449,7 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
cairo_destroy (cr);
}
- image_rect.width = gdk_pixbuf_get_width (pixbuf);
- image_rect.height = gdk_pixbuf_get_height (pixbuf);
- image_rect.x = thumb_rect.x + (thumb_rect.width - image_rect.width) * .5;
- image_rect.y = thumb_rect.y + (thumb_rect.height - image_rect.height) * .5;
-
- if (! self->priv->is_icon) {
+ if (! self->priv->is_icon && ! ((image_rect.width < self->priv->size) && (image_rect.height < self->priv->size))) {
GdkRectangle frame_rect;
if (! _g_mime_type_is_image (gth_file_data_get_mime_type (self->priv->file))) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]