From d76f64a10cdfbfe44f5cf3f35351ae8f3307d7df Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 10 Sep 2010 14:27:37 +0100 Subject: [PATCH] Do not use deprecated API internally --- clutter/clutter-backend.c | 8 +++++++- clutter/clutter-main.c | 18 ++++++++++++++---- clutter/clutter-text.c | 32 ++++++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index 3974bc7f9..8f54fb0bb 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -121,12 +121,18 @@ get_units_per_em (ClutterBackend *backend, if (font_desc == NULL) { - const gchar *font_name = clutter_backend_get_font_name (backend); + ClutterSettings *settings; + gchar *font_name = NULL; + + settings = clutter_settings_get_default (); + g_object_get (settings, "font-name", &font_name, NULL); if (G_LIKELY (font_name != NULL && *font_name != '\0')) { font_desc = pango_font_description_from_string (font_name); free_font_desc = TRUE; + + g_free (font_name); } } diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index a7f1dfca9..67cc85084 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -821,12 +821,15 @@ static void update_pango_context (ClutterBackend *backend, PangoContext *context) { + ClutterSettings *settings; PangoFontDescription *font_desc; const cairo_font_options_t *font_options; - const gchar *font_name; + gchar *font_name; PangoDirection pango_dir; gdouble resolution; + settings = clutter_settings_get_default (); + /* update the text direction */ if (clutter_text_direction == CLUTTER_TEXT_DIRECTION_RTL) pango_dir = PANGO_DIRECTION_RTL; @@ -835,8 +838,9 @@ update_pango_context (ClutterBackend *backend, pango_context_set_base_dir (context, pango_dir); + g_object_get (settings, "font-name", &font_name, NULL); + /* get the configuration for the PangoContext from the backend */ - font_name = clutter_backend_get_font_name (backend); font_options = clutter_backend_get_font_options (backend); resolution = clutter_backend_get_resolution (backend); @@ -850,6 +854,7 @@ update_pango_context (ClutterBackend *backend, pango_cairo_context_set_resolution (context, resolution); pango_font_description_free (font_desc); + g_free (font_name); } PangoContext * @@ -2160,13 +2165,18 @@ event_click_count_generate (ClutterEvent *event) static gint previous_button_number = -1; ClutterInputDevice *device = NULL; + ClutterSettings *settings; ClutterBackend *backend; guint double_click_time; guint double_click_distance; + settings = clutter_settings_get_default (); backend = clutter_get_default_backend (); - double_click_distance = clutter_backend_get_double_click_distance (backend); - double_click_time = clutter_backend_get_double_click_time (backend); + + g_object_get (settings, + "double-click-distance", &double_click_distance, + "double-click-time", &double_click_time, + NULL); device = clutter_event_get_device (event); if (device != NULL) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index e89fb5209..b87f6c1a7 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -495,16 +495,21 @@ clutter_text_font_changed_cb (ClutterText *text) { if (text->priv->is_default_font) { - const gchar *font_name; PangoFontDescription *font_desc; + ClutterSettings *settings; + gchar *font_name = NULL; + + settings = clutter_settings_get_default (); + g_object_get (settings, "font-name", &font_name, NULL); - font_name = clutter_backend_get_font_name (clutter_get_default_backend ()); CLUTTER_NOTE (ACTOR, "Text[%p]: default font changed to '%s'", text, font_name); font_desc = pango_font_description_from_string (font_name); clutter_text_set_font_description_internal (text, font_desc); + + g_free (font_name); } clutter_text_dirty_cache (text); @@ -3109,8 +3114,9 @@ clutter_text_class_init (ClutterTextClass *klass) static void clutter_text_init (ClutterText *self) { + ClutterSettings *settings; ClutterTextPrivate *priv; - const gchar *font_name; + gchar *font_name; int i; self->priv = priv = CLUTTER_TEXT_GET_PRIVATE (self); @@ -3140,8 +3146,10 @@ clutter_text_init (ClutterText *self) * set_font_description() here because we are initializing * the Text and we don't need notifications and sanity checks */ - font_name = clutter_backend_get_font_name (clutter_get_default_backend ()); - priv->font_name = g_strdup (font_name); + settings = clutter_settings_get_default (); + g_object_get (settings, "font-name", &font_name, NULL); + + priv->font_name = font_name; /* font_name is allocated */ priv->font_desc = pango_font_description_from_string (font_name); priv->is_default_font = TRUE; @@ -3846,7 +3854,11 @@ clutter_text_set_font_name (ClutterText *self, /* get the default font name from the backend */ if (!font_name || font_name[0] == '\0') { - font_name = clutter_backend_get_font_name (clutter_get_default_backend ()); + ClutterSettings *settings = clutter_settings_get_default (); + gchar *default_font_name = NULL; + + g_object_get (settings, "font-name", default_font_name, NULL); + font_name = default_font_name; is_default_font = TRUE; } else @@ -3855,7 +3867,7 @@ clutter_text_set_font_name (ClutterText *self, priv = self->priv; if (priv->font_name && strcmp (priv->font_name, font_name) == 0) - return; + goto out; desc = pango_font_description_from_string (font_name); if (!desc) @@ -3863,7 +3875,7 @@ clutter_text_set_font_name (ClutterText *self, g_warning ("Attempting to create a PangoFontDescription for " "font name '%s', but failed.", font_name); - return; + goto out; } /* this will set the font_name field as well */ @@ -3871,6 +3883,10 @@ clutter_text_set_font_name (ClutterText *self, priv->is_default_font = is_default_font; _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_FONT_NAME]); + +out: + if (is_default_font) + g_free ((gchar *) font_name); } /**