diff --git a/docs/reference/gobject/tut_gobject.xml b/docs/reference/gobject/tut_gobject.xml index 0423a38a3..7a2ecc77e 100644 --- a/docs/reference/gobject/tut_gobject.xml +++ b/docs/reference/gobject/tut_gobject.xml @@ -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, diff --git a/docs/reference/gobject/tut_howto.xml b/docs/reference/gobject/tut_howto.xml index b61a328b6..4ed178cec 100644 --- a/docs/reference/gobject/tut_howto.xml +++ b/docs/reference/gobject/tut_howto.xml @@ -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)); } diff --git a/gobject/glib-types.h b/gobject/glib-types.h index f0d33234a..c54eda99c 100644 --- a/gobject/glib-types.h +++ b/gobject/glib-types.h @@ -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); diff --git a/gobject/gobject.c b/gobject/gobject.c index d33d8e5b0..a7a1d3032 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -707,9 +707,11 @@ g_object_class_install_property (GObjectClass *class, * class initialization: * * |[ - * 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.: * *|[ - * 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]); diff --git a/gobject/gparam.h b/gobject/gparam.h index e0f316682..4dff763e5 100644 --- a/gobject/gparam.h +++ b/gobject/gparam.h @@ -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)