forked from AuroraMiddleware/gtk
Use g_filename_display_name() instead of g_filename_to_utf8() when putting
2004-11-10 Matthias Clasen <mclasen@redhat.com> * gdk-pixbuf-animation.c: * gdk-pixbuf-io.c: Use g_filename_display_name() instead of g_filename_to_utf8() when putting filenames in error messages.
This commit is contained in:
parent
34cbb87cc3
commit
2b080cc294
@ -1,3 +1,9 @@
|
|||||||
|
2004-11-10 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk-pixbuf-animation.c:
|
||||||
|
* gdk-pixbuf-io.c: Use g_filename_display_name() instead of
|
||||||
|
g_filename_to_utf8() when putting filenames in error messages.
|
||||||
|
|
||||||
2004-11-04 Matthias Clasen <mclasen@redhat.com>
|
2004-11-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* gdk-pixbuf.c (gdk_pixbuf_class_init): Document current
|
* gdk-pixbuf.c (gdk_pixbuf_class_init): Document current
|
||||||
|
@ -136,49 +136,47 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
guchar buffer [128];
|
guchar buffer [128];
|
||||||
GdkPixbufModule *image_module;
|
GdkPixbufModule *image_module;
|
||||||
gchar *utf8_filename;
|
gchar *display_name;
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
|
display_name = g_filename_display_name (filename);
|
||||||
f = fopen (filename, "rb");
|
f = fopen (filename, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_FILE_ERROR,
|
G_FILE_ERROR,
|
||||||
g_file_error_from_errno (errno),
|
g_file_error_from_errno (errno),
|
||||||
_("Failed to open file '%s': %s"),
|
_("Failed to open file '%s': %s"),
|
||||||
utf8_filename ? utf8_filename : "???",
|
display_name,
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = fread (&buffer, 1, sizeof (buffer), f);
|
size = fread (&buffer, 1, sizeof (buffer), f);
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
||||||
_("Image file '%s' contains no data"),
|
_("Image file '%s' contains no data"),
|
||||||
utf8_filename ? utf8_filename : "???");
|
display_name);
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
|
image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
|
||||||
if (!image_module) {
|
if (!image_module) {
|
||||||
|
g_free (display_name);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image_module->module == NULL)
|
if (image_module->module == NULL)
|
||||||
if (!_gdk_pixbuf_load_module (image_module, error)) {
|
if (!_gdk_pixbuf_load_module (image_module, error)) {
|
||||||
|
g_free (display_name);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -201,18 +199,17 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
|
|||||||
|
|
||||||
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
|
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
|
||||||
image_module->module_name);
|
image_module->module_name);
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_FAILED,
|
GDK_PIXBUF_ERROR_FAILED,
|
||||||
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
|
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
|
||||||
utf8_filename ? utf8_filename : "???");
|
display_name);
|
||||||
g_free (utf8_filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixbuf == NULL)
|
if (pixbuf == NULL) {
|
||||||
|
g_free (display_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
animation = gdk_pixbuf_non_anim_new (pixbuf);
|
animation = gdk_pixbuf_non_anim_new (pixbuf);
|
||||||
|
|
||||||
@ -232,19 +229,18 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
|
|||||||
|
|
||||||
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
|
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
|
||||||
image_module->module_name);
|
image_module->module_name);
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_FAILED,
|
GDK_PIXBUF_ERROR_FAILED,
|
||||||
_("Failed to load animation '%s': reason not known, probably a corrupt animation file"),
|
_("Failed to load animation '%s': reason not known, probably a corrupt animation file"),
|
||||||
utf8_filename ? utf8_filename : "???");
|
display_name);
|
||||||
g_free (utf8_filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (display_name);
|
||||||
|
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size,
|
|||||||
|
|
||||||
gint score, best = 0;
|
gint score, best = 0;
|
||||||
GdkPixbufModule *selected = NULL;
|
GdkPixbufModule *selected = NULL;
|
||||||
gchar *utf8_filename = NULL;
|
gchar *display_name = NULL;
|
||||||
|
|
||||||
for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
|
for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
|
||||||
GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
|
GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
|
||||||
@ -662,16 +662,14 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size,
|
|||||||
return selected;
|
return selected;
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1,
|
{
|
||||||
NULL, NULL, NULL);
|
display_name = g_filename_display_name (filename);
|
||||||
|
|
||||||
if (utf8_filename) {
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
|
GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
|
||||||
_("Couldn't recognize the image file format for file '%s'"),
|
_("Couldn't recognize the image file format for file '%s'"),
|
||||||
utf8_filename);
|
display_name);
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -774,46 +772,47 @@ gdk_pixbuf_new_from_file (const char *filename,
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
guchar buffer [128];
|
guchar buffer [128];
|
||||||
GdkPixbufModule *image_module;
|
GdkPixbufModule *image_module;
|
||||||
|
gchar *display_name;
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
|
display_name = g_filename_display_name (filename);
|
||||||
|
|
||||||
f = fopen (filename, "rb");
|
f = fopen (filename, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_FILE_ERROR,
|
G_FILE_ERROR,
|
||||||
g_file_error_from_errno (errno),
|
g_file_error_from_errno (errno),
|
||||||
_("Failed to open file '%s': %s"),
|
_("Failed to open file '%s': %s"),
|
||||||
utf8_filename ? utf8_filename : "???",
|
display_name,
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = fread (&buffer, 1, sizeof (buffer), f);
|
size = fread (&buffer, 1, sizeof (buffer), f);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
|
||||||
_("Image file '%s' contains no data"),
|
_("Image file '%s' contains no data"),
|
||||||
utf8_filename ? utf8_filename : "???");
|
display_name);
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
|
image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
|
||||||
if (image_module == NULL) {
|
if (image_module == NULL) {
|
||||||
|
g_free (display_name);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image_module->module == NULL)
|
if (image_module->module == NULL)
|
||||||
if (!_gdk_pixbuf_load_module (image_module, error)) {
|
if (!_gdk_pixbuf_load_module (image_module, error)) {
|
||||||
|
g_free (display_name);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -830,34 +829,26 @@ gdk_pixbuf_new_from_file (const char *filename,
|
|||||||
* the invariant that error gets set if NULL is returned.
|
* the invariant that error gets set if NULL is returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.", image_module->module_name);
|
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.", image_module->module_name);
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_FAILED,
|
GDK_PIXBUF_ERROR_FAILED,
|
||||||
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
|
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
|
||||||
utf8_filename ? utf8_filename : "???");
|
display_name);
|
||||||
g_free (utf8_filename);
|
|
||||||
} else if (error != NULL && *error != NULL) {
|
} else if (error != NULL && *error != NULL) {
|
||||||
|
|
||||||
/* Add the filename to the error message */
|
/* Add the filename to the error message */
|
||||||
GError *e = *error;
|
GError *e = *error;
|
||||||
gchar *old;
|
gchar *old;
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
old = e->message;
|
old = e->message;
|
||||||
|
|
||||||
e->message = g_strdup_printf (_("Failed to load image '%s': %s"),
|
e->message = g_strdup_printf (_("Failed to load image '%s': %s"),
|
||||||
utf8_filename ? utf8_filename : "???",
|
display_name,
|
||||||
old);
|
old);
|
||||||
|
|
||||||
g_free (utf8_filename);
|
|
||||||
g_free (old);
|
g_free (old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (display_name);
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,15 +929,14 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
|
|||||||
|
|
||||||
f = fopen (filename, "rb");
|
f = fopen (filename, "rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
gchar *display_name = g_filename_display_name (filename);
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_FILE_ERROR,
|
G_FILE_ERROR,
|
||||||
g_file_error_from_errno (errno),
|
g_file_error_from_errno (errno),
|
||||||
_("Failed to open file '%s': %s"),
|
_("Failed to open file '%s': %s"),
|
||||||
utf8_filename ? utf8_filename : "???",
|
display_name,
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,17 +969,14 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
|
|||||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||||
|
|
||||||
if (!pixbuf) {
|
if (!pixbuf) {
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
gchar *display_name = g_filename_display_name (filename);
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
g_object_unref (loader);
|
g_object_unref (loader);
|
||||||
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_FAILED,
|
GDK_PIXBUF_ERROR_FAILED,
|
||||||
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
|
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
|
||||||
utf8_filename ? utf8_filename : "???");
|
display_name);
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,15 +1476,14 @@ gdk_pixbuf_savev (GdkPixbuf *pixbuf,
|
|||||||
f = fopen (filename, "wb");
|
f = fopen (filename, "wb");
|
||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
gchar *display_name = g_filename_display_name (filename);
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_FILE_ERROR,
|
G_FILE_ERROR,
|
||||||
g_file_error_from_errno (errno),
|
g_file_error_from_errno (errno),
|
||||||
_("Failed to open '%s' for writing: %s"),
|
_("Failed to open '%s' for writing: %s"),
|
||||||
utf8_filename ? utf8_filename : "???",
|
display_name,
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1514,15 +1500,14 @@ gdk_pixbuf_savev (GdkPixbuf *pixbuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fclose (f) < 0) {
|
if (fclose (f) < 0) {
|
||||||
gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
|
gchar *display_name = g_filename_display_name (filename);
|
||||||
NULL, NULL, NULL);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_FILE_ERROR,
|
G_FILE_ERROR,
|
||||||
g_file_error_from_errno (errno),
|
g_file_error_from_errno (errno),
|
||||||
_("Failed to close '%s' while writing image, all data may not have been saved: %s"),
|
_("Failed to close '%s' while writing image, all data may not have been saved: %s"),
|
||||||
utf8_filename ? utf8_filename : "???",
|
display_name,
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (utf8_filename);
|
g_free (display_name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user