mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Merge branch 'static-param-strings-docs' into 'main'
docs: Use G_PARAM_STATIC_STRINGS in examples and explain it more See merge request GNOME/glib!2675
This commit is contained in:
commit
4173d44abe
@ -555,7 +555,7 @@ viewer_file_class_init (ViewerFileClass *klass)
|
||||
"Filename",
|
||||
"Name of the file to load and display from.",
|
||||
NULL /* default value */,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_ZOOM_LEVEL] =
|
||||
g_param_spec_uint ("zoom-level",
|
||||
@ -564,7 +564,7 @@ viewer_file_class_init (ViewerFileClass *klass)
|
||||
0 /* minimum value */,
|
||||
10 /* maximum value */,
|
||||
2 /* default value */,
|
||||
G_PARAM_READWRITE);
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class,
|
||||
N_PROPERTIES,
|
||||
|
@ -1226,7 +1226,7 @@ viewer_editable_default_init (ViewerEditableInterface *iface)
|
||||
0.0, /* minimum */
|
||||
G_MAXDOUBLE, /* maximum */
|
||||
0.0, /* default */
|
||||
G_PARAM_READWRITE));
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
</programlisting></informalexample>
|
||||
</para>
|
||||
|
@ -54,7 +54,7 @@ typedef gsize GType;
|
||||
* _("Authors"),
|
||||
* _("List of authors"),
|
||||
* G_TYPE_STRV,
|
||||
* G_PARAM_READWRITE));
|
||||
* G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
*
|
||||
* gchar *authors[] = { "Owen", "Tim", NULL };
|
||||
* g_object_set (obj, "authors", authors, NULL);
|
||||
|
@ -707,9 +707,11 @@ g_object_class_install_property (GObjectClass *class,
|
||||
* class initialization:
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
* enum {
|
||||
* PROP_0, PROP_FOO, PROP_BAR, N_PROPERTIES
|
||||
* };
|
||||
* typedef enum {
|
||||
* PROP_FOO = 1,
|
||||
* PROP_BAR,
|
||||
* N_PROPERTIES
|
||||
* } MyObjectProperty;
|
||||
*
|
||||
* static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
|
||||
*
|
||||
@ -722,17 +724,17 @@ g_object_class_install_property (GObjectClass *class,
|
||||
* g_param_spec_int ("foo", "Foo", "Foo",
|
||||
* -1, G_MAXINT,
|
||||
* 0,
|
||||
* G_PARAM_READWRITE);
|
||||
* G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
*
|
||||
* obj_properties[PROP_BAR] =
|
||||
* g_param_spec_string ("bar", "Bar", "Bar",
|
||||
* NULL,
|
||||
* G_PARAM_READWRITE);
|
||||
* G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
*
|
||||
* gobject_class->set_property = my_object_set_property;
|
||||
* gobject_class->get_property = my_object_get_property;
|
||||
* g_object_class_install_properties (gobject_class,
|
||||
* N_PROPERTIES,
|
||||
* G_N_ELEMENTS (obj_properties),
|
||||
* obj_properties);
|
||||
* }
|
||||
* ]|
|
||||
@ -1406,12 +1408,11 @@ g_object_notify (GObject *object,
|
||||
* g_object_class_install_property() inside a static array, e.g.:
|
||||
*
|
||||
*|[<!-- language="C" -->
|
||||
* enum
|
||||
* typedef enum
|
||||
* {
|
||||
* PROP_0,
|
||||
* PROP_FOO,
|
||||
* PROP_FOO = 1,
|
||||
* PROP_LAST
|
||||
* };
|
||||
* } MyObjectProperty;
|
||||
*
|
||||
* static GParamSpec *properties[PROP_LAST];
|
||||
*
|
||||
@ -1421,7 +1422,7 @@ g_object_notify (GObject *object,
|
||||
* properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
|
||||
* 0, 100,
|
||||
* 50,
|
||||
* G_PARAM_READWRITE);
|
||||
* G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
* g_object_class_install_property (gobject_class,
|
||||
* PROP_FOO,
|
||||
* properties[PROP_FOO]);
|
||||
|
@ -172,6 +172,12 @@ typedef enum
|
||||
*
|
||||
* #GParamFlags value alias for %G_PARAM_STATIC_NAME | %G_PARAM_STATIC_NICK | %G_PARAM_STATIC_BLURB.
|
||||
*
|
||||
* It is recommended to use this for all properties by default, as it allows for
|
||||
* internal performance improvements in GObject.
|
||||
*
|
||||
* It is very rare that a property would have a dynamically constructed name,
|
||||
* nickname or blurb.
|
||||
*
|
||||
* Since 2.13.0
|
||||
*/
|
||||
#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
|
||||
|
Loading…
Reference in New Issue
Block a user