Store the default font name inside ClutterBackend
The default backend stores some of the global defaults, like the font options, text resolution, double click settings. It should also store the default font name, to allow various text-based actors to share the same settings. When the font name changes, the ::font-changed signal is emitted, to allow actors to pick up the change.
This commit is contained in:
parent
977bdcf89b
commit
7262542155
@ -49,6 +49,8 @@
|
|||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
|
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
#define DEFAULT_FONT_NAME "Sans 10"
|
||||||
|
|
||||||
#define CLUTTER_BACKEND_GET_PRIVATE(obj) \
|
#define CLUTTER_BACKEND_GET_PRIVATE(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BACKEND, ClutterBackendPrivate))
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BACKEND, ClutterBackendPrivate))
|
||||||
|
|
||||||
@ -61,6 +63,8 @@ struct _ClutterBackendPrivate
|
|||||||
ClutterFixed resolution;
|
ClutterFixed resolution;
|
||||||
|
|
||||||
cairo_font_options_t *font_options;
|
cairo_font_options_t *font_options;
|
||||||
|
|
||||||
|
gchar *font_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -76,6 +80,7 @@ static guint backend_signals[LAST_SIGNAL] = { 0, };
|
|||||||
static void
|
static void
|
||||||
clutter_backend_dispose (GObject *gobject)
|
clutter_backend_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
|
ClutterBackendPrivate *priv = CLUTTER_BACKEND (gobject)->priv;
|
||||||
ClutterMainContext *clutter_context;
|
ClutterMainContext *clutter_context;
|
||||||
|
|
||||||
clutter_context = clutter_context_get_default ();
|
clutter_context = clutter_context_get_default ();
|
||||||
@ -87,6 +92,8 @@ clutter_backend_dispose (GObject *gobject)
|
|||||||
clutter_context->events_queue = NULL;
|
clutter_context->events_queue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (priv->font_name);
|
||||||
|
|
||||||
clutter_backend_set_font_options (CLUTTER_BACKEND (gobject), NULL);
|
clutter_backend_set_font_options (CLUTTER_BACKEND (gobject), NULL);
|
||||||
|
|
||||||
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
|
||||||
@ -514,3 +521,30 @@ clutter_backend_get_font_options (ClutterBackend *backend)
|
|||||||
return priv->font_options;
|
return priv->font_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_backend_set_font_name (ClutterBackend *backend,
|
||||||
|
const gchar *font_name)
|
||||||
|
{
|
||||||
|
ClutterBackendPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
|
||||||
|
|
||||||
|
priv = backend->priv;
|
||||||
|
|
||||||
|
g_free (priv->font_name);
|
||||||
|
|
||||||
|
if (font_name == NULL || *font_name == '\0')
|
||||||
|
priv->font_name = g_strdup (DEFAULT_FONT_NAME);
|
||||||
|
else
|
||||||
|
priv->font_name = g_strdup (font_name);
|
||||||
|
|
||||||
|
g_signal_emit (backend, backend_signals[FONT_CHANGED], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_CONST_RETURN gchar *
|
||||||
|
clutter_backend_get_font_name (ClutterBackend *backend)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL);
|
||||||
|
|
||||||
|
return backend->priv->font_name;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <pango/pango.h>
|
||||||
|
|
||||||
#include <clutter/clutter-actor.h>
|
#include <clutter/clutter-actor.h>
|
||||||
#include <clutter/clutter-stage.h>
|
#include <clutter/clutter-stage.h>
|
||||||
#include <clutter/clutter-event.h>
|
#include <clutter/clutter-event.h>
|
||||||
@ -99,6 +101,9 @@ guint clutter_backend_get_double_click_distance (ClutterBackend
|
|||||||
void clutter_backend_set_font_options (ClutterBackend *backend,
|
void clutter_backend_set_font_options (ClutterBackend *backend,
|
||||||
cairo_font_options_t *options);
|
cairo_font_options_t *options);
|
||||||
cairo_font_options_t *clutter_backend_get_font_options (ClutterBackend *backend);
|
cairo_font_options_t *clutter_backend_get_font_options (ClutterBackend *backend);
|
||||||
|
void clutter_backend_set_font_name (ClutterBackend *backend,
|
||||||
|
const gchar *font_name);
|
||||||
|
G_CONST_RETURN gchar *clutter_backend_get_font_name (ClutterBackend *backend);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user