[libgepub] Added functions to get the current doc mime and path



commit 51ff62e64199647c56c13a8d2363dd0ed0d13b76
Author: Daniel Garcia Moreno <danigm wadobo com>
Date:   Tue May 31 19:57:57 2016 +0200

    Added functions to get the current doc mime and path

 libgepub/gepub-doc.c |   31 ++++++++++++++++++++++++++++++-
 libgepub/gepub-doc.h |    2 ++
 2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/libgepub/gepub-doc.c b/libgepub/gepub-doc.c
index 5194b59..272f89e 100644
--- a/libgepub/gepub-doc.c
+++ b/libgepub/gepub-doc.c
@@ -428,6 +428,18 @@ gepub_doc_get_resource_mime (GepubDoc *doc, gchar *v)
 }
 
 /**
+ * gepub_doc_get_current_mime:
+ * @doc: a #GepubDoc
+ *
+ * Returns: (transfer full): the current resource mime
+ */
+gchar *
+gepub_doc_get_current_mime (GepubDoc *doc)
+{
+    return gepub_doc_get_resource_mime_by_id (doc, doc->spine->data);
+}
+
+/**
  * gepub_doc_get_spine:
  * @doc: a #GepubDoc
  *
@@ -597,5 +609,22 @@ gchar *gepub_doc_get_resource_path (GepubDoc *doc, gchar *id)
         return NULL;
     }
 
-    return gres->uri;
+    return g_strdup (gres->uri);
+}
+
+/**
+ * gepub_doc_get_resource_path:
+ * @doc: a #GepubDoc
+ *
+ * Returns: (transfer full): the current resource path
+ */
+gchar *gepub_doc_get_current_path (GepubDoc *doc)
+{
+    GepubResource *gres = g_hash_table_lookup (doc->resources, doc->spine->data);
+    if (!gres) {
+        // not found
+        return NULL;
+    }
+
+    return g_strdup (gres->uri);
 }
diff --git a/libgepub/gepub-doc.h b/libgepub/gepub-doc.h
index 15f2460..b399545 100644
--- a/libgepub/gepub-doc.h
+++ b/libgepub/gepub-doc.h
@@ -52,6 +52,7 @@ guchar           *gepub_doc_get_resource_v (GepubDoc *doc, gchar *v, gsize *bufs
 GHashTable       *gepub_doc_get_resources  (GepubDoc *doc);
 gchar            *gepub_doc_get_resource_mime (GepubDoc *doc, gchar *v);
 gchar            *gepub_doc_get_resource_mime_by_id (GepubDoc *doc, gchar *id);
+gchar            *gepub_doc_get_current_mime (GepubDoc *doc);
 GList            *gepub_doc_get_spine      (GepubDoc *doc);
 GList            *gepub_doc_get_text       (GepubDoc *doc);
 GList            *gepub_doc_get_text_by_id (GepubDoc *doc, gchar *id);
@@ -61,6 +62,7 @@ gboolean          gepub_doc_go_next        (GepubDoc *doc);
 gboolean          gepub_doc_go_prev        (GepubDoc *doc);
 gchar            *gepub_doc_get_cover      (GepubDoc *doc);
 gchar            *gepub_doc_get_resource_path (GepubDoc *doc, gchar *id);
+gchar            *gepub_doc_get_current_path (GepubDoc *doc);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]