From 32956587f35a8c4f1048549f9fce521c1e21de15 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 18 Feb 2015 17:58:32 +0000 Subject: [PATCH] docs: Remove redundant header examples from GObject tutorial These are in the header boilerplate section, but are actually source boilerplate which is covered in later sections. https://bugzilla.gnome.org/show_bug.cgi?id=744060 --- docs/reference/gobject/tut_howto.xml | 73 ++-------------------------- 1 file changed, 4 insertions(+), 69 deletions(-) diff --git a/docs/reference/gobject/tut_howto.xml b/docs/reference/gobject/tut_howto.xml index d834db01d..97987fc51 100644 --- a/docs/reference/gobject/tut_howto.xml +++ b/docs/reference/gobject/tut_howto.xml @@ -80,10 +80,10 @@ The basic conventions for any header which exposes a GType are described - in . Most GObject-based code also - obeys one of of the following conventions: pick one and stick to it. - - + in . + + + If you want to declare a type named bar with prefix maman, name the type instance MamanBar and its class MamanBarClass (name is case-sensitive). It is customary to declare them with code similar to the @@ -140,71 +140,6 @@ GType maman_bar_get_type (void); #endif /* __MAMAN_BAR_H__ */ - - - Types that require per-instance private data should use the - G_DEFINE_TYPE_WITH_PRIVATE() macro, or use the G_ADD_PRIVATE() - macro with the G_DEFINE_TYPE_WITH_CODE() or the G_DEFINE_TYPE_EXTENDED() - macros. The private structure is then defined in the .c file, - and can be accessed using the get_instance_private() - function generated by the G_DEFINE_TYPE_* macros. It is automatically - zero-filled on creation, so it is unnecessary to explicitly - initialize pointer members to NULL. - -struct _MamanBarPrivate -{ - int hsize; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (MamanBar, maman_bar, G_TYPE_OBJECT) - -static void -maman_bar_class_init (MamanBarClass *klass) -{ -} - -static void -maman_bar_init (MamanBar *self) -{ - /* maman_bar_get_instance_private() is generated by G_DEFINE_TYPE_WITH_PRIVATE() - * above, and it's local to the current compilation unit. - */ - MamanBarPrivate *priv = maman_bar_get_instance_private (self); - - priv->hsize = 42; -} - - - - - Most GNOME libraries use a pointer inside the instance structure - for simpler access to the private data structure, as described by - Herb Sutter in his Pimpl article (see Compilation Firewalls - and The Fast Pimpl Idiom - for reference). If you opt to use this idiom, you can assign the - pointer inside the instance initialization function, e.g.: - -G_DEFINE_TYPE_WITH_PRIVATE (MamanBar, maman_bar, G_TYPE_OBJECT) - -struct _MamanBarPrivate -{ - int hsize; -}; - -static void -maman_bar_class_init (MamanBarClass *klass) -{ -} - -static void -maman_bar_init (MamanBar *self) -{ - self->priv = maman_bar_get_instance_private (self); - self->priv->hsize = 42; -} - - -