[gthumb: 4/20] added a GTH_FILE_LIST_TYPE_THUMBNAIL type
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 4/20] added a GTH_FILE_LIST_TYPE_THUMBNAIL type
- Date: Tue, 30 Mar 2010 19:32:28 +0000 (UTC)
commit e33aa1b967e57edec2334745b2e9ccd021daaadc
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Mar 28 14:31:09 2010 +0200
added a GTH_FILE_LIST_TYPE_THUMBNAIL type
the new type has special settings like single file selection and a fixed
thumbnail size.
gthumb/gth-cell-renderer-thumbnail.c | 24 +++++++++++++++++++++---
gthumb/gth-file-list.c | 3 +++
gthumb/gth-file-list.h | 3 ++-
3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/gthumb/gth-cell-renderer-thumbnail.c b/gthumb/gth-cell-renderer-thumbnail.c
index 6ba673d..d821dfe 100644
--- a/gthumb/gth-cell-renderer-thumbnail.c
+++ b/gthumb/gth-cell-renderer-thumbnail.c
@@ -41,7 +41,8 @@ enum {
PROP_THUMBNAIL,
PROP_CHECKED,
PROP_SELECTED,
- PROP_FILE
+ PROP_FILE,
+ PROP_FIXED_SIZE
};
@@ -53,6 +54,7 @@ struct _GthCellRendererThumbnailPrivate
GthFileData *file;
gboolean checked;
gboolean selected;
+ gboolean fixed_size;
};
@@ -106,6 +108,9 @@ gth_cell_renderer_thumbnail_get_property (GObject *object,
case PROP_SELECTED:
g_value_set_boolean (value, self->priv->selected);
break;
+ case PROP_FIXED_SIZE:
+ g_value_set_boolean (value, self->priv->fixed_size);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -142,6 +147,9 @@ gth_cell_renderer_thumbnail_set_property (GObject *object,
case PROP_SELECTED:
self->priv->selected = g_value_get_boolean (value);
break;
+ case PROP_FIXED_SIZE:
+ self->priv->fixed_size = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -175,7 +183,7 @@ gth_cell_renderer_thumbnail_get_size (GtkCellRenderer *cell,
image_height = 0;
}
- if (self->priv->is_icon || (self->priv->thumbnail == NULL) || ((image_width < self->priv->size) && (image_height < self->priv->size))) {
+ if (self->priv->is_icon || self->priv->fixed_size || (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;
}
@@ -315,7 +323,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) || ((image_rect.width < self->priv->size) && (image_rect.height < self->priv->size))) {
+ if (self->priv->is_icon /*|| (state != GTK_STATE_NORMAL) FIXME */ || ((image_rect.width < self->priv->size) && (image_rect.height < self->priv->size))) {
int R = 7;
if (state == GTK_STATE_NORMAL)
@@ -338,6 +346,9 @@ gth_cell_renderer_thumbnail_render (GtkCellRenderer *cell,
if (! self->priv->is_icon && ! ((image_rect.width < self->priv->size) && (image_rect.height < self->priv->size))) {
GdkRectangle frame_rect;
+ if (state == GTK_STATE_ACTIVE)
+ state = GTK_STATE_SELECTED;
+
if (! _g_mime_type_is_image (gth_file_data_get_mime_type (self->priv->file))) {
B = 1;
frame_rect = image_rect;
@@ -491,6 +502,13 @@ gth_cell_renderer_thumbnail_class_init (GthCellRendererThumbnailClass *klass)
"Whether the image has been selected by the user",
FALSE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_FIXED_SIZE,
+ g_param_spec_boolean ("fixed-size",
+ "Fixed size",
+ "Whether to always use the maximum size for width and height",
+ FALSE,
+ G_PARAM_READWRITE));
}
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 0caa0a5..295c0b3 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -577,6 +577,8 @@ gth_file_list_construct (GthFileList *file_list,
if ((file_list->priv->type == GTH_FILE_LIST_TYPE_SELECTOR) || (file_list->priv->type == GTH_FILE_LIST_TYPE_NO_SELECTION))
gth_file_selection_set_selection_mode (GTH_FILE_SELECTION (file_list->priv->view), GTK_SELECTION_NONE);
+ else if (file_list->priv->type == GTH_FILE_LIST_TYPE_THUMBNAIL)
+ gth_file_selection_set_selection_mode (GTH_FILE_SELECTION (file_list->priv->view), GTK_SELECTION_SINGLE);
else
gth_file_selection_set_selection_mode (GTH_FILE_SELECTION (file_list->priv->view), GTK_SELECTION_MULTIPLE);
@@ -620,6 +622,7 @@ gth_file_list_construct (GthFileList *file_list,
g_object_set (renderer,
"size", file_list->priv->thumb_size,
"yalign", 1.0,
+ "fixed_size", (file_list->priv->type == GTH_FILE_LIST_TYPE_THUMBNAIL), /* FIXME */
NULL);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (file_list->priv->view), renderer, FALSE);
diff --git a/gthumb/gth-file-list.h b/gthumb/gth-file-list.h
index 3c6454a..353d626 100644
--- a/gthumb/gth-file-list.h
+++ b/gthumb/gth-file-list.h
@@ -36,7 +36,8 @@ typedef enum {
GTH_FILE_LIST_TYPE_NORMAL,
GTH_FILE_LIST_TYPE_BROWSER,
GTH_FILE_LIST_TYPE_SELECTOR,
- GTH_FILE_LIST_TYPE_NO_SELECTION
+ GTH_FILE_LIST_TYPE_NO_SELECTION,
+ GTH_FILE_LIST_TYPE_THUMBNAIL,
} GthFileListType;
#define GTH_TYPE_FILE_LIST (gth_file_list_get_type ())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]