Merge branch 'doc-declare' into 'main'

doc: Extend a bit G_DECLARE_* documentation example

See merge request GNOME/glib!2512
This commit is contained in:
Emmanuele Bassi 2022-02-19 20:52:21 +00:00
commit 056d0dc7f3

View File

@ -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