Commit e76a587d authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

libgimpthumb/Makefile.am libgimpthumb/gimpthumb-enums.h

2003-11-26  Sven Neumann  <sven@gimp.org>

	* libgimpthumb/Makefile.am
	* libgimpthumb/gimpthumb-enums.h
	* libgimpthumb/gimpthumb-utils.[ch]
	* libgimpthumb/gimpthumbnail.[ch]: more changes, still unfinished.
parent c97d090d
2003-11-26 Sven Neumann <sven@gimp.org>
* libgimpthumb/Makefile.am
* libgimpthumb/gimpthumb-enums.h
* libgimpthumb/gimpthumb-utils.[ch]
* libgimpthumb/gimpthumbnail.[ch]: more changes, still unfinished.
2003-11-26 Michael Natterer <mitch@gimp.org> 2003-11-26 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.[ch]: eek, it should be * app/core/core-enums.[ch]: eek, it should be
...@@ -23,6 +23,7 @@ Enums and definitions. ...@@ -23,6 +23,7 @@ Enums and definitions.
@GIMP_ADD_WHITE_MASK: @GIMP_ADD_WHITE_MASK:
@GIMP_ADD_BLACK_MASK: @GIMP_ADD_BLACK_MASK:
@GIMP_ADD_ALPHA_MASK: @GIMP_ADD_ALPHA_MASK:
@GIMP_ADD_ALPHA_TRANSFER_MASK:
@GIMP_ADD_SELECTION_MASK: @GIMP_ADD_SELECTION_MASK:
@GIMP_ADD_COPY_MASK: @GIMP_ADD_COPY_MASK:
......
...@@ -68,6 +68,7 @@ libgimpthumbinclude_HEADERS = \ ...@@ -68,6 +68,7 @@ libgimpthumbinclude_HEADERS = \
gimpthumb.h \ gimpthumb.h \
gimpthumb-enums.h \ gimpthumb-enums.h \
gimpthumb-types.h \ gimpthumb-types.h \
gimpthumb-utils.h \
gimpthumbnail.h gimpthumbnail.h
libgimpthumb_1_3_la_LDFLAGS = \ libgimpthumb_1_3_la_LDFLAGS = \
......
...@@ -49,11 +49,9 @@ typedef enum ...@@ -49,11 +49,9 @@ typedef enum
GIMP_THUMB_STATE_REMOTE, GIMP_THUMB_STATE_REMOTE,
GIMP_THUMB_STATE_NOT_FOUND, GIMP_THUMB_STATE_NOT_FOUND,
GIMP_THUMB_STATE_EXISTS, GIMP_THUMB_STATE_EXISTS,
GIMP_THUMB_STATE_THUMBNAIL_NOT_FOUND, GIMP_THUMB_STATE_OLD,
GIMP_THUMB_STATE_THUMBNAIL_EXISTS, GIMP_THUMB_STATE_FAILED,
GIMP_THUMB_STATE_THUMBNAIL_OLD, GIMP_THUMB_STATE_OK
GIMP_THUMB_STATE_THUMBNAIL_FAILED,
GIMP_THUMB_STATE_THUMBNAIL_OK
} GimpThumbState; } GimpThumbState;
......
...@@ -150,8 +150,8 @@ gimp_thumb_png_thumb_name (const gchar *uri, ...@@ -150,8 +150,8 @@ gimp_thumb_png_thumb_name (const gchar *uri,
} }
gchar * gchar *
gimp_thumbnail_find_png_thumb (const gchar *uri, gimp_thumb_find_png_thumb (const gchar *uri,
GimpThumbSize *size) GimpThumbSize *size)
{ {
const gchar *name; const gchar *name;
gchar *thumb_name; gchar *thumb_name;
......
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
G_BEGIN_DECLS G_BEGIN_DECLS
gboolean gimp_thumb_init (const gchar *creator, gboolean gimp_thumb_init (const gchar *creator,
const gchar *thumb_basedir); const gchar *thumb_basedir);
gchar * gimp_thumb_png_thumb_name (const gchar *uri, gchar * gimp_thumb_png_thumb_name (const gchar *uri,
GimpThumbSize *size); GimpThumbSize *size);
gchar * gimp_thumbnail_find_png_thumb (const gchar *uri, gchar * gimp_thumb_find_png_thumb (const gchar *uri,
GimpThumbSize *size); GimpThumbSize *size);
gboolean gimp_thumb_file_test (const gchar *filename, gboolean gimp_thumb_file_test (const gchar *filename,
gint64 *mtime, gint64 *mtime,
gint64 *size); gint64 *size);
G_END_DECLS G_END_DECLS
......
...@@ -38,45 +38,50 @@ ...@@ -38,45 +38,50 @@
#include "gimpthumbnail.h" #include "gimpthumbnail.h"
#define TAG_DESCRIPTION "tEXt::Description" #define TAG_DESCRIPTION "tEXt::Description"
#define TAG_SOFTWARE "tEXt::Software" #define TAG_SOFTWARE "tEXt::Software"
#define TAG_THUMB_URI "tEXt::Thumb::URI" #define TAG_THUMB_URI "tEXt::Thumb::URI"
#define TAG_THUMB_MTIME "tEXt::Thumb::MTime" #define TAG_THUMB_MTIME "tEXt::Thumb::MTime"
#define TAG_THUMB_FILESIZE "tEXt::Thumb::Size" #define TAG_THUMB_FILESIZE "tEXt::Thumb::Size"
#define TAG_THUMB_IMAGE_WIDTH "tEXt::Thumb::Image::Width" #define TAG_THUMB_IMAGE_WIDTH "tEXt::Thumb::Image::Width"
#define TAG_THUMB_IMAGE_HEIGHT "tEXt::Thumb::Image::Height" #define TAG_THUMB_IMAGE_HEIGHT "tEXt::Thumb::Image::Height"
#define TAG_THUMB_GIMP_TYPE "tEXt::Thumb::X-GIMP::Type" #define TAG_THUMB_GIMP_TYPE "tEXt::Thumb::X-GIMP::Type"
#define TAG_THUMB_GIMP_LAYERS "tEXt::Thumb::X-GIMP::Layers" #define TAG_THUMB_GIMP_LAYERS "tEXt::Thumb::X-GIMP::Layers"
enum enum
{ {
PROP_0, PROP_0,
PROP_URI, PROP_IMAGE_STATE,
PROP_STATE, PROP_IMAGE_URI,
PROP_MTIME, PROP_IMAGE_MTIME,
PROP_FILESIZE, PROP_IMAGE_FILESIZE,
PROP_WIDTH, PROP_IMAGE_WIDTH,
PROP_HEIGHT, PROP_IMAGE_HEIGHT,
PROP_TYPE, PROP_IMAGE_TYPE,
PROP_NUM_LAYERS PROP_IMAGE_NUM_LAYERS,
PROP_THUMB_STATE
}; };
static void gimp_thumbnail_class_init (GimpThumbnailClass *klass); static void gimp_thumbnail_class_init (GimpThumbnailClass *klass);
static void gimp_thumbnail_init (GimpThumbnail *thumbnail); static void gimp_thumbnail_init (GimpThumbnail *thumbnail);
static void gimp_thumbnail_finalize (GObject *object); static void gimp_thumbnail_finalize (GObject *object);
static void gimp_thumbnail_set_property (GObject *object, static void gimp_thumbnail_set_property (GObject *object,
guint property_id, guint property_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_thumbnail_get_property (GObject *object, static void gimp_thumbnail_get_property (GObject *object,
guint property_id, guint property_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_thumbnail_reset_info (GimpThumbnail *thumbnail); static void gimp_thumbnail_invalidate_thumb (GimpThumbnail *thumbnail);
static void gimp_thumbnail_reset_info (GimpThumbnail *thumbnail);
static GdkPixbuf * gimp_thumbnail_read_png_thumb (GimpThumbnail *thumbnail, static void gimp_thumbnail_update_image (GimpThumbnail *thumbnail);
static void gimp_thumbnail_update_thumb (GimpThumbnail *thumbnail);
static GdkPixbuf * gimp_thumbnail_read_png_thumb (GimpThumbnail *thumbnail,
GimpThumbSize thumb_size, GimpThumbSize thumb_size,
GError **error); GError **error);
...@@ -126,74 +131,80 @@ gimp_thumbnail_class_init (GimpThumbnailClass *klass) ...@@ -126,74 +131,80 @@ gimp_thumbnail_class_init (GimpThumbnailClass *klass)
object_class->get_property = gimp_thumbnail_get_property; object_class->get_property = gimp_thumbnail_get_property;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_URI, PROP_IMAGE_STATE,
g_param_spec_string ("uri", NULL, g_param_spec_enum ("image-state", NULL,
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_STATE,
g_param_spec_enum ("state", NULL,
NULL, NULL,
GIMP_TYPE_THUMB_STATE, GIMP_TYPE_THUMB_STATE,
GIMP_THUMB_STATE_UNKNOWN, GIMP_THUMB_STATE_UNKNOWN,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_MTIME, PROP_IMAGE_URI,
g_param_spec_string ("image-uri", NULL,
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_IMAGE_MTIME,
g_param_spec_int64 ("image-mtime", NULL, g_param_spec_int64 ("image-mtime", NULL,
NULL, NULL,
0, G_MAXINT64, 0, 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_FILESIZE, PROP_IMAGE_FILESIZE,
g_param_spec_int64 ("image-filesize", NULL, g_param_spec_int64 ("image-filesize", NULL,
NULL, NULL,
0, G_MAXINT64, 0, 0, G_MAXINT64, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_WIDTH, PROP_IMAGE_WIDTH,
g_param_spec_int ("image-width", NULL, g_param_spec_int ("image-width", NULL,
NULL, NULL,
0, G_MAXINT, 0, 0, G_MAXINT, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_HEIGHT, PROP_IMAGE_HEIGHT,
g_param_spec_int ("image-height", NULL, g_param_spec_int ("image-height", NULL,
NULL, NULL,
0, G_MAXINT, 0, 0, G_MAXINT, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_TYPE, PROP_IMAGE_TYPE,
g_param_spec_string ("image-type", NULL, g_param_spec_string ("image-type", NULL,
NULL, NULL,
NULL, NULL,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_TYPE, PROP_IMAGE_NUM_LAYERS,
g_param_spec_int ("image-num-layers", NULL, g_param_spec_int ("image-num-layers", NULL,
NULL, NULL,
0, G_MAXINT, 0, 0, G_MAXINT, 0,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_THUMB_STATE,
g_param_spec_enum ("thumb-state", NULL,
NULL,
GIMP_TYPE_THUMB_STATE,
GIMP_THUMB_STATE_UNKNOWN,
G_PARAM_READWRITE));
} }
static void static void
gimp_thumbnail_init (GimpThumbnail *thumbnail) gimp_thumbnail_init (GimpThumbnail *thumbnail)
{ {
thumbnail->uri = NULL; thumbnail->image_state = GIMP_THUMB_STATE_UNKNOWN;
thumbnail->state = GIMP_THUMB_STATE_UNKNOWN; thumbnail->image_uri = NULL;
thumbnail->thumb_filename = NULL;
thumbnail->thumb_mtime = 0;
thumbnail->thumb_filesize = 0;
thumbnail->image_filename = NULL; thumbnail->image_filename = NULL;
thumbnail->image_mtime = 0; thumbnail->image_mtime = 0;
thumbnail->image_filesize = 0; thumbnail->image_filesize = 0;
thumbnail->image_width = 0; thumbnail->image_width = 0;
thumbnail->image_height = 0; thumbnail->image_height = 0;
thumbnail->image_type = 0; thumbnail->image_type = 0;
thumbnail->image_num_layers = 0; thumbnail->image_num_layers = 0;
thumbnail->thumb_state = GIMP_THUMB_STATE_UNKNOWN;
thumbnail->thumb_filename = NULL;
thumbnail->thumb_mtime = 0;
thumbnail->thumb_filesize = 0;
} }
static void static void
...@@ -201,15 +212,10 @@ gimp_thumbnail_finalize (GObject *object) ...@@ -201,15 +212,10 @@ gimp_thumbnail_finalize (GObject *object)
{ {
GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object); GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object);
if (thumbnail->uri) if (thumbnail->image_uri)
{
g_free (thumbnail->uri);
thumbnail->uri = NULL;
}
if (thumbnail->thumb_filename)
{ {
g_free (thumbnail->thumb_filename); g_free (thumbnail->image_uri);
thumbnail->thumb_filename = NULL; thumbnail->image_uri = NULL;
} }
if (thumbnail->image_filename) if (thumbnail->image_filename)
{ {
...@@ -221,6 +227,11 @@ gimp_thumbnail_finalize (GObject *object) ...@@ -221,6 +227,11 @@ gimp_thumbnail_finalize (GObject *object)
g_free (thumbnail->image_type); g_free (thumbnail->image_type);
thumbnail->image_type = NULL; thumbnail->image_type = NULL;
} }
if (thumbnail->thumb_filename)
{
g_free (thumbnail->thumb_filename);
thumbnail->thumb_filename = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
...@@ -232,32 +243,49 @@ gimp_thumbnail_set_property (GObject *object, ...@@ -232,32 +243,49 @@ gimp_thumbnail_set_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object); GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object);
gint64 int_value;
switch (property_id) switch (property_id)
{ {
case PROP_URI: case PROP_IMAGE_STATE:
thumbnail->image_state = g_value_get_enum (value);
break;
case PROP_IMAGE_URI:
gimp_thumbnail_set_uri (GIMP_THUMBNAIL (object), gimp_thumbnail_set_uri (GIMP_THUMBNAIL (object),
g_value_get_string (value)); g_value_get_string (value));
break; break;
case PROP_MTIME: case PROP_IMAGE_MTIME:
thumbnail->image_mtime = g_value_get_int64 (value); int_value = g_value_get_int64 (value);
if (thumbnail->image_mtime != int_value)
{
thumbnail->image_mtime = int_value;
gimp_thumbnail_invalidate_thumb (thumbnail);
}
break; break;
case PROP_FILESIZE: case PROP_IMAGE_FILESIZE:
thumbnail->image_filesize = g_value_get_int64 (value); int_value = g_value_get_int64 (value);
if (thumbnail->image_filesize != int_value)
{
thumbnail->image_filesize = int_value;
gimp_thumbnail_invalidate_thumb (thumbnail);
}
break; break;
case PROP_WIDTH: case PROP_IMAGE_WIDTH:
thumbnail->image_width = g_value_get_int (value); thumbnail->image_width = g_value_get_int (value);
break; break;
case PROP_HEIGHT: case PROP_IMAGE_HEIGHT:
thumbnail->image_height = g_value_get_int (value); thumbnail->image_height = g_value_get_int (value);
break; break;
case PROP_TYPE: case PROP_IMAGE_TYPE:
g_free (thumbnail->image_type); g_free (thumbnail->image_type);
thumbnail->image_type = g_value_dup_string (value); thumbnail->image_type = g_value_dup_string (value);
break; break;
case PROP_NUM_LAYERS: case PROP_IMAGE_NUM_LAYERS:
thumbnail->image_num_layers = g_value_get_int (value); thumbnail->image_num_layers = g_value_get_int (value);
break; break;
case PROP_THUMB_STATE:
thumbnail->thumb_state = g_value_get_enum (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
...@@ -275,30 +303,33 @@ gimp_thumbnail_get_property (GObject *object, ...@@ -275,30 +303,33 @@ gimp_thumbnail_get_property (GObject *object,
switch (property_id) switch (property_id)
{ {
case PROP_URI: case PROP_IMAGE_STATE:
g_value_set_string (value, thumbnail->uri); g_value_set_enum (value, thumbnail->image_state);
break; break;
case PROP_STATE: case PROP_IMAGE_URI:
g_value_set_enum (value, thumbnail->state); g_value_set_string (value, thumbnail->image_uri);
break; break;
case PROP_MTIME: case PROP_IMAGE_MTIME:
g_value_set_int64 (value, thumbnail->image_mtime); g_value_set_int64 (value, thumbnail->image_mtime);
break; break;
case PROP_FILESIZE: case PROP_IMAGE_FILESIZE:
g_value_set_int64 (value, thumbnail->image_filesize); g_value_set_int64 (value, thumbnail->image_filesize);
break; break;
case PROP_WIDTH: case PROP_IMAGE_WIDTH:
g_value_set_int (value, thumbnail->image_width); g_value_set_int (value, thumbnail->image_width);
break; break;
case PROP_HEIGHT: case PROP_IMAGE_HEIGHT:
g_value_set_int (value, thumbnail->image_height); g_value_set_int (value, thumbnail->image_height);
break; break;
case PROP_TYPE: case PROP_IMAGE_TYPE:
g_value_set_string (value, thumbnail->image_type); g_value_set_string (value, thumbnail->image_type);
break; break;
case PROP_NUM_LAYERS: case PROP_IMAGE_NUM_LAYERS:
g_value_set_int (value, thumbnail->image_height); g_value_set_int (value, thumbnail->image_height);
break; break;
case PROP_THUMB_STATE:
g_value_set_enum (value, thumbnail->thumb_state);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
...@@ -329,6 +360,33 @@ gimp_thumbnail_set_uri (GimpThumbnail *thumbnail, ...@@ -329,6 +360,33 @@ gimp_thumbnail_set_uri (GimpThumbnail *thumbnail,
{ {
g_return_if_fail (GIMP_IS_THUMBNAIL (thumbnail)); g_return_if_fail (GIMP_IS_THUMBNAIL (thumbnail));
g_object_set (thumbnail,
"image-state", GIMP_THUMB_STATE_UNKNOWN,
"image-filesize", 0,
"image-mtime", 0,
"image-width", 0,
"image-height", 0,
"image-type", NULL,
"image-num-layers", 0,
NULL);
gimp_thumbnail_invalidate_thumb (thumbnail);
}
void
gimp_thumbnail_update (GimpThumbnail *thumbnail)
{
g_object_freeze_notify (G_OBJECT (thumbnail));
gimp_thumbnail_update_image (thumbnail);
gimp_thumbnail_update_thumb (thumbnail);
g_object_thaw_notify (G_OBJECT (thumbnail));
}
static void
gimp_thumbnail_invalidate_thumb (GimpThumbnail *thumbnail)
{
if (thumbnail->thumb_filename) if (thumbnail->thumb_filename)
{ {
g_free (thumbnail->thumb_filename); g_free (thumbnail->thumb_filename);
...@@ -338,35 +396,31 @@ gimp_thumbnail_set_uri (GimpThumbnail *thumbnail, ...@@ -338,35 +396,31 @@ gimp_thumbnail_set_uri (GimpThumbnail *thumbnail,
thumbnail->thumb_filesize = 0; thumbnail->thumb_filesize = 0;
thumbnail->thumb_mtime = 0; thumbnail->thumb_mtime = 0;
g_object_set (thumbnail, if (thumbnail->thumb_state != GIMP_THUMB_STATE_UNKNOWN)
"state", GIMP_THUMB_STATE_UNKNOWN, {
"image-filesize", 0, g_object_set (thumbnail,
"image-mtime", 0, "thumb-state", GIMP_THUMB_STATE_UNKNOWN,
"image-width", 0, NULL);
"image-height", 0, }
"image-type", NULL,
"image-num-layers", 0,
NULL);
} }
void static void
gimp_thumbnail_update (GimpThumbnail *thumbnail) gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
{ {
GimpThumbState state = thumbnail->state; GimpThumbState state;
gchar *thumbname = NULL; gint64 filesize = 0;
gint64 image_filesize = 0; gint64 mtime = 0;
gint64 image_mtime = 0;
g_return_if_fail (thumbnail->image_uri != NULL);
if (! thumbnail->uri) state = thumbnail->image_state;
return;
/* do we know the image filename already ? */
switch (state) switch (state)
{ {
case GIMP_THUMB_STATE_UNKNOWN: case GIMP_THUMB_STATE_UNKNOWN:
g_return_if_fail (thumbnail->image_filename == NULL); g_return_if_fail (thumbnail->image_filename == NULL);
thumbnail->image_filename = g_filename_from_uri (thumbnail->uri, thumbnail->image_filename = g_filename_from_uri (thumbnail->image_uri,
NULL, NULL); NULL, NULL);
if (! thumbnail->image_filename) if (! thumbnail->image_filename)
...@@ -382,64 +436,73 @@ gimp_thumbnail_update (GimpThumbnail *thumbnail) ...@@ -382,64 +436,73 @@ gimp_thumbnail_update (GimpThumbnail *thumbnail)
break; break;
} }
/* check if the imagefile changed */
switch (state) switch (state)
{ {
case GIMP_THUMB_STATE_REMOTE: case GIMP_THUMB_STATE_REMOTE:
break; break;
default: default:
if (gimp_thumb_file_test (thumbnail->image_filename, if (gimp_thumb_file_test (thumbnail->image_filename, &mtime, &filesize))
&image_mtime, &image_filesize)) state = GIMP_THUMB_STATE_EXISTS;
{
if (image_mtime != thumbnail->image_mtime ||
image_filesize != thumbnail->image_filesize)
{
state = GIMP_THUMB_STATE_EXISTS;
}
}
else else
{ state = GIMP_THUMB_STATE_NOT_FOUND;
state = GIMP_THUMB_STATE_NOT_FOUND;
}
break; break;
} }
/* do we know the thumbnail filename ? */ if (state != thumbnail->image_state)
switch (state)
{ {
case GIMP_THUMB_STATE_EXISTS: g_object_set (thumbnail,
thumbname = gimp_thumbnail_find_png_thumb (thumbnail->uri, NULL); "image-state",
break; state, NULL);
}
#if 0 if (mtime != thumbnail->image_mtime || filesize != thumbnail->image_filesize)
thumbname = gimp_thumbnail_find_png_thumb (thumbnail->uri, NULL); {
g_object_set (thumbnail,
"image-mtime", mtime,
"image-filesize", filesize,
NULL);
}
}
thumbnail->state = GIMP_THUMB_STATE_THUMBNAIL_NOT_FOUND; static void
thumbnail->mtime = thumb_mtime; gimp_thumbnail_update_thumb (GimpThumbnail *thumbnail)
thumbnail->filesize = thumb_filesize; {
GimpThumbState state;
GimpThumbSize size;
gint64 filesize;
gint64 mtime;
thumbname = gimp_thumbnail_find_png_thumb (uri, NULL); g_return_if_fail (thumbnail->image_uri != NULL);
if (thumbname) state = thumbnail->thumb_state;
thumbnail->state = GIMP_THUMB_STATE_THUMBNAIL_EXISTS;
cleanup: switch (state)
g_free (filename); {
g_free (thumbname); case GIMP_THUMB_STATE_UNKNOWN:
#endif g_return_if_fail (thumbnail->thumb_filename == NULL);
thumbnail->thumb_filename =
gimp_thumb_find_png_thumb (thumbnail->image_uri, &size);
break;
case GIMP_THUMB_STATE_UNKNOWN: default:
case GIMP_THUMB_STATE_REMOTE: g_return_if_fail (thumbnail->thumb_filename != NULL);
case GIMP_THUMB_STATE_NOT_FOUND:
case GIMP_THUMB_STATE_THUMBNAIL_NOT_FOUND:
case GIMP_THUMB_STATE_THUMBNAIL_EXISTS:
case GIMP_THUMB_STATE_THUMBNAIL_OLD:
case GIMP_THUMB_STATE_THUMBNAIL_FAILED:
case GIMP_THUMB_STATE_THUMBNAIL_OK:
break; break;
} }
switch (state)
{
default:
if (gimp_thumb_file_test (thumbnail->thumb_filename, &mtime, &filesize))
state = GIMP_THUMB_STATE_EXISTS;
else
state = GIMP_THUMB_STATE_NOT_FOUND;
break;
}
if (state != thumbnail->thumb_state)
g_object_set (thumbnail, "thumb-state", state, NULL);
} }
gboolean gboolean
...@@ -460,16 +523,6 @@ gimp_thumbnail_set_filename (GimpThumbnail *thumbnail, ...@@ -460,16 +523,6 @@ gimp_thumbnail_set_filename (GimpThumbnail *thumbnail,
return (!filename || uri); return (!filename || uri);
} }
GimpThumbState
gimp_thumbnail_get_state (GimpThumbnail *thumbnail)
{
g_return_val_if_fail