summaryrefslogtreecommitdiff
path: root/libyelp/yelp-man-document.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-08-29 14:44:44 +0200
committerDavid King <amigadave@amigadave.com>2015-06-22 10:39:52 +0100
commit65d2f05a31bafad5d4f6147fc16db9fdd9aeadc9 (patch)
tree9a779bf74debe6bb2e444142cfee3c50ce4e3045 /libyelp/yelp-man-document.c
parentb9eac3dd0a0896919a027bd5ee03dcf81740e5bd (diff)
downloadyelp-65d2f05a31bafad5d4f6147fc16db9fdd9aeadc9.tar.gz
yelp-document: Make document-uri property a YelpUri
All implementations of YelpDocument except YelpSimpleDocument keep a reference to the YelpUri, so move it to the parent class and add a getter to use the YelpUri from derived classes. This is also useful to get the YelpUri directly from the document, instead of getting the document uri string, create a YelpUri and resolve it.
Diffstat (limited to 'libyelp/yelp-man-document.c')
-rw-r--r--libyelp/yelp-man-document.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/libyelp/yelp-man-document.c b/libyelp/yelp-man-document.c
index 77e5b51a..77e74143 100644
--- a/libyelp/yelp-man-document.c
+++ b/libyelp/yelp-man-document.c
@@ -44,7 +44,6 @@ typedef enum {
typedef struct _YelpManDocumentPrivate YelpManDocumentPrivate;
struct _YelpManDocumentPrivate {
- YelpUri *uri;
ManState state;
gchar *page_id;
@@ -118,7 +117,6 @@ static const YelpLangEncodings langmap[] = {
{ NULL, NULL },
};
-static void yelp_man_document_dispose (GObject *object);
static void yelp_man_document_finalize (GObject *object);
/* YelpDocument */
@@ -154,7 +152,6 @@ yelp_man_document_class_init (YelpManDocumentClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
YelpDocumentClass *document_class = YELP_DOCUMENT_CLASS (klass);
- object_class->dispose = yelp_man_document_dispose;
object_class->finalize = yelp_man_document_finalize;
document_class->request_page = man_request_page;
@@ -172,19 +169,6 @@ yelp_man_document_init (YelpManDocument *man)
}
static void
-yelp_man_document_dispose (GObject *object)
-{
- YelpManDocumentPrivate *priv = GET_PRIV (object);
-
- if (priv->uri) {
- g_object_unref (priv->uri);
- priv->uri = NULL;
- }
-
- G_OBJECT_CLASS (yelp_man_document_parent_class)->dispose (object);
-}
-
-static void
yelp_man_document_finalize (GObject *object)
{
YelpManDocumentPrivate *priv = GET_PRIV (object);
@@ -203,22 +187,11 @@ yelp_man_document_finalize (GObject *object)
YelpDocument *
yelp_man_document_new (YelpUri *uri)
{
- YelpManDocument *man;
- YelpManDocumentPrivate *priv;
- gchar *doc_uri;
-
g_return_val_if_fail (uri != NULL, NULL);
- doc_uri = yelp_uri_get_document_uri (uri);
- man = (YelpManDocument *) g_object_new (YELP_TYPE_MAN_DOCUMENT,
- "document-uri", doc_uri,
- NULL);
- g_free (doc_uri);
- priv = GET_PRIV (man);
-
- priv->uri = g_object_ref (uri);
-
- return (YelpDocument *) man;
+ return (YelpDocument *) g_object_new (YELP_TYPE_MAN_DOCUMENT,
+ "document-uri", uri,
+ NULL);
}
@@ -237,7 +210,7 @@ man_request_page (YelpDocument *document,
GError *error;
gboolean handled;
- fulluri = yelp_uri_get_canonical_uri (priv->uri);
+ fulluri = yelp_uri_get_canonical_uri (yelp_document_get_uri (document));
if (g_str_has_prefix (fulluri, "man:"))
priv->page_id = g_strdup (fulluri + 4);
else
@@ -274,7 +247,7 @@ man_request_page (YelpDocument *document,
break;
case MAN_STATE_PARSED:
case MAN_STATE_STOP:
- docuri = yelp_uri_get_document_uri (priv->uri);
+ docuri = yelp_uri_get_document_uri (yelp_document_get_uri (document));
error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
_("The page ‘%s’ was not found in the document ‘%s’."),
page_id, docuri);
@@ -354,7 +327,7 @@ transform_finished (YelpTransform *transform,
(GWeakNotify) transform_finalized,
man);
- docuri = yelp_uri_get_document_uri (priv->uri);
+ docuri = yelp_uri_get_document_uri (yelp_document_get_uri ((YelpDocument *) man));
error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
_("The requested page was not found in the document ‘%s’."),
docuri);
@@ -411,7 +384,7 @@ man_document_process (YelpManDocument *man)
YelpManParser *parser;
const gchar *language, *encoding;
- file = yelp_uri_get_file (priv->uri);
+ file = yelp_uri_get_file (yelp_document_get_uri ((YelpDocument *) man));
if (file == NULL) {
error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
_("The file does not exist."));