Initial checkin of Pika from heckimp
This commit is contained in:
14
libpikathumb/Makefile.gi
Normal file
14
libpikathumb/Makefile.gi
Normal file
@ -0,0 +1,14 @@
|
||||
# Introspectable sources for libpikathumb
|
||||
|
||||
libpikathumb_introspectable_headers = \
|
||||
../libpikathumb/pikathumb-enums.h \
|
||||
../libpikathumb/pikathumb-error.h \
|
||||
../libpikathumb/pikathumb-types.h \
|
||||
../libpikathumb/pikathumb-utils.h \
|
||||
../libpikathumb/pikathumbnail.h
|
||||
|
||||
libpikathumb_introspectable = \
|
||||
../libpikathumb/pikathumb-error.c \
|
||||
../libpikathumb/pikathumb-utils.c \
|
||||
../libpikathumb/pikathumbnail.c \
|
||||
$(libpikathumb_introspectable_headers)
|
98
libpikathumb/meson.build
Normal file
98
libpikathumb/meson.build
Normal file
@ -0,0 +1,98 @@
|
||||
# Unlike other enums file, we don't use the mkenums_wrap because this
|
||||
# one is not versionned in the repository (not sure why). Moreover the
|
||||
# options are quite different from the other generated enums, so it
|
||||
# didn't make sense to overdo it.
|
||||
pikathumbenums = custom_target('pikathumb-enums.c',
|
||||
input : [ 'pikathumb-enums.h', ],
|
||||
output: [ 'pikathumb-enums.c', ],
|
||||
command: [
|
||||
pika_mkenums,
|
||||
'--fhead','#include "config.h"\n'+
|
||||
'#include <glib-object.h>\n'+
|
||||
'#include "pikathumb-enums.h"\n',
|
||||
'--fprod','/* enumerations from "@filename@" */',
|
||||
'--vhead','GType\n'+
|
||||
'@enum_name@_get_type (void)\n'+
|
||||
'{\n'+
|
||||
' static const G@Type@Value values[] =\n'+
|
||||
' {',
|
||||
'--vprod',' { @VALUENAME@, @valuedesc@, "@valuenick@" },',
|
||||
'--vtail',' { 0, NULL, NULL }\n'+
|
||||
' };\n'+
|
||||
'\n'+
|
||||
' static GType type = 0;\n'+
|
||||
'\n'+
|
||||
' if (G_UNLIKELY (! type))\n'+
|
||||
' type = g_@type@_register_static ("@EnumName@", values);\n'+
|
||||
'\n'+
|
||||
' return type;\n'+
|
||||
'}\n',
|
||||
'@INPUT@',
|
||||
],
|
||||
capture: true,
|
||||
)
|
||||
|
||||
libpikathumb_sources_introspectable = files(
|
||||
'pikathumb-error.c',
|
||||
'pikathumb-utils.c',
|
||||
'pikathumbnail.c',
|
||||
)
|
||||
|
||||
libpikathumb_sources = [
|
||||
libpikathumb_sources_introspectable,
|
||||
pikathumbenums,
|
||||
]
|
||||
|
||||
libpikathumb_headers_introspectable = files(
|
||||
'pikathumb-enums.h',
|
||||
'pikathumb-error.h',
|
||||
'pikathumb-types.h',
|
||||
'pikathumb-utils.h',
|
||||
'pikathumbnail.h',
|
||||
)
|
||||
|
||||
libpikathumb_headers = [
|
||||
libpikathumb_headers_introspectable,
|
||||
'pikathumb.h',
|
||||
]
|
||||
|
||||
libpikathumb_introspectable = [
|
||||
libpikathumb_sources_introspectable,
|
||||
libpikathumb_headers_introspectable,
|
||||
]
|
||||
|
||||
libpikathumb = library('pikathumb-'+ pika_api_version,
|
||||
libpikathumb_sources,
|
||||
include_directories: rootInclude,
|
||||
dependencies: [
|
||||
glib, gobject, gdk_pixbuf, gio,
|
||||
],
|
||||
c_args: [ '-DG_LOG_DOMAIN="LibPikaThumb"', '-DPIKA_THUMB_COMPILATION', ],
|
||||
link_with: [
|
||||
libpikabase,
|
||||
],
|
||||
vs_module_defs: 'pikathumb.def',
|
||||
install: true,
|
||||
version: so_version,
|
||||
)
|
||||
|
||||
install_headers(
|
||||
libpikathumb_headers,
|
||||
subdir: pika_api_name / 'libpikathumb',
|
||||
)
|
||||
|
||||
|
||||
# Test program, not installed
|
||||
pika_thumbnail_list = executable('pika-thumbnail-list',
|
||||
'pika-thumbnail-list.c',
|
||||
include_directories: rootInclude,
|
||||
dependencies: [
|
||||
gdk_pixbuf,
|
||||
],
|
||||
c_args: '-DG_LOG_DOMAIN="LibPikaThumb"',
|
||||
link_with: [
|
||||
libpikabase,
|
||||
libpikathumb,
|
||||
],
|
||||
install: false,
|
||||
)
|
251
libpikathumb/pika-thumbnail-list.c
Normal file
251
libpikathumb/pika-thumbnail-list.c
Normal file
@ -0,0 +1,251 @@
|
||||
/*
|
||||
* pika-thumbnail-list.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <libpikathumb/pikathumb.h>
|
||||
|
||||
|
||||
#define STATE_NONE -1
|
||||
#define STATE_ERROR -2
|
||||
|
||||
|
||||
static gboolean parse_option_state (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error);
|
||||
static gboolean parse_option_path (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error);
|
||||
static void process_folder (const gchar *folder);
|
||||
static void process_thumbnail (const gchar *filename);
|
||||
|
||||
|
||||
static PikaThumbState option_state = STATE_NONE;
|
||||
static gboolean option_verbose = FALSE;
|
||||
static gchar *option_path = NULL;
|
||||
|
||||
|
||||
static const GOptionEntry main_entries[] =
|
||||
{
|
||||
{
|
||||
"state", 's', 0,
|
||||
G_OPTION_ARG_CALLBACK, parse_option_state,
|
||||
"Filter by thumbnail state "
|
||||
"(unknown|remote|folder|special|not-found|exists|old|failed|ok|error)",
|
||||
"<state>"
|
||||
},
|
||||
{
|
||||
"path", 'p', 0,
|
||||
G_OPTION_ARG_CALLBACK, parse_option_path,
|
||||
"Filter by original file's path",
|
||||
"<path>"
|
||||
},
|
||||
{
|
||||
"verbose", 'v', 0,
|
||||
G_OPTION_ARG_NONE, &option_verbose,
|
||||
"Print additional info per matched file", NULL
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar *argv[])
|
||||
{
|
||||
GOptionContext *context;
|
||||
GDir *dir;
|
||||
const gchar *thumb_folder;
|
||||
const gchar *folder;
|
||||
GError *error = NULL;
|
||||
|
||||
pika_thumb_init ("pika-thumbnail-list", NULL);
|
||||
|
||||
thumb_folder = pika_thumb_get_thumb_base_dir ();
|
||||
|
||||
context = g_option_context_new (NULL);
|
||||
g_option_context_add_main_entries (context, main_entries, NULL);
|
||||
|
||||
if (! g_option_context_parse (context, &argc, &argv, &error))
|
||||
{
|
||||
g_printerr ("%s\n", error->message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dir = g_dir_open (thumb_folder, 0, &error);
|
||||
|
||||
if (! dir)
|
||||
g_error ("Error opening %s: %s", thumb_folder, error->message);
|
||||
|
||||
while ((folder = g_dir_read_name (dir)))
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
filename = g_build_filename (thumb_folder, folder, NULL);
|
||||
|
||||
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
|
||||
process_folder (filename);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_option_state (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
{
|
||||
if (strcmp (value, "unknown") == 0)
|
||||
option_state = PIKA_THUMB_STATE_UNKNOWN;
|
||||
else if (strcmp (value, "remote") == 0)
|
||||
option_state = PIKA_THUMB_STATE_REMOTE;
|
||||
else if (strcmp (value, "folder") == 0)
|
||||
option_state = PIKA_THUMB_STATE_FOLDER;
|
||||
else if (strcmp (value, "special") == 0)
|
||||
option_state = PIKA_THUMB_STATE_SPECIAL;
|
||||
else if (strcmp (value, "not-found") == 0)
|
||||
option_state = PIKA_THUMB_STATE_NOT_FOUND;
|
||||
else if (strcmp (value, "exists") == 0)
|
||||
option_state = PIKA_THUMB_STATE_EXISTS;
|
||||
else if (strcmp (value, "old") == 0)
|
||||
option_state = PIKA_THUMB_STATE_OLD;
|
||||
else if (strcmp (value, "failed") == 0)
|
||||
option_state = PIKA_THUMB_STATE_FAILED;
|
||||
else if (strcmp (value, "ok") == 0)
|
||||
option_state = PIKA_THUMB_STATE_OK;
|
||||
else if (strcmp (value, "error") == 0)
|
||||
option_state = STATE_ERROR;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_option_path (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
{
|
||||
option_path = g_strdup (value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
process_folder (const gchar *folder)
|
||||
{
|
||||
GDir *dir;
|
||||
const gchar *name;
|
||||
GError *error = NULL;
|
||||
|
||||
#if 0
|
||||
g_print ("processing folder: %s\n", folder);
|
||||
#endif
|
||||
|
||||
dir = g_dir_open (folder, 0, &error);
|
||||
|
||||
if (! dir)
|
||||
{
|
||||
g_printerr ("Error opening '%s': %s", folder, error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
while ((name = g_dir_read_name (dir)))
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
filename = g_build_filename (folder, name, NULL);
|
||||
|
||||
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
|
||||
process_folder (filename);
|
||||
else
|
||||
process_thumbnail (filename);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
}
|
||||
|
||||
static void
|
||||
process_thumbnail (const gchar *filename)
|
||||
{
|
||||
PikaThumbnail *thumbnail;
|
||||
GError *error = NULL;
|
||||
|
||||
thumbnail = pika_thumbnail_new ();
|
||||
|
||||
if (! pika_thumbnail_set_from_thumb (thumbnail, filename, &error))
|
||||
{
|
||||
if (option_state == STATE_ERROR)
|
||||
{
|
||||
if (option_verbose)
|
||||
g_print ("%s '%s'\n", filename, error->message);
|
||||
else
|
||||
g_print ("%s\n", filename);
|
||||
}
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
else
|
||||
{
|
||||
PikaThumbState state = pika_thumbnail_peek_image (thumbnail);
|
||||
|
||||
if ((option_state == STATE_NONE || state == option_state)
|
||||
|
||||
&&
|
||||
|
||||
(option_path == NULL ||
|
||||
strstr (thumbnail->image_uri, option_path)))
|
||||
{
|
||||
if (option_verbose)
|
||||
g_print ("%s '%s'\n", filename, thumbnail->image_uri);
|
||||
else
|
||||
g_print ("%s\n", filename);
|
||||
}
|
||||
|
||||
#if 0
|
||||
switch (foo)
|
||||
{
|
||||
case PIKA_THUMB_STATE_REMOTE:
|
||||
g_print ("%s Remote image '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
|
||||
case PIKA_THUMB_STATE_FOLDER:
|
||||
g_print ("%s Folder '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
|
||||
case PIKA_THUMB_STATE_SPECIAL:
|
||||
g_print ("%s Special file '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
|
||||
case PIKA_THUMB_STATE_NOT_FOUND:
|
||||
g_print ("%s Image not found '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
|
||||
case PIKA_THUMB_STATE_OLD:
|
||||
g_print ("%s Thumbnail old '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
|
||||
case PIKA_THUMB_STATE_FAILED:
|
||||
g_print ("%s EEEEEEEEK '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_print ("%s '%s'\n", filename, thumbnail->image_uri);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
g_object_unref (thumbnail);
|
||||
}
|
118
libpikathumb/pikathumb-enums.h
Normal file
118
libpikathumb/pikathumb-enums.h
Normal file
@ -0,0 +1,118 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PIKA_THUMB_ENUMS_H__
|
||||
#define __PIKA_THUMB_ENUMS_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: pikathumb-enums
|
||||
* @title: PikaThumb-enums
|
||||
* @short_description: Enumerations used by libpikathumb
|
||||
*
|
||||
* Enumerations used by libpikathumb
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* PikaThumbFileType:
|
||||
* @PIKA_THUMB_FILE_TYPE_NONE: file does not exist
|
||||
* @PIKA_THUMB_FILE_TYPE_REGULAR: a regular file
|
||||
* @PIKA_THUMB_FILE_TYPE_FOLDER: a directory
|
||||
* @PIKA_THUMB_FILE_TYPE_SPECIAL: a special file (device node, fifo, socket, ...)
|
||||
*
|
||||
* File types as returned by pika_thumb_file_test().
|
||||
**/
|
||||
#define PIKA_TYPE_THUMB_FILE_TYPE (pika_thumb_file_type_get_type ())
|
||||
|
||||
GType pika_thumb_file_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PIKA_THUMB_FILE_TYPE_NONE,
|
||||
PIKA_THUMB_FILE_TYPE_REGULAR,
|
||||
PIKA_THUMB_FILE_TYPE_FOLDER,
|
||||
PIKA_THUMB_FILE_TYPE_SPECIAL
|
||||
} PikaThumbFileType;
|
||||
|
||||
|
||||
/**
|
||||
* PikaThumbSize:
|
||||
* @PIKA_THUMB_SIZE_FAIL: special size used to indicate a thumbnail
|
||||
* creation failure
|
||||
* @PIKA_THUMB_SIZE_NORMAL: normal thumbnail size (128 pixels)
|
||||
* @PIKA_THUMB_SIZE_LARGE: large thumbnail size (256 pixels)
|
||||
*
|
||||
* Possible thumbnail sizes as defined by the Thumbnail Managing
|
||||
* Standard.
|
||||
**/
|
||||
#define PIKA_TYPE_THUMB_SIZE (pika_thumb_size_get_type ())
|
||||
|
||||
GType pika_thumb_size_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PIKA_THUMB_SIZE_FAIL = 0,
|
||||
PIKA_THUMB_SIZE_NORMAL = 128,
|
||||
PIKA_THUMB_SIZE_LARGE = 256
|
||||
} PikaThumbSize;
|
||||
|
||||
|
||||
/**
|
||||
* PikaThumbState:
|
||||
* @PIKA_THUMB_STATE_UNKNOWN: nothing is known about the file/thumbnail
|
||||
* @PIKA_THUMB_STATE_REMOTE: the file is on a remote file system
|
||||
* @PIKA_THUMB_STATE_FOLDER: the file is a directory
|
||||
* @PIKA_THUMB_STATE_SPECIAL: the file is a special file
|
||||
* @PIKA_THUMB_STATE_NOT_FOUND: the file/thumbnail doesn't exist
|
||||
* @PIKA_THUMB_STATE_EXISTS: the file/thumbnail exists
|
||||
* @PIKA_THUMB_STATE_OLD: the thumbnail may be outdated
|
||||
* @PIKA_THUMB_STATE_FAILED: the thumbnail couldn't be created
|
||||
* @PIKA_THUMB_STATE_OK: the thumbnail exists and matches the image
|
||||
*
|
||||
* Possible image and thumbnail file states used by libpikathumb.
|
||||
**/
|
||||
#define PIKA_TYPE_THUMB_STATE (pika_thumb_state_get_type ())
|
||||
|
||||
GType pika_thumb_state_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PIKA_THUMB_STATE_UNKNOWN,
|
||||
PIKA_THUMB_STATE_REMOTE,
|
||||
PIKA_THUMB_STATE_FOLDER,
|
||||
PIKA_THUMB_STATE_SPECIAL,
|
||||
PIKA_THUMB_STATE_NOT_FOUND,
|
||||
PIKA_THUMB_STATE_EXISTS,
|
||||
PIKA_THUMB_STATE_OLD,
|
||||
PIKA_THUMB_STATE_FAILED,
|
||||
PIKA_THUMB_STATE_OK
|
||||
} PikaThumbState;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_THUMB_ENUMS_H__ */
|
52
libpikathumb/pikathumb-error.c
Normal file
52
libpikathumb/pikathumb-error.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "pikathumb-error.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: pikathumb-error
|
||||
* @title: PikaThumb-error
|
||||
* @short_description: Error codes used by libpikathumb
|
||||
*
|
||||
* Error codes used by libpikathumb
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* pika_thumb_error_quark:
|
||||
*
|
||||
* This function is never called directly. Use PIKA_THUMB_ERROR() instead.
|
||||
*
|
||||
* Returns: the #GQuark that defines the PikaThumb error domain.
|
||||
**/
|
||||
GQuark
|
||||
pika_thumb_error_quark (void)
|
||||
{
|
||||
return g_quark_from_static_string ("pika-thumb-error-quark");
|
||||
}
|
64
libpikathumb/pikathumb-error.h
Normal file
64
libpikathumb/pikathumb-error.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (__PIKA_THUMB_H_INSIDE__) && !defined (PIKA_THUMB_COMPILATION)
|
||||
#error "Only <libpikathumb/pikathumb.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __PIKA_THUMB_ERROR_H__
|
||||
#define __PIKA_THUMB_ERROR_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/**
|
||||
* PikaThumbError:
|
||||
* @PIKA_THUMB_ERROR_OPEN: there was a problem opening the file
|
||||
* @PIKA_THUMB_ERROR_OPEN_ENOENT: the file doesn't exist
|
||||
* @PIKA_THUMB_ERROR_MKDIR: there was a problem creating a directory
|
||||
*
|
||||
* These are the possible error codes used when a #GError is set by
|
||||
* libpikathumb.
|
||||
**/
|
||||
typedef enum
|
||||
{
|
||||
PIKA_THUMB_ERROR_OPEN,
|
||||
PIKA_THUMB_ERROR_OPEN_ENOENT,
|
||||
PIKA_THUMB_ERROR_MKDIR
|
||||
} PikaThumbError;
|
||||
|
||||
|
||||
/**
|
||||
* PIKA_THUMB_ERROR:
|
||||
*
|
||||
* Identifier for the libpikathumb error domain.
|
||||
**/
|
||||
#define PIKA_THUMB_ERROR (pika_thumb_error_quark ())
|
||||
|
||||
GQuark pika_thumb_error_quark (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_THUMB_ERROR_H__ */
|
38
libpikathumb/pikathumb-types.h
Normal file
38
libpikathumb/pikathumb-types.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PIKA_THUMB_TYPES_H__
|
||||
#define __PIKA_THUMB_TYPES_H__
|
||||
|
||||
|
||||
#include <libpikathumb/pikathumb-enums.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _PikaThumbnail PikaThumbnail;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __PIKA_THUMB_TYPES_H__ */
|
870
libpikathumb/pikathumb-utils.c
Normal file
870
libpikathumb/pikathumb-utils.c
Normal file
@ -0,0 +1,870 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef PLATFORM_OSX
|
||||
#include <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include "libpikabase/pikawin32-io.h"
|
||||
#endif
|
||||
|
||||
#include "pikathumb-error.h"
|
||||
#include "pikathumb-types.h"
|
||||
#include "pikathumb-utils.h"
|
||||
|
||||
#include "libpika/libpika-intl.h"
|
||||
|
||||
|
||||
/**
|
||||
* SECTION: pikathumb-utils
|
||||
* @title: PikaThumb-utils
|
||||
* @short_description: Utility functions provided and used by libpikathumb
|
||||
*
|
||||
* Utility functions provided and used by libpikathumb
|
||||
**/
|
||||
|
||||
|
||||
static gint pika_thumb_size (PikaThumbSize size);
|
||||
static gchar * pika_thumb_png_lookup (const gchar *name,
|
||||
const gchar *basedir,
|
||||
PikaThumbSize *size) G_GNUC_MALLOC;
|
||||
static const gchar * pika_thumb_png_name (const gchar *uri);
|
||||
static void pika_thumb_exit (void);
|
||||
|
||||
|
||||
|
||||
static gboolean pika_thumb_initialized = FALSE;
|
||||
static gint thumb_num_sizes = 0;
|
||||
static gint *thumb_sizes = NULL;
|
||||
static const gchar **thumb_sizenames = NULL;
|
||||
static gchar *thumb_dir = NULL;
|
||||
static gchar **thumb_subdirs = NULL;
|
||||
static gchar *thumb_fail_subdir = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* pika_thumb_init:
|
||||
* @creator: an ASCII string that identifies the thumbnail creator
|
||||
* @thumb_basedir: an absolute path or %NULL to use the default
|
||||
*
|
||||
* This function initializes the thumbnail system. It must be called
|
||||
* before any other functions from libpikathumb are used. You may call
|
||||
* it more than once if you want to change the @thumb_basedir but if
|
||||
* you do that, you should make sure that no thread is still using the
|
||||
* library. Apart from this function, libpikathumb is multi-thread
|
||||
* safe.
|
||||
*
|
||||
* The @creator string must be 7bit ASCII and should contain the name
|
||||
* of the software that creates the thumbnails. It is used to handle
|
||||
* thumbnail creation failures. See the spec for more details.
|
||||
*
|
||||
* Usually you will pass %NULL for @thumb_basedir. Thumbnails will
|
||||
* then be stored in the user's personal thumbnail directory as
|
||||
* defined in the spec. If you wish to use libpikathumb to store
|
||||
* application-specific thumbnails, you can specify a different base
|
||||
* directory here.
|
||||
*
|
||||
* Returns: %TRUE if the library was successfully initialized.
|
||||
**/
|
||||
gboolean
|
||||
pika_thumb_init (const gchar *creator,
|
||||
const gchar *thumb_basedir)
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (creator != NULL, FALSE);
|
||||
g_return_val_if_fail (thumb_basedir == NULL ||
|
||||
g_path_is_absolute (thumb_basedir), FALSE);
|
||||
|
||||
if (pika_thumb_initialized)
|
||||
pika_thumb_exit ();
|
||||
|
||||
if (thumb_basedir)
|
||||
{
|
||||
thumb_dir = g_strdup (thumb_basedir);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PLATFORM_OSX
|
||||
|
||||
NSAutoreleasePool *pool;
|
||||
NSArray *path;
|
||||
NSString *cache_dir;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
path = NSSearchPathForDirectoriesInDomains (NSCachesDirectory,
|
||||
NSUserDomainMask, YES);
|
||||
cache_dir = [path objectAtIndex:0];
|
||||
|
||||
thumb_dir = g_build_filename ([cache_dir UTF8String], "org.freedesktop.thumbnails",
|
||||
NULL);
|
||||
|
||||
[pool drain];
|
||||
|
||||
#else
|
||||
|
||||
const gchar *cache_dir = g_get_user_cache_dir ();
|
||||
|
||||
if (cache_dir && g_file_test (cache_dir, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
thumb_dir = g_build_filename (cache_dir, "thumbnails", NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (! thumb_dir)
|
||||
{
|
||||
gchar *name = g_filename_display_name (g_get_tmp_dir ());
|
||||
|
||||
g_message (_("Cannot determine a valid thumbnails directory.\n"
|
||||
"Thumbnails will be stored in the folder for "
|
||||
"temporary files (%s) instead."), name);
|
||||
g_free (name);
|
||||
|
||||
thumb_dir = g_build_filename (g_get_tmp_dir (), ".thumbnails", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
enum_class = g_type_class_ref (PIKA_TYPE_THUMB_SIZE);
|
||||
|
||||
thumb_num_sizes = enum_class->n_values;
|
||||
thumb_sizes = g_new (gint, thumb_num_sizes);
|
||||
thumb_sizenames = g_new (const gchar *, thumb_num_sizes);
|
||||
thumb_subdirs = g_new (gchar *, thumb_num_sizes);
|
||||
|
||||
for (i = 0, enum_value = enum_class->values;
|
||||
i < enum_class->n_values;
|
||||
i++, enum_value++)
|
||||
{
|
||||
thumb_sizes[i] = enum_value->value;
|
||||
thumb_sizenames[i] = enum_value->value_nick;
|
||||
thumb_subdirs[i] = g_build_filename (thumb_dir,
|
||||
enum_value->value_nick, NULL);
|
||||
}
|
||||
|
||||
thumb_fail_subdir = thumb_subdirs[0];
|
||||
thumb_subdirs[0] = g_build_filename (thumb_fail_subdir, creator, NULL);
|
||||
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
pika_thumb_initialized = TRUE;
|
||||
|
||||
return pika_thumb_initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_get_thumb_base_dir:
|
||||
*
|
||||
* Returns the base directory of thumbnails cache.
|
||||
* It uses the Freedesktop Thumbnail Managing Standard on UNIX,
|
||||
* "~/Library/Caches/org.freedesktop.thumbnails" on OSX, and a cache
|
||||
* folder determined by glib on Windows (currently the common repository
|
||||
* for temporary Internet files).
|
||||
* The returned string belongs to PIKA and must not be changed nor freed.
|
||||
*
|
||||
* Returns: the thumbnails cache directory.
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
const gchar *
|
||||
pika_thumb_get_thumb_base_dir (void)
|
||||
{
|
||||
g_return_val_if_fail (pika_thumb_initialized, NULL);
|
||||
|
||||
return thumb_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_get_thumb_dir:
|
||||
* @size: a PikaThumbSize
|
||||
*
|
||||
* Retrieve the name of the thumbnail folder for a specific size. The
|
||||
* returned pointer will become invalid if pika_thumb_init() is used
|
||||
* again. It must not be changed or freed.
|
||||
*
|
||||
* Returns: the thumbnail directory in the encoding of the filesystem
|
||||
**/
|
||||
const gchar *
|
||||
pika_thumb_get_thumb_dir (PikaThumbSize size)
|
||||
{
|
||||
g_return_val_if_fail (pika_thumb_initialized, NULL);
|
||||
|
||||
size = pika_thumb_size (size);
|
||||
|
||||
return thumb_subdirs[size];
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_get_thumb_dir_local:
|
||||
* @dirname: the basename of the dir, without the actual dirname itself
|
||||
* @size: a PikaThumbSize
|
||||
*
|
||||
* Retrieve the name of the local thumbnail folder for a specific
|
||||
* size. Unlike pika_thumb_get_thumb_dir() the returned string is not
|
||||
* constant and should be free'd when it is not any longer needed.
|
||||
*
|
||||
* Returns: the thumbnail directory in the encoding of the filesystem
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
gchar *
|
||||
pika_thumb_get_thumb_dir_local (const gchar *dirname,
|
||||
PikaThumbSize size)
|
||||
{
|
||||
g_return_val_if_fail (pika_thumb_initialized, NULL);
|
||||
g_return_val_if_fail (dirname != NULL, NULL);
|
||||
g_return_val_if_fail (size > PIKA_THUMB_SIZE_FAIL, NULL);
|
||||
|
||||
size = pika_thumb_size (size);
|
||||
|
||||
return g_build_filename (dirname, thumb_sizenames[size], NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_ensure_thumb_dir:
|
||||
* @size: a PikaThumbSize
|
||||
* @error: return location for possible errors
|
||||
*
|
||||
* This function checks if the directory that is required to store
|
||||
* thumbnails for a particular @size exist and attempts to create it
|
||||
* if necessary.
|
||||
*
|
||||
* You shouldn't have to call this function directly since
|
||||
* pika_thumbnail_save_thumb() and pika_thumbnail_save_failure() will
|
||||
* do this for you.
|
||||
*
|
||||
* Returns: %TRUE is the directory exists, %FALSE if it could not
|
||||
* be created
|
||||
**/
|
||||
gboolean
|
||||
pika_thumb_ensure_thumb_dir (PikaThumbSize size,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (pika_thumb_initialized, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
size = pika_thumb_size (size);
|
||||
|
||||
if (g_file_test (thumb_subdirs[size], G_FILE_TEST_IS_DIR))
|
||||
return TRUE;
|
||||
|
||||
if (g_file_test (thumb_dir, G_FILE_TEST_IS_DIR) ||
|
||||
(g_mkdir_with_parents (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
|
||||
{
|
||||
if (size == 0)
|
||||
g_mkdir_with_parents (thumb_fail_subdir, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
|
||||
g_mkdir_with_parents (thumb_subdirs[size], S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
}
|
||||
|
||||
if (g_file_test (thumb_subdirs[size], G_FILE_TEST_IS_DIR))
|
||||
return TRUE;
|
||||
|
||||
g_set_error (error,
|
||||
PIKA_THUMB_ERROR, PIKA_THUMB_ERROR_MKDIR,
|
||||
_("Failed to create thumbnail folder '%s'."),
|
||||
thumb_subdirs[size]);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_ensure_thumb_dir_local:
|
||||
* @dirname: the basename of the dir, without the actual dirname itself
|
||||
* @size: a PikaThumbSize
|
||||
* @error: return location for possible errors
|
||||
*
|
||||
* This function checks if the directory that is required to store
|
||||
* local thumbnails for a particular @size exist and attempts to
|
||||
* create it if necessary.
|
||||
*
|
||||
* You shouldn't have to call this function directly since
|
||||
* pika_thumbnail_save_thumb_local() will do this for you.
|
||||
*
|
||||
* Returns: %TRUE is the directory exists, %FALSE if it could not
|
||||
* be created
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
gboolean
|
||||
pika_thumb_ensure_thumb_dir_local (const gchar *dirname,
|
||||
PikaThumbSize size,
|
||||
GError **error)
|
||||
{
|
||||
gchar *basedir;
|
||||
gchar *subdir;
|
||||
|
||||
g_return_val_if_fail (pika_thumb_initialized, FALSE);
|
||||
g_return_val_if_fail (dirname != NULL, FALSE);
|
||||
g_return_val_if_fail (g_path_is_absolute (dirname), FALSE);
|
||||
g_return_val_if_fail (size > PIKA_THUMB_SIZE_FAIL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
size = pika_thumb_size (size);
|
||||
|
||||
subdir = g_build_filename (dirname,
|
||||
".thumblocal", thumb_sizenames[size],
|
||||
NULL);
|
||||
|
||||
if (g_file_test (subdir, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
g_free (subdir);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
basedir = g_build_filename (dirname, ".thumblocal", NULL);
|
||||
|
||||
if (g_file_test (basedir, G_FILE_TEST_IS_DIR) ||
|
||||
(g_mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
|
||||
{
|
||||
g_mkdir (subdir, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
}
|
||||
|
||||
g_free (basedir);
|
||||
|
||||
if (g_file_test (subdir, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
g_free (subdir);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_set_error (error,
|
||||
PIKA_THUMB_ERROR, PIKA_THUMB_ERROR_MKDIR,
|
||||
_("Failed to create thumbnail folder '%s'."),
|
||||
subdir);
|
||||
g_free (subdir);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_name_from_uri:
|
||||
* @uri: an escaped URI
|
||||
* @size: a #PikaThumbSize
|
||||
*
|
||||
* Creates the name of the thumbnail file of the specified @size that
|
||||
* belongs to an image file located at the given @uri.
|
||||
*
|
||||
* Returns: a newly allocated filename in the encoding of the
|
||||
* filesystem or %NULL if @uri points to the user's
|
||||
* thumbnail repository.
|
||||
**/
|
||||
gchar *
|
||||
pika_thumb_name_from_uri (const gchar *uri,
|
||||
PikaThumbSize size)
|
||||
{
|
||||
g_return_val_if_fail (pika_thumb_initialized, NULL);
|
||||
g_return_val_if_fail (uri != NULL, NULL);
|
||||
|
||||
if (strstr (uri, thumb_dir))
|
||||
return NULL;
|
||||
|
||||
size = pika_thumb_size (size);
|
||||
|
||||
return g_build_filename (thumb_subdirs[size],
|
||||
pika_thumb_png_name (uri),
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_name_from_uri_local:
|
||||
* @uri: an escaped URI
|
||||
* @size: a #PikaThumbSize
|
||||
*
|
||||
* Creates the name of a local thumbnail file of the specified @size
|
||||
* that belongs to an image file located at the given @uri. Local
|
||||
* thumbnails have been introduced with version 0.7 of the spec.
|
||||
*
|
||||
* Returns: a newly allocated filename in the encoding of the
|
||||
* filesystem or %NULL if @uri is a remote file or
|
||||
* points to the user's thumbnail repository.
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
gchar *
|
||||
pika_thumb_name_from_uri_local (const gchar *uri,
|
||||
PikaThumbSize size)
|
||||
{
|
||||
gchar *filename;
|
||||
gchar *result = NULL;
|
||||
|
||||
g_return_val_if_fail (pika_thumb_initialized, NULL);
|
||||
g_return_val_if_fail (uri != NULL, NULL);
|
||||
g_return_val_if_fail (size > PIKA_THUMB_SIZE_FAIL, NULL);
|
||||
|
||||
if (strstr (uri, thumb_dir))
|
||||
return NULL;
|
||||
|
||||
filename = _pika_thumb_filename_from_uri (uri);
|
||||
|
||||
if (filename)
|
||||
{
|
||||
const gchar *baseuri = strrchr (uri, '/');
|
||||
|
||||
if (baseuri && baseuri[0] && baseuri[1])
|
||||
{
|
||||
gchar *dirname = g_path_get_dirname (filename);
|
||||
gint i = pika_thumb_size (size);
|
||||
|
||||
result = g_build_filename (dirname,
|
||||
".thumblocal", thumb_sizenames[i],
|
||||
pika_thumb_png_name (uri),
|
||||
NULL);
|
||||
|
||||
g_free (dirname);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_find_thumb:
|
||||
* @uri: an escaped URI
|
||||
* @size: pointer to a #PikaThumbSize
|
||||
*
|
||||
* This function attempts to locate a thumbnail for the given
|
||||
* @uri. First it tries the size that is stored at @size. If no
|
||||
* thumbnail of that size is found, it will look for a larger
|
||||
* thumbnail, then falling back to a smaller size.
|
||||
*
|
||||
* If the user's thumbnail repository doesn't provide a thumbnail but
|
||||
* a local thumbnail repository exists for the folder the image is
|
||||
* located in, the same search is done among the local thumbnails (if
|
||||
* there are any).
|
||||
*
|
||||
* If a thumbnail is found, it's size is written to the variable
|
||||
* pointer to by @size and the file location is returned.
|
||||
*
|
||||
* Returns: a newly allocated string in the encoding of the
|
||||
* filesystem or %NULL if no thumbnail for @uri was found
|
||||
**/
|
||||
gchar *
|
||||
pika_thumb_find_thumb (const gchar *uri,
|
||||
PikaThumbSize *size)
|
||||
{
|
||||
gchar *result;
|
||||
|
||||
g_return_val_if_fail (pika_thumb_initialized, NULL);
|
||||
g_return_val_if_fail (uri != NULL, NULL);
|
||||
g_return_val_if_fail (size != NULL, NULL);
|
||||
g_return_val_if_fail (*size > PIKA_THUMB_SIZE_FAIL, NULL);
|
||||
|
||||
result = pika_thumb_png_lookup (pika_thumb_png_name (uri), NULL, size);
|
||||
|
||||
if (! result)
|
||||
{
|
||||
gchar *filename = _pika_thumb_filename_from_uri (uri);
|
||||
|
||||
if (filename)
|
||||
{
|
||||
const gchar *baseuri = strrchr (uri, '/');
|
||||
|
||||
if (baseuri && baseuri[0] && baseuri[1])
|
||||
{
|
||||
gchar *dirname = g_path_get_dirname (filename);
|
||||
|
||||
result = pika_thumb_png_lookup (pika_thumb_png_name (baseuri + 1),
|
||||
dirname, size);
|
||||
|
||||
g_free (dirname);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumb_file_test:
|
||||
* @filename: a filename in the encoding of the filesystem
|
||||
* @mtime: return location for modification time
|
||||
* @size: return location for file size
|
||||
* @err_no: return location for system "errno"
|
||||
*
|
||||
* This is a convenience and portability wrapper around stat(). It
|
||||
* checks if the given @filename exists and returns modification time
|
||||
* and file size in 64bit integer values.
|
||||
*
|
||||
* Returns: The type of the file, or #PIKA_THUMB_FILE_TYPE_NONE if
|
||||
* the file doesn't exist.
|
||||
**/
|
||||
PikaThumbFileType
|
||||
pika_thumb_file_test (const gchar *filename,
|
||||
gint64 *mtime,
|
||||
gint64 *size,
|
||||
gint *err_no)
|
||||
{
|
||||
PikaThumbFileType type = PIKA_THUMB_FILE_TYPE_NONE;
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
file = g_file_new_for_path (filename);
|
||||
|
||||
info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_TYPE ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL, NULL);
|
||||
|
||||
if (info)
|
||||
{
|
||||
if (mtime)
|
||||
*mtime =
|
||||
g_file_info_get_attribute_uint64 (info,
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||
|
||||
if (size)
|
||||
*size = g_file_info_get_size (info);
|
||||
|
||||
if (err_no)
|
||||
*err_no = 0;
|
||||
|
||||
switch (g_file_info_get_attribute_uint32 (info,
|
||||
G_FILE_ATTRIBUTE_STANDARD_TYPE))
|
||||
{
|
||||
case G_FILE_TYPE_REGULAR:
|
||||
type = PIKA_THUMB_FILE_TYPE_REGULAR;
|
||||
break;
|
||||
|
||||
case G_FILE_TYPE_DIRECTORY:
|
||||
type = PIKA_THUMB_FILE_TYPE_FOLDER;
|
||||
break;
|
||||
|
||||
default:
|
||||
type = PIKA_THUMB_FILE_TYPE_SPECIAL;
|
||||
break;
|
||||
}
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mtime) *mtime = 0;
|
||||
if (size) *size = 0;
|
||||
if (err_no) *err_no = ENOENT;
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumbs_delete_for_uri:
|
||||
* @uri: an escaped URI
|
||||
*
|
||||
* Deletes all thumbnails for the image file specified by @uri from the
|
||||
* user's thumbnail repository.
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
void
|
||||
pika_thumbs_delete_for_uri (const gchar *uri)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (pika_thumb_initialized);
|
||||
g_return_if_fail (uri != NULL);
|
||||
|
||||
for (i = 0; i < thumb_num_sizes; i++)
|
||||
{
|
||||
gchar *filename = pika_thumb_name_from_uri (uri, thumb_sizes[i]);
|
||||
|
||||
if (filename)
|
||||
{
|
||||
g_unlink (filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pika_thumbs_delete_for_uri_local:
|
||||
* @uri: an escaped URI
|
||||
*
|
||||
* Deletes all thumbnails for the image file specified by @uri from
|
||||
* the local thumbnail repository.
|
||||
*
|
||||
* Since: 2.2
|
||||
**/
|
||||
void
|
||||
pika_thumbs_delete_for_uri_local (const gchar *uri)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (pika_thumb_initialized);
|
||||
g_return_if_fail (uri != NULL);
|
||||
|
||||
for (i = 0; i < thumb_num_sizes; i++)
|
||||
{
|
||||
gchar *filename = pika_thumb_name_from_uri_local (uri, thumb_sizes[i]);
|
||||
|
||||
if (filename)
|
||||
{
|
||||
g_unlink (filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_pika_thumbs_delete_others (const gchar *uri,
|
||||
PikaThumbSize size)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (pika_thumb_initialized);
|
||||
g_return_if_fail (uri != NULL);
|
||||
|
||||
size = pika_thumb_size (size);
|
||||
|
||||
for (i = 0; i < thumb_num_sizes; i++)
|
||||
{
|
||||
gchar *filename;
|
||||
|
||||
if (i == size)
|
||||
continue;
|
||||
|
||||
filename = pika_thumb_name_from_uri (uri, thumb_sizes[i]);
|
||||
if (filename)
|
||||
{
|
||||
g_unlink (filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gchar *
|
||||
_pika_thumb_filename_from_uri (const gchar *uri)
|
||||
{
|
||||
gchar *filename;
|
||||
gchar *hostname;
|
||||
|
||||
g_return_val_if_fail (uri != NULL, NULL);
|
||||
|
||||
filename = g_filename_from_uri (uri, &hostname, NULL);
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
if (hostname)
|
||||
{
|
||||
/* we have a file: URI with a hostname */
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* on Win32, create a valid UNC path and use it as the filename */
|
||||
gchar *tmp = g_build_filename ("//", hostname, filename, NULL);
|
||||
|
||||
g_free (filename);
|
||||
filename = tmp;
|
||||
#else
|
||||
/* otherwise return NULL, caller should use URI then */
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
#endif
|
||||
|
||||
g_free (hostname);
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
static void
|
||||
pika_thumb_exit (void)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_free (thumb_dir);
|
||||
g_free (thumb_sizes);
|
||||
g_free (thumb_sizenames);
|
||||
for (i = 0; i < thumb_num_sizes; i++)
|
||||
g_free (thumb_subdirs[i]);
|
||||
g_free (thumb_subdirs);
|
||||
g_free (thumb_fail_subdir);
|
||||
|
||||
thumb_num_sizes = 0;
|
||||
thumb_sizes = NULL;
|
||||
thumb_sizenames = NULL;
|
||||
thumb_dir = NULL;
|
||||
thumb_subdirs = NULL;
|
||||
thumb_fail_subdir = NULL;
|
||||
pika_thumb_initialized = FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
pika_thumb_size (PikaThumbSize size)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
if (size > PIKA_THUMB_SIZE_FAIL)
|
||||
{
|
||||
for (i = 1;
|
||||
i < thumb_num_sizes && thumb_sizes[i] < size;
|
||||
i++)
|
||||
/* nothing */;
|
||||
|
||||
if (i == thumb_num_sizes)
|
||||
i--;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
pika_thumb_png_lookup (const gchar *name,
|
||||
const gchar *basedir,
|
||||
PikaThumbSize *size)
|
||||
{
|
||||
gchar *thumb_name = NULL;
|
||||
gchar **subdirs = NULL;
|
||||
gint i, n;
|
||||
|
||||
if (basedir)
|
||||
{
|
||||
gchar *dir = g_build_filename (basedir, ".thumblocal", NULL);
|
||||
|
||||
if (g_file_test (basedir, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
gint i;
|
||||
|
||||
subdirs = g_new (gchar *, thumb_num_sizes);
|
||||
|
||||
subdirs[0] = NULL; /* PIKA_THUMB_SIZE_FAIL */
|
||||
|
||||
for (i = 1; i < thumb_num_sizes; i++)
|
||||
subdirs[i] = g_build_filename (dir, thumb_sizenames[i], NULL);
|
||||
}
|
||||
|
||||
g_free (dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
subdirs = thumb_subdirs;
|
||||
}
|
||||
|
||||
if (! subdirs)
|
||||
return NULL;
|
||||
|
||||
i = n = pika_thumb_size (*size);
|
||||
|
||||
for (; i < thumb_num_sizes; i++)
|
||||
{
|
||||
if (! subdirs[i])
|
||||
continue;
|
||||
|
||||
thumb_name = g_build_filename (subdirs[i], name, NULL);
|
||||
|
||||
if (pika_thumb_file_test (thumb_name,
|
||||
NULL, NULL,
|
||||
NULL) == PIKA_THUMB_FILE_TYPE_REGULAR)
|
||||
{
|
||||
*size = thumb_sizes[i];
|
||||
goto finish;
|
||||
}
|
||||
|
||||
g_free (thumb_name);
|
||||
}
|
||||
|
||||
for (i = n - 1; i >= 0; i--)
|
||||
{
|
||||
if (! subdirs[i])
|
||||
continue;
|
||||
|
||||
thumb_name = g_build_filename (subdirs[i], name, NULL);
|
||||
|
||||
if (pika_thumb_file_test (thumb_name,
|
||||
NULL, NULL,
|
||||
NULL) == PIKA_THUMB_FILE_TYPE_REGULAR)
|
||||
{
|
||||
*size = thumb_sizes[i];
|
||||
goto finish;
|
||||
}
|
||||
|
||||
g_free (thumb_name);
|
||||
}
|
||||
|
||||
thumb_name = NULL;
|
||||
|
||||
finish:
|
||||
if (basedir)
|
||||
{
|
||||
for (i = 0; i < thumb_num_sizes; i++)
|
||||
g_free (subdirs[i]);
|
||||
g_free (subdirs);
|
||||
}
|
||||
|
||||
return thumb_name;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
pika_thumb_png_name (const gchar *uri)
|
||||
{
|
||||
static gchar name[40];
|
||||
|
||||
GChecksum *checksum;
|
||||
guchar digest[16];
|
||||
gsize len = sizeof (digest);
|
||||
gsize i;
|
||||
|
||||
checksum = g_checksum_new (G_CHECKSUM_MD5);
|
||||
g_checksum_update (checksum, (const guchar *) uri, -1);
|
||||
g_checksum_get_digest (checksum, digest, &len);
|
||||
g_checksum_free (checksum);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
guchar n;
|
||||
|
||||
n = (digest[i] >> 4) & 0xF;
|
||||
name[i * 2] = (n > 9) ? 'a' + n - 10 : '0' + n;
|
||||
|
||||
n = digest[i] & 0xF;
|
||||
name[i * 2 + 1] = (n > 9) ? 'a' + n - 10 : '0' + n;
|
||||
}
|
||||
|
||||
strncpy (name + 32, ".png", 5);
|
||||
|
||||
return (const gchar *) name;
|
||||
}
|
73
libpikathumb/pikathumb-utils.h
Normal file
73
libpikathumb/pikathumb-utils.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (__PIKA_THUMB_H_INSIDE__) && !defined (PIKA_THUMB_COMPILATION)
|
||||
#error "Only <libpikathumb/pikathumb.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __PIKA_THUMB_UTILS_H__
|
||||
#define __PIKA_THUMB_UTILS_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
gboolean pika_thumb_init (const gchar *creator,
|
||||
const gchar *thumb_basedir);
|
||||
|
||||
const gchar * pika_thumb_get_thumb_base_dir (void);
|
||||
|
||||
gchar * pika_thumb_find_thumb (const gchar *uri,
|
||||
PikaThumbSize *size) G_GNUC_MALLOC;
|
||||
|
||||
PikaThumbFileType pika_thumb_file_test (const gchar *filename,
|
||||
gint64 *mtime,
|
||||
gint64 *size,
|
||||
gint *err_no);
|
||||
|
||||
gchar * pika_thumb_name_from_uri (const gchar *uri,
|
||||
PikaThumbSize size) G_GNUC_MALLOC;
|
||||
const gchar * pika_thumb_get_thumb_dir (PikaThumbSize size);
|
||||
gboolean pika_thumb_ensure_thumb_dir (PikaThumbSize size,
|
||||
GError **error);
|
||||
void pika_thumbs_delete_for_uri (const gchar *uri);
|
||||
|
||||
gchar * pika_thumb_name_from_uri_local (const gchar *uri,
|
||||
PikaThumbSize size) G_GNUC_MALLOC;
|
||||
gchar * pika_thumb_get_thumb_dir_local (const gchar *dirname,
|
||||
PikaThumbSize size) G_GNUC_MALLOC;
|
||||
gboolean pika_thumb_ensure_thumb_dir_local (const gchar *dirname,
|
||||
PikaThumbSize size,
|
||||
GError **error);
|
||||
void pika_thumbs_delete_for_uri_local (const gchar *uri);
|
||||
|
||||
|
||||
/* for internal use only */
|
||||
G_GNUC_INTERNAL void _pika_thumbs_delete_others (const gchar *uri,
|
||||
PikaThumbSize size);
|
||||
G_GNUC_INTERNAL gchar * _pika_thumb_filename_from_uri (const gchar *uri);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_THUMB_UTILS_H__ */
|
32
libpikathumb/pikathumb.def
Normal file
32
libpikathumb/pikathumb.def
Normal file
@ -0,0 +1,32 @@
|
||||
EXPORTS
|
||||
pika_thumb_ensure_thumb_dir
|
||||
pika_thumb_ensure_thumb_dir_local
|
||||
pika_thumb_error_quark
|
||||
pika_thumb_file_test
|
||||
pika_thumb_file_type_get_type
|
||||
pika_thumb_find_thumb
|
||||
pika_thumb_get_thumb_base_dir
|
||||
pika_thumb_get_thumb_dir
|
||||
pika_thumb_get_thumb_dir_local
|
||||
pika_thumb_init
|
||||
pika_thumb_name_from_uri
|
||||
pika_thumb_name_from_uri_local
|
||||
pika_thumb_size_get_type
|
||||
pika_thumb_state_get_type
|
||||
pika_thumbnail_check_thumb
|
||||
pika_thumbnail_delete_failure
|
||||
pika_thumbnail_delete_others
|
||||
pika_thumbnail_get_type
|
||||
pika_thumbnail_has_failed
|
||||
pika_thumbnail_load_thumb
|
||||
pika_thumbnail_new
|
||||
pika_thumbnail_peek_image
|
||||
pika_thumbnail_peek_thumb
|
||||
pika_thumbnail_save_failure
|
||||
pika_thumbnail_save_thumb
|
||||
pika_thumbnail_save_thumb_local
|
||||
pika_thumbnail_set_filename
|
||||
pika_thumbnail_set_from_thumb
|
||||
pika_thumbnail_set_uri
|
||||
pika_thumbs_delete_for_uri
|
||||
pika_thumbs_delete_for_uri_local
|
38
libpikathumb/pikathumb.h
Normal file
38
libpikathumb/pikathumb.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PIKA_THUMB_H__
|
||||
#define __PIKA_THUMB_H__
|
||||
|
||||
#define __PIKA_THUMB_H_INSIDE__
|
||||
|
||||
#include <libpikathumb/pikathumb-types.h>
|
||||
|
||||
#include <libpikathumb/pikathumb-error.h>
|
||||
#include <libpikathumb/pikathumb-utils.h>
|
||||
#include <libpikathumb/pikathumbnail.h>
|
||||
|
||||
#undef __PIKA_THUMB_H_INSIDE__
|
||||
|
||||
#endif /* __PIKA_THUMB_H__ */
|
1403
libpikathumb/pikathumbnail.c
Normal file
1403
libpikathumb/pikathumbnail.c
Normal file
File diff suppressed because it is too large
Load Diff
141
libpikathumb/pikathumbnail.h
Normal file
141
libpikathumb/pikathumbnail.h
Normal file
@ -0,0 +1,141 @@
|
||||
/* LIBPIKA - The PIKA Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* Thumbnail handling according to the Thumbnail Managing Standard.
|
||||
* https://specifications.freedesktop.org/thumbnail-spec/
|
||||
*
|
||||
* Copyright (C) 2001-2004 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (__PIKA_THUMB_H_INSIDE__) && !defined (PIKA_THUMB_COMPILATION)
|
||||
#error "Only <libpikathumb/pikathumb.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __PIKA_THUMBNAIL_H__
|
||||
#define __PIKA_THUMBNAIL_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define PIKA_TYPE_THUMBNAIL (pika_thumbnail_get_type ())
|
||||
#define PIKA_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_THUMBNAIL, PikaThumbnail))
|
||||
#define PIKA_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_THUMBNAIL, PikaThumbnailClass))
|
||||
#define PIKA_IS_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_THUMBNAIL))
|
||||
#define PIKA_IS_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_THUMBNAIL))
|
||||
#define PIKA_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_THUMBNAIL, PikaThumbnailClass))
|
||||
|
||||
|
||||
typedef struct _PikaThumbnailPrivate PikaThumbnailPrivate;
|
||||
typedef struct _PikaThumbnailClass PikaThumbnailClass;
|
||||
|
||||
/**
|
||||
* PikaThumbnail:
|
||||
*
|
||||
* All members of #PikaThumbnail are private and should only be accessed
|
||||
* using object properties.
|
||||
**/
|
||||
struct _PikaThumbnail
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
PikaThumbnailPrivate *priv;
|
||||
|
||||
/* FIXME MOVE TO PRIVATE */
|
||||
/*< private >*/
|
||||
PikaThumbState 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;
|
||||
|
||||
PikaThumbState thumb_state;
|
||||
PikaThumbSize thumb_size;
|
||||
gchar *thumb_filename;
|
||||
gint64 thumb_filesize;
|
||||
gint64 thumb_mtime;
|
||||
|
||||
gchar *image_mimetype;
|
||||
};
|
||||
|
||||
struct _PikaThumbnailClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (* _pika_reserved1) (void);
|
||||
void (* _pika_reserved2) (void);
|
||||
void (* _pika_reserved3) (void);
|
||||
void (* _pika_reserved4) (void);
|
||||
void (* _pika_reserved5) (void);
|
||||
void (* _pika_reserved6) (void);
|
||||
void (* _pika_reserved7) (void);
|
||||
void (* _pika_reserved8) (void);
|
||||
};
|
||||
|
||||
|
||||
GType pika_thumbnail_get_type (void) G_GNUC_CONST;
|
||||
|
||||
PikaThumbnail * pika_thumbnail_new (void);
|
||||
|
||||
void pika_thumbnail_set_uri (PikaThumbnail *thumbnail,
|
||||
const gchar *uri);
|
||||
gboolean pika_thumbnail_set_filename (PikaThumbnail *thumbnail,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
gboolean pika_thumbnail_set_from_thumb (PikaThumbnail *thumbnail,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
PikaThumbState pika_thumbnail_peek_image (PikaThumbnail *thumbnail);
|
||||
PikaThumbState pika_thumbnail_peek_thumb (PikaThumbnail *thumbnail,
|
||||
PikaThumbSize size);
|
||||
|
||||
PikaThumbState pika_thumbnail_check_thumb (PikaThumbnail *thumbnail,
|
||||
PikaThumbSize size);
|
||||
|
||||
GdkPixbuf * pika_thumbnail_load_thumb (PikaThumbnail *thumbnail,
|
||||
PikaThumbSize size,
|
||||
GError **error);
|
||||
|
||||
gboolean pika_thumbnail_save_thumb (PikaThumbnail *thumbnail,
|
||||
GdkPixbuf *pixbuf,
|
||||
const gchar *software,
|
||||
GError **error);
|
||||
gboolean pika_thumbnail_save_thumb_local (PikaThumbnail *thumbnail,
|
||||
GdkPixbuf *pixbuf,
|
||||
const gchar *software,
|
||||
GError **error);
|
||||
|
||||
gboolean pika_thumbnail_save_failure (PikaThumbnail *thumbnail,
|
||||
const gchar *software,
|
||||
GError **error);
|
||||
void pika_thumbnail_delete_failure (PikaThumbnail *thumbnail);
|
||||
void pika_thumbnail_delete_others (PikaThumbnail *thumbnail,
|
||||
PikaThumbSize size);
|
||||
|
||||
gboolean pika_thumbnail_has_failed (PikaThumbnail *thumbnail);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PIKA_THUMBNAIL_H__ */
|
Reference in New Issue
Block a user