mirror of
https://github.com/brl/mutter.git
synced 2025-02-08 17:44:09 +00:00
Use "" as the default value for the :text property
This follows the convention of GtkLabel/GtkEntry in GTK+ and the old ClutterEntry. It makes it easier to use strlen/strcmp etc on the output, since we can assume that it is always a string. This commit also updates the test unit for ClutterText to verify that the clutter_text_get_text() function also returns an empty string when a ClutterText actor has been created.
This commit is contained in:
parent
4a934c363c
commit
b021f518c1
@ -1519,7 +1519,7 @@ clutter_text_class_init (ClutterTextClass *klass)
|
|||||||
pspec = g_param_spec_string ("text",
|
pspec = g_param_spec_string ("text",
|
||||||
"Text",
|
"Text",
|
||||||
"The text to render",
|
"The text to render",
|
||||||
NULL,
|
"",
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_class_install_property (gobject_class, PROP_TEXT, pspec);
|
g_object_class_install_property (gobject_class, PROP_TEXT, pspec);
|
||||||
|
|
||||||
@ -1981,7 +1981,11 @@ clutter_text_init (ClutterText *self)
|
|||||||
for (i = 0; i < N_CACHED_LAYOUTS; i++)
|
for (i = 0; i < N_CACHED_LAYOUTS; i++)
|
||||||
priv->cached_layouts[i].layout = NULL;
|
priv->cached_layouts[i].layout = NULL;
|
||||||
|
|
||||||
priv->text = NULL;
|
/* default to "" so that clutter_text_get_text() will
|
||||||
|
* return a valid string and we can safely call strlen()
|
||||||
|
* or strcmp() on it
|
||||||
|
*/
|
||||||
|
priv->text = g_strdup ("");
|
||||||
|
|
||||||
priv->text_color = default_text_color;
|
priv->text_color = default_text_color;
|
||||||
priv->cursor_color = default_cursor_color;
|
priv->cursor_color = default_cursor_color;
|
||||||
@ -2640,7 +2644,9 @@ clutter_text_get_text (ClutterText *self)
|
|||||||
* @self: a #ClutterText
|
* @self: a #ClutterText
|
||||||
* @text: the text to set
|
* @text: the text to set
|
||||||
*
|
*
|
||||||
* Sets the contents of a #ClutterText actor.
|
* Sets the contents of a #ClutterText actor. The @text string
|
||||||
|
* must not be %NULL; to unset the current contents of the
|
||||||
|
* #ClutterText actor simply pass "" (an empty string).
|
||||||
*
|
*
|
||||||
* Since: 1.0
|
* Since: 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -76,7 +76,8 @@ test_text_empty (TestConformSimpleFixture *fixture,
|
|||||||
{
|
{
|
||||||
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
|
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
|
||||||
|
|
||||||
g_assert (clutter_text_get_text (text) == NULL);
|
g_assert_cmpstr (clutter_text_get_text (text), ==, "");
|
||||||
|
g_assert_cmpint (*clutter_text_get_text (text), ==, '\0');
|
||||||
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
|
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
|
||||||
|
|
||||||
clutter_actor_destroy (CLUTTER_ACTOR (text));
|
clutter_actor_destroy (CLUTTER_ACTOR (text));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user