summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Smith <bmsmith@src.gnome.org>2006-07-03 19:08:31 +0000
committerBrent Smith <bmsmith@src.gnome.org>2006-07-03 19:08:31 +0000
commit2524515ad88847e4a4f98a4e01688aad2f3a109b (patch)
tree3edea27c4637bf6f0d1a45e95c3d398980752e6f
parentfe0e434b8096f96ed3c3885efce70c7dfbdec8a6 (diff)
downloadyelp-2524515ad88847e4a4f98a4e01688aad2f3a109b.tar.gz
Put an #ifdef around HAVE_CONFIG_H
* src/yelp-debug.h: Put an #ifdef around HAVE_CONFIG_H * src/yelp-utils.c: * src/yelp-utils.h: - Get rid of the unused YelpDocPage type and related function(s) - created branch "yelp-document", branchpoint YELP_DOCUMENT_BRANCHPOINT for working on the new YelpDocument API; see http://live.gnome.org/Yelp * yelp-document.c: (yelp_document_dispose), (yelp_document_finalize), (yelp_document_class_init), (yelp_document_init), (document_set_property), (document_get_property), (yelp_document_get_page), (yelp_document_cancel_get), (yelp_document_get_sections), (yelp_document_add_page): * yelp-document.h: * yelp-page.c: (yelp_page_new), (yelp_page_set_id), (yelp_page_get_id), (yelp_page_set_title), (yelp_page_get_title), (yelp_page_set_contents), (yelp_page_get_contents), (yelp_page_set_prev_id), (yelp_page_get_prev_id), (yelp_page_set_next_id), (yelp_page_get_next_id), (yelp_page_set_toc_id), (yelp_page_get_toc_id), (yelp_page_free): * yelp-page.h: New files yelp-document.[ch] and yelp-page.[ch] for the new API
-rw-r--r--ChangeLog25
-rw-r--r--src/yelp-debug.h3
-rw-r--r--src/yelp-utils.c17
-rw-r--r--src/yelp-utils.h14
-rw-r--r--yelp-document.c328
-rw-r--r--yelp-document.h102
-rw-r--r--yelp-page.c191
-rw-r--r--yelp-page.h48
8 files changed, 697 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index c147894c..3499ff87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2006-07-03 Brent Smith <gnome@nextreality.net>
+
+ * src/yelp-debug.h: Put an #ifdef around HAVE_CONFIG_H
+ * src/yelp-utils.c:
+ * src/yelp-utils.h:
+ - Get rid of the unused YelpDocPage type and related function(s)
+ - created branch "yelp-document", branchpoint
+ YELP_DOCUMENT_BRANCHPOINT for working on the new YelpDocument API; see
+ http://live.gnome.org/Yelp
+ * yelp-document.c: (yelp_document_dispose),
+ (yelp_document_finalize), (yelp_document_class_init),
+ (yelp_document_init), (document_set_property),
+ (document_get_property), (yelp_document_get_page),
+ (yelp_document_cancel_get), (yelp_document_get_sections),
+ (yelp_document_add_page):
+ * yelp-document.h:
+ * yelp-page.c: (yelp_page_new), (yelp_page_set_id),
+ (yelp_page_get_id), (yelp_page_set_title), (yelp_page_get_title),
+ (yelp_page_set_contents), (yelp_page_get_contents),
+ (yelp_page_set_prev_id), (yelp_page_get_prev_id),
+ (yelp_page_set_next_id), (yelp_page_get_next_id),
+ (yelp_page_set_toc_id), (yelp_page_get_toc_id), (yelp_page_free):
+ * yelp-page.h:
+ New files yelp-document.[ch] and yelp-page.[ch] for the new API
+
2006-07-03 Shaun McCance <shaunm@gnome.org>
* src/Makefile.am:
diff --git a/src/yelp-debug.h b/src/yelp-debug.h
index 657859f9..846ad750 100644
--- a/src/yelp-debug.h
+++ b/src/yelp-debug.h
@@ -23,7 +23,10 @@
G_BEGIN_DECLS
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <glib.h>
typedef enum {
diff --git a/src/yelp-utils.c b/src/yelp-utils.c
index 48cce7fe..5c2b27b0 100644
--- a/src/yelp-utils.c
+++ b/src/yelp-utils.c
@@ -499,23 +499,6 @@ yelp_doc_info_equal (YelpDocInfo *doc1, YelpDocInfo *doc2)
return equal;
}
-void
-yelp_doc_page_free (YelpDocPage *page)
-{
- if (!page)
- return;
-
- g_free (page->page_id);
- g_free (page->title);
- g_free (page->contents);
-
- g_free (page->prev_id);
- g_free (page->next_id);
- g_free (page->toc_id);
-
- g_free (page);
-}
-
gchar *
yelp_uri_get_fragment (const gchar *uri)
{
diff --git a/src/yelp-utils.h b/src/yelp-utils.h
index a2fede29..8794d364 100644
--- a/src/yelp-utils.h
+++ b/src/yelp-utils.h
@@ -26,7 +26,6 @@
#include <glib/gi18n.h>
typedef struct _YelpDocInfo YelpDocInfo;
-typedef struct _YelpDocPage YelpDocPage;
typedef enum {
YELP_DOC_TYPE_ERROR = 0,
@@ -65,17 +64,6 @@ typedef enum {
#include "yelp-pager.h"
-struct _YelpDocPage {
- YelpDocInfo *document;
- gchar *page_id;
- gchar *title;
- gchar *contents;
-
- gchar *prev_id;
- gchar *next_id;
- gchar *toc_id;
-};
-
const char * yelp_dot_dir (void);
YelpDocInfo * yelp_doc_info_new (const gchar *uri,
gboolean trust_uri);
@@ -118,8 +106,6 @@ gchar * yelp_doc_info_get_filename (YelpDocInfo *doc);
gboolean yelp_doc_info_equal (YelpDocInfo *doc1,
YelpDocInfo *doc2);
-void yelp_doc_page_free (YelpDocPage *page);
-
gchar * yelp_uri_get_fragment (const gchar *uri);
gchar * yelp_uri_get_relative (gchar *base,
gchar *ref);
diff --git a/yelp-document.c b/yelp-document.c
new file mode 100644
index 00000000..8b197476
--- /dev/null
+++ b/yelp-document.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 2006 Brent Smith <gnome@nextreality.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Brent Smith <gnome@nextreality.net>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include "yelp-document.h"
+#include "yelp-page.h"
+#include "yelp-utils.h"
+#include "yelp-debug.h"
+
+#define YELP_DOCUMENT_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_DOCUMENT, YelpDocumentPriv))
+
+struct _YelpDocumentPriv {
+ YelpDocInfo *doc_info;
+
+ /* key is string of page name, value is the corresponding YelpPage */
+ GHashTable *page_hash;
+
+ /* the source_id of any current page requests */
+ gint idle_source_id;
+
+ /* callback functions for current page request */
+ YelpPageLoadFunc page_func;
+ YelpPageTitleFunc title_func;
+ YelpPageErrorFunc error_func;
+};
+
+/* properties for the YelpDocument class */
+enum {
+ PROP_0,
+ PROP_DOCINFO
+};
+
+/* this defines our prototypes for class and instance init functions,
+ * our full get_type function, and the global yelp_document_parent_class */
+G_DEFINE_TYPE (YelpDocument, yelp_document, G_TYPE_OBJECT);
+
+/* prototypes for static functions */
+static void document_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void document_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void
+yelp_document_dispose (GObject *object)
+{
+ YelpDocument *document = YELP_DOCUMENT (object);
+ YelpDocumentPriv *priv = document->priv;
+
+ G_OBJECT_CLASS (yelp_document_parent_class)->dispose (object);
+}
+
+static void
+yelp_document_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (yelp_document_parent_class)->finalize (object);
+}
+
+static void
+yelp_document_class_init (YelpDocumentClass *klass)
+{
+ GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
+
+ g_object_class->dispose = yelp_document_dispose;
+ g_object_class->finalize = yelp_document_finalize;
+
+ /* install the document-info property */
+ g_object_class_install_property (g_object_class,
+ PROP_DOCINFO,
+ g_param_spec_pointer ("document-info",
+ "Document Information",
+ "The YelpDocInfo struct",
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
+
+ g_type_class_add_private (g_object_class, sizeof (YelpDocumentPriv));
+}
+
+static void
+yelp_document_init (YelpDocument *document)
+{
+ document->priv = YELP_DOCUMENT_GET_PRIVATE (document);
+ YelpDocumentPriv *priv = document->priv;
+
+ /* initialize the page hash table */
+ priv->page_hash =
+ g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL, /* use page->page_id directly */
+ (GDestroyNotify)yelp_page_free);
+
+}
+
+static void
+document_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ YelpDocument *document = YELP_DOCUMENT (object);
+
+ switch (prop_id) {
+ case PROP_DOCINFO:
+ if (document->priv->doc_info)
+ yelp_doc_info_unref (document->priv->doc_info);
+ document->priv->doc_info = (YelpDocInfo *) g_value_get_pointer (value);
+ yelp_doc_info_ref (document->priv->doc_info);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+document_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ YelpDocument *document = YELP_DOCUMENT (object);
+
+ switch (prop_id) {
+ case PROP_DOCINFO:
+ g_value_set_pointer (value, document->priv->doc_info);
+ break;
+ default:
+ break;
+ }
+}
+
+/*****************************************
+ * public methods for class YelpDocument *
+ *****************************************/
+
+/**
+ * @document: The #YelpDocument in which to get the page
+ * @page_id: a NULL terminated string indicating the name of the page to get.
+ * @page_func: the YelpPageLoadFunc callback function which is called when the
+ * page has completed loading.
+ * @title_func: the YelpPageTitleFunc callback function which is called when the
+ * title of the page is known.
+ * @error_func: the YelpPageErrorFunc callback function which is called when an
+ * error occurs trying to get the page.
+ * @user_date: User defined data that is passed to each callback function as the
+ * last parameter
+ *
+ * Initiates a page request for the given document. It takes callback
+ * functions for page loading, page title loading, and error handling. It returns a
+ * request ID, which can be used by yelp_document_cancel_get() to cancel the request.
+ *
+ * Returns: an integer representing the source_id of the idle function that is
+ * added to the main loop. Use the yelp_document_cancel_get() function
+ * with this source_id to cancel any pending page requests. If the
+ * function fails or there is already a page request in progress, it should
+ * return 0.
+ */
+gint
+yelp_document_get_page (YelpDocument *document,
+ const gchar *page_id,
+ YelpPageLoadFunc page_func,
+ YelpPageTitleFunc title_func,
+ YelpPageErrorFunc error_func,
+ gpointer user_data)
+{
+ debug_print (DB_FUNCTION, "entering\n");
+
+ g_return_val_if_fail (YELP_IS_DOCUMENT (document), 0);
+ g_return_val_if_fail (page_id != NULL, 0);
+ g_return_val_if_fail (page_func != NULL, 0);
+ g_return_val_if_fail (title_func != NULL, 0);
+ g_return_val_if_fail (error_func != NULL, 0);
+
+ YelpDocumentPriv *priv = document->priv;
+ YelpDocumentClass *klass = YELP_DOCUMENT_GET_CLASS (document);
+
+ /* check for an in progress page request and bail if one exists */
+ if (priv->idle_source_id > 0)
+ return 0;
+
+ /* save our callback functions in the private structure for use by the
+ * virtual functions get_page and cancel */
+ priv->page_func = page_func;
+ priv->title_func = title_func;
+ priv->error_func = error_func;
+
+ /* add the virtual functions get_page and cancel (to be implemented by
+ * the derived class) to the main loop to be run during idle */
+ priv->idle_source_id =
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc)klass->get_page,
+ document, (GDestroyNotify)klass->cancel);
+
+ debug_print (DB_FUNCTION, "leaving\n");
+ return priv->idle_source_id;
+}
+
+/**
+ * @document: The #YelpDocument in which to cancel a page get
+ * @source_id: The source_id returned from the yelp_document_get_page() function.
+ *
+ * Cancels a page request that is currently in progress. If there
+ * is no page request in progress, then the function returns immediately.
+ *
+ * Returns: TRUE if the page request was found and removed, FALSE otherwise
+ */
+gboolean
+yelp_document_cancel_get (YelpDocument *document,
+ gint source_id)
+{
+ debug_print (DB_FUNCTION, "entering\n");
+
+ YelpDocumentPriv *priv = document->priv;
+ gboolean retval;
+
+ g_return_if_fail (YELP_IS_DOCUMENT (document));
+ g_return_if_fail (source_id > 0);
+
+ /* return if we don't have a running page request */
+ if (priv->idle_source_id <= 0)
+ return FALSE;
+
+ /* this will call the GDestroyNotify callback (the virtual function cancel())
+ * to cleanup any resources currently allocated for the page get request */
+ retval = g_source_remove (source_id);
+
+ /* reset some private data */
+ priv->idle_source_id = 0;
+ priv->page_func = NULL;
+ priv->title_func = NULL;
+ priv->error_func = NULL;
+
+ debug_print (DB_FUNCTION, "leaving\n");
+ return retval;
+}
+
+/**
+ * @document: The #YelpDocument in which to get the sections
+ *
+ * Gets all the sections in a document.
+ *
+ * Returns: a GtkTreeModel representing all the sections in the
+ * document
+ *
+ */
+GtkTreeModel *
+yelp_document_get_sections (YelpDocument *document)
+{
+ debug_print (DB_FUNCTION, "entering\n");
+
+ YelpDocumentClass *klass = YELP_DOCUMENT_GET_CLASS (document);
+ GtkTreeModel *sections;
+
+ sections = klass->get_sections (document);
+
+ debug_print (DB_FUNCTION, "leaving\n");
+ return sections;
+}
+
+/**
+ * @document: The #YelpDocument in which to add the page
+ * @page: A #YelpPage to add to the #YelpDocument
+ *
+ * Adds a page to the #YelpDocument passed.
+ *
+ * Returns: nothing
+ */
+void
+yelp_document_add_page (YelpDocument *document,
+ YelpPage *page)
+{
+ debug_print (DB_FUNCTION, "entering\n");
+
+ g_return_if_fail (document != NULL);
+ g_return_if_fail (YELP_IS_DOCUMENT (document));
+ g_return_if_fail (page != NULL);
+
+ const gchar *page_id = yelp_page_get_id (page);
+ if (!page_id)
+ return;
+
+ YelpDocumentPriv *priv = document->priv;
+
+ g_hash_table_replace (priv->page_hash, (gchar *)page_id, page);
+
+ debug_print (DB_FUNCTION, "leaving\n");
+}
+
+/*const YelpPage *
+yelp_pager_get_page (YelpPager *pager, const gchar *frag_id)
+{
+ YelpPage *page;
+ const gchar *page_id = YELP_PAGER_GET_CLASS (pager)->resolve_frag (pager, frag_id);
+
+ if (page_id == NULL)
+ return NULL;
+
+ page = (YelpPage *) g_hash_table_lookup (pager->priv->page_hash, page_id);
+
+ return (const YelpPage *) page;
+}*/
diff --git a/yelp-document.h b/yelp-document.h
new file mode 100644
index 00000000..ffd60049
--- /dev/null
+++ b/yelp-document.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2006 Brent Smith <gnome@nextreality.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Brent Smith <gnome@nextreality.net>
+ */
+
+#ifndef __YELP_DOCUMENT_H__
+#define __YELP_DOCUMENT_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "yelp-page.h"
+
+G_BEGIN_DECLS
+
+typedef struct _YelpDocument YelpDocument;
+typedef struct _YelpDocumentClass YelpDocumentClass;
+typedef struct _YelpDocumentPriv YelpDocumentPriv;
+
+#define YELP_TYPE_DOCUMENT (yelp_document_get_type ())
+#define YELP_DOCUMENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), YELP_TYPE_DOCUMENT, YelpDocument))
+#define YELP_DOCUMENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), YELP_TYPE_DOCUMENT, YelpDocumentClass))
+#define YELP_IS_DOCUMENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), YELP_TYPE_DOCUMENT))
+#define YELP_IS_DOCUMENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), YELP_TYPE_DOCUMENT))
+#define YELP_DOCUMENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), YELP_TYPE_DOCUMENT, YelpDocumentClass))
+
+struct _YelpDocument {
+ GObject parent;
+
+ YelpDocumentPriv *priv;
+};
+
+struct _YelpDocumentClass {
+ GObjectClass parent_class;
+
+ /* virtual functions - must be implemented by derived classes */
+ /* initiates a page request */
+ gboolean (*get_page) (YelpDocument *document);
+
+ /* cancels a page request */
+ gboolean (*cancel) (YelpDocument *document);
+
+ /* gets a #GtkTreeModel which represents all the sections in the
+ * document */
+ GtkTreeModel * (*get_sections) (YelpDocument *document);
+};
+
+/* callback function definitions */
+typedef void (*YelpPageLoadFunc) (YelpDocument *document,
+ gint req_id,
+ const gchar *page_id,
+ YelpPage *page,
+ gpointer user_data);
+
+typedef void (*YelpPageTitleFunc) (YelpDocument *document,
+ gint req_id,
+ const gchar *page_id,
+ const gchar *title,
+ gpointer user_data);
+
+typedef void (*YelpPageErrorFunc) (YelpDocument *document,
+ gint req_id,
+ const gchar *page_id,
+ const GError *error,
+ gpointer user_data);
+
+/* public methods for YelpDocument Class */
+gint yelp_document_get_page (YelpDocument *document,
+ const gchar *page_id,
+ YelpPageLoadFunc page_func,
+ YelpPageTitleFunc title_func,
+ YelpPageErrorFunc error_func,
+ gpointer user_data);
+
+gboolean yelp_document_cancel_get (YelpDocument *document,
+ gint source_id);
+
+GtkTreeModel *yelp_document_get_sections (YelpDocument *document);
+
+void yelp_document_add_page (YelpDocument *document,
+ YelpPage *page);
+
+
+G_END_DECLS
+
+#endif
diff --git a/yelp-page.c b/yelp-page.c
new file mode 100644
index 00000000..38aa9e61
--- /dev/null
+++ b/yelp-page.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2006 Brent Smith <gnome@nextreality.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Brent Smith <gnome@nextreality.net>
+ */
+
+#include "yelp-page.h"
+
+#include <glib.h>
+
+struct _YelpPage {
+ gchar *page_id;
+ gchar *title;
+ gchar *contents;
+ gchar *prev_id;
+ gchar *next_id;
+ gchar *toc_id;
+};
+
+
+YelpPage *
+yelp_page_new (void)
+{
+ YelpPage *page;
+
+ page = g_slice_new0 (YelpPage);
+
+ return page;
+}
+
+void
+yelp_page_set_id (YelpPage *page, const gchar *page_id)
+{
+ g_return_if_fail (page != NULL);
+ if (page_id == NULL)
+ return;
+
+ if (page->page_id)
+ g_free (page->page_id);
+
+ page->page_id = g_strdup (page_id);
+
+ return;
+}
+
+const gchar *
+yelp_page_get_id (YelpPage *page)
+{
+ g_return_if_fail (page != NULL);
+
+ return (const gchar *) page->page_id;
+}
+
+void
+yelp_page_set_title (YelpPage *page, const gchar *title)
+{
+ g_return_if_fail (page != NULL);
+ if (title == NULL)
+ return;
+
+ if (page->title)
+ g_free (page->title);
+
+ page->title = g_strdup (title);
+
+ return;
+}
+
+const gchar *
+yelp_page_get_title (YelpPage *page)
+{
+ g_return_if_fail (page != NULL);
+
+ return (const gchar *)page->title;
+}
+
+void
+yelp_page_set_contents (YelpPage *page, const gchar *contents)
+{
+ g_return_if_fail (page != NULL);
+ if (contents == NULL)
+ return;
+
+ if (page->contents)
+ g_free (page->contents);
+
+ page->contents = g_strdup (contents);
+
+ return;
+}
+
+const gchar *
+yelp_page_get_contents (YelpPage *page)
+{
+ g_return_if_fail (page != NULL);
+
+ return (const gchar *)page->contents;
+}
+
+void
+yelp_page_set_prev_id (YelpPage *page, const gchar *prev_id)
+{
+ g_return_if_fail (page != NULL);
+ if (prev_id == NULL)
+ return;
+
+ if (page->prev_id)
+ g_free (page->prev_id);
+
+ page->prev_id = g_strdup (prev_id);
+
+ return;
+}
+
+const gchar *
+yelp_page_get_prev_id (YelpPage *page)
+{
+ g_return_if_fail (page != NULL);
+
+ return (const gchar *)page->prev_id;
+}
+
+void
+yelp_page_set_next_id (YelpPage *page, const gchar *next_id)
+{
+ g_return_if_fail (page != NULL);
+ if (next_id == NULL)
+ return;
+
+ if (page->next_id)
+ g_free (page->next_id);
+
+ page->next_id = g_strdup (next_id);
+
+ return;
+}
+
+const gchar *
+yelp_page_get_next_id (YelpPage *page)
+{
+ g_return_if_fail (page != NULL);
+
+ return (const gchar *)page->next_id;
+}
+
+void
+yelp_page_set_toc_id (YelpPage *page, const gchar *toc_id)
+{
+ g_return_if_fail (page != NULL);
+ if (toc_id == NULL)
+ return;
+
+ if (page->toc_id)
+ g_free (page->toc_id);
+
+ page->toc_id = g_strdup (toc_id);
+
+ return;
+}
+
+const gchar *
+yelp_page_get_toc_id (YelpPage *page)
+{
+ g_return_if_fail (page != NULL);
+
+ return (const gchar *)page->toc_id;
+}
+
+void
+yelp_page_free (YelpPage *page)
+{
+ if (page == NULL)
+ return;
+
+ g_slice_free (YelpPage, page);
+}
diff --git a/yelp-page.h b/yelp-page.h
new file mode 100644
index 00000000..3a7d1ca6
--- /dev/null
+++ b/yelp-page.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2006 Brent Smith <gnome@nextreality.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Brent Smith <gnome@nextreality.net>
+ */
+
+#ifndef __YELP_PAGE_H__
+#define __YELP_PAGE_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _YelpPage YelpPage;
+
+YelpPage *yelp_page_new (void);
+void yelp_page_set_id (YelpPage *page, const gchar *page_id);
+const gchar *yelp_page_get_id (YelpPage *page);
+void yelp_page_set_title (YelpPage *page, const gchar *title);
+const gchar *yelp_page_get_title (YelpPage *page);
+void yelp_page_set_contents (YelpPage *page, const gchar *contents);
+const gchar *yelp_page_get_contents (YelpPage *page);
+void yelp_page_set_prev_id (YelpPage *page, const gchar *prev_id);
+const gchar *yelp_page_get_prev_id (YelpPage *page);
+void yelp_page_set_next_id (YelpPage *page, const gchar *next_id);
+const gchar *yelp_page_get_next_id (YelpPage *page);
+void yelp_page_set_toc_id (YelpPage *page, const gchar *toc_id);
+const gchar *yelp_page_get_toc_id (YelpPage *page);
+void yelp_page_free (YelpPage *page);
+
+G_END_DECLS
+
+#endif