[glib: 1/2] doc: Extend a bit G_DECLARE_* documentation example




commit 893ff61176e37f36496f6797c42be6433c5fcd18
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Sat Feb 19 12:41:42 2022 -0500

    doc: Extend a bit G_DECLARE_* documentation example

 gobject/gtype.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 5c9077745..eaebee42f 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1401,6 +1401,17 @@ guint     g_type_get_type_registration_serial (void);
  * #endif
  * ]|
  *
+ * And use it as follow in your C file:
+ *
+ * |[<!-- language="C" -->
+ * struct _MyAppWindow
+ * {
+ *  GtkWindow parent;
+ *  ...
+ * };
+ * G_DEFINE_TYPE (MyAppWindow, my_app_window, GTK_TYPE_WINDOW)
+ * ]|
+ *
  * This results in the following things happening:
  *
  * - the usual `my_app_window_get_type()` function is declared with a return type of #GType
@@ -1491,6 +1502,18 @@ guint     g_type_get_type_registration_serial (void);
  * #endif
  * ]|
  *
+ * Since the instance structure is public it is often needed to declare a
+ * private struct as follow in your C file:
+ *
+ * |[<!-- language="C" -->
+ * typedef struct _GtkFrobberPrivate GtkFrobberPrivate;
+ * struct _GtkFrobberPrivate
+ * {
+ *   ...
+ * };
+ * G_DEFINE_TYPE_WITH_PRIVATE (GtkFrobber, gtk_frobber, GTK_TYPE_WIDGET)
+ * ]|
+ *
  * This results in the following things happening:
  *
  * - the usual `gtk_frobber_get_type()` function is declared with a return type of #GType
@@ -1585,6 +1608,18 @@ guint     g_type_get_type_registration_serial (void);
  * #endif
  * ]|
  *
+ * And use it as follow in your C file:
+ *
+ * |[<!-- language="C" -->
+ * G_DEFINE_INTERFACE (MyModel, my_model, G_TYPE_OBJECT);
+ *
+ * static void
+ * my_model_default_init (MyModelInterface *iface)
+ * {
+ *   ...
+ * }
+ * ]|
+ *
  * This results in the following things happening:
  *
  * - the usual `my_model_get_type()` function is declared with a return type of #GType


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]