[gnome-color-manager] trivial: Use GFile in gcm_exif_parse() not a filename
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: Use GFile in gcm_exif_parse() not a filename
- Date: Fri, 21 May 2010 11:49:29 +0000 (UTC)
commit 38bc8f222e99a581eaa86ca537f721b91a9aab20
Author: Richard Hughes <richard hughsie com>
Date: Fri May 21 12:03:06 2010 +0100
trivial: Use GFile in gcm_exif_parse() not a filename
src/gcm-calibrate.c | 5 ++++-
src/gcm-exif.c | 10 +++++-----
src/gcm-exif.h | 3 ++-
src/gcm-self-test.c | 13 ++++++++++---
4 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index 2427f65..a2fd82a 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -340,10 +340,12 @@ gcm_calibrate_set_from_exif (GcmCalibrate *calibrate, const gchar *filename, GEr
gchar *description = NULL;
gboolean ret;
GcmExif *exif;
+ GFile *file;
/* parse file */
exif = gcm_exif_new ();
- ret = gcm_exif_parse (exif, filename, error);
+ file = g_file_new_for_path (filename);
+ ret = gcm_exif_parse (exif, file, error);
if (!ret)
goto out;
@@ -366,6 +368,7 @@ gcm_calibrate_set_from_exif (GcmCalibrate *calibrate, const gchar *filename, GEr
g_object_set (calibrate, "serial", serial, NULL);
out:
+ g_object_unref (file);
g_object_unref (exif);
g_free (description);
return ret;
diff --git a/src/gcm-exif.c b/src/gcm-exif.c
index 03d73a8..3c177f9 100644
--- a/src/gcm-exif.c
+++ b/src/gcm-exif.c
@@ -29,7 +29,6 @@
#include "config.h"
#include <glib-object.h>
-#include <gio/gio.h>
#include <tiff.h>
#include <tiffio.h>
#include <libexif/exif-data.h>
@@ -174,10 +173,10 @@ out:
* gcm_exif_parse:
**/
gboolean
-gcm_exif_parse (GcmExif *exif, const gchar *filename, GError **error)
+gcm_exif_parse (GcmExif *exif, GFile *file, GError **error)
{
gboolean ret = FALSE;
- GFile *file = NULL;
+ gchar *filename = NULL;
GFileInfo *info = NULL;
const gchar *content_type;
@@ -185,7 +184,6 @@ gcm_exif_parse (GcmExif *exif, const gchar *filename, GError **error)
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* check exists */
- file = g_file_new_for_path (filename);
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NONE, NULL, error);
if (info == NULL)
@@ -194,10 +192,12 @@ gcm_exif_parse (GcmExif *exif, const gchar *filename, GError **error)
/* get EXIF data in different ways depending on content type */
content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
if (g_strcmp0 (content_type, "image/tiff") == 0) {
+ filename = g_file_get_path (file);
ret = gcm_exif_parse_tiff (exif, filename, error);
goto out;
}
if (g_strcmp0 (content_type, "image/jpeg") == 0) {
+ filename = g_file_get_path (file);
ret = gcm_exif_parse_jpeg (exif, filename, error);
goto out;
}
@@ -208,7 +208,7 @@ gcm_exif_parse (GcmExif *exif, const gchar *filename, GError **error)
GCM_EXIF_ERROR_NO_SUPPORT,
"no support for %s content type", content_type);
out:
- g_object_unref (file);
+ g_free (filename);
if (info != NULL)
g_object_unref (info);
return ret;
diff --git a/src/gcm-exif.h b/src/gcm-exif.h
index b888ba9..5879b96 100644
--- a/src/gcm-exif.h
+++ b/src/gcm-exif.h
@@ -23,6 +23,7 @@
#define __GCM_EXIF_H
#include <glib-object.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
@@ -65,7 +66,7 @@ const gchar *gcm_exif_get_manufacturer (GcmExif *exif);
const gchar *gcm_exif_get_model (GcmExif *exif);
const gchar *gcm_exif_get_serial (GcmExif *exif);
gboolean gcm_exif_parse (GcmExif *exif,
- const gchar *filename,
+ GFile *file,
GError **error);
G_END_DECLS
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index d17ee8e..a38fde6 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -556,14 +556,17 @@ gcm_test_exif_func (void)
gboolean ret;
GError *error = NULL;
gchar *filename;
+ GFile *file;
exif = gcm_exif_new ();
g_assert (exif != NULL);
/* TIFF */
filename = gcm_test_get_data_file ("test.tif");
- ret = gcm_exif_parse (exif, filename, &error);
+ file = g_file_new_for_path (filename);
+ ret = gcm_exif_parse (exif, file, &error);
g_free (filename);
+ g_object_unref (file);
g_assert_no_error (error);
g_assert (ret);
g_assert_cmpstr (gcm_exif_get_model (exif), ==, "NIKON D60");
@@ -572,8 +575,10 @@ gcm_test_exif_func (void)
/* JPG */
filename = gcm_test_get_data_file ("test.jpg");
- ret = gcm_exif_parse (exif, filename, &error);
+ file = g_file_new_for_path (filename);
+ ret = gcm_exif_parse (exif, file, &error);
g_free (filename);
+ g_object_unref (file);
g_assert_no_error (error);
g_assert (ret);
g_assert_cmpstr (gcm_exif_get_model (exif), ==, "NIKON D60");
@@ -582,8 +587,10 @@ gcm_test_exif_func (void)
/* PNG */
filename = gcm_test_get_data_file ("test.png");
- ret = gcm_exif_parse (exif, filename, &error);
+ file = g_file_new_for_path (filename);
+ ret = gcm_exif_parse (exif, file, &error);
g_free (filename);
+ g_object_unref (file);
g_assert_error (error, GCM_EXIF_ERROR, GCM_EXIF_ERROR_NO_SUPPORT);
g_assert (!ret);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]