removed commented-out message.

2004-06-03  Sven Neumann  <sven@gimp.org>

	* app/core/gimpdatafactory.c (gimp_data_factory_load_data):
	removed commented-out message.

	* app/core/gimppattern.[ch]: fixed handling of errors and PNG
	comments in new pattern loader. Renamed functions for consistency
	with other data loaders.

	* app/core/gimp.c: changed accordingly.
This commit is contained in:
Sven Neumann 2004-06-03 11:34:51 +00:00 committed by Sven Neumann
parent d088fd3fe1
commit 532d42d012
6 changed files with 95 additions and 151 deletions

View File

@ -1,3 +1,14 @@
2004-06-03 Sven Neumann <sven@gimp.org>
* app/core/gimpdatafactory.c (gimp_data_factory_load_data):
removed commented-out message.
* app/core/gimppattern.[ch]: fixed handling of errors and PNG
comments in new pattern loader. Renamed functions for consistency
with other data loaders.
* app/core/gimp.c: changed accordingly.
2004-06-03 Dave Neary <bolsh@gimp.org>
* app/core/gimp.c:

View File

@ -567,20 +567,20 @@ gimp_real_initialize (Gimp *gimp,
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
{
{ gimp_pattern_native_load, GIMP_PATTERN_FILE_EXTENSION },
{ gimp_pattern_load, NULL /* Fallback - try to load all files */ }
{ gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION },
{ gimp_pattern_load_pixbuf, NULL }
};
static const GimpDataFactoryLoaderEntry gradient_loader_entries[] =
{
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
{ gimp_gradient_load, NULL /* fallback loader */ }
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
{ gimp_gradient_load, NULL /* legacy loader */ }
};
static const GimpDataFactoryLoaderEntry palette_loader_entries[] =
{
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
{ gimp_palette_load, NULL /* fallback loader */ }
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
{ gimp_palette_load, NULL /* legacy loader */ }
};
if (gimp->be_verbose)

View File

@ -579,11 +579,6 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
}
else
{
/*
g_message (_("Trying fallback loader on file '%s' "
"with unknown extension."),
gimp_filename_to_utf8 (file_data->filename));
*/
goto insert;
}
}

View File

@ -307,9 +307,9 @@ gimp_pattern_get_standard (void)
}
GimpData *
gimp_pattern_native_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
gimp_pattern_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
{
GimpPattern *pattern = NULL;
gint fd;
@ -438,95 +438,64 @@ gimp_pattern_native_load (const gchar *filename,
}
GimpData *
gimp_pattern_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
gimp_pattern_load_pixbuf (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
{
GimpPattern *pattern = NULL;
GdkPixbuf *pat_buf = NULL;
guchar *pat_data, *buf_data;
gchar *name = NULL;
gint width,
height,
bytes,
rowstride,
i;
gchar *utf8_filename;
gsize filename_length;
GimpPattern *pattern;
GdkPixbuf *pixbuf;
guchar *pat_data;
guchar *buf_data;
gchar *name;
gint width;
gint height;
gint bytes;
gint rowstride;
gint i;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
pat_buf = gdk_pixbuf_new_from_file (filename, error);
pixbuf = gdk_pixbuf_new_from_file (filename, error);
if (*error)
if (! pixbuf)
return NULL;
name = g_strdup (gdk_pixbuf_get_option (pixbuf, "tEXt::Comment"));
if (! name)
{
if ((*error)->domain == G_FILE_ERROR)
g_message (_("Could not open file %s: %s"),
gimp_filename_to_utf8 (filename),
(*error)->message);
else if ((*error)->domain == GDK_PIXBUF_ERROR)
g_message (_("Filename %s is not a valid GdkPixbuf: %s"),
gimp_filename_to_utf8 (filename),
(*error)->message);
return NULL;
gchar *basename = g_path_get_basename (filename);
name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
g_free (basename);
}
/* Read in the pattern name -
First try to get a "comment" option, this could be set for pnm,
jpeg and gif (it isn't yet)
Then try the tEXt option, which is set for pngs,
Then fall back to filename
*/
utf8_filename = g_filename_to_utf8 (filename, -1, NULL, &filename_length,
error);
if (*error)
{
g_message (_("Problem converting filename to UTF8: %s"),
(*error)->message);
utf8_filename = "Unnamed";
g_clear_error (error);
}
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "comment"));
if (name == NULL)
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "tEXt"));
if (name == NULL)
name = g_strdup (utf8_filename);
pattern = g_object_new (GIMP_TYPE_PATTERN,
"name", name,
NULL);
g_free (name);
g_free (utf8_filename);
width = gdk_pixbuf_get_width (pat_buf);
height = gdk_pixbuf_get_height (pat_buf);
bytes = gdk_pixbuf_get_n_channels (pat_buf);
rowstride = gdk_pixbuf_get_rowstride (pat_buf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
bytes = gdk_pixbuf_get_n_channels (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pattern->mask = temp_buf_new (width, height, bytes,
0, 0, NULL);
pat_data = gdk_pixbuf_get_pixels (pat_buf);
pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
pat_data = gdk_pixbuf_get_pixels (pixbuf);
buf_data = temp_buf_data (pattern->mask);
for (i = 0; i < height; i++)
{
memcpy(buf_data + i * width * bytes, pat_data, width * bytes);
memcpy (buf_data + i * width * bytes, pat_data, width * bytes);
pat_data += rowstride;
}
/* Free up loaded Pixbuf */
g_object_unref (pat_buf);
g_object_unref (pixbuf);
/* Swap the pattern to disk (if we're being stingy with memory) */
if (stingy_memory_use)
temp_buf_swap (pattern->mask);

View File

@ -307,9 +307,9 @@ gimp_pattern_get_standard (void)
}
GimpData *
gimp_pattern_native_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
gimp_pattern_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
{
GimpPattern *pattern = NULL;
gint fd;
@ -438,95 +438,64 @@ gimp_pattern_native_load (const gchar *filename,
}
GimpData *
gimp_pattern_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
gimp_pattern_load_pixbuf (const gchar *filename,
gboolean stingy_memory_use,
GError **error)
{
GimpPattern *pattern = NULL;
GdkPixbuf *pat_buf = NULL;
guchar *pat_data, *buf_data;
gchar *name = NULL;
gint width,
height,
bytes,
rowstride,
i;
gchar *utf8_filename;
gsize filename_length;
GimpPattern *pattern;
GdkPixbuf *pixbuf;
guchar *pat_data;
guchar *buf_data;
gchar *name;
gint width;
gint height;
gint bytes;
gint rowstride;
gint i;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
pat_buf = gdk_pixbuf_new_from_file (filename, error);
pixbuf = gdk_pixbuf_new_from_file (filename, error);
if (*error)
if (! pixbuf)
return NULL;
name = g_strdup (gdk_pixbuf_get_option (pixbuf, "tEXt::Comment"));
if (! name)
{
if ((*error)->domain == G_FILE_ERROR)
g_message (_("Could not open file %s: %s"),
gimp_filename_to_utf8 (filename),
(*error)->message);
else if ((*error)->domain == GDK_PIXBUF_ERROR)
g_message (_("Filename %s is not a valid GdkPixbuf: %s"),
gimp_filename_to_utf8 (filename),
(*error)->message);
return NULL;
gchar *basename = g_path_get_basename (filename);
name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
g_free (basename);
}
/* Read in the pattern name -
First try to get a "comment" option, this could be set for pnm,
jpeg and gif (it isn't yet)
Then try the tEXt option, which is set for pngs,
Then fall back to filename
*/
utf8_filename = g_filename_to_utf8 (filename, -1, NULL, &filename_length,
error);
if (*error)
{
g_message (_("Problem converting filename to UTF8: %s"),
(*error)->message);
utf8_filename = "Unnamed";
g_clear_error (error);
}
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "comment"));
if (name == NULL)
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "tEXt"));
if (name == NULL)
name = g_strdup (utf8_filename);
pattern = g_object_new (GIMP_TYPE_PATTERN,
"name", name,
NULL);
g_free (name);
g_free (utf8_filename);
width = gdk_pixbuf_get_width (pat_buf);
height = gdk_pixbuf_get_height (pat_buf);
bytes = gdk_pixbuf_get_n_channels (pat_buf);
rowstride = gdk_pixbuf_get_rowstride (pat_buf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
bytes = gdk_pixbuf_get_n_channels (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pattern->mask = temp_buf_new (width, height, bytes,
0, 0, NULL);
pat_data = gdk_pixbuf_get_pixels (pat_buf);
pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
pat_data = gdk_pixbuf_get_pixels (pixbuf);
buf_data = temp_buf_data (pattern->mask);
for (i = 0; i < height; i++)
{
memcpy(buf_data + i * width * bytes, pat_data, width * bytes);
memcpy (buf_data + i * width * bytes, pat_data, width * bytes);
pat_data += rowstride;
}
/* Free up loaded Pixbuf */
g_object_unref (pat_buf);
g_object_unref (pixbuf);
/* Swap the pattern to disk (if we're being stingy with memory) */
if (stingy_memory_use)
temp_buf_swap (pattern->mask);

View File

@ -54,10 +54,10 @@ GType gimp_pattern_get_type (void) G_GNUC_CONST;
GimpData * gimp_pattern_new (const gchar *name,
gboolean stingy_memory_use);
GimpData * gimp_pattern_get_standard (void);
GimpData * gimp_pattern_native_load (const gchar *filename,
GimpData * gimp_pattern_load (const gchar *filename,
gboolean stingy_memory_use,
GError **error);
GimpData * gimp_pattern_load (const gchar *filename,
GimpData * gimp_pattern_load_pixbuf (const gchar *filename,
gboolean stingy_memory_use,
GError **error);