diff --git a/ChangeLog b/ChangeLog index 0a0095b66..0f264bea2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-06-13 Emmanuele Bassi + + Bug #960 - PangoContext creation code should not be duplicated + + * clutter/clutter-private.h: + * clutter/clutter-main.c: + (_clutter_context_create_pango_context): Abstract the creation + of the PangoContext inside its own function, to avoid code and + bugs duplication. (Tommi Komulainen) + + * clutter/clutter-entry.c (clutter_entry_init): Use the newly + added PangoContext creation function. + + * clutter/clutter-label.c (clutter_label_init): Ditto as above. + 2008-06-12 Emmanuele Bassi Bug #964 - "unrealized" signal of ClutterActor wrongly named diff --git a/clutter/clutter-entry.c b/clutter/clutter-entry.c index bb10b7f59..8489adcb4 100644 --- a/clutter/clutter-entry.c +++ b/clutter/clutter-entry.c @@ -866,23 +866,10 @@ clutter_entry_init (ClutterEntry *self) self->priv = priv = CLUTTER_ENTRY_GET_PRIVATE (self); - resolution = clutter_backend_get_resolution (clutter_get_default_backend ()); - if (resolution < 0) - resolution = 96.0; /* fall back */ - if (G_UNLIKELY (_context == NULL)) - { - ClutterBackend *backend = clutter_get_default_backend (); - PangoClutterFontMap *font_map = CLUTTER_CONTEXT ()->font_map; - cairo_font_options_t *font_options; + _context = _clutter_context_create_pango_context (CLUTTER_CONTEXT ()); - _context = pango_clutter_font_map_create_context (font_map); - - pango_cairo_context_set_resolution (_context, resolution); - - font_options = clutter_backend_get_font_options (backend); - pango_cairo_context_set_font_options (_context, font_options); - } + resolution = pango_cairo_context_get_resolution (_context); priv->alignment = PANGO_ALIGN_LEFT; priv->wrap = FALSE; diff --git a/clutter/clutter-label.c b/clutter/clutter-label.c index 9458a6245..26f741007 100644 --- a/clutter/clutter-label.c +++ b/clutter/clutter-label.c @@ -561,22 +561,7 @@ clutter_label_init (ClutterLabel *self) self->priv = priv = CLUTTER_LABEL_GET_PRIVATE (self); if (G_UNLIKELY (_context == NULL)) - { - ClutterBackend *backend = clutter_get_default_backend (); - PangoClutterFontMap *font_map = CLUTTER_CONTEXT ()->font_map; - gdouble resolution; - cairo_font_options_t *font_options; - - _context = pango_clutter_font_map_create_context (font_map); - - resolution = clutter_backend_get_resolution (backend); - if (resolution < 0) - resolution = 96.0; - pango_cairo_context_set_resolution (_context, resolution); - - font_options = clutter_backend_get_font_options (backend); - pango_cairo_context_set_font_options (_context, font_options); - } + _context = _clutter_context_create_pango_context (CLUTTER_CONTEXT ()); priv->alignment = PANGO_ALIGN_LEFT; priv->wrap = FALSE; diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index a53388467..6d668ba5c 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -414,6 +414,27 @@ clutter_context_free (ClutterMainContext *context) g_free (context); } +PangoContext * +_clutter_context_create_pango_context (ClutterMainContext *self) +{ + PangoContext *context; + gdouble resolution; + cairo_font_options_t *font_options; + + resolution = clutter_backend_get_resolution (self->backend); + if (resolution < 0) + resolution = 96.0; /* fall back */ + + context = pango_clutter_font_map_create_context (self->font_map); + + pango_cairo_context_set_resolution (context, resolution); + + font_options = clutter_backend_get_font_options (self->backend); + pango_cairo_context_set_font_options (context, font_options); + + return context; +} + /** * clutter_main_quit: * diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 113bc8654..03f50a363 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -114,6 +114,7 @@ or enter/leave events */ #define CLUTTER_CONTEXT() (clutter_context_get_default ()) ClutterMainContext *clutter_context_get_default (void); +PangoContext *_clutter_context_create_pango_context (ClutterMainContext *self); #define CLUTTER_PRIVATE_FLAGS(a) (((ClutterActor *) (a))->private_flags) #define CLUTTER_SET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) |= (f))