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

renamed a function, added another one.

2003-12-08  Sven Neumann  <sven@gimp.org>

	* libgimpthumb/gimpthumb-utils.[ch]: renamed a function, added
	another one.

	* libgimpthumb/gimpthumb.def
	* libgimpthumb/gimpthumbnail.c: changed accordingly.

2003-12-08  Sven Neumann  <sven@gimp.org>

	* Makefile.am: removed unnecessary stuff.

	* libgimpthumb/libgimpthumb-sections.txt
	* libgimpthumb/tmpl/gimpthumb-utils.sgml: updated.
parent 5ab09335
2003-12-08 Sven Neumann <sven@gimp.org>
* libgimpthumb/gimpthumb-utils.[ch]: renamed a function, added
another one.
* libgimpthumb/gimpthumb.def
* libgimpthumb/gimpthumbnail.c: changed accordingly.
2003-12-08 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/channel.pdb
2003-12-08 Sven Neumann <sven@gimp.org>
* Makefile.am: removed unnecessary stuff.
* libgimpthumb/libgimpthumb-sections.txt
* libgimpthumb/tmpl/gimpthumb-utils.sgml: updated.
2003-12-08 Sven Neumann <sven@gimp.org>
* Makefile.am
......
......@@ -19,7 +19,7 @@ SCAN_OPTIONS =
MKDB_OPTIONS = --sgml-mode --output-format=xml
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS = --extra-dir=../libgimpbase/html --extra-dir=../libgimpcolor/html --extra-dir=../libgimpmath/html --extra-dir=../libgimp/html
FIXXREF_OPTIONS = --extra-dir=../libgimpmath/html
# Used for dependencies
HFILE_GLOB = $(DOC_SOURCE_DIR)/*.h
......@@ -46,7 +46,6 @@ GTKDOC_CFLAGS = \
@GDK_PIXBUF_CFLAGS@
GTKDOC_LIBS = \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(top_builddir)/libgimpmath/libgimpmath-$(LT_RELEASE).la \
$(top_builddir)/libgimpthumb/libgimpthumb-$(LT_RELEASE).la \
@GDK_PIXBUF_LIBS@
......
......@@ -27,7 +27,8 @@ gimp_thumb_init
gimp_thumb_name_from_uri
gimp_thumb_find_thumb
gimp_thumb_file_test
gimp_thumb_ensure_thumb_dirs
gimp_thumb_ensure_thumb_dir
gimp_thumb_get_thumb_dir
</SECTION>
<SECTION>
......
......@@ -55,12 +55,3 @@ gimpthumb-utils
@Returns:
<!-- ##### FUNCTION gimp_thumb_ensure_thumb_dirs ##### -->
<para>
</para>
@error:
@Returns:
......@@ -47,8 +47,9 @@
#include "libgimp/libgimp-intl.h"
static const gchar * gimp_thumb_png_name (const gchar *uri);
static void gimp_thumb_exit (void);
static gint gimp_thumb_size (GimpThumbSize size);
static const gchar * gimp_thumb_png_name (const gchar *uri);
static void gimp_thumb_exit (void);
......@@ -101,40 +102,47 @@ gimp_thumb_init (const gchar *creator,
return gimp_thumb_initialized;
}
gchar *
gimp_thumb_get_thumb_dir (GimpThumbSize size)
{
g_return_val_if_fail (gimp_thumb_initialized, FALSE);
size = gimp_thumb_size (size);
return thumb_subdirs[size];
}
gboolean
gimp_thumb_ensure_thumb_dirs (GError **error)
gimp_thumb_ensure_thumb_dir (GimpThumbSize size,
GError **error)
{
gint i;
g_return_val_if_fail (gimp_thumb_initialized, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
for (i = 0; i < thumb_num_sizes; i++)
i = gimp_thumb_size (size);
if (g_file_test (thumb_subdirs[i], G_FILE_TEST_IS_DIR))
return TRUE;
if (g_file_test (thumb_dir, G_FILE_TEST_IS_DIR) ||
(mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
{
if (! g_file_test (thumb_subdirs[i], G_FILE_TEST_IS_DIR))
{
if (g_file_test (thumb_dir, G_FILE_TEST_IS_DIR) ||
(mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
{
if (i == 0)
mkdir (thumb_fail_subdir, S_IRUSR | S_IWUSR | S_IXUSR);
mkdir (thumb_subdirs[i], S_IRUSR | S_IWUSR | S_IXUSR);
}
if (! g_file_test (thumb_subdirs[i], G_FILE_TEST_IS_DIR))
{
g_set_error (error,
GIMP_THUMB_ERROR, GIMP_THUMB_ERROR_MKDIR,
_("Failed to create thumbnail folder '%s'."),
thumb_subdirs[i]);
return FALSE;
}
}
if (i == 0)
mkdir (thumb_fail_subdir, S_IRUSR | S_IWUSR | S_IXUSR);
mkdir (thumb_subdirs[i], S_IRUSR | S_IWUSR | S_IXUSR);
}
return TRUE;
if (g_file_test (thumb_subdirs[i], G_FILE_TEST_IS_DIR))
return TRUE;
g_set_error (error,
GIMP_THUMB_ERROR, GIMP_THUMB_ERROR_MKDIR,
_("Failed to create thumbnail folder '%s'."),
thumb_subdirs[i]);
return FALSE;
}
gchar *
......@@ -142,25 +150,17 @@ gimp_thumb_name_from_uri (const gchar *uri,
GimpThumbSize *size)
{
const gchar *name;
gint i = 0;
gint i;
g_return_val_if_fail (gimp_thumb_initialized, NULL);
g_return_val_if_fail (size != NULL, NULL);
if (strstr (uri, thumb_dir))
return NULL;
name = gimp_thumb_png_name (uri);
if (*size != GIMP_THUMB_SIZE_FAIL)
{
for (i = 1;
i < thumb_num_sizes && thumb_sizes[i] < *size;
i++)
/* nothing */;
if (i == thumb_num_sizes)
i--;
}
i = gimp_thumb_size (*size);
*size = thumb_sizes[i];
......@@ -176,13 +176,11 @@ gimp_thumb_find_thumb (const gchar *uri,
gint i, n;
g_return_val_if_fail (gimp_thumb_initialized, NULL);
g_return_val_if_fail (size > GIMP_THUMB_SIZE_FAIL, NULL);
name = gimp_thumb_png_name (uri);
for (i = 1; i < thumb_num_sizes && thumb_sizes[i] < *size; i++)
/* do nothing */;
n = i;
i = n = gimp_thumb_size (*size);
for (; i < thumb_num_sizes; i++)
{
......@@ -253,6 +251,25 @@ gimp_thumb_exit (void)
gimp_thumb_initialized = FALSE;
}
static gint
gimp_thumb_size (GimpThumbSize size)
{
gint i = 0;
if (size > GIMP_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 const gchar *
gimp_thumb_png_name (const gchar *uri)
{
......
......@@ -29,19 +29,21 @@
G_BEGIN_DECLS
gboolean gimp_thumb_init (const gchar *creator,
const gchar *thumb_basedir);
gboolean gimp_thumb_init (const gchar *creator,
const gchar *thumb_basedir);
gchar * gimp_thumb_name_from_uri (const gchar *uri,
GimpThumbSize *size);
gchar * gimp_thumb_find_thumb (const gchar *uri,
GimpThumbSize *size);
gchar * gimp_thumb_get_thumb_dir (GimpThumbSize size);
gboolean gimp_thumb_ensure_thumb_dir (GimpThumbSize size,
GError **error);
gboolean gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size);
gchar * gimp_thumb_name_from_uri (const gchar *uri,
GimpThumbSize *size);
gchar * gimp_thumb_find_thumb (const gchar *uri,
GimpThumbSize *size);
gboolean gimp_thumb_ensure_thumb_dirs (GError **error);
gboolean gimp_thumb_file_test (const gchar *filename,
gint64 *mtime,
gint64 *size);
G_END_DECLS
......
EXPORTS
gimp_thumb_ensure_thumb_dirs
gimp_thumb_ensure_thumb_dir
gimp_thumb_get_thumb_dir
gimp_thumb_error_quark
gimp_thumb_file_test
gimp_thumb_find_thumb
......
......@@ -647,9 +647,6 @@ gimp_thumbnail_save_thumb (GimpThumbnail *thumbnail,
g_return_val_if_fail (software != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (! gimp_thumb_ensure_thumb_dirs (error))
return FALSE;
size = MAX (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf));
if (size < 1)
return TRUE;
......@@ -658,6 +655,12 @@ gimp_thumbnail_save_thumb (GimpThumbnail *thumbnail,
if (! name)
return TRUE;
if (! gimp_thumb_ensure_thumb_dir (size, error))
{
g_free (name);
return FALSE;
}
desc = g_strdup_printf ("Thumbnail of %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);
......@@ -687,7 +690,7 @@ gimp_thumbnail_save_thumb (GimpThumbnail *thumbnail,
if (success)
{
success = chmod (name, 0600);
success = (chmod (name, 0600) == 0);
if (! success)
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
......@@ -723,13 +726,16 @@ gimp_thumbnail_save_failure (GimpThumbnail *thumbnail,
g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);
g_return_val_if_fail (software != NULL, FALSE);
if (! gimp_thumb_ensure_thumb_dirs (error))
return FALSE;
name = gimp_thumb_name_from_uri (thumbnail->image_uri, &size);
if (! name)
return TRUE;
if (! gimp_thumb_ensure_thumb_dir (size, error))
{
g_free (name);
return FALSE;
}
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
desc = g_strdup_printf ("Thumbnail failure for %s", thumbnail->image_uri);
......@@ -745,7 +751,7 @@ gimp_thumbnail_save_failure (GimpThumbnail *thumbnail,
NULL);
if (success)
{
success = chmod (name, 0600);
success = (chmod (name, 0600) == 0);
if (! success)
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment