Add signals for Backend options
The ClutterBackend instance at the moment lacks the ability to notify runtime changes of the font options and the resolution. For this reason, this commit adds a ::resolution-changed and a ::font-changed signals to the Backend class. The ::resolution-changed signal is emitted when set_resolution() is called with a different DPI; ::font-changed is emitted when the cairo_font_options_t* changes from the default.
This commit is contained in:
parent
b021f518c1
commit
b8b8b155c4
@ -44,6 +44,7 @@
|
|||||||
#include "clutter-backend.h"
|
#include "clutter-backend.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-fixed.h"
|
#include "clutter-fixed.h"
|
||||||
|
#include "clutter-marshal.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
|
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
|
||||||
@ -62,6 +63,16 @@ struct _ClutterBackendPrivate
|
|||||||
cairo_font_options_t *font_options;
|
cairo_font_options_t *font_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RESOLUTION_CHANGED,
|
||||||
|
FONT_CHANGED,
|
||||||
|
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint backend_signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_backend_dispose (GObject *gobject)
|
clutter_backend_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
@ -89,6 +100,24 @@ clutter_backend_class_init (ClutterBackendClass *klass)
|
|||||||
gobject_class->dispose = clutter_backend_dispose;
|
gobject_class->dispose = clutter_backend_dispose;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (ClutterBackendPrivate));
|
g_type_class_add_private (gobject_class, sizeof (ClutterBackendPrivate));
|
||||||
|
|
||||||
|
backend_signals[RESOLUTION_CHANGED] =
|
||||||
|
g_signal_new (I_("resolution-changed"),
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (ClutterBackendClass, resolution_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
clutter_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
backend_signals[FONT_CHANGED] =
|
||||||
|
g_signal_new (I_("font-changed"),
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (ClutterBackendClass, font_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
clutter_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -388,8 +417,9 @@ clutter_backend_set_resolution (ClutterBackend *backend,
|
|||||||
priv->resolution = fixed_dpi;
|
priv->resolution = fixed_dpi;
|
||||||
|
|
||||||
if (CLUTTER_CONTEXT ()->font_map)
|
if (CLUTTER_CONTEXT ()->font_map)
|
||||||
cogl_pango_font_map_set_resolution (CLUTTER_CONTEXT ()->font_map,
|
cogl_pango_font_map_set_resolution (CLUTTER_CONTEXT ()->font_map, dpi);
|
||||||
COGL_FIXED_TO_FLOAT (fixed_dpi));
|
|
||||||
|
g_signal_emit (backend, backend_signals[RESOLUTION_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -445,6 +475,8 @@ clutter_backend_set_font_options (ClutterBackend *backend,
|
|||||||
priv->font_options = cairo_font_options_copy (options);
|
priv->font_options = cairo_font_options_copy (options);
|
||||||
else
|
else
|
||||||
priv->font_options = NULL;
|
priv->font_options = NULL;
|
||||||
|
|
||||||
|
g_signal_emit (backend, backend_signals[FONT_CHANGED], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ struct _ClutterBackendClass
|
|||||||
ClutterStage *stage);
|
ClutterStage *stage);
|
||||||
void (* ensure_context) (ClutterBackend *backend,
|
void (* ensure_context) (ClutterBackend *backend,
|
||||||
ClutterStage *stage);
|
ClutterStage *stage);
|
||||||
|
|
||||||
|
/* signals */
|
||||||
|
void (* resolution_changed) (ClutterBackend *backend);
|
||||||
|
void (* font_changed) (ClutterBackend *backend);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType clutter_backend_get_type (void) G_GNUC_CONST;
|
GType clutter_backend_get_type (void) G_GNUC_CONST;
|
||||||
|
Loading…
Reference in New Issue
Block a user