docs: Use G_PARAM_STATIC_STRINGS in examples and explain it more

Make it a bit clearer in the documentation that using
`G_PARAM_STATIC_STRINGS` everywhere is a good thing.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall
2022-05-20 12:55:18 +01:00
parent 6b5b1cd314
commit 8f9c5090db
5 changed files with 13 additions and 7 deletions

View File

@@ -555,7 +555,7 @@ viewer_file_class_init (ViewerFileClass *klass)
"Filename", "Filename",
"Name of the file to load and display from.", "Name of the file to load and display from.",
NULL /* default value */, 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] = obj_properties[PROP_ZOOM_LEVEL] =
g_param_spec_uint ("zoom-level", g_param_spec_uint ("zoom-level",
@@ -564,7 +564,7 @@ viewer_file_class_init (ViewerFileClass *klass)
0 /* minimum value */, 0 /* minimum value */,
10 /* maximum value */, 10 /* maximum value */,
2 /* default value */, 2 /* default value */,
G_PARAM_READWRITE); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, g_object_class_install_properties (object_class,
N_PROPERTIES, N_PROPERTIES,

View File

@@ -1226,7 +1226,7 @@ viewer_editable_default_init (ViewerEditableInterface *iface)
0.0, /* minimum */ 0.0, /* minimum */
G_MAXDOUBLE, /* maximum */ G_MAXDOUBLE, /* maximum */
0.0, /* default */ 0.0, /* default */
G_PARAM_READWRITE)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
} }
</programlisting></informalexample> </programlisting></informalexample>
</para> </para>

View File

@@ -54,7 +54,7 @@ typedef gsize GType;
* _("Authors"), * _("Authors"),
* _("List of authors"), * _("List of authors"),
* G_TYPE_STRV, * G_TYPE_STRV,
* G_PARAM_READWRITE)); * G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
* *
* gchar *authors[] = { "Owen", "Tim", NULL }; * gchar *authors[] = { "Owen", "Tim", NULL };
* g_object_set (obj, "authors", authors, NULL); * g_object_set (obj, "authors", authors, NULL);

View File

@@ -722,12 +722,12 @@ g_object_class_install_property (GObjectClass *class,
* g_param_spec_int ("foo", "Foo", "Foo", * g_param_spec_int ("foo", "Foo", "Foo",
* -1, G_MAXINT, * -1, G_MAXINT,
* 0, * 0,
* G_PARAM_READWRITE); * G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
* *
* obj_properties[PROP_BAR] = * obj_properties[PROP_BAR] =
* g_param_spec_string ("bar", "Bar", "Bar", * g_param_spec_string ("bar", "Bar", "Bar",
* NULL, * NULL,
* G_PARAM_READWRITE); * G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
* *
* gobject_class->set_property = my_object_set_property; * gobject_class->set_property = my_object_set_property;
* gobject_class->get_property = my_object_get_property; * gobject_class->get_property = my_object_get_property;
@@ -1421,7 +1421,7 @@ g_object_notify (GObject *object,
* properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo", * properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
* 0, 100, * 0, 100,
* 50, * 50,
* G_PARAM_READWRITE); * G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
* g_object_class_install_property (gobject_class, * g_object_class_install_property (gobject_class,
* PROP_FOO, * PROP_FOO,
* properties[PROP_FOO]); * properties[PROP_FOO]);

View File

@@ -172,6 +172,12 @@ typedef enum
* *
* #GParamFlags value alias for %G_PARAM_STATIC_NAME | %G_PARAM_STATIC_NICK | %G_PARAM_STATIC_BLURB. * #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 * Since 2.13.0
*/ */
#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) #define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)