From 4c1231c7fe545a7764d06754d7d6be0906686e0a Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Wed, 6 Jan 2010 11:48:46 +0000 Subject: [PATCH] media: Add an API to specify which font should be used for subtitles Allow the user of the ClutterMedia interface to specify a Pango font description to display subtitles. Even if the underlying implementation of the interface does not natively use Pange, it must be capable of parsing the grammar that pango_font_description_from_string() accepts. --- clutter/clutter-media.c | 64 ++++++++++++++++++++++ clutter/clutter-media.h | 45 ++++++++------- doc/reference/clutter/clutter-sections.txt | 2 + 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/clutter/clutter-media.c b/clutter/clutter-media.c index 30e51bec6..ce50cf27a 100644 --- a/clutter/clutter-media.c +++ b/clutter/clutter-media.c @@ -123,6 +123,22 @@ clutter_media_base_init (gpointer g_iface) CLUTTER_PARAM_READWRITE); g_object_interface_install_property (g_iface, pspec); + /** + * ClutterMedia:subtitle-font-name: + * + * The font used to display subtitles. The font description has to + * follow the same grammar as the one recognized by + * pango_font_description_from_string(). + * + * Since: 1.2 + */ + pspec = g_param_spec_string ("subtitle-font-name", + "Subtitle Font Name", + "The font used to display subtitles", + NULL, + CLUTTER_PARAM_READWRITE); + g_object_interface_install_property (g_iface, pspec); + /** * ClutterMedia:audio-volume: * @@ -403,6 +419,54 @@ clutter_media_get_subtitle_uri (ClutterMedia *media) return retval; } +/** + * clutter_media_set_subtitle_font_name: + * @media: a #ClutterMedia + * @font_name: a font name, or %NULL to set the default font name + * + * Sets the font used by the subtitle renderer. The @font_name string must be + * either %NULL, which means that the default font name of the underlying + * implementation will be used; or must follow the grammar recognized by + * pango_font_description_from_string() like: + * + * |[ + * clutter_media_set_subtitle_font_name (media, "Sans 24pt"); + * ]| + * + * Since: 1.2 + */ +void +clutter_media_set_subtitle_font_name (ClutterMedia *media, + const char *font_name) +{ + g_return_if_fail (CLUTTER_IS_MEDIA (media)); + + g_object_set (G_OBJECT (media), "subtitle-font-name", font_name, NULL); +} + +/** + * clutter_media_get_subtitle_font_name: + * @media: a #ClutterMedia + * + * Retrieves the font name currently used. + * + * Return value: a string containing the font name. Use g_free() + * to free the returned string + * + * Since: 1.2 + */ +gchar * +clutter_media_get_subtitle_font_name (ClutterMedia *media) +{ + gchar *retval = NULL; + + g_return_val_if_fail (CLUTTER_IS_MEDIA(media), NULL); + + g_object_get (G_OBJECT (media), "subtitle-font-name", &retval, NULL); + + return retval; +} + /** * clutter_media_set_audio_volume: * @media: a #ClutterMedia diff --git a/clutter/clutter-media.h b/clutter/clutter-media.h index c776c647c..95fe42713 100644 --- a/clutter/clutter-media.h +++ b/clutter/clutter-media.h @@ -62,29 +62,32 @@ struct _ClutterMediaIface const GError *error); }; -GType clutter_media_get_type (void) G_GNUC_CONST; +GType clutter_media_get_type (void) G_GNUC_CONST; -void clutter_media_set_uri (ClutterMedia *media, - const gchar *uri); -gchar * clutter_media_get_uri (ClutterMedia *media); -void clutter_media_set_filename (ClutterMedia *media, - const gchar *filename); +void clutter_media_set_uri (ClutterMedia *media, + const gchar *uri); +gchar * clutter_media_get_uri (ClutterMedia *media); +void clutter_media_set_filename (ClutterMedia *media, + const gchar *filename); -void clutter_media_set_playing (ClutterMedia *media, - gboolean playing); -gboolean clutter_media_get_playing (ClutterMedia *media); -void clutter_media_set_progress (ClutterMedia *media, - gdouble progress); -gdouble clutter_media_get_progress (ClutterMedia *media); -void clutter_media_set_subtitle_uri (ClutterMedia *media, - const gchar *uri); -gchar * clutter_media_get_subtitle_uri (ClutterMedia *media); -void clutter_media_set_audio_volume (ClutterMedia *media, - gdouble volume); -gdouble clutter_media_get_audio_volume (ClutterMedia *media); -gboolean clutter_media_get_can_seek (ClutterMedia *media); -gdouble clutter_media_get_buffer_fill (ClutterMedia *media); -gdouble clutter_media_get_duration (ClutterMedia *media); +void clutter_media_set_playing (ClutterMedia *media, + gboolean playing); +gboolean clutter_media_get_playing (ClutterMedia *media); +void clutter_media_set_progress (ClutterMedia *media, + gdouble progress); +gdouble clutter_media_get_progress (ClutterMedia *media); +void clutter_media_set_subtitle_uri (ClutterMedia *media, + const gchar *uri); +gchar * clutter_media_get_subtitle_uri (ClutterMedia *media); +void clutter_media_set_subtitle_font_name (ClutterMedia *media, + const char *font_name); +gchar * clutter_media_get_subtitle_font_name (ClutterMedia *media); +void clutter_media_set_audio_volume (ClutterMedia *media, + gdouble volume); +gdouble clutter_media_get_audio_volume (ClutterMedia *media); +gboolean clutter_media_get_can_seek (ClutterMedia *media); +gdouble clutter_media_get_buffer_fill (ClutterMedia *media); +gdouble clutter_media_get_duration (ClutterMedia *media); G_END_DECLS diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 0da1f24bb..a1a7b7581 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -11,6 +11,8 @@ clutter_media_set_progress clutter_media_get_progress clutter_media_set_subtitle_uri clutter_media_get_subtitle_uri +clutter_media_set_subtitle_font_name +clutter_media_get_subtitle_font_name clutter_media_set_audio_volume clutter_media_get_audio_volume clutter_media_get_can_seek