[Xfce4-commits] <ristretto:stephan/icon-bar> Keep the thumbnails in memory for a while
Stephan Arts
noreply at xfce.org
Sun Feb 5 11:04:05 CET 2012
Updating branch refs/heads/stephan/icon-bar
to fcf14bf68694998111cc10caece5f502bcc1227f (commit)
from 77f1395f227ccfb96cb317d0dac80b3cac76f755 (commit)
commit fcf14bf68694998111cc10caece5f502bcc1227f
Author: Stephan Arts <stephan at xfce.org>
Date: Sun Feb 5 01:35:55 2012 +0100
Keep the thumbnails in memory for a while
src/file.c | 61 +++++++++
src/file.h | 6 +
src/icon_bar.c | 365 ++++++++++++++++++++++++++++-------------------------
src/icon_bar.h | 4 -
src/image_list.c | 235 ----------------------------------
src/main_window.c | 1 -
src/util.h | 9 ++
7 files changed, 268 insertions(+), 413 deletions(-)
diff --git a/src/file.c b/src/file.c
index f7ec265..13e5df3 100644
--- a/src/file.c
+++ b/src/file.c
@@ -20,6 +20,7 @@
#include <glib.h>
#include <gio/gio.h>
+#include <gtk/gtk.h>
#include <libexif/exif-data.h>
@@ -100,6 +101,9 @@ struct _RsttoFilePriv
gchar *uri;
gchar *path;
+ gchar *thumbnail_path;
+ GdkPixbuf *thumbnails[THUMBNAIL_SIZE_COUNT];
+
ExifData *exif_data;
RsttoImageOrientation orientation;
};
@@ -137,6 +141,7 @@ static void
rstto_file_dispose (GObject *object)
{
RsttoFile *file = RSTTO_FILE (object);
+ gint i = 0;
if (file->priv)
{
@@ -160,12 +165,26 @@ rstto_file_dispose (GObject *object)
g_free (file->priv->path);
file->priv->path = NULL;
}
+ if (file->priv->thumbnail_path)
+ {
+ g_free (file->priv->thumbnail_path);
+ file->priv->thumbnail_path = NULL;
+ }
if (file->priv->uri)
{
g_free (file->priv->uri);
file->priv->uri = NULL;
}
+ for (i = 0; i < THUMBNAIL_SIZE_COUNT; ++i)
+ {
+ if (file->priv->thumbnails[i])
+ {
+ g_object_unref (file->priv->thumbnails[i]);
+ file->priv->thumbnails[i] = NULL;
+ }
+ }
+
g_free (file->priv);
file->priv = NULL;
@@ -408,3 +427,45 @@ rstto_file_has_exif ( RsttoFile *file )
}
return TRUE;
}
+
+const gchar *
+rstto_file_get_thumbnail_path ( RsttoFile *file)
+{
+ const gchar *uri;
+ gchar *checksum;
+ gchar *filename;
+
+ if (NULL == file->priv->thumbnail_path)
+ {
+ uri = rstto_file_get_uri (file);
+ checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, strlen (uri));
+ filename = g_strconcat (checksum, ".png", NULL);
+
+ file->priv->thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
+
+ g_free (checksum);
+ g_free (filename);
+ }
+
+ return file->priv->thumbnail_path;
+}
+
+const GdkPixbuf *
+rstto_file_get_thumbnail ( RsttoFile *file , RsttoThumbnailSize size)
+{
+ const gchar *thumbnail_path;
+
+ if (file->priv->thumbnails[size])
+ return file->priv->thumbnails[size];
+
+ thumbnail_path = rstto_file_get_thumbnail_path (file);
+
+ file->priv->thumbnails[size] = gdk_pixbuf_new_from_file_at_scale (
+ thumbnail_path,
+ rstto_thumbnail_size[size],
+ rstto_thumbnail_size[size],
+ TRUE,
+ NULL);
+
+ return file->priv->thumbnails[size];
+}
diff --git a/src/file.h b/src/file.h
index 467813a..2a667b4 100644
--- a/src/file.h
+++ b/src/file.h
@@ -83,6 +83,12 @@ rstto_file_get_uri ( RsttoFile * );
const gchar *
rstto_file_get_content_type ( RsttoFile * );
+const gchar *
+rstto_file_get_thumbnail_path ( RsttoFile *);
+
+const GdkPixbuf *
+rstto_file_get_thumbnail ( RsttoFile *, RsttoThumbnailSize );
+
guint64
rstto_file_get_modified_time ( RsttoFile *);
diff --git a/src/icon_bar.c b/src/icon_bar.c
index f557d2b..573524d 100644
--- a/src/icon_bar.c
+++ b/src/icon_bar.c
@@ -33,6 +33,7 @@
#include "util.h"
#include "file.h"
+#include "settings.h"
#include "marshal.h"
#include "icon_bar.h"
@@ -94,7 +95,6 @@
#define RSTTO_ICON_BAR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), RSTTO_TYPE_ICON_BAR, RsttoIconBarPrivate))
#define RSTTO_ICON_BAR_VALID_MODEL_AND_COLUMNS(obj) ((obj)->priv->model != NULL && \
- (obj)->priv->pixbuf_column != -1 && \
(obj)->priv->file_column != -1)
@@ -105,7 +105,6 @@ enum
{
PROP_0,
PROP_ORIENTATION,
- PROP_PIXBUF_COLUMN,
PROP_FILE_COLUMN,
PROP_MODEL,
PROP_ACTIVE,
@@ -118,7 +117,7 @@ enum
LAST_SIGNAL,
};
-
+static GdkPixbuf *thumbnail_missing = NULL;
static void
rstto_icon_bar_destroy (GtkObject *object);
@@ -241,6 +240,16 @@ rstto_icon_bar_adjustment_value_changed (
RsttoIconBar *icon_bar,
GtkAdjustment *adjustment);
+static void
+cb_rstto_thumbnail_size_changed (
+ GObject *settings,
+ GParamSpec *pspec,
+ gpointer user_data);
+
+static void
+rstto_icon_bar_update_missing_icon (RsttoIconBar *icon_bar);
+
+
static RsttoIconBarItem *
rstto_icon_bar_item_new (void);
@@ -317,6 +326,10 @@ struct _RsttoIconBarPrivate
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
+ RsttoSettings *settings;
+
+ RsttoThumbnailSize thumbnail_size;
+
gboolean auto_center; /* automatically center the active item */
GtkOrientation orientation;
@@ -384,22 +397,6 @@ rstto_icon_bar_class_init (RsttoIconBarClass *klass)
G_PARAM_READWRITE));
/**
- * RsttoIconBar:pixbuf-column:
- *
- * The ::pixbuf-column property contains the number of the model column
- * containing the pixbufs which are displyed. The pixbuf column must be
- * of type #GDK_TYPE_PIXBUF. Setting this property to -1 turns off the
- * display of pixbufs.
- **/
- g_object_class_install_property (gobject_class,
- PROP_PIXBUF_COLUMN,
- g_param_spec_int ("pixbuf-column",
- _("Pixbuf column"),
- _("Model column used to retrieve the icon pixbuf from"),
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
-
- /**
* RsttoIconBar:file-column:
*
* The ::file-column property contains the number of the model column
@@ -552,6 +549,13 @@ rstto_icon_bar_init (RsttoIconBar *icon_bar)
icon_bar->priv->file_column = -1;
icon_bar->priv->show_text = TRUE;
icon_bar->priv->auto_center = TRUE;
+ icon_bar->priv->settings = rstto_settings_new ();
+
+ icon_bar->priv->thumbnail_size = rstto_settings_get_uint_property (
+ icon_bar->priv->settings,
+ "thumbnail-size");
+
+ rstto_icon_bar_update_missing_icon (icon_bar);
icon_bar->priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (icon_bar), NULL);
pango_layout_set_width (icon_bar->priv->layout, -1);
@@ -563,6 +567,13 @@ rstto_icon_bar_init (RsttoIconBar *icon_bar)
GTK_WIDGET_UNSET_FLAGS (icon_bar, GTK_CAN_FOCUS);
rstto_icon_bar_set_adjustments (icon_bar, NULL, NULL);
+
+ g_signal_connect (
+ G_OBJECT(icon_bar->priv->settings),
+ "notify::thumbnail-size",
+ G_CALLBACK (cb_rstto_thumbnail_size_changed),
+ icon_bar);
+
}
@@ -585,6 +596,7 @@ rstto_icon_bar_finalize (GObject *object)
RsttoIconBar *icon_bar = RSTTO_ICON_BAR (object);
g_object_unref (G_OBJECT (icon_bar->priv->layout));
+ g_object_unref (G_OBJECT (icon_bar->priv->settings));
(*G_OBJECT_CLASS (rstto_icon_bar_parent_class)->finalize) (object);
}
@@ -606,10 +618,6 @@ rstto_icon_bar_get_property (
g_value_set_enum (value, icon_bar->priv->orientation);
break;
- case PROP_PIXBUF_COLUMN:
- g_value_set_int (value, icon_bar->priv->pixbuf_column);
- break;
-
case PROP_FILE_COLUMN:
g_value_set_int (value, icon_bar->priv->file_column);
break;
@@ -649,10 +657,6 @@ rstto_icon_bar_set_property (
rstto_icon_bar_set_orientation (icon_bar, g_value_get_enum (value));
break;
- case PROP_PIXBUF_COLUMN:
- rstto_icon_bar_set_pixbuf_column (icon_bar, g_value_get_int (value));
- break;
-
case PROP_FILE_COLUMN:
rstto_icon_bar_set_file_column (icon_bar, g_value_get_int (value));
break;
@@ -1161,6 +1165,7 @@ static void
rstto_icon_bar_invalidate (RsttoIconBar *icon_bar)
{
g_list_foreach (icon_bar->priv->items, (GFunc) rstto_icon_bar_item_invalidate, NULL);
+
gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
}
@@ -1220,15 +1225,19 @@ rstto_icon_bar_paint_item (
RsttoIconBarItem *item,
GdkRectangle *area)
{
- GdkPixbuf *pixbuf;
- GdkColor *border_color;
- GdkColor *fill_color;
- GdkColor *text_color;
- GdkGC *gc;
- gint focus_width;
- gint focus_pad;
- gint x, y;
- gint px, py;
+ const GdkPixbuf *pixbuf = NULL;
+ GdkColor *border_color;
+ GdkColor *fill_color;
+ GdkColor *text_color;
+ GdkGC *gc;
+ gint focus_width;
+ gint focus_pad;
+ gint x, y;
+ gint px, py;
+ gint pixbuf_height, pixbuf_width;
+ const gchar *thumbnail_path;
+ RsttoFile *file;
+ GtkTreeIter iter;
if (!RSTTO_ICON_BAR_VALID_MODEL_AND_COLUMNS (icon_bar))
return;
@@ -1238,22 +1247,40 @@ rstto_icon_bar_paint_item (
"focus-padding", &focus_pad,
NULL);
+ iter = item->iter;
+ gtk_tree_model_get (icon_bar->priv->model, &iter,
+ icon_bar->priv->file_column, &file,
+ -1);
+
+ pixbuf = rstto_file_get_thumbnail (file, icon_bar->priv->thumbnail_size);
+
+ if (NULL == pixbuf)
+ {
+ pixbuf = thumbnail_missing;
+ }
+
+ if (pixbuf)
+ {
+ pixbuf_width = gdk_pixbuf_get_width (pixbuf);
+ pixbuf_height = gdk_pixbuf_get_height (pixbuf);
+ }
+
/* calculate pixbuf/layout location */
if (icon_bar->priv->orientation == GTK_ORIENTATION_VERTICAL)
{
x = 0;
y = icon_bar->priv->item_height * item->index;
- px = (icon_bar->priv->item_width - item->pixbuf_width) / 2;
- py = (icon_bar->priv->item_height - (item->pixbuf_height)) / 2 + icon_bar->priv->item_height * item->index;
+ px = (icon_bar->priv->item_width - pixbuf_width) / 2;
+ py = (icon_bar->priv->item_height - pixbuf_height) / 2 + icon_bar->priv->item_height * item->index;
}
else
{
x = icon_bar->priv->item_width * item->index;
y = 0;
- px = (icon_bar->priv->item_width - item->pixbuf_width) / 2 + icon_bar->priv->item_width * item->index;
- py = (icon_bar->priv->item_height - (item->pixbuf_height)) / 2;
+ px = (icon_bar->priv->item_width - pixbuf_width) / 2 + icon_bar->priv->item_width * item->index;
+ py = (icon_bar->priv->item_height - pixbuf_height) / 2;
}
if (icon_bar->priv->active_item == item)
@@ -1333,17 +1360,14 @@ rstto_icon_bar_paint_item (
g_object_unref (gc);
}
- if (icon_bar->priv->pixbuf_column != -1)
+
+ if (NULL != pixbuf)
{
- pixbuf = rstto_icon_bar_get_item_icon (icon_bar, item);
- if (G_LIKELY (pixbuf != NULL))
- {
- gdk_draw_pixbuf (icon_bar->priv->bin_window, NULL, pixbuf, 0, 0,
- px, py, item->pixbuf_width, item->pixbuf_height,
- GDK_RGB_DITHER_NORMAL, item->pixbuf_width,
- item->pixbuf_height);
- g_object_unref (pixbuf);
- }
+ gdk_draw_pixbuf (icon_bar->priv->bin_window, NULL, pixbuf, 0, 0,
+ px, py,
+ pixbuf_width, pixbuf_height,
+ GDK_RGB_DITHER_NORMAL,
+ pixbuf_width, pixbuf_height);
}
}
@@ -1368,67 +1392,34 @@ rstto_icon_bar_calculate_item_size (
NULL);
int_pad = focus_pad;
- if (icon_bar->priv->pixbuf_column != -1)
- {
- pixbuf = rstto_icon_bar_get_item_icon (icon_bar, item);
- if (G_LIKELY (pixbuf != NULL))
- {
- item->pixbuf_width = gdk_pixbuf_get_width (pixbuf);
- item->pixbuf_height = gdk_pixbuf_get_height (pixbuf);
- g_object_unref (G_OBJECT (pixbuf));
- }
- else
- {
- item->pixbuf_width = 0;
- item->pixbuf_height = 0;
- }
- }
- else
- {
- item->pixbuf_width = 0;
- item->pixbuf_height = 0;
- }
-
- item->width = item->pixbuf_width + 2 * (int_pad + focus_width + focus_pad);
- item->height = item->pixbuf_height + 2 * (int_pad + focus_width + focus_pad );
-
-
- if (item->width < item->height)
+ switch (icon_bar->priv->thumbnail_size)
{
- item->width = item->height;
- }
-
-}
-
-static GdkPixbuf *
-rstto_icon_bar_get_item_icon (
- RsttoIconBar *icon_bar,
- RsttoIconBarItem *item)
-{
- GtkTreePath *path;
- GtkTreeIter iter;
- GdkPixbuf *pixbuf;
-
- if ((gtk_tree_model_get_flags (icon_bar->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST) == 0)
- {
- path = gtk_tree_path_new_from_indices (item->index, -1);
- gtk_tree_model_get_iter (icon_bar->priv->model, &iter, path);
- gtk_tree_path_free (path);
- }
- else
- {
- iter = item->iter;
+ case THUMBNAIL_SIZE_VERY_SMALL:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_VERY_SMALL_SIZE;
+ break;
+ case THUMBNAIL_SIZE_SMALLER:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_SMALLER_SIZE;
+ break;
+ case THUMBNAIL_SIZE_SMALL:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_SMALL_SIZE;
+ break;
+ case THUMBNAIL_SIZE_NORMAL:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_NORMAL_SIZE;
+ break;
+ case THUMBNAIL_SIZE_LARGE:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_LARGE_SIZE;
+ break;
+ case THUMBNAIL_SIZE_LARGER:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_LARGER_SIZE;
+ break;
+ case THUMBNAIL_SIZE_VERY_LARGE:
+ item->width = (2 * (int_pad + focus_width + focus_pad)) + THUMBNAIL_SIZE_VERY_LARGE_SIZE;
+ break;
}
- gtk_tree_model_get (icon_bar->priv->model, &iter,
- icon_bar->priv->pixbuf_column, &pixbuf,
- -1);
-
- return pixbuf;
+ item->height = item->width;
}
-
-
static RsttoIconBarItem *
rstto_icon_bar_item_new (void)
{
@@ -1695,7 +1686,6 @@ rstto_icon_bar_set_model (
RsttoIconBar *icon_bar,
GtkTreeModel *model)
{
- GType pixbuf_column_type;
GType file_column_type;
gint active = -1;
@@ -1709,12 +1699,6 @@ rstto_icon_bar_set_model (
{
g_return_if_fail (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_LIST_ONLY);
- if (icon_bar->priv->pixbuf_column != -1)
- {
- pixbuf_column_type = gtk_tree_model_get_column_type (model, icon_bar->priv->pixbuf_column);
- g_return_if_fail (pixbuf_column_type == GDK_TYPE_PIXBUF);
- }
-
if (icon_bar->priv->file_column != -1)
{
file_column_type = gtk_tree_model_get_column_type (model, icon_bar->priv->file_column);
@@ -1775,66 +1759,6 @@ rstto_icon_bar_set_model (
}
-
-/**
- * rstto_icon_bar_get_pixbuf_column:
- * @icon_bar : An #RsttoIconBar.
- *
- * Returns the column with pixbufs for @icon_bar.
- *
- * Returns: the pixbuf column, or -1 if it's unset.
- **/
-gint
-rstto_icon_bar_get_pixbuf_column (RsttoIconBar *icon_bar)
-{
- g_return_val_if_fail (RSTTO_IS_ICON_BAR (icon_bar), -1);
- return icon_bar->priv->pixbuf_column;
-}
-
-
-
-/**
- * rstto_icon_bar_set_pixbuf_column:
- * @icon_bar : An #RsttoIconBar.
- * @column : A column in the currently used model.
- *
- * Sets the column with pixbufs for @icon_bar to be @column. The pixbuf
- * column must be of type #GDK_TYPE_PIXBUF.
- **/
-void
-rstto_icon_bar_set_pixbuf_column (
- RsttoIconBar *icon_bar,
- gint column)
-{
- GType pixbuf_column_type;
-
- g_return_if_fail (RSTTO_IS_ICON_BAR (icon_bar));
-
- if (column == icon_bar->priv->pixbuf_column)
- return;
-
- if (column == -1)
- {
- icon_bar->priv->pixbuf_column = -1;
- }
- else
- {
- if (icon_bar->priv->model != NULL)
- {
- pixbuf_column_type = gtk_tree_model_get_column_type (icon_bar->priv->model, column);
- g_return_if_fail (pixbuf_column_type == GDK_TYPE_PIXBUF);
- }
-
- icon_bar->priv->pixbuf_column = column;
- }
-
- rstto_icon_bar_invalidate (icon_bar);
-
- g_object_notify (G_OBJECT (icon_bar), "pixbuf-column");
-}
-
-
-
/**
* rstto_icon_bar_get_file_column:
* @icon_bar : An #RsttoIconBar.
@@ -2194,3 +2118,98 @@ rstto_icon_bar_adjustment_value_changed (
gtk_adjustment_value_changed (adjustment);
}
}
+
+static void
+cb_rstto_thumbnail_size_changed (
+ GObject *settings,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GValue val_thumbnail_size = { 0, };
+ RsttoIconBar *icon_bar = RSTTO_ICON_BAR (user_data);
+
+ g_value_init (&val_thumbnail_size, G_TYPE_UINT);
+
+ g_object_get_property (
+ settings,
+ "thumbnail-size",
+ &val_thumbnail_size);
+
+ icon_bar->priv->thumbnail_size = g_value_get_uint (&val_thumbnail_size);
+
+ rstto_icon_bar_invalidate (icon_bar);
+
+ rstto_icon_bar_update_missing_icon (icon_bar);
+}
+
+
+static void
+rstto_icon_bar_update_missing_icon (RsttoIconBar *icon_bar)
+{
+
+ if (NULL != thumbnail_missing)
+ {
+ g_object_unref (thumbnail_missing);
+ }
+
+ switch (icon_bar->priv->thumbnail_size)
+ {
+ case THUMBNAIL_SIZE_VERY_SMALL:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_VERY_SMALL_SIZE,
+ 0,
+ NULL);
+ break;
+ case THUMBNAIL_SIZE_SMALLER:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_SMALLER_SIZE,
+ 0,
+ NULL);
+ break;
+ case THUMBNAIL_SIZE_SMALL:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_SMALL_SIZE,
+ 0,
+ NULL);
+ break;
+ case THUMBNAIL_SIZE_NORMAL:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_NORMAL_SIZE,
+ 0,
+ NULL);
+ break;
+ case THUMBNAIL_SIZE_LARGE:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_LARGE_SIZE,
+ 0,
+ NULL);
+ break;
+ case THUMBNAIL_SIZE_LARGER:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_LARGER_SIZE,
+ 0,
+ NULL);
+ break;
+ case THUMBNAIL_SIZE_VERY_LARGE:
+ thumbnail_missing = gtk_icon_theme_load_icon (
+ gtk_icon_theme_get_default(),
+ "image-missing",
+ THUMBNAIL_SIZE_VERY_LARGE_SIZE,
+ 0,
+ NULL);
+ break;
+ }
+
+}
diff --git a/src/icon_bar.h b/src/icon_bar.h
index aed7118..5f846a7 100644
--- a/src/icon_bar.h
+++ b/src/icon_bar.h
@@ -83,10 +83,6 @@ GtkTreeModel *rstto_icon_bar_get_model (RsttoIconBar *icon_bar);
void rstto_icon_bar_set_model (RsttoIconBar *icon_bar,
GtkTreeModel *model);
-gint rstto_icon_bar_get_pixbuf_column (RsttoIconBar *icon_bar);
-void rstto_icon_bar_set_pixbuf_column (RsttoIconBar *icon_bar,
- gint column);
-
gint rstto_icon_bar_get_file_column (RsttoIconBar *icon_bar);
void rstto_icon_bar_set_file_column (RsttoIconBar *icon_bar,
gint column);
diff --git a/src/image_list.c b/src/image_list.c
index f451aa2..e29db5e 100644
--- a/src/image_list.c
+++ b/src/image_list.c
@@ -66,11 +66,6 @@ cb_rstto_wrap_images_changed (
GObject *settings,
GParamSpec *pspec,
gpointer user_data);
-static void
-cb_rstto_thumbnail_size_changed (
- GObject *settings,
- GParamSpec *pspec,
- gpointer user_data);
static void
rstto_image_list_monitor_dir (
@@ -78,10 +73,6 @@ rstto_image_list_monitor_dir (
GFile *dir );
static void
-rstto_image_list_update_missing_icon (
- RsttoImageList *image_list);
-
-static void
rstto_image_list_remove_all (
RsttoImageList *image_list);
@@ -220,8 +211,6 @@ struct _RsttoImageListPriv
GList *images;
gint n_images;
- RsttoThumbnailSize thumbnail_size;
-
GSList *iterators;
GCompareFunc cb_rstto_image_list_compare_func;
@@ -320,11 +309,6 @@ rstto_image_list_init(RsttoImageList *image_list)
image_list->priv->wrap_images = rstto_settings_get_boolean_property (
image_list->priv->settings,
"wrap-images");
- image_list->priv->thumbnail_size = rstto_settings_get_uint_property (
- image_list->priv->settings,
- "thumbnail-size");
-
- rstto_image_list_update_missing_icon (image_list);
g_signal_connect (
G_OBJECT(image_list->priv->settings),
@@ -332,12 +316,6 @@ rstto_image_list_init(RsttoImageList *image_list)
G_CALLBACK (cb_rstto_wrap_images_changed),
image_list);
- g_signal_connect (
- G_OBJECT(image_list->priv->settings),
- "notify::thumbnail-size",
- G_CALLBACK (cb_rstto_thumbnail_size_changed),
- image_list);
-
}
static void
@@ -1232,47 +1210,6 @@ cb_rstto_wrap_images_changed (
image_list->priv->wrap_images = g_value_get_boolean (&val_wrap_images);
}
-static void
-cb_rstto_thumbnail_size_changed (
- GObject *settings,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GValue val_thumbnail_size = { 0, };
- RsttoImageList *image_list = RSTTO_IMAGE_LIST (user_data);
- GList *image_iter = image_list->priv->images;
- gint i = 0;
- GtkTreePath *path_ = NULL;
- GtkTreeIter iter;
-
- g_value_init (&val_thumbnail_size, G_TYPE_UINT);
-
- g_object_get_property (
- settings,
- "thumbnail-size",
- &val_thumbnail_size);
-
- image_list->priv->thumbnail_size = g_value_get_uint (&val_thumbnail_size);
-
-
- rstto_image_list_update_missing_icon (image_list);
-
- while (image_iter)
- {
- path_ = gtk_tree_path_new();
- gtk_tree_path_append_index(path_, i);
-
- iter.stamp = image_list->priv->stamp;
- iter.user_data = image_iter->data;
- iter.user_data3 = GINT_TO_POINTER (i);
-
- gtk_tree_model_row_changed(GTK_TREE_MODEL(image_list), path_, &iter);
-
- i++;
- image_iter = g_list_next (image_iter);
- }
-}
-
/***************************************/
/* TreeModelIface Functions */
/***************************************/
@@ -1480,11 +1417,6 @@ image_list_model_get_value (
{
RsttoImageList *image_list = RSTTO_IMAGE_LIST (tree_model);
RsttoFile *file = RSTTO_FILE(iter->user_data);
- const gchar *uri = NULL;
- gchar *checksum = NULL;
- gchar *thumbnail_path = NULL;
- gchar *filename = NULL;
- GdkPixbuf *thumbnail = NULL;
switch (column)
{
@@ -1492,172 +1424,5 @@ image_list_model_get_value (
g_value_init (value, RSTTO_TYPE_FILE);
g_value_set_object (value, file);
break;
- case 1:
- uri = rstto_file_get_uri (file);
- checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, strlen (uri));
- filename = g_strconcat (checksum, ".png", NULL);
- thumbnail_path = g_build_path ("/", g_get_home_dir(), ".thumbnails", "normal", filename, NULL);
-
- g_value_init (value, GDK_TYPE_PIXBUF);
- /*
- * TINY: 32x32
- * SMALL: 48x48
- * NORMAL: 64x64
- * LARGE: 96x96
- * HUGE: 128x128
- * INSANE: 256x256
- */
- switch (image_list->priv->thumbnail_size)
- {
- case THUMBNAIL_SIZE_VERY_SMALL:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_VERY_SMALL_SIZE,
- THUMBNAIL_SIZE_VERY_SMALL_SIZE,
- TRUE,
- NULL);
- break;
- case THUMBNAIL_SIZE_SMALLER:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_SMALLER_SIZE,
- THUMBNAIL_SIZE_SMALLER_SIZE,
- TRUE,
- NULL);
- break;
- case THUMBNAIL_SIZE_SMALL:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_SMALL_SIZE,
- THUMBNAIL_SIZE_SMALL_SIZE,
- TRUE,
- NULL);
- break;
- case THUMBNAIL_SIZE_NORMAL:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_NORMAL_SIZE,
- THUMBNAIL_SIZE_NORMAL_SIZE,
- TRUE,
- NULL);
- break;
- case THUMBNAIL_SIZE_LARGE:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_LARGE_SIZE,
- THUMBNAIL_SIZE_LARGE_SIZE,
- TRUE,
- NULL);
- break;
- case THUMBNAIL_SIZE_LARGER:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_LARGER_SIZE,
- THUMBNAIL_SIZE_LARGER_SIZE,
- TRUE,
- NULL);
- break;
- case THUMBNAIL_SIZE_VERY_LARGE:
- thumbnail = gdk_pixbuf_new_from_file_at_scale (
- thumbnail_path,
- THUMBNAIL_SIZE_VERY_LARGE_SIZE,
- THUMBNAIL_SIZE_VERY_LARGE_SIZE,
- TRUE,
- NULL);
- break;
- }
-
- /* If we have a thumbnail, pass it on.
- * If not, ask tumbler for one.
- */
- if (G_LIKELY (NULL != thumbnail))
- {
- g_value_take_object (
- value,
- thumbnail);
- }
- else
- {
- g_value_set_object (
- value,
- thumbnail_missing);
- }
-
- g_free (checksum);
- g_free (filename);
- g_free (thumbnail_path);
- break;
}
}
-
-static void
-rstto_image_list_update_missing_icon (
- RsttoImageList *image_list)
-{
-
- if (NULL != thumbnail_missing)
- {
- g_object_unref (thumbnail_missing);
- }
-
- switch (image_list->priv->thumbnail_size)
- {
- case THUMBNAIL_SIZE_VERY_SMALL:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_VERY_SMALL_SIZE,
- 0,
- NULL);
- break;
- case THUMBNAIL_SIZE_SMALLER:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_SMALLER_SIZE,
- 0,
- NULL);
- break;
- case THUMBNAIL_SIZE_SMALL:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_SMALL_SIZE,
- 0,
- NULL);
- break;
- case THUMBNAIL_SIZE_NORMAL:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_NORMAL_SIZE,
- 0,
- NULL);
- break;
- case THUMBNAIL_SIZE_LARGE:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_LARGE_SIZE,
- 0,
- NULL);
- break;
- case THUMBNAIL_SIZE_LARGER:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_LARGER_SIZE,
- 0,
- NULL);
- break;
- case THUMBNAIL_SIZE_VERY_LARGE:
- thumbnail_missing = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default(),
- "image-missing",
- THUMBNAIL_SIZE_VERY_LARGE_SIZE,
- 0,
- NULL);
- break;
- }
-
-}
diff --git a/src/main_window.c b/src/main_window.c
index 03d1bbc..c615325 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -655,7 +655,6 @@ rstto_main_window_init (RsttoMainWindow *window)
gtk_container_add (GTK_CONTAINER (window->priv->t_bar_s_window), window->priv->thumbnailbar);
rstto_icon_bar_set_file_column (RSTTO_ICON_BAR (window->priv->thumbnailbar), 0);
- rstto_icon_bar_set_pixbuf_column (RSTTO_ICON_BAR (window->priv->thumbnailbar), 1);
rstto_icon_bar_set_item_width (RSTTO_ICON_BAR (window->priv->thumbnailbar), 96);
window->priv->table = gtk_table_new (5, 5, FALSE);
diff --git a/src/util.h b/src/util.h
index ecb76a7..e815e26 100644
--- a/src/util.h
+++ b/src/util.h
@@ -58,6 +58,15 @@ typedef enum {
THUMBNAIL_SIZE_COUNT,
} RsttoThumbnailSize;
+static guint rstto_thumbnail_size[] = {
+ 24,
+ 32,
+ 48,
+ 64,
+ 96,
+ 128,
+ 256};
+
#define THUMBNAIL_SIZE_VERY_SMALL_SIZE 24
#define THUMBNAIL_SIZE_SMALLER_SIZE 32
#define THUMBNAIL_SIZE_SMALL_SIZE 48
More information about the Xfce4-commits
mailing list