mirror of https://github.com/GNOME/gimp.git
libgimpthumb, app: Make gimpthumbnail attributes private
Move all public attributes of GimpThumbnail from the header to a private struct in GimpThumbnail.c. Also replace direct access of these attributes in app/core and app/widget with get/set calls.
This commit is contained in:
parent
438bc4f229
commit
175b50ead5
|
@ -242,10 +242,17 @@ gimp_imagefile_get_description (GimpViewable *viewable,
|
|||
GimpImagefilePrivate *private = GET_PRIVATE (imagefile);
|
||||
GimpThumbnail *thumbnail = private->thumbnail;
|
||||
gchar *basename;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
|
||||
if (! private->file)
|
||||
return NULL;
|
||||
|
||||
g_object_get (thumbnail,
|
||||
"image-width", &image_width,
|
||||
"image-height", &image_height,
|
||||
NULL);
|
||||
|
||||
if (tooltip)
|
||||
{
|
||||
const gchar *name;
|
||||
|
@ -262,14 +269,14 @@ gimp_imagefile_get_description (GimpViewable *viewable,
|
|||
|
||||
basename = g_path_get_basename (gimp_file_get_utf8_name (private->file));
|
||||
|
||||
if (thumbnail->image_width > 0 && thumbnail->image_height > 0)
|
||||
if (image_width > 0 && image_height > 0)
|
||||
{
|
||||
gchar *tmp = basename;
|
||||
|
||||
basename = g_strdup_printf ("%s (%d × %d)",
|
||||
tmp,
|
||||
thumbnail->image_width,
|
||||
thumbnail->image_height);
|
||||
image_width,
|
||||
image_height);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
|
@ -750,6 +757,15 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
{
|
||||
GimpImagefilePrivate *private;
|
||||
GimpThumbnail *thumbnail;
|
||||
GimpThumbState image_state;
|
||||
GimpThumbState thumb_state;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
gchar *image_uri;
|
||||
gchar *image_type;
|
||||
gint64 image_filesize;
|
||||
gint image_num_layers;
|
||||
gint image_not_found_errno;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGEFILE (imagefile), NULL);
|
||||
|
||||
|
@ -760,7 +776,19 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
|
||||
thumbnail = private->thumbnail;
|
||||
|
||||
switch (thumbnail->image_state)
|
||||
g_object_get (thumbnail,
|
||||
"image-state", &image_state,
|
||||
"thumb-state", &thumb_state,
|
||||
"image-width", &image_width,
|
||||
"image-height", &image_height,
|
||||
"image-uri", &image_uri,
|
||||
"image-type", &image_type,
|
||||
"image-filesize", &image_filesize,
|
||||
"image-num-layers", &image_num_layers,
|
||||
"image-not-found-errno", &image_not_found_errno,
|
||||
NULL);
|
||||
|
||||
switch (image_state)
|
||||
{
|
||||
case GIMP_THUMB_STATE_UNKNOWN:
|
||||
private->description = NULL;
|
||||
|
@ -779,7 +807,7 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
|
||||
case GIMP_THUMB_STATE_NOT_FOUND:
|
||||
private->description =
|
||||
(gchar *) g_strerror (thumbnail->image_not_found_errno);
|
||||
(gchar *) g_strerror (image_not_found_errno);
|
||||
private->static_desc = TRUE;
|
||||
break;
|
||||
|
||||
|
@ -787,14 +815,14 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
{
|
||||
GString *str = g_string_new (NULL);
|
||||
|
||||
if (thumbnail->image_state == GIMP_THUMB_STATE_REMOTE)
|
||||
if (image_state == GIMP_THUMB_STATE_REMOTE)
|
||||
{
|
||||
g_string_append (str, _("Remote File"));
|
||||
}
|
||||
|
||||
if (thumbnail->image_filesize > 0)
|
||||
if (image_filesize > 0)
|
||||
{
|
||||
gchar *size = g_format_size (thumbnail->image_filesize);
|
||||
gchar *size = g_format_size (image_filesize);
|
||||
|
||||
if (str->len > 0)
|
||||
g_string_append_c (str, '\n');
|
||||
|
@ -803,7 +831,7 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
g_free (size);
|
||||
}
|
||||
|
||||
switch (thumbnail->thumb_state)
|
||||
switch (thumb_state)
|
||||
{
|
||||
case GIMP_THUMB_STATE_NOT_FOUND:
|
||||
if (str->len > 0)
|
||||
|
@ -831,7 +859,7 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
|
||||
case GIMP_THUMB_STATE_OK:
|
||||
{
|
||||
if (thumbnail->image_state == GIMP_THUMB_STATE_REMOTE)
|
||||
if (image_state == GIMP_THUMB_STATE_REMOTE)
|
||||
{
|
||||
if (str->len > 0)
|
||||
g_string_append_c (str, '\n');
|
||||
|
@ -839,7 +867,7 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
g_string_append (str, _("(Preview may be out of date)"));
|
||||
}
|
||||
|
||||
if (thumbnail->image_width > 0 && thumbnail->image_height > 0)
|
||||
if (image_width > 0 && image_height > 0)
|
||||
{
|
||||
if (str->len > 0)
|
||||
g_string_append_c (str, '\n');
|
||||
|
@ -847,22 +875,22 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
g_string_append_printf (str,
|
||||
ngettext ("%d × %d pixel",
|
||||
"%d × %d pixels",
|
||||
thumbnail->image_height),
|
||||
thumbnail->image_width,
|
||||
thumbnail->image_height);
|
||||
image_height),
|
||||
image_width,
|
||||
image_height);
|
||||
}
|
||||
|
||||
if (thumbnail->image_type)
|
||||
if (image_type)
|
||||
{
|
||||
if (str->len > 0)
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
g_string_append (str, gettext (thumbnail->image_type));
|
||||
g_string_append (str, gettext (image_type));
|
||||
}
|
||||
|
||||
if (thumbnail->image_num_layers > 0)
|
||||
if (image_num_layers > 0)
|
||||
{
|
||||
if (thumbnail->image_type)
|
||||
if (image_type)
|
||||
g_string_append_len (str, ", ", 2);
|
||||
else if (str->len > 0)
|
||||
g_string_append_c (str, '\n');
|
||||
|
@ -870,8 +898,8 @@ gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
|
|||
g_string_append_printf (str,
|
||||
ngettext ("%d layer",
|
||||
"%d layers",
|
||||
thumbnail->image_num_layers),
|
||||
thumbnail->image_num_layers);
|
||||
image_num_layers),
|
||||
image_num_layers);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -895,6 +923,10 @@ gimp_imagefile_load_thumb (GimpImagefile *imagefile,
|
|||
{
|
||||
GimpImagefilePrivate *private = GET_PRIVATE (imagefile);
|
||||
GimpThumbnail *thumbnail = private->thumbnail;
|
||||
GimpThumbState image_state;
|
||||
gchar *image_uri;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GError *error = NULL;
|
||||
gint size = MAX (width, height);
|
||||
|
@ -903,10 +935,17 @@ gimp_imagefile_load_thumb (GimpImagefile *imagefile,
|
|||
gint preview_width;
|
||||
gint preview_height;
|
||||
|
||||
g_object_get (thumbnail,
|
||||
"image-state", &image_state,
|
||||
"image-uri", &image_uri,
|
||||
"image-width", &image_width,
|
||||
"image-height", &image_height,
|
||||
NULL);
|
||||
|
||||
if (gimp_thumbnail_peek_thumb (thumbnail, size) < GIMP_THUMB_STATE_EXISTS)
|
||||
return NULL;
|
||||
|
||||
if (thumbnail->image_state == GIMP_THUMB_STATE_NOT_FOUND)
|
||||
if (image_state == GIMP_THUMB_STATE_NOT_FOUND)
|
||||
return NULL;
|
||||
|
||||
pixbuf = gimp_thumbnail_load_thumb (thumbnail, size, &error);
|
||||
|
@ -915,10 +954,18 @@ gimp_imagefile_load_thumb (GimpImagefile *imagefile,
|
|||
{
|
||||
if (error)
|
||||
{
|
||||
GimpThumbSize thumb_size = size;
|
||||
gchar *thumb_filename;
|
||||
|
||||
thumb_filename = gimp_thumb_find_thumb (image_uri, &thumb_size);
|
||||
|
||||
gimp_message (private->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
_("Could not open thumbnail '%s': %s"),
|
||||
thumbnail->thumb_filename, error->message);
|
||||
thumb_filename, error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
if (thumb_filename)
|
||||
g_free (thumb_filename);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -511,13 +511,21 @@ gimp_thumb_box_thumb_state_notify (GimpThumbnail *thumb,
|
|||
GParamSpec *pspec,
|
||||
GimpThumbBox *box)
|
||||
{
|
||||
GimpThumbState image_state;
|
||||
GimpThumbState thumb_state;
|
||||
|
||||
if (box->idle_id)
|
||||
return;
|
||||
|
||||
if (thumb->image_state == GIMP_THUMB_STATE_REMOTE)
|
||||
g_object_get (thumb,
|
||||
"image-state", &image_state,
|
||||
"thumb-state", &thumb_state,
|
||||
NULL);
|
||||
|
||||
if (image_state == GIMP_THUMB_STATE_REMOTE)
|
||||
return;
|
||||
|
||||
switch (thumb->thumb_state)
|
||||
switch (thumb_state)
|
||||
{
|
||||
case GIMP_THUMB_STATE_NOT_FOUND:
|
||||
case GIMP_THUMB_STATE_OLD:
|
||||
|
@ -687,28 +695,37 @@ gimp_thumb_box_auto_thumbnail (GimpThumbBox *box)
|
|||
Gimp *gimp = box->context->gimp;
|
||||
GimpThumbnail *thumb = gimp_imagefile_get_thumbnail (box->imagefile);
|
||||
GFile *file = gimp_imagefile_get_file (box->imagefile);
|
||||
GimpThumbState image_state;
|
||||
GimpThumbState thumb_state;
|
||||
gint64 image_filesize;
|
||||
|
||||
g_object_get (thumb,
|
||||
"image-state", &image_state,
|
||||
"thumb-state", &thumb_state,
|
||||
"image-filesize", &image_filesize,
|
||||
NULL);
|
||||
|
||||
box->idle_id = 0;
|
||||
|
||||
if (thumb->image_state == GIMP_THUMB_STATE_NOT_FOUND)
|
||||
if (image_state == GIMP_THUMB_STATE_NOT_FOUND)
|
||||
return FALSE;
|
||||
|
||||
switch (thumb->thumb_state)
|
||||
switch (thumb_state)
|
||||
{
|
||||
case GIMP_THUMB_STATE_NOT_FOUND:
|
||||
case GIMP_THUMB_STATE_OLD:
|
||||
if (thumb->image_filesize < gimp->config->thumbnail_filesize_limit &&
|
||||
if (image_filesize < gimp->config->thumbnail_filesize_limit &&
|
||||
! gimp_thumbnail_has_failed (thumb) &&
|
||||
gimp_plug_in_manager_file_procedure_find_by_extension (gimp->plug_in_manager,
|
||||
GIMP_FILE_PROCEDURE_GROUP_OPEN,
|
||||
file))
|
||||
{
|
||||
if (thumb->image_filesize > 0)
|
||||
if (image_filesize > 0)
|
||||
{
|
||||
gchar *size;
|
||||
gchar *text;
|
||||
|
||||
size = g_format_size (thumb->image_filesize);
|
||||
size = g_format_size (image_filesize);
|
||||
text = g_strdup_printf ("%s\n%s",
|
||||
size, _("Creating preview..."));
|
||||
|
||||
|
|
|
@ -158,11 +158,18 @@ gimp_view_renderer_imagefile_get_icon (GimpImagefile *imagefile,
|
|||
GdkScreen *screen = gtk_widget_get_screen (widget);
|
||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_screen (screen);
|
||||
GimpThumbnail *thumbnail = gimp_imagefile_get_thumbnail (imagefile);
|
||||
GimpThumbState image_state;
|
||||
gchar *image_mimetype;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
if (! gimp_object_get_name (imagefile))
|
||||
return NULL;
|
||||
|
||||
g_object_get (thumbnail,
|
||||
"image-state", &image_state,
|
||||
"image-mimetype", &image_mimetype,
|
||||
NULL);
|
||||
|
||||
if (! pixbuf)
|
||||
{
|
||||
GIcon *icon = gimp_imagefile_get_gicon (imagefile);
|
||||
|
@ -184,11 +191,11 @@ gimp_view_renderer_imagefile_get_icon (GimpImagefile *imagefile,
|
|||
|
||||
if (! pixbuf)
|
||||
{
|
||||
if (thumbnail->image_mimetype)
|
||||
if (image_mimetype)
|
||||
{
|
||||
pixbuf = get_icon_for_mime_type (thumbnail->image_mimetype, size);
|
||||
pixbuf = get_icon_for_mime_type (image_mimetype, size);
|
||||
}
|
||||
else if (thumbnail->image_state == GIMP_THUMB_STATE_FOLDER)
|
||||
else if (image_state == GIMP_THUMB_STATE_FOLDER)
|
||||
{
|
||||
pixbuf = get_icon_for_mime_type ("inode/directory", size);
|
||||
}
|
||||
|
@ -198,7 +205,7 @@ gimp_view_renderer_imagefile_get_icon (GimpImagefile *imagefile,
|
|||
{
|
||||
const gchar *icon_name = "text-x-generic";
|
||||
|
||||
if (thumbnail->image_state == GIMP_THUMB_STATE_FOLDER)
|
||||
if (image_state == GIMP_THUMB_STATE_FOLDER)
|
||||
icon_name = "folder";
|
||||
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme,
|
||||
|
|
|
@ -181,6 +181,7 @@ process_thumbnail (const gchar *filename)
|
|||
{
|
||||
GimpThumbnail *thumbnail;
|
||||
GError *error = NULL;
|
||||
gchar *image_uri;
|
||||
|
||||
thumbnail = gimp_thumbnail_new ();
|
||||
|
||||
|
@ -200,15 +201,17 @@ process_thumbnail (const gchar *filename)
|
|||
{
|
||||
GimpThumbState state = gimp_thumbnail_peek_image (thumbnail);
|
||||
|
||||
g_object_get (thumbnail, "image-uri", &image_uri, NULL);
|
||||
|
||||
if ((option_state == STATE_NONE || state == option_state)
|
||||
|
||||
&&
|
||||
|
||||
(option_path == NULL ||
|
||||
strstr (thumbnail->image_uri, option_path)))
|
||||
strstr (image_uri, option_path)))
|
||||
{
|
||||
if (option_verbose)
|
||||
g_print ("%s '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s '%s'\n", filename, image_uri);
|
||||
else
|
||||
g_print ("%s\n", filename);
|
||||
}
|
||||
|
@ -217,31 +220,31 @@ process_thumbnail (const gchar *filename)
|
|||
switch (foo)
|
||||
{
|
||||
case GIMP_THUMB_STATE_REMOTE:
|
||||
g_print ("%s Remote image '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s Remote image '%s'\n", filename, image_uri);
|
||||
break;
|
||||
|
||||
case GIMP_THUMB_STATE_FOLDER:
|
||||
g_print ("%s Folder '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s Folder '%s'\n", filename, image_uri);
|
||||
break;
|
||||
|
||||
case GIMP_THUMB_STATE_SPECIAL:
|
||||
g_print ("%s Special file '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s Special file '%s'\n", filename, image_uri);
|
||||
break;
|
||||
|
||||
case GIMP_THUMB_STATE_NOT_FOUND:
|
||||
g_print ("%s Image not found '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s Image not found '%s'\n", filename, image_uri);
|
||||
break;
|
||||
|
||||
case GIMP_THUMB_STATE_OLD:
|
||||
g_print ("%s Thumbnail old '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s Thumbnail old '%s'\n", filename, image_uri);
|
||||
break;
|
||||
|
||||
case GIMP_THUMB_STATE_FAILED:
|
||||
g_print ("%s EEEEEEEEK '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s EEEEEEEEK '%s'\n", filename, image_uri);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_print ("%s '%s'\n", filename, thumbnail->image_uri);
|
||||
g_print ("%s '%s'\n", filename, image_uri);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
#if defined (GIMP_THUMB_DEBUG) && defined (__GNUC__)
|
||||
#define GIMP_THUMB_DEBUG_CALL(t) \
|
||||
g_printerr ("%s: %s\n", \
|
||||
__FUNCTION__, t->image_uri ? t->image_uri : "(null)")
|
||||
__FUNCTION__, GET_PRIVATE (t)->image_uri ? GET_PRIVATE (t)->image_uri : "(null)")
|
||||
#else
|
||||
#define GIMP_THUMB_DEBUG_CALL(t) ((void)(0))
|
||||
#endif
|
||||
|
@ -96,10 +96,37 @@ enum
|
|||
PROP_IMAGE_HEIGHT,
|
||||
PROP_IMAGE_TYPE,
|
||||
PROP_IMAGE_NUM_LAYERS,
|
||||
PROP_IMAGE_NOT_FOUND_ERRNO,
|
||||
PROP_THUMB_STATE
|
||||
};
|
||||
|
||||
|
||||
typedef struct _GimpThumbnailPrivate
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GimpThumbState image_state;
|
||||
gchar *image_uri;
|
||||
gchar *image_filename;
|
||||
gint64 image_filesize;
|
||||
gint64 image_mtime;
|
||||
gint image_not_found_errno;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
gchar *image_type;
|
||||
gint image_num_layers;
|
||||
|
||||
GimpThumbState thumb_state;
|
||||
GimpThumbSize thumb_size;
|
||||
gchar *thumb_filename;
|
||||
gint64 thumb_filesize;
|
||||
gint64 thumb_mtime;
|
||||
|
||||
gchar *image_mimetype;
|
||||
} GimpThumbnailPrivate;
|
||||
|
||||
#define GET_PRIVATE(obj) ((GimpThumbnailPrivate *) gimp_thumbnail_get_instance_private ((GimpThumbnail *) (obj)))
|
||||
|
||||
static void gimp_thumbnail_finalize (GObject *object);
|
||||
static void gimp_thumbnail_set_property (GObject *object,
|
||||
guint property_id,
|
||||
|
@ -127,7 +154,7 @@ static void gimp_thumbnail_debug_notify (GObject *object,
|
|||
#endif
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpThumbnail, gimp_thumbnail, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpThumbnail, gimp_thumbnail, G_TYPE_OBJECT)
|
||||
|
||||
#define parent_class gimp_thumbnail_parent_class
|
||||
|
||||
|
@ -203,6 +230,14 @@ gimp_thumbnail_class_init (GimpThumbnailClass *klass)
|
|||
"The number of layers in the image",
|
||||
0, G_MAXINT, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_IMAGE_NOT_FOUND_ERRNO,
|
||||
g_param_spec_int ("image-not-found-errno", NULL,
|
||||
"Error number if image not found",
|
||||
0, G_MAXINT, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_THUMB_STATE,
|
||||
g_param_spec_enum ("thumb-state", NULL,
|
||||
|
@ -215,22 +250,25 @@ gimp_thumbnail_class_init (GimpThumbnailClass *klass)
|
|||
static void
|
||||
gimp_thumbnail_init (GimpThumbnail *thumbnail)
|
||||
{
|
||||
thumbnail->image_state = GIMP_THUMB_STATE_UNKNOWN;
|
||||
thumbnail->image_uri = NULL;
|
||||
thumbnail->image_filename = NULL;
|
||||
thumbnail->image_mtime = 0;
|
||||
thumbnail->image_filesize = 0;
|
||||
thumbnail->image_mimetype = NULL;
|
||||
thumbnail->image_width = 0;
|
||||
thumbnail->image_height = 0;
|
||||
thumbnail->image_type = NULL;
|
||||
thumbnail->image_num_layers = 0;
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
thumbnail->thumb_state = GIMP_THUMB_STATE_UNKNOWN;
|
||||
thumbnail->thumb_size = -1;
|
||||
thumbnail->thumb_filename = NULL;
|
||||
thumbnail->thumb_mtime = 0;
|
||||
thumbnail->thumb_filesize = 0;
|
||||
priv->image_state = GIMP_THUMB_STATE_UNKNOWN;
|
||||
priv->image_uri = NULL;
|
||||
priv->image_filename = NULL;
|
||||
priv->image_mtime = 0;
|
||||
priv->image_filesize = 0;
|
||||
priv->image_mimetype = NULL;
|
||||
priv->image_width = 0;
|
||||
priv->image_height = 0;
|
||||
priv->image_type = NULL;
|
||||
priv->image_num_layers = 0;
|
||||
priv->image_not_found_errno = 0;
|
||||
|
||||
priv->thumb_state = GIMP_THUMB_STATE_UNKNOWN;
|
||||
priv->thumb_size = -1;
|
||||
priv->thumb_filename = NULL;
|
||||
priv->thumb_mtime = 0;
|
||||
priv->thumb_filesize = 0;
|
||||
|
||||
#ifdef GIMP_THUMB_DEBUG
|
||||
g_signal_connect (thumbnail, "notify",
|
||||
|
@ -242,13 +280,13 @@ gimp_thumbnail_init (GimpThumbnail *thumbnail)
|
|||
static void
|
||||
gimp_thumbnail_finalize (GObject *object)
|
||||
{
|
||||
GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object);
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (object);
|
||||
|
||||
g_clear_pointer (&thumbnail->image_uri, g_free);
|
||||
g_clear_pointer (&thumbnail->image_filename, g_free);
|
||||
g_clear_pointer (&thumbnail->image_mimetype, g_free);
|
||||
g_clear_pointer (&thumbnail->image_type, g_free);
|
||||
g_clear_pointer (&thumbnail->thumb_filename, g_free);
|
||||
g_clear_pointer (&priv->image_uri, g_free);
|
||||
g_clear_pointer (&priv->image_filename, g_free);
|
||||
g_clear_pointer (&priv->image_mimetype, g_free);
|
||||
g_clear_pointer (&priv->image_type, g_free);
|
||||
g_clear_pointer (&priv->thumb_filename, g_free);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -259,42 +297,45 @@ gimp_thumbnail_set_property (GObject *object,
|
|||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object);
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_IMAGE_STATE:
|
||||
thumbnail->image_state = g_value_get_enum (value);
|
||||
priv->image_state = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_IMAGE_URI:
|
||||
gimp_thumbnail_set_uri (GIMP_THUMBNAIL (object),
|
||||
g_value_get_string (value));
|
||||
break;
|
||||
case PROP_IMAGE_MTIME:
|
||||
thumbnail->image_mtime = g_value_get_int64 (value);
|
||||
priv->image_mtime = g_value_get_int64 (value);
|
||||
break;
|
||||
case PROP_IMAGE_FILESIZE:
|
||||
thumbnail->image_filesize = g_value_get_int64 (value);
|
||||
priv->image_filesize = g_value_get_int64 (value);
|
||||
break;
|
||||
case PROP_IMAGE_MIMETYPE:
|
||||
g_free (thumbnail->image_mimetype);
|
||||
thumbnail->image_mimetype = g_value_dup_string (value);
|
||||
g_free (priv->image_mimetype);
|
||||
priv->image_mimetype = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_IMAGE_WIDTH:
|
||||
thumbnail->image_width = g_value_get_int (value);
|
||||
priv->image_width = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_IMAGE_HEIGHT:
|
||||
thumbnail->image_height = g_value_get_int (value);
|
||||
priv->image_height = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_IMAGE_TYPE:
|
||||
g_free (thumbnail->image_type);
|
||||
thumbnail->image_type = g_value_dup_string (value);
|
||||
g_free (priv->image_type);
|
||||
priv->image_type = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_IMAGE_NUM_LAYERS:
|
||||
thumbnail->image_num_layers = g_value_get_int (value);
|
||||
priv->image_num_layers = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_IMAGE_NOT_FOUND_ERRNO:
|
||||
priv->image_not_found_errno = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_THUMB_STATE:
|
||||
thumbnail->thumb_state = g_value_get_enum (value);
|
||||
priv->thumb_state = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -309,39 +350,43 @@ gimp_thumbnail_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpThumbnail *thumbnail = GIMP_THUMBNAIL (object);
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_IMAGE_STATE:
|
||||
g_value_set_enum (value, thumbnail->image_state);
|
||||
g_value_set_enum (value, priv->image_state);
|
||||
break;
|
||||
case PROP_IMAGE_URI:
|
||||
g_value_set_string (value, thumbnail->image_uri);
|
||||
g_value_set_string (value, priv->image_uri);
|
||||
break;
|
||||
case PROP_IMAGE_MTIME:
|
||||
g_value_set_int64 (value, thumbnail->image_mtime);
|
||||
g_value_set_int64 (value, priv->image_mtime);
|
||||
break;
|
||||
case PROP_IMAGE_FILESIZE:
|
||||
g_value_set_int64 (value, thumbnail->image_filesize);
|
||||
g_value_set_int64 (value, priv->image_filesize);
|
||||
break;
|
||||
case PROP_IMAGE_MIMETYPE:
|
||||
g_value_set_string (value, thumbnail->image_mimetype);
|
||||
g_value_set_string (value, priv->image_mimetype);
|
||||
break;
|
||||
case PROP_IMAGE_WIDTH:
|
||||
g_value_set_int (value, thumbnail->image_width);
|
||||
g_value_set_int (value, priv->image_width);
|
||||
break;
|
||||
case PROP_IMAGE_HEIGHT:
|
||||
g_value_set_int (value, thumbnail->image_height);
|
||||
g_value_set_int (value, priv->image_height);
|
||||
break;
|
||||
case PROP_IMAGE_TYPE:
|
||||
g_value_set_string (value, thumbnail->image_type);
|
||||
g_value_set_string (value, priv->image_type);
|
||||
break;
|
||||
case PROP_IMAGE_NUM_LAYERS:
|
||||
g_value_set_int (value, thumbnail->image_num_layers);
|
||||
g_value_set_int (value, priv->image_num_layers);
|
||||
break;
|
||||
case PROP_IMAGE_NOT_FOUND_ERRNO:
|
||||
g_value_set_int (value, priv->image_not_found_errno);
|
||||
break;
|
||||
|
||||
case PROP_THUMB_STATE:
|
||||
g_value_set_enum (value, thumbnail->thumb_state);
|
||||
g_value_set_enum (value, priv->thumb_state);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -378,21 +423,25 @@ void
|
|||
gimp_thumbnail_set_uri (GimpThumbnail *thumbnail,
|
||||
const gchar *uri)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_THUMBNAIL (thumbnail));
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
if (thumbnail->image_uri)
|
||||
g_free (thumbnail->image_uri);
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
thumbnail->image_uri = g_strdup (uri);
|
||||
if (priv->image_uri)
|
||||
g_free (priv->image_uri);
|
||||
|
||||
g_clear_pointer (&thumbnail->image_filename, g_free);
|
||||
g_clear_pointer (&thumbnail->thumb_filename, g_free);
|
||||
priv->image_uri = g_strdup (uri);
|
||||
|
||||
thumbnail->thumb_size = -1;
|
||||
thumbnail->thumb_filesize = 0;
|
||||
thumbnail->thumb_mtime = 0;
|
||||
g_clear_pointer (&priv->image_filename, g_free);
|
||||
g_clear_pointer (&priv->thumb_filename, g_free);
|
||||
|
||||
priv->thumb_size = -1;
|
||||
priv->thumb_filesize = 0;
|
||||
priv->thumb_mtime = 0;
|
||||
|
||||
g_object_set (thumbnail,
|
||||
"image-state", GIMP_THUMB_STATE_UNKNOWN,
|
||||
|
@ -512,7 +561,7 @@ gimp_thumbnail_peek_image (GimpThumbnail *thumbnail)
|
|||
|
||||
g_object_thaw_notify (G_OBJECT (thumbnail));
|
||||
|
||||
return thumbnail->image_state;
|
||||
return GET_PRIVATE (thumbnail)->image_state;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -547,7 +596,7 @@ gimp_thumbnail_peek_thumb (GimpThumbnail *thumbnail,
|
|||
|
||||
g_object_thaw_notify (G_OBJECT (thumbnail));
|
||||
|
||||
return thumbnail->thumb_state;
|
||||
return GET_PRIVATE (thumbnail)->thumb_state;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -581,30 +630,31 @@ gimp_thumbnail_check_thumb (GimpThumbnail *thumbnail,
|
|||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return thumbnail->thumb_state;
|
||||
return GET_PRIVATE (thumbnail)->thumb_state;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
|
||||
{
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (thumbnail);
|
||||
GimpThumbState state;
|
||||
gint64 mtime = 0;
|
||||
gint64 filesize = 0;
|
||||
|
||||
if (! thumbnail->image_uri)
|
||||
if (! priv->image_uri)
|
||||
return;
|
||||
|
||||
state = thumbnail->image_state;
|
||||
state = priv->image_state;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GIMP_THUMB_STATE_UNKNOWN:
|
||||
g_return_if_fail (thumbnail->image_filename == NULL);
|
||||
g_return_if_fail (priv->image_filename == NULL);
|
||||
|
||||
thumbnail->image_filename =
|
||||
_gimp_thumb_filename_from_uri (thumbnail->image_uri);
|
||||
priv->image_filename =
|
||||
_gimp_thumb_filename_from_uri (priv->image_uri);
|
||||
|
||||
if (! thumbnail->image_filename)
|
||||
if (! priv->image_filename)
|
||||
state = GIMP_THUMB_STATE_REMOTE;
|
||||
|
||||
break;
|
||||
|
@ -613,7 +663,7 @@ gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
|
|||
break;
|
||||
|
||||
default:
|
||||
g_return_if_fail (thumbnail->image_filename != NULL);
|
||||
g_return_if_fail (priv->image_filename != NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -623,9 +673,9 @@ gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
|
|||
break;
|
||||
|
||||
default:
|
||||
switch (gimp_thumb_file_test (thumbnail->image_filename,
|
||||
switch (gimp_thumb_file_test (priv->image_filename,
|
||||
&mtime, &filesize,
|
||||
&thumbnail->image_not_found_errno))
|
||||
&priv->image_not_found_errno))
|
||||
{
|
||||
case GIMP_THUMB_FILE_TYPE_REGULAR:
|
||||
state = GIMP_THUMB_STATE_EXISTS;
|
||||
|
@ -646,21 +696,21 @@ gimp_thumbnail_update_image (GimpThumbnail *thumbnail)
|
|||
break;
|
||||
}
|
||||
|
||||
if (state != thumbnail->image_state)
|
||||
if (state != priv->image_state)
|
||||
{
|
||||
g_object_set (thumbnail,
|
||||
"image-state", state,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (mtime != thumbnail->image_mtime || filesize != thumbnail->image_filesize)
|
||||
if (mtime != priv->image_mtime || filesize != priv->image_filesize)
|
||||
{
|
||||
g_object_set (thumbnail,
|
||||
"image-mtime", mtime,
|
||||
"image-filesize", filesize,
|
||||
NULL);
|
||||
|
||||
if (thumbnail->thumb_state == GIMP_THUMB_STATE_OK)
|
||||
if (priv->thumb_state == GIMP_THUMB_STATE_OK)
|
||||
g_object_set (thumbnail,
|
||||
"thumb-state", GIMP_THUMB_STATE_OLD,
|
||||
NULL);
|
||||
|
@ -671,17 +721,18 @@ static void
|
|||
gimp_thumbnail_update_thumb (GimpThumbnail *thumbnail,
|
||||
GimpThumbSize size)
|
||||
{
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (thumbnail);
|
||||
gchar *filename;
|
||||
GimpThumbState state;
|
||||
gint64 filesize = 0;
|
||||
gint64 mtime = 0;
|
||||
|
||||
if (! thumbnail->image_uri)
|
||||
if (! priv->image_uri)
|
||||
return;
|
||||
|
||||
state = thumbnail->thumb_state;
|
||||
state = priv->thumb_state;
|
||||
|
||||
filename = gimp_thumb_find_thumb (thumbnail->image_uri, &size);
|
||||
filename = gimp_thumb_find_thumb (priv->image_uri, &size);
|
||||
|
||||
/* We don't want to clear the GIMP_THUMB_STATE_FAILED state, because
|
||||
* it is normal to have no filename if thumbnail creation failed. */
|
||||
|
@ -693,11 +744,11 @@ gimp_thumbnail_update_thumb (GimpThumbnail *thumbnail,
|
|||
case GIMP_THUMB_STATE_EXISTS:
|
||||
case GIMP_THUMB_STATE_OLD:
|
||||
case GIMP_THUMB_STATE_OK:
|
||||
g_return_if_fail (thumbnail->thumb_filename != NULL);
|
||||
g_return_if_fail (priv->thumb_filename != NULL);
|
||||
|
||||
if (thumbnail->thumb_size == size &&
|
||||
thumbnail->thumb_filesize == filesize &&
|
||||
thumbnail->thumb_mtime == mtime)
|
||||
if (priv->thumb_size == size &&
|
||||
priv->thumb_filesize == filesize &&
|
||||
priv->thumb_mtime == mtime)
|
||||
{
|
||||
g_free (filename);
|
||||
return;
|
||||
|
@ -707,20 +758,20 @@ gimp_thumbnail_update_thumb (GimpThumbnail *thumbnail,
|
|||
break;
|
||||
}
|
||||
|
||||
if (thumbnail->thumb_filename)
|
||||
g_free (thumbnail->thumb_filename);
|
||||
if (priv->thumb_filename)
|
||||
g_free (priv->thumb_filename);
|
||||
|
||||
thumbnail->thumb_filename = filename;
|
||||
priv->thumb_filename = filename;
|
||||
|
||||
if (filename)
|
||||
state = (size > GIMP_THUMB_SIZE_FAIL ?
|
||||
GIMP_THUMB_STATE_EXISTS : GIMP_THUMB_STATE_FAILED);
|
||||
|
||||
thumbnail->thumb_size = size;
|
||||
thumbnail->thumb_filesize = filesize;
|
||||
thumbnail->thumb_mtime = mtime;
|
||||
priv->thumb_size = size;
|
||||
priv->thumb_filesize = filesize;
|
||||
priv->thumb_mtime = mtime;
|
||||
|
||||
if (state != thumbnail->thumb_state)
|
||||
if (state != priv->thumb_state)
|
||||
{
|
||||
g_object_freeze_notify (G_OBJECT (thumbnail));
|
||||
|
||||
|
@ -746,6 +797,7 @@ static void
|
|||
gimp_thumbnail_set_info_from_pixbuf (GimpThumbnail *thumbnail,
|
||||
GdkPixbuf *pixbuf)
|
||||
{
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (thumbnail);
|
||||
const gchar *option;
|
||||
gint num;
|
||||
|
||||
|
@ -753,24 +805,24 @@ gimp_thumbnail_set_info_from_pixbuf (GimpThumbnail *thumbnail,
|
|||
|
||||
gimp_thumbnail_reset_info (thumbnail);
|
||||
|
||||
g_free (thumbnail->image_mimetype);
|
||||
thumbnail->image_mimetype =
|
||||
g_free (priv->image_mimetype);
|
||||
priv->image_mimetype =
|
||||
g_strdup (gdk_pixbuf_get_option (pixbuf, TAG_THUMB_MIMETYPE));
|
||||
|
||||
option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_IMAGE_WIDTH);
|
||||
if (option && sscanf (option, "%d", &num) == 1)
|
||||
thumbnail->image_width = num;
|
||||
priv->image_width = num;
|
||||
|
||||
option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_IMAGE_HEIGHT);
|
||||
if (option && sscanf (option, "%d", &num) == 1)
|
||||
thumbnail->image_height = num;
|
||||
priv->image_height = num;
|
||||
|
||||
thumbnail->image_type =
|
||||
priv->image_type =
|
||||
g_strdup (gdk_pixbuf_get_option (pixbuf, TAG_THUMB_GIMP_TYPE));
|
||||
|
||||
option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_GIMP_LAYERS);
|
||||
if (option && sscanf (option, "%d", &num) == 1)
|
||||
thumbnail->image_num_layers = num;
|
||||
priv->image_num_layers = num;
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (thumbnail));
|
||||
}
|
||||
|
@ -783,6 +835,7 @@ gimp_thumbnail_save (GimpThumbnail *thumbnail,
|
|||
const gchar *software,
|
||||
GError **error)
|
||||
{
|
||||
GimpThumbnailPrivate *priv = GET_PRIVATE (thumbnail);
|
||||
const gchar *keys[12];
|
||||
gchar *values[12];
|
||||
gchar *basename;
|
||||
|
@ -792,7 +845,7 @@ gimp_thumbnail_save (GimpThumbnail *thumbnail,
|
|||
gint i = 0;
|
||||
|
||||
keys[i] = TAG_DESCRIPTION;
|
||||
values[i] = g_strdup_printf ("Thumbnail of %s", thumbnail->image_uri);
|
||||
values[i] = g_strdup_printf ("Thumbnail of %s", priv->image_uri);
|
||||
i++;
|
||||
|
||||
keys[i] = TAG_SOFTWARE;
|
||||
|
@ -800,49 +853,49 @@ gimp_thumbnail_save (GimpThumbnail *thumbnail,
|
|||
i++;
|
||||
|
||||
keys[i] = TAG_THUMB_URI;
|
||||
values[i] = g_strdup (thumbnail->image_uri);
|
||||
values[i] = g_strdup (priv->image_uri);
|
||||
i++;
|
||||
|
||||
keys[i] = TAG_THUMB_MTIME;
|
||||
values[i] = g_strdup_printf ("%" G_GINT64_FORMAT, thumbnail->image_mtime);
|
||||
values[i] = g_strdup_printf ("%" G_GINT64_FORMAT, priv->image_mtime);
|
||||
i++;
|
||||
|
||||
keys[i] = TAG_THUMB_FILESIZE;
|
||||
values[i] = g_strdup_printf ("%" G_GINT64_FORMAT, thumbnail->image_filesize);
|
||||
values[i] = g_strdup_printf ("%" G_GINT64_FORMAT, priv->image_filesize);
|
||||
i++;
|
||||
|
||||
if (thumbnail->image_mimetype)
|
||||
if (priv->image_mimetype)
|
||||
{
|
||||
keys[i] = TAG_THUMB_MIMETYPE;
|
||||
values[i] = g_strdup (thumbnail->image_mimetype);
|
||||
values[i] = g_strdup (priv->image_mimetype);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (thumbnail->image_width > 0)
|
||||
if (priv->image_width > 0)
|
||||
{
|
||||
keys[i] = TAG_THUMB_IMAGE_WIDTH;
|
||||
values[i] = g_strdup_printf ("%d", thumbnail->image_width);
|
||||
values[i] = g_strdup_printf ("%d", priv->image_width);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (thumbnail->image_height > 0)
|
||||
if (priv->image_height > 0)
|
||||
{
|
||||
keys[i] = TAG_THUMB_IMAGE_HEIGHT;
|
||||
values[i] = g_strdup_printf ("%d", thumbnail->image_height);
|
||||
values[i] = g_strdup_printf ("%d", priv->image_height);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (thumbnail->image_type)
|
||||
if (priv->image_type)
|
||||
{
|
||||
keys[i] = TAG_THUMB_GIMP_TYPE;
|
||||
values[i] = g_strdup (thumbnail->image_type);
|
||||
values[i] = g_strdup (priv->image_type);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (thumbnail->image_num_layers > 0)
|
||||
if (priv->image_num_layers > 0)
|
||||
{
|
||||
keys[i] = TAG_THUMB_GIMP_LAYERS;
|
||||
values[i] = g_strdup_printf ("%d", thumbnail->image_num_layers);
|
||||
values[i] = g_strdup_printf ("%d", priv->image_num_layers);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -876,7 +929,7 @@ gimp_thumbnail_save (GimpThumbnail *thumbnail,
|
|||
if (! success)
|
||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Could not create thumbnail for %s: %s"),
|
||||
thumbnail->image_uri, g_strerror (errno));
|
||||
priv->image_uri, g_strerror (errno));
|
||||
}
|
||||
|
||||
if (success)
|
||||
|
@ -890,17 +943,17 @@ gimp_thumbnail_save (GimpThumbnail *thumbnail,
|
|||
if (! success)
|
||||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
"Could not set permissions of thumbnail for %s: %s",
|
||||
thumbnail->image_uri, g_strerror (errno));
|
||||
priv->image_uri, g_strerror (errno));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (thumbnail));
|
||||
|
||||
gimp_thumbnail_update_thumb (thumbnail, size);
|
||||
|
||||
if (success &&
|
||||
thumbnail->thumb_state == GIMP_THUMB_STATE_EXISTS &&
|
||||
strcmp (filename, thumbnail->thumb_filename) == 0)
|
||||
priv->thumb_state == GIMP_THUMB_STATE_EXISTS &&
|
||||
strcmp (filename, priv->thumb_filename) == 0)
|
||||
{
|
||||
thumbnail->thumb_state = GIMP_THUMB_STATE_OK;
|
||||
priv->thumb_state = GIMP_THUMB_STATE_OK;
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (thumbnail));
|
||||
|
@ -979,6 +1032,7 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
GimpThumbSize size,
|
||||
GError **error)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
GimpThumbState state;
|
||||
GdkPixbuf *pixbuf;
|
||||
const gchar *option;
|
||||
|
@ -989,7 +1043,9 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
if (! thumbnail->image_uri)
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
if (! priv->image_uri)
|
||||
return NULL;
|
||||
|
||||
state = gimp_thumbnail_peek_thumb (thumbnail, size);
|
||||
|
@ -997,12 +1053,12 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
if (state < GIMP_THUMB_STATE_EXISTS || state == GIMP_THUMB_STATE_FAILED)
|
||||
return NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (thumbnail->thumb_filename, NULL);
|
||||
pixbuf = gdk_pixbuf_new_from_file (priv->thumb_filename, NULL);
|
||||
if (! pixbuf)
|
||||
return NULL;
|
||||
|
||||
#ifdef GIMP_THUMB_DEBUG
|
||||
g_printerr ("thumbnail loaded from %s\n", thumbnail->thumb_filename);
|
||||
g_printerr ("thumbnail loaded from %s\n", priv->thumb_filename);
|
||||
#endif
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (thumbnail));
|
||||
|
@ -1012,10 +1068,10 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
if (!option)
|
||||
goto finish;
|
||||
|
||||
if (strcmp (option, thumbnail->image_uri))
|
||||
if (strcmp (option, priv->image_uri))
|
||||
{
|
||||
/* might be a local thumbnail, try if the local part matches */
|
||||
const gchar *baseuri = strrchr (thumbnail->image_uri, '/');
|
||||
const gchar *baseuri = strrchr (priv->image_uri, '/');
|
||||
|
||||
if (!baseuri || strcmp (option, baseuri))
|
||||
goto finish;
|
||||
|
@ -1032,10 +1088,10 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
goto finish;
|
||||
|
||||
/* TAG_THUMB_FILESIZE is optional but must match if present */
|
||||
if (image_mtime == thumbnail->image_mtime &&
|
||||
(option == NULL || image_size == thumbnail->image_filesize))
|
||||
if (image_mtime == priv->image_mtime &&
|
||||
(option == NULL || image_size == priv->image_filesize))
|
||||
{
|
||||
if (thumbnail->thumb_size == GIMP_THUMB_SIZE_FAIL)
|
||||
if (priv->thumb_size == GIMP_THUMB_SIZE_FAIL)
|
||||
state = GIMP_THUMB_STATE_FAILED;
|
||||
else
|
||||
state = GIMP_THUMB_STATE_OK;
|
||||
|
@ -1047,7 +1103,7 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
gimp_thumbnail_set_info_from_pixbuf (thumbnail, pixbuf);
|
||||
|
||||
finish:
|
||||
if (thumbnail->thumb_size == GIMP_THUMB_SIZE_FAIL ||
|
||||
if (priv->thumb_size == GIMP_THUMB_SIZE_FAIL ||
|
||||
(state != GIMP_THUMB_STATE_OLD && state != GIMP_THUMB_STATE_OK))
|
||||
{
|
||||
g_object_unref (pixbuf);
|
||||
|
@ -1092,23 +1148,26 @@ gimp_thumbnail_save_thumb (GimpThumbnail *thumbnail,
|
|||
const gchar *software,
|
||||
GError **error)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
GimpThumbSize size;
|
||||
gchar *name;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE);
|
||||
g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (GET_PRIVATE (thumbnail)->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
|
||||
g_return_val_if_fail (software != NULL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
size = MAX (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf));
|
||||
if (size < 1)
|
||||
return TRUE;
|
||||
|
||||
name = gimp_thumb_name_from_uri (thumbnail->image_uri, size);
|
||||
name = gimp_thumb_name_from_uri (priv->image_uri, size);
|
||||
if (! name)
|
||||
return TRUE;
|
||||
|
||||
|
@ -1151,6 +1210,7 @@ gimp_thumbnail_save_thumb_local (GimpThumbnail *thumbnail,
|
|||
const gchar *software,
|
||||
GError **error)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
GimpThumbSize size;
|
||||
gchar *name;
|
||||
gchar *filename;
|
||||
|
@ -1158,25 +1218,27 @@ gimp_thumbnail_save_thumb_local (GimpThumbnail *thumbnail,
|
|||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE);
|
||||
g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (GET_PRIVATE (thumbnail)->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
|
||||
g_return_val_if_fail (software != NULL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
size = MAX (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf));
|
||||
if (size < 1)
|
||||
return TRUE;
|
||||
|
||||
filename = _gimp_thumb_filename_from_uri (thumbnail->image_uri);
|
||||
filename = _gimp_thumb_filename_from_uri (priv->image_uri);
|
||||
if (! filename)
|
||||
return TRUE;
|
||||
|
||||
dirname = g_path_get_dirname (filename);
|
||||
g_free (filename);
|
||||
|
||||
name = gimp_thumb_name_from_uri_local (thumbnail->image_uri, size);
|
||||
name = gimp_thumb_name_from_uri_local (priv->image_uri, size);
|
||||
if (! name)
|
||||
{
|
||||
g_free (dirname);
|
||||
|
@ -1219,6 +1281,7 @@ gimp_thumbnail_save_failure (GimpThumbnail *thumbnail,
|
|||
const gchar *software,
|
||||
GError **error)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
GdkPixbuf *pixbuf;
|
||||
gchar *name;
|
||||
gchar *desc;
|
||||
|
@ -1227,12 +1290,14 @@ gimp_thumbnail_save_failure (GimpThumbnail *thumbnail,
|
|||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE);
|
||||
g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (GET_PRIVATE (thumbnail)->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (software != NULL, FALSE);
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
name = gimp_thumb_name_from_uri (thumbnail->image_uri, GIMP_THUMB_SIZE_FAIL);
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
name = gimp_thumb_name_from_uri (priv->image_uri, GIMP_THUMB_SIZE_FAIL);
|
||||
if (! name)
|
||||
return TRUE;
|
||||
|
||||
|
@ -1244,14 +1309,14 @@ gimp_thumbnail_save_failure (GimpThumbnail *thumbnail,
|
|||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
|
||||
|
||||
desc = g_strdup_printf ("Thumbnail failure for %s", thumbnail->image_uri);
|
||||
time_str = g_strdup_printf ("%" G_GINT64_FORMAT, thumbnail->image_mtime);
|
||||
size_str = g_strdup_printf ("%" G_GINT64_FORMAT, thumbnail->image_filesize);
|
||||
desc = g_strdup_printf ("Thumbnail failure for %s", priv->image_uri);
|
||||
time_str = g_strdup_printf ("%" G_GINT64_FORMAT, priv->image_mtime);
|
||||
size_str = g_strdup_printf ("%" G_GINT64_FORMAT, priv->image_filesize);
|
||||
|
||||
success = gdk_pixbuf_save (pixbuf, name, "png", error,
|
||||
TAG_DESCRIPTION, desc,
|
||||
TAG_SOFTWARE, software,
|
||||
TAG_THUMB_URI, thumbnail->image_uri,
|
||||
TAG_THUMB_URI, priv->image_uri,
|
||||
TAG_THUMB_MTIME, time_str,
|
||||
TAG_THUMB_FILESIZE, size_str,
|
||||
NULL);
|
||||
|
@ -1289,14 +1354,17 @@ gimp_thumbnail_save_failure (GimpThumbnail *thumbnail,
|
|||
void
|
||||
gimp_thumbnail_delete_failure (GimpThumbnail *thumbnail)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
gchar *filename;
|
||||
|
||||
g_return_if_fail (GIMP_IS_THUMBNAIL (thumbnail));
|
||||
g_return_if_fail (thumbnail->image_uri != NULL);
|
||||
g_return_if_fail (GET_PRIVATE (thumbnail)->image_uri != NULL);
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
filename = gimp_thumb_name_from_uri (thumbnail->image_uri,
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
filename = gimp_thumb_name_from_uri (priv->image_uri,
|
||||
GIMP_THUMB_SIZE_FAIL);
|
||||
if (filename)
|
||||
{
|
||||
|
@ -1323,11 +1391,11 @@ gimp_thumbnail_delete_others (GimpThumbnail *thumbnail,
|
|||
GimpThumbSize size)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_THUMBNAIL (thumbnail));
|
||||
g_return_if_fail (thumbnail->image_uri != NULL);
|
||||
g_return_if_fail (GET_PRIVATE (thumbnail)->image_uri != NULL);
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
_gimp_thumbs_delete_others (thumbnail->image_uri, size);
|
||||
_gimp_thumbs_delete_others (GET_PRIVATE (thumbnail)->image_uri, size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1350,6 +1418,7 @@ gimp_thumbnail_delete_others (GimpThumbnail *thumbnail,
|
|||
gboolean
|
||||
gimp_thumbnail_has_failed (GimpThumbnail *thumbnail)
|
||||
{
|
||||
GimpThumbnailPrivate *priv;
|
||||
GdkPixbuf *pixbuf;
|
||||
const gchar *option;
|
||||
gchar *filename;
|
||||
|
@ -1358,11 +1427,13 @@ gimp_thumbnail_has_failed (GimpThumbnail *thumbnail)
|
|||
gboolean failed = FALSE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE);
|
||||
g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);
|
||||
g_return_val_if_fail (GET_PRIVATE (thumbnail)->image_uri != NULL, FALSE);
|
||||
|
||||
GIMP_THUMB_DEBUG_CALL (thumbnail);
|
||||
|
||||
filename = gimp_thumb_name_from_uri (thumbnail->image_uri,
|
||||
priv = GET_PRIVATE (thumbnail);
|
||||
|
||||
filename = gimp_thumb_name_from_uri (priv->image_uri,
|
||||
GIMP_THUMB_SIZE_FAIL);
|
||||
if (! filename)
|
||||
return FALSE;
|
||||
|
@ -1378,7 +1449,7 @@ gimp_thumbnail_has_failed (GimpThumbnail *thumbnail)
|
|||
|
||||
/* URI and mtime from the thumbnail need to match our file */
|
||||
option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_URI);
|
||||
if (! option || strcmp (option, thumbnail->image_uri))
|
||||
if (! option || strcmp (option, priv->image_uri))
|
||||
goto finish;
|
||||
|
||||
option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_MTIME);
|
||||
|
@ -1390,8 +1461,8 @@ gimp_thumbnail_has_failed (GimpThumbnail *thumbnail)
|
|||
goto finish;
|
||||
|
||||
/* TAG_THUMB_FILESIZE is optional but must match if present */
|
||||
if (image_mtime == thumbnail->image_mtime &&
|
||||
(option == NULL || image_size == thumbnail->image_filesize))
|
||||
if (image_mtime == priv->image_mtime &&
|
||||
(option == NULL || image_size == priv->image_filesize))
|
||||
{
|
||||
failed = TRUE;
|
||||
}
|
||||
|
|
|
@ -33,49 +33,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define GIMP_TYPE_THUMBNAIL (gimp_thumbnail_get_type ())
|
||||
#define GIMP_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_THUMBNAIL, GimpThumbnail))
|
||||
#define GIMP_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_THUMBNAIL, GimpThumbnailClass))
|
||||
#define GIMP_IS_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_THUMBNAIL))
|
||||
#define GIMP_IS_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_THUMBNAIL))
|
||||
#define GIMP_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_THUMBNAIL, GimpThumbnailClass))
|
||||
|
||||
|
||||
typedef struct _GimpThumbnailPrivate GimpThumbnailPrivate;
|
||||
typedef struct _GimpThumbnailClass GimpThumbnailClass;
|
||||
|
||||
/**
|
||||
* GimpThumbnail:
|
||||
*
|
||||
* All members of #GimpThumbnail are private and should only be accessed
|
||||
* using object properties.
|
||||
**/
|
||||
struct _GimpThumbnail
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GimpThumbnailPrivate *priv;
|
||||
|
||||
/* FIXME MOVE TO PRIVATE */
|
||||
/*< private >*/
|
||||
GimpThumbState image_state;
|
||||
gchar *image_uri;
|
||||
gchar *image_filename;
|
||||
gint64 image_filesize;
|
||||
gint64 image_mtime;
|
||||
gint image_not_found_errno;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
gchar *image_type;
|
||||
gint image_num_layers;
|
||||
|
||||
GimpThumbState thumb_state;
|
||||
GimpThumbSize thumb_size;
|
||||
gchar *thumb_filename;
|
||||
gint64 thumb_filesize;
|
||||
gint64 thumb_mtime;
|
||||
|
||||
gchar *image_mimetype;
|
||||
};
|
||||
G_DECLARE_DERIVABLE_TYPE (GimpThumbnail, gimp_thumbnail, GIMP, THUMBNAIL, GObject)
|
||||
|
||||
struct _GimpThumbnailClass
|
||||
{
|
||||
|
@ -93,8 +51,6 @@ struct _GimpThumbnailClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_thumbnail_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpThumbnail * gimp_thumbnail_new (void);
|
||||
|
||||
void gimp_thumbnail_set_uri (GimpThumbnail *thumbnail,
|
||||
|
|
Loading…
Reference in New Issue