[gimp] app: port more palette importers to GIO
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: port more palette importers to GIO
- Date: Thu, 3 Jul 2014 14:45:28 +0000 (UTC)
commit 5d4d3a0e3cc65ff7f212e7588378cb31d8f26052
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 3 16:42:37 2014 +0200
app: port more palette importers to GIO
app/core/gimppalette-import.c | 4 ++--
app/core/gimppalette-load.c | 36 +++++++++++++++++++++---------------
app/core/gimppalette-load.h | 4 ++--
3 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/app/core/gimppalette-import.c b/app/core/gimppalette-import.c
index 526abd6..08e645e 100644
--- a/app/core/gimppalette-import.c
+++ b/app/core/gimppalette-import.c
@@ -539,11 +539,11 @@ gimp_palette_import_from_file (GimpContext *context,
break;
case GIMP_PALETTE_FILE_FORMAT_ACT:
- palette_list = gimp_palette_load_act (context, file, f, error);
+ palette_list = gimp_palette_load_act (context, file, input, error);
break;
case GIMP_PALETTE_FILE_FORMAT_RIFF_PAL:
- palette_list = gimp_palette_load_riff (context, file, f, error);
+ palette_list = gimp_palette_load_riff (context, file, input, error);
break;
case GIMP_PALETTE_FILE_FORMAT_PSP_PAL:
diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c
index c06e5cc..8c2b95c 100644
--- a/app/core/gimppalette-load.c
+++ b/app/core/gimppalette-load.c
@@ -288,24 +288,27 @@ gimp_palette_load_gpl (GimpContext *context,
}
GList *
-gimp_palette_load_act (GimpContext *context,
- GFile *file,
- FILE *f,
- GError **error)
+gimp_palette_load_act (GimpContext *context,
+ GFile *file,
+ GInputStream *input,
+ GError **error)
{
GimpPalette *palette;
gchar *palette_name;
- gint fd = fileno (f);
- guchar color_bytes[4];
+ guchar color_bytes[3];
+ gsize bytes_read;
g_return_val_if_fail (G_IS_FILE (file), NULL);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
palette_name = g_path_get_basename (gimp_file_get_utf8_name (file));
palette = GIMP_PALETTE (gimp_palette_new (context, palette_name));
g_free (palette_name);
- while (read (fd, color_bytes, 3) == 3)
+ while (g_input_stream_read_all (input, color_bytes, sizeof (color_bytes),
+ &bytes_read, NULL, NULL) &&
+ bytes_read == sizeof (color_bytes))
{
GimpRGB color;
@@ -321,27 +324,30 @@ gimp_palette_load_act (GimpContext *context,
}
GList *
-gimp_palette_load_riff (GimpContext *context,
- GFile *file,
- FILE *f,
- GError **error)
+gimp_palette_load_riff (GimpContext *context,
+ GFile *file,
+ GInputStream *input,
+ GError **error)
{
GimpPalette *palette;
gchar *palette_name;
- gint fd = fileno (f);
guchar color_bytes[4];
+ gsize bytes_read;
g_return_val_if_fail (G_IS_FILE (file), NULL);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
palette_name = g_path_get_basename (gimp_file_get_utf8_name (file));
palette = GIMP_PALETTE (gimp_palette_new (context, palette_name));
g_free (palette_name);
- lseek (fd, 28, SEEK_SET);
+ if (! g_seekable_seek (G_SEEKABLE (input), 28, G_SEEK_SET, NULL, error))
+ return NULL;
- while (read (fd,
- color_bytes, sizeof (color_bytes)) == sizeof (color_bytes))
+ while (g_input_stream_read_all (input, color_bytes, sizeof (color_bytes),
+ &bytes_read, NULL, NULL) &&
+ bytes_read == sizeof (color_bytes))
{
GimpRGB color;
diff --git a/app/core/gimppalette-load.h b/app/core/gimppalette-load.h
index 487b43c..5786d4d 100644
--- a/app/core/gimppalette-load.h
+++ b/app/core/gimppalette-load.h
@@ -43,11 +43,11 @@ GList * gimp_palette_load_gpl (GimpContext *context,
GError **error);
GList * gimp_palette_load_act (GimpContext *context,
GFile *file,
- FILE *f,
+ GInputStream *input,
GError **error);
GList * gimp_palette_load_riff (GimpContext *context,
GFile *file,
- FILE *f,
+ GInputStream *input,
GError **error);
GList * gimp_palette_load_psp (GimpContext *context,
GFile *file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]