Commit e6e3f254 authored by Shaun McCance's avatar Shaun McCance

Remove deprecated method of doing private structs on gobjects

parent 3bf41221
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2003-2009 Shaun McCance <shaunm@gnome.org>
* Copyright (C) 2003-2020 Shaun McCance <shaunm@gnome.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -94,9 +94,6 @@ static void transform_error (YelpTransform *transform
static void transform_finalized (YelpDocbookDocument *docbook,
gpointer transform);
G_DEFINE_TYPE (YelpDocbookDocument, yelp_docbook_document, YELP_TYPE_DOCUMENT)
#define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_DOCBOOK_DOCUMENT, YelpDocbookDocumentPrivate))
typedef struct _YelpDocbookDocumentPrivate YelpDocbookDocumentPrivate;
struct _YelpDocbookDocumentPrivate {
DocbookState state;
......@@ -129,6 +126,8 @@ struct _YelpDocbookDocumentPrivate {
GHashTable *autoids;
};
G_DEFINE_TYPE_WITH_PRIVATE (YelpDocbookDocument, yelp_docbook_document, YELP_TYPE_DOCUMENT)
/******************************************************************************/
static void
......@@ -155,14 +154,12 @@ yelp_docbook_document_class_init (YelpDocbookDocumentClass *klass)
document_class->index = docbook_index;
document_class->request_page = docbook_request_page;
g_type_class_add_private (klass, sizeof (YelpDocbookDocumentPrivate));
}
static void
yelp_docbook_document_init (YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
priv->state = DOCBOOK_STATE_BLANK;
priv->autoids = NULL;
......@@ -174,7 +171,8 @@ static void
yelp_docbook_document_dispose (GObject *object)
{
gint i;
YelpDocbookDocumentPrivate *priv = GET_PRIV (object);
YelpDocbookDocumentPrivate *priv =
yelp_docbook_document_get_instance_private (YELP_DOCBOOK_DOCUMENT (object));
if (priv->monitors != NULL) {
for (i = 0; priv->monitors[i]; i++) {
......@@ -190,7 +188,8 @@ yelp_docbook_document_dispose (GObject *object)
static void
yelp_docbook_document_finalize (GObject *object)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (object);
YelpDocbookDocumentPrivate *priv =
yelp_docbook_document_get_instance_private (YELP_DOCBOOK_DOCUMENT (object));
if (priv->xmldoc)
xmlFreeDoc (priv->xmldoc);
......@@ -221,7 +220,7 @@ yelp_docbook_document_new (YelpUri *uri)
docbook = (YelpDocbookDocument *) g_object_new (YELP_TYPE_DOCBOOK_DOCUMENT,
"document-uri", uri,
NULL);
priv = GET_PRIV (docbook);
priv = yelp_docbook_document_get_instance_private (docbook);
path = yelp_uri_get_search_path (uri);
priv->monitors = g_new0 (GFileMonitor*, g_strv_length (path) + 1);
......@@ -250,7 +249,8 @@ docbook_request_page (YelpDocument *document,
gpointer user_data,
GDestroyNotify notify)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (document);
YelpDocbookDocumentPrivate *priv =
yelp_docbook_document_get_instance_private (YELP_DOCBOOK_DOCUMENT (document));
gchar *docuri;
GError *error;
gboolean handled;
......@@ -311,7 +311,7 @@ docbook_request_page (YelpDocument *document,
static void
docbook_process (YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
YelpDocument *document = YELP_DOCUMENT (docbook);
GFile *file = NULL;
gchar *filepath = NULL;
......@@ -469,7 +469,7 @@ docbook_process (YelpDocbookDocument *docbook)
static void
docbook_disconnect (YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
if (priv->chunk_ready) {
g_signal_handler_disconnect (priv->transform, priv->chunk_ready);
priv->chunk_ready = 0;
......@@ -491,7 +491,7 @@ docbook_disconnect (YelpDocbookDocument *docbook)
static gboolean
docbook_reload (YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
if (priv->index_running || priv->process_running || priv->transform_running)
return TRUE;
......@@ -521,7 +521,7 @@ docbook_monitor_changed (GFileMonitor *monitor,
GFileMonitorEvent event_type,
YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
if (g_get_monotonic_time() - priv->reload_time < 1000)
return;
......@@ -546,7 +546,7 @@ docbook_walk (YelpDocbookDocument *docbook)
xmlChar *keywords = NULL;
xmlNodePtr cur, old_cur;
gboolean chunkQ;
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
YelpDocument *document = YELP_DOCUMENT (docbook);
debug_print (DB_FUNCTION, "entering\n");
......@@ -853,7 +853,7 @@ transform_chunk_ready (YelpTransform *transform,
gchar *chunk_id,
YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
gchar *content;
debug_print (DB_FUNCTION, "entering\n");
......@@ -880,7 +880,7 @@ static void
transform_finished (YelpTransform *transform,
YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
YelpDocument *document = YELP_DOCUMENT (docbook);
gchar *docuri;
GError *error;
......@@ -916,7 +916,7 @@ static void
transform_error (YelpTransform *transform,
YelpDocbookDocument *docbook)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
GError *error;
debug_print (DB_FUNCTION, "entering\n");
......@@ -938,7 +938,7 @@ static void
transform_finalized (YelpDocbookDocument *docbook,
gpointer transform)
{
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
debug_print (DB_FUNCTION, "entering\n");
......@@ -1007,7 +1007,7 @@ docbook_index_chunk (DocbookIndexData *index)
gchar *title = NULL;
gchar *keywords;
GSList *chunks = NULL;
YelpDocbookDocumentPrivate *priv = GET_PRIV (index->docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (index->docbook);
id = xmlGetProp (index->cur, BAD_CAST "id");
if (!id)
......@@ -1092,7 +1092,7 @@ docbook_index_threaded (YelpDocbookDocument *docbook)
GFile *file = NULL;
gchar *filename = NULL;
YelpUri *uri;
YelpDocbookDocumentPrivate *priv = GET_PRIV (docbook);
YelpDocbookDocumentPrivate *priv = yelp_docbook_document_get_instance_private (docbook);
uri = yelp_document_get_uri (YELP_DOCUMENT (docbook));
file = yelp_uri_get_file (uri);
......@@ -1153,7 +1153,7 @@ docbook_index (YelpDocument *document)
if (done)
return;
priv = GET_PRIV (document);
priv = yelp_docbook_document_get_instance_private (YELP_DOCBOOK_DOCUMENT (document));
g_object_ref (document);
priv->index = g_thread_new ("docbook-index",
(GThreadFunc)(GCallback) docbook_index_threaded,
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2003-2009 Shaun McCance <shaunm@gnome.org>
* Copyright (C) 2003-2020 Shaun McCance <shaunm@gnome.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -64,7 +64,7 @@ struct _Hash {
GDestroyNotify destroy;
};
struct _YelpDocumentPriv {
struct _YelpDocumentPrivate {
GMutex mutex;
GSList *reqs_all; /* Holds canonical refs, only free from here */
......@@ -97,9 +97,7 @@ struct _YelpDocumentPriv {
GError *idle_error;
};
G_DEFINE_TYPE (YelpDocument, yelp_document, G_TYPE_OBJECT)
#define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_DOCUMENT, YelpDocumentPriv))
G_DEFINE_TYPE_WITH_PRIVATE (YelpDocument, yelp_document, G_TYPE_OBJECT)
static void yelp_document_dispose (GObject *object);
static void yelp_document_finalize (GObject *object);
......@@ -292,16 +290,14 @@ yelp_document_class_init (YelpDocumentClass *klass)
YELP_TYPE_URI,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
g_type_class_add_private (klass, sizeof (YelpDocumentPriv));
}
static void
yelp_document_init (YelpDocument *document)
{
YelpDocumentPriv *priv;
YelpDocumentPrivate *priv;
document->priv = priv = GET_PRIV (document);
document->priv = priv = yelp_document_get_instance_private (document);
g_mutex_init (&priv->mutex);
......@@ -1263,7 +1259,7 @@ yelp_document_signal (YelpDocument *document,
static gboolean
yelp_document_error_pending_idle (YelpDocument *document)
{
YelpDocumentPriv *priv = GET_PRIV (document);
YelpDocumentPrivate *priv = yelp_document_get_instance_private (document);
GSList *cur;
Request *request;
......@@ -1291,7 +1287,7 @@ void
yelp_document_error_pending (YelpDocument *document,
const GError *error)
{
YelpDocumentPriv *priv = GET_PRIV (document);
YelpDocumentPrivate *priv = yelp_document_get_instance_private (document);
g_assert (document != NULL && YELP_IS_DOCUMENT (document));
......@@ -1433,7 +1429,7 @@ static gboolean
request_idle_contents (Request *request)
{
YelpDocument *document;
YelpDocumentPriv *priv;
YelpDocumentPrivate *priv;
YelpDocumentCallback callback = NULL;
gpointer user_data;
......@@ -1445,7 +1441,7 @@ request_idle_contents (Request *request)
}
document = g_object_ref (request->document);
priv = GET_PRIV (document);
priv = yelp_document_get_instance_private (document);
g_mutex_lock (&document->priv->mutex);
......@@ -1499,7 +1495,7 @@ static gboolean
request_idle_error (Request *request)
{
YelpDocument *document;
YelpDocumentPriv *priv;
YelpDocumentPrivate *priv;
YelpDocumentCallback callback = NULL;
GError *error = NULL;
gpointer user_data;
......@@ -1512,7 +1508,7 @@ request_idle_error (Request *request)
}
document = g_object_ref (request->document);
priv = GET_PRIV (document);
priv = yelp_document_get_instance_private (document);
g_mutex_lock (&priv->mutex);
......
......@@ -35,9 +35,9 @@ G_BEGIN_DECLS
#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))
typedef struct _YelpDocument YelpDocument;
typedef struct _YelpDocumentClass YelpDocumentClass;
typedef struct _YelpDocumentPriv YelpDocumentPriv;
typedef struct _YelpDocument YelpDocument;
typedef struct _YelpDocumentClass YelpDocumentClass;
typedef struct _YelpDocumentPrivate YelpDocumentPrivate;
typedef enum {
YELP_DOCUMENT_SIGNAL_CONTENTS,
......@@ -51,8 +51,8 @@ typedef void (*YelpDocumentCallback) (YelpDocument *document,
GError *error);
struct _YelpDocument {
GObject parent;
YelpDocumentPriv *priv;
GObject parent;
YelpDocumentPrivate *priv;
};
struct _YelpDocumentClass {
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2010 Shaun McCance <shaunm@gnome.org>
* Copyright (C) 2010-2020 Shaun McCance <shaunm@gnome.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -85,9 +85,6 @@ help_list_entry_cmp (HelpListEntry *a, HelpListEntry *b)
return g_utf8_collate (as, bs);
}
G_DEFINE_TYPE (YelpHelpList, yelp_help_list, YELP_TYPE_DOCUMENT)
#define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_HELP_LIST, YelpHelpListPrivate))
typedef struct _YelpHelpListPrivate YelpHelpListPrivate;
struct _YelpHelpListPrivate {
GMutex mutex;
......@@ -105,6 +102,8 @@ struct _YelpHelpListPrivate {
xmlXPathCompExprPtr get_mallard_desc;
};
G_DEFINE_TYPE_WITH_PRIVATE (YelpHelpList, yelp_help_list, YELP_TYPE_DOCUMENT)
static void
yelp_help_list_class_init (YelpHelpListClass *klass)
{
......@@ -115,14 +114,12 @@ yelp_help_list_class_init (YelpHelpListClass *klass)
object_class->finalize = yelp_help_list_finalize;
document_class->request_page = help_list_request_page;
g_type_class_add_private (klass, sizeof (YelpHelpListPrivate));
}
static void
yelp_help_list_init (YelpHelpList *list)
{
YelpHelpListPrivate *priv = GET_PRIV (list);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (list);
g_mutex_init (&priv->mutex);
priv->entries = g_hash_table_new_full (g_str_hash, g_str_equal,
......@@ -152,7 +149,7 @@ yelp_help_list_dispose (GObject *object)
static void
yelp_help_list_finalize (GObject *object)
{
YelpHelpListPrivate *priv = GET_PRIV (object);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (YELP_HELP_LIST (object));
g_hash_table_destroy (priv->entries);
g_mutex_clear (&priv->mutex);
......@@ -184,7 +181,7 @@ help_list_request_page (YelpDocument *document,
GDestroyNotify notify)
{
gboolean handled;
YelpHelpListPrivate *priv = GET_PRIV (document);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (YELP_HELP_LIST (document));
if (page_id == NULL)
page_id = "index";
......@@ -223,7 +220,7 @@ help_list_think (YelpHelpList *list)
{
const gchar * const *sdatadirs = g_get_system_data_dirs ();
const gchar * const *langs = g_get_language_names ();
YelpHelpListPrivate *priv = GET_PRIV (list);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (list);
/* The strings are still owned by GLib; we just own the array. */
gchar **datadirs;
gint datadir_i, lang_i;
......@@ -445,7 +442,7 @@ help_list_handle_page (YelpHelpList *list,
{
gchar **colors, *tmp;
GList *cur;
YelpHelpListPrivate *priv = GET_PRIV (list);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (list);
GtkTextDirection direction = gtk_widget_get_default_direction ();
GString *string = g_string_new
("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><style type='text/css'>\n"
......@@ -610,7 +607,7 @@ help_list_process_docbook (YelpHelpList *list,
xmlDocPtr xmldoc;
xmlXPathContextPtr xpath;
xmlXPathObjectPtr obj = NULL;
YelpHelpListPrivate *priv = GET_PRIV (list);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (list);
parserCtxt = xmlNewParserCtxt ();
xmldoc = xmlCtxtReadFile (parserCtxt,
......@@ -649,7 +646,7 @@ help_list_process_mallard (YelpHelpList *list,
xmlDocPtr xmldoc;
xmlXPathContextPtr xpath;
xmlXPathObjectPtr obj = NULL;
YelpHelpListPrivate *priv = GET_PRIV (list);
YelpHelpListPrivate *priv = yelp_help_list_get_instance_private (list);
parserCtxt = xmlNewParserCtxt ();
xmldoc = xmlCtxtReadFile (parserCtxt,
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2007 Don Scorgie <dscorgie@svn.gnome.org>
* Copyright (C) 2010 Shaun McCance <shaunm@gnome.org>
* Copyright (C) 2010-2020 Shaun McCance <shaunm@gnome.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -66,6 +66,7 @@ struct _YelpInfoDocumentPrivate {
gchar *visit_prev_id;
};
G_DEFINE_TYPE_WITH_PRIVATE (YelpInfoDocument, yelp_info_document, YELP_TYPE_DOCUMENT)
static void yelp_info_document_dispose (GObject *object);
static void yelp_info_document_finalize (GObject *object);
......@@ -97,9 +98,6 @@ static gboolean info_sections_visit (GtkTreeModel *model,
static void info_document_disconnect (YelpInfoDocument *info);
G_DEFINE_TYPE (YelpInfoDocument, yelp_info_document, YELP_TYPE_DOCUMENT)
#define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_INFO_DOCUMENT, YelpInfoDocumentPrivate))
static void
yelp_info_document_class_init (YelpInfoDocumentClass *klass)
{
......@@ -110,14 +108,12 @@ yelp_info_document_class_init (YelpInfoDocumentClass *klass)
object_class->finalize = yelp_info_document_finalize;
document_class->request_page = info_request_page;
g_type_class_add_private (klass, sizeof (YelpInfoDocumentPrivate));
}
static void
yelp_info_document_init (YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
priv->state = INFO_STATE_BLANK;
priv->xmldoc = NULL;
......@@ -127,7 +123,8 @@ yelp_info_document_init (YelpInfoDocument *info)
static void
yelp_info_document_dispose (GObject *object)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (object);
YelpInfoDocumentPrivate *priv =
yelp_info_document_get_instance_private (YELP_INFO_DOCUMENT (object));
if (priv->sections) {
g_object_unref (priv->sections);
......@@ -145,7 +142,8 @@ yelp_info_document_dispose (GObject *object)
static void
yelp_info_document_finalize (GObject *object)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (object);
YelpInfoDocumentPrivate *priv =
yelp_info_document_get_instance_private (YELP_INFO_DOCUMENT (object));
if (priv->xmldoc)
xmlFreeDoc (priv->xmldoc);
......@@ -182,7 +180,8 @@ info_request_page (YelpDocument *document,
gpointer user_data,
GDestroyNotify notify)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (document);
YelpInfoDocumentPrivate *priv =
yelp_info_document_get_instance_private (YELP_INFO_DOCUMENT (document));
gchar *docuri;
GError *error;
gboolean handled;
......@@ -244,7 +243,7 @@ transform_chunk_ready (YelpTransform *transform,
gchar *chunk_id,
YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
gchar *content;
g_assert (transform == priv->transform);
......@@ -274,7 +273,7 @@ static void
transform_finished (YelpTransform *transform,
YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
gchar *docuri;
GError *error;
......@@ -309,7 +308,7 @@ static void
transform_error (YelpTransform *transform,
YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
GError *error;
g_assert (transform == priv->transform);
......@@ -330,7 +329,7 @@ static void
transform_finalized (YelpInfoDocument *info,
gpointer transform)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
if (priv->xmldoc)
xmlFreeDoc (priv->xmldoc);
......@@ -345,7 +344,7 @@ transform_finalized (YelpInfoDocument *info,
static void
info_document_process (YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
GFile *file = NULL;
gchar *filepath = NULL;
GError *error;
......@@ -429,7 +428,7 @@ info_sections_visit (GtkTreeModel *model,
GtkTreeIter *iter,
YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
gchar *page_id, *title;
gtk_tree_model_get (model, iter,
......@@ -458,7 +457,7 @@ info_sections_visit (GtkTreeModel *model,
static void
info_document_disconnect (YelpInfoDocument *info)
{
YelpInfoDocumentPrivate *priv = GET_PRIV (info);
YelpInfoDocumentPrivate *priv = yelp_info_document_get_instance_private (info);
if (priv->chunk_ready) {
g_signal_handler_disconnect (priv->transform, priv->chunk_ready);
priv->chunk_ready = 0;
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2009 Shaun McCance <shaunm@gnome.org>
* Copyright (C) 2009-2020 Shaun McCance <shaunm@gnome.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -115,9 +115,6 @@ static gboolean xml_node_is_ns_name (xmlNodePtr node,
const xmlChar *name);
G_DEFINE_TYPE (YelpMallardDocument, yelp_mallard_document, YELP_TYPE_DOCUMENT)
#define GET_PRIV(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), YELP_TYPE_MALLARD_DOCUMENT, YelpMallardDocumentPrivate))
typedef struct _YelpMallardDocumentPrivate YelpMallardDocumentPrivate;
struct _YelpMallardDocumentPrivate {
MallardState state;
......@@ -139,6 +136,8 @@ struct _YelpMallardDocumentPrivate {
xmlXPathCompExprPtr normalize;
};
G_DEFINE_TYPE_WITH_PRIVATE (YelpMallardDocument, yelp_mallard_document, YELP_TYPE_DOCUMENT)
/******************************************************************************/
static void
......@@ -152,14 +151,12 @@ yelp_mallard_document_class_init (YelpMallardDocumentClass *klass)
document_class->request_page = mallard_request_page;
document_class->index = mallard_index;
g_type_class_add_private (klass, sizeof (YelpMallardDocumentPrivate));
}
static void
yelp_mallard_document_init (YelpMallardDocument *mallard)
{
YelpMallardDocumentPrivate *priv = GET_PRIV (mallard);
YelpMallardDocumentPrivate *priv = yelp_mallard_document_get_instance_private (mallard);
xmlNodePtr cur;
g_mutex_init (&priv->mutex);
......@@ -185,7 +182,8 @@ static void
yelp_mallard_document_dispose (GObject *object)
{
gint i;
YelpMallardDocumentPrivate *priv = GET_PRIV (object);
YelpMallardDocumentPrivate *priv =
yelp_mallard_document_get_instance_private (YELP_MALLARD_DOCUMENT (object));
if (priv->monitors != NULL) {
for (i = 0; priv->monitors[i]; i++) {
......@@ -201,7 +199,8 @@ yelp_mallard_document_dispose (GObject *object)
static void
yelp_mallard_document_finalize (GObject *object)
{
YelpMallardDocumentPrivate *priv = GET_PRIV (object);
YelpMallardDocumentPrivate *priv =
yelp_mallard_document_get_instance_private (YELP_MALLARD_DOCUMENT (object));
g_mutex_clear (&priv->mutex);
g_hash_table_destroy (priv->pages_hash);
......@@ -228,7 +227,7 @@ yelp_mallard_document_new (YelpUri *uri)
mallard = (YelpMallardDocument *) g_object_new (YELP_TYPE_MALLARD_DOCUMENT,
"document-uri", uri,
NULL);
priv = GET_PRIV (mallard);
priv = yelp_mallard_document_get_instance_private (mallard);
yelp_document_set_page_id ((YelpDocument *) mallard, NULL, "index");
yelp_document_set_page_id ((YelpDocument *) mallard, "index", "index");
......@@ -259,7 +258,8 @@ mallard_request_page (YelpDocument *document,
gpointer user_data,
GDestroyNotify notify)
{
YelpMallardDocumentPrivate *priv = GET_PRIV (document);
YelpMallardDocumentPrivate *priv =
yelp_mallard_document_get_instance_private (YELP_MALLARD_DOCUMENT (document));
gchar *docuri;
GError *error;
gboolean handled;
......@@ -326,7 +326,7 @@ mallard_request_page (YelpDocument *document,
static void
mallard_think (YelpMallardDocument *mallard)
{
YelpMallardDocumentPrivate *priv = GET_PRIV (mallard);
YelpMallardDocumentPrivate *priv = yelp_mallard_document_get_instance_private (mallard);
GError *error = NULL;
gboolean editor_mode;
......@@ -442,7 +442,7 @@ mallard_try_run (YelpMallardDocument *mallard,
const gchar *page_id)
{
/* We expect to be in a locked mutex when this function is called. */
YelpMallardDocumentPrivate *priv = GET_PRIV (mallard);
YelpMallardDocumentPrivate *priv = yelp_mallard_document_get_instance_private (mallard);
MallardPageData *page_data = NULL;
gchar *real_id = NULL;
GError *error;
......@@ -507,7 +507,7 @@ mallard_page_data_cancel (MallardPageData *page_data)
static void
mallard_page_data_walk (MallardPageData *page_data)
{
YelpMallardDocumentPrivate *priv = GET_PRIV (page_data->mallard);
YelpMallardDocumentPrivate *priv = yelp_mallard_document_get_instance_private (page_data->mallard);
xmlParserCtxtPtr parserCtxt = NULL;
xmlChar *id = NULL;
......@@ -649,7 +649,8 @@ mallard_page_data_info (MallardPageData *page_data,
if (xmlStrEqual (type, BAD_CAST "sort"))
page_data->sort_title = TRUE;
if (xmlStrEqual (type, BAD_CAST "text")) {
YelpMallardDocumentPrivate *priv = GET_PRIV (page_data->mallard);
YelpMallardDocumentPrivate *priv =
yelp_mallard_document_get_instance_private (page_data->mallard);
xmlXPathObjectPtr obj;
page_data->xpath->node = child;
obj = xmlXPathCompiledEval (priv->normalize, page_data->xpath);
......@@ -663,7 +664,7 @@ mallard_page_data_info (MallardPageData *page_data,
}
}
else if (xml_node_is_ns_name (child, MALLARD_NS, BAD_CAST "desc")) {
YelpMallardDocumentPrivate *priv = GET_PRIV (page_data->mallard);
YelpMallardDocumentPrivate *priv = yelp_mallard_document_get_instance_private (page_data->mallard);
xmlXPathObjectPtr obj;
page_data->xpath->node = child;
obj = xmlXPathCompiledEval (priv->normalize, page_data->xpath);
......@@ -676,7 +677,7 @@ mallard_page_data_info (MallardPageData *page_data,
else if (xml_node_is_ns_name (child, MALLARD_NS, BAD_CAST "keywords")) {
/* FIXME: multiple keywords? same for desc/title */
YelpMallardDocumentPrivate *priv = GET_PRIV (page_data->mallard);
YelpMallardDocumentPrivate *priv = yelp_mallard_document_get_instance_private (page_data->mallard);
xmlXPathObjectPtr obj;
page_data->xpath->node = child;