[discident-glib] ean: Export EAN through the result
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [discident-glib] ean: Export EAN through the result
- Date: Sat, 27 Apr 2013 17:58:56 +0000 (UTC)
commit f3a754c5cdacb467dac044c18607b87ba086fb55
Author: Bastien Nocera <hadess hadess net>
Date: Tue Apr 2 23:35:47 2013 +0200
ean: Export EAN through the result
So that it's available before checking the status of the lookup.
discident-glib/discident-ean-glib.c | 34 ++++++++++++++++++++++++++------
discident-glib/discident-ean-glib.h | 3 +-
discident-glib/discident-glib.symbols | 1 +
discident-glib/test-diglib.c | 3 +-
4 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/discident-glib/discident-ean-glib.c b/discident-glib/discident-ean-glib.c
index c64dcdc..0bb39bf 100644
--- a/discident-glib/discident-ean-glib.c
+++ b/discident-glib/discident-ean-glib.c
@@ -510,20 +510,18 @@ discident_ean_lookup (DiscidentEan *ean,
* discident_ean_lookup_finish:
* @ean: a #DiscidentEan object
* @res: a #GAsyncResult.
- * @barcode: (out) the return location for the looked up barcode, or %NULL to ignore.
* @img_url: (out) the return location for the image URL, or %NULL to ignore.
* @error: a #GError.
*
* Finishes an EAN lookup operation. See discident_ean_lookup().
*
- * Returns: a string containing the name of the looked up barcode, or
- * %NULL in case of errors.
+ * Returns: a string containing the description of the looked up
+ * barcode, or %NULL in case of errors.
* Free the returned string with g_free() when done.
**/
char *
discident_ean_lookup_finish (DiscidentEan *ean,
GAsyncResult *res,
- char **barcode,
char **img_url,
GError **error)
{
@@ -542,13 +540,35 @@ discident_ean_lookup_finish (DiscidentEan *ean,
*img_url = g_strdup (g_object_get_data (G_OBJECT (res), "image-url"));
out:
- if (barcode != NULL)
- *barcode = g_strdup (g_object_get_data (G_OBJECT (res), "barcode"));
-
return ret;
}
/**
+ * discident_ean_lookup_get_barcode:
+ * @ean: a #DiscidentEan object
+ * @res: a #GAsyncResult.
+ *
+ * Returns the barcode used for the EAN lookup operation.
+ * See discident_ean_lookup().
+ *
+ * Returns: a string containing the looked up barcode, or
+ * %NULL in case of errors.
+ * Free the returned string with g_free() when done.
+ **/
+char *
+discident_ean_lookup_get_barcode (DiscidentEan *ean,
+ GAsyncResult *res)
+{
+ GSimpleAsyncResult *simple;
+
+ g_return_val_if_fail (res != NULL, NULL);
+ simple = G_SIMPLE_ASYNC_RESULT (res);
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == discident_ean_lookup);
+
+ return g_strdup (g_object_get_data (G_OBJECT (res), "barcode"));
+}
+
+/**
* discident_ean_new:
*
* Create a new #DiscidentEan object to lookup barcodes with.
diff --git a/discident-glib/discident-ean-glib.h b/discident-glib/discident-ean-glib.h
index cfeae20..a7b473a 100644
--- a/discident-glib/discident-ean-glib.h
+++ b/discident-glib/discident-ean-glib.h
@@ -69,9 +69,10 @@ void discident_ean_lookup (DiscidentEan *ean,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
+char * discident_ean_lookup_get_barcode (DiscidentEan *ean,
+ GAsyncResult *res);
char * discident_ean_lookup_finish (DiscidentEan *ean,
GAsyncResult *res,
- char **barcode,
char **img_url,
GError **error);
diff --git a/discident-glib/discident-glib.symbols b/discident-glib/discident-glib.symbols
index 22949cd..7adf80c 100644
--- a/discident-glib/discident-glib.symbols
+++ b/discident-glib/discident-glib.symbols
@@ -10,5 +10,6 @@ discident_ean_get_type
discident_ean_new
discident_ean_lookup_sync
discident_ean_lookup
+discident_ean_lookup_get_barcode
discident_ean_lookup_finish
discident_error_quark
diff --git a/discident-glib/test-diglib.c b/discident-glib/test-diglib.c
index 45e31dd..b2864e9 100644
--- a/discident-glib/test-diglib.c
+++ b/discident-glib/test-diglib.c
@@ -183,9 +183,10 @@ discident_ean_print (GObject *source_object,
GError *error = NULL;
char *title, *img_url, *barcode;
+ barcode = discident_ean_lookup_get_barcode (DISCIDENT_EAN (source_object),
+ res);
title = discident_ean_lookup_finish (DISCIDENT_EAN (source_object),
res,
- &barcode,
&img_url,
&error);
if (title == NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]