Correctly initialize the initial state of ClutterText

Some of the values in ClutterText have an initial state that
does not match a zero-ed out ClutterTextPrivate structure.
This commit is contained in:
Emmanuele Bassi 2008-12-11 11:35:52 +00:00 committed by Emmanuele Bassi
parent fc168a3482
commit 97cf7e6819

View File

@ -244,9 +244,6 @@ clutter_text_create_layout_no_cache (ClutterText *text,
ClutterTextPrivate *priv = text->priv; ClutterTextPrivate *priv = text->priv;
PangoLayout *layout; PangoLayout *layout;
if (G_UNLIKELY (_context == NULL))
_context = _clutter_context_create_pango_context (CLUTTER_CONTEXT ());
layout = pango_layout_new (_context); layout = pango_layout_new (_context);
pango_layout_set_font_description (layout, priv->font_desc); pango_layout_set_font_description (layout, priv->font_desc);
@ -1024,6 +1021,8 @@ clutter_text_class_init (ClutterTextClass *klass)
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GParamSpec *pspec; GParamSpec *pspec;
_context = _clutter_context_create_pango_context (CLUTTER_CONTEXT ());
gobject_class->set_property = clutter_text_set_property; gobject_class->set_property = clutter_text_set_property;
gobject_class->get_property = clutter_text_get_property; gobject_class->get_property = clutter_text_get_property;
gobject_class->dispose = clutter_text_dispose; gobject_class->dispose = clutter_text_dispose;
@ -1301,9 +1300,29 @@ static void
clutter_text_init (ClutterText *self) clutter_text_init (ClutterText *self)
{ {
ClutterTextPrivate *priv; ClutterTextPrivate *priv;
int i;
self->priv = priv = CLUTTER_TEXT_GET_PRIVATE (self); self->priv = priv = CLUTTER_TEXT_GET_PRIVATE (self);
priv->alignment = PANGO_ALIGN_LEFT;
priv->wrap = FALSE;
priv->wrap_mode = PANGO_WRAP_WORD;
priv->ellipsize = PANGO_ELLIPSIZE_NONE;
priv->use_underline = FALSE;
priv->use_markup = FALSE;
priv->justify = FALSE;
for (i = 0; i < N_CACHED_LAYOUTS; i++)
priv->cached_layouts[i].layout = NULL;
priv->text = NULL;
priv->text_color = default_text_color;
priv->cursor_color = default_cursor_color;
priv->font_name = g_strdup (DEFAULT_FONT_NAME);
priv->font_desc = pango_font_description_from_string (priv->font_name);
priv->x_pos = -1; priv->x_pos = -1;
priv->cursor_visible = TRUE; priv->cursor_visible = TRUE;
priv->editable = FALSE; priv->editable = FALSE;