diff options
Diffstat (limited to 'libyelp/yelp-document.c')
-rw-r--r-- | libyelp/yelp-document.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c index 899aae6c..74275523 100644 --- a/libyelp/yelp-document.c +++ b/libyelp/yelp-document.c @@ -65,6 +65,7 @@ struct _YelpDocumentPriv { */ Hash *page_ids; /* Mapping of fragment IDs to real page IDs */ Hash *titles; /* Mapping of page IDs to titles */ + Hash *descs; /* Mapping of page IDs to descs */ Hash *mime_types; /* Mapping of page IDs to mime types */ Hash *contents; /* Mapping of page IDs to string content */ @@ -223,6 +224,7 @@ yelp_document_init (YelpDocument *document) priv->page_ids = hash_new (g_free ); priv->titles = hash_new (g_free); + priv->descs = hash_new (g_free); priv->mime_types = hash_new (g_free); priv->contents = hash_new ((GDestroyNotify) str_unref); @@ -258,6 +260,7 @@ yelp_document_finalize (GObject *object) hash_free (document->priv->page_ids); hash_free (document->priv->titles); + hash_free (document->priv->descs); hash_free (document->priv->mime_types); hash_free (document->priv->contents); @@ -450,8 +453,8 @@ yelp_document_set_up_id (YelpDocument *document, } gchar * -yelp_document_get_title (YelpDocument *document, - const gchar *page_id) +yelp_document_get_page_title (YelpDocument *document, + const gchar *page_id) { gchar *real, *ret = NULL; @@ -470,9 +473,9 @@ yelp_document_get_title (YelpDocument *document, } void -yelp_document_set_title (YelpDocument *document, - const gchar *page_id, - const gchar *title) +yelp_document_set_page_title (YelpDocument *document, + const gchar *page_id, + const gchar *title) { g_assert (document != NULL && YELP_IS_DOCUMENT (document)); @@ -481,6 +484,38 @@ yelp_document_set_title (YelpDocument *document, g_mutex_unlock (document->priv->mutex); } +gchar * +yelp_document_get_page_desc (YelpDocument *document, + const gchar *page_id) +{ + gchar *real, *ret = NULL; + + g_assert (document != NULL && YELP_IS_DOCUMENT (document)); + + g_mutex_lock (document->priv->mutex); + real = hash_lookup (document->priv->page_ids, page_id); + if (real) { + ret = hash_lookup (document->priv->descs, real); + if (ret) + ret = g_strdup (ret); + } + g_mutex_unlock (document->priv->mutex); + + return ret; +} + +void +yelp_document_set_page_desc (YelpDocument *document, + const gchar *page_id, + const gchar *desc) +{ + g_assert (document != NULL && YELP_IS_DOCUMENT (document)); + + g_mutex_lock (document->priv->mutex); + hash_replace (document->priv->descs, page_id, g_strdup (desc)); + g_mutex_unlock (document->priv->mutex); +} + /******************************************************************************/ gboolean |