diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2013-02-12 15:02:21 -0500 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2013-02-14 17:19:52 -0500 |
commit | 5f2d1654a5085fb64af96310e297db4a7c4a39c2 (patch) | |
tree | b74dd1c718660dbe14b98a5efe566c7a3290ebcf /gdk/gdkframeclock.c | |
parent | be22b9fbb9ecd683b9b41d64144460f41d07f248 (diff) | |
download | gtk+-5f2d1654a5085fb64af96310e297db4a7c4a39c2.tar.gz |
Change GdkFrameClock from an interface to a class
It's unlikely that anyone will want to have, say, a GtkWidget that
also acts as a GdkFrameClock, so an abstract base class is as
flexible as making GdkFrameClock an interface, but has advantages:
- If we decide to never make implementing your own frame clock
possible, we can remove the virtualization.
- We can put functionality like history into the base class.
- Avoids the oddity of a interface without a public interface
VTable, which may cause problems for language bindings.
Diffstat (limited to 'gdk/gdkframeclock.c')
-rw-r--r-- | gdk/gdkframeclock.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c index 08789ebb04..8cdc1d109d 100644 --- a/gdk/gdkframeclock.c +++ b/gdk/gdkframeclock.c @@ -26,7 +26,7 @@ #include "config.h" -#include "gdkframeclock.h" +#include "gdkframeclockprivate.h" /** * SECTION:frameclock @@ -74,7 +74,7 @@ * time that doesn't have a lot to do with wall clock time. */ -G_DEFINE_INTERFACE (GdkFrameClock, gdk_frame_clock, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE (GdkFrameClock, gdk_frame_clock, G_TYPE_OBJECT) enum { FRAME_REQUESTED, @@ -90,9 +90,28 @@ enum { static guint signals[LAST_SIGNAL]; +struct _GdkFrameClockPrivate +{ + GdkFrameHistory *history; +}; + +static void +gdk_frame_clock_finalize (GObject *object) +{ + GdkFrameClockPrivate *priv = GDK_FRAME_CLOCK (object)->priv; + + g_object_unref (priv->history); + + G_OBJECT_CLASS (gdk_frame_clock_parent_class)->finalize (object); +} + static void -gdk_frame_clock_default_init (GdkFrameClockInterface *iface) +gdk_frame_clock_class_init (GdkFrameClockClass *klass) { + GObjectClass *gobject_class = (GObjectClass*) klass; + + gobject_class->finalize = gdk_frame_clock_finalize; + /** * GdkFrameClock::frame-requested: * @clock: the frame clock emitting the signal @@ -221,6 +240,21 @@ gdk_frame_clock_default_init (GdkFrameClockInterface *iface) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_type_class_add_private (klass, sizeof (GdkFrameClockPrivate)); +} + +static void +gdk_frame_clock_init (GdkFrameClock *clock) +{ + GdkFrameClockPrivate *priv; + + clock->priv = G_TYPE_INSTANCE_GET_PRIVATE (clock, + GDK_TYPE_FRAME_CLOCK, + GdkFrameClockPrivate); + priv = clock->priv; + + priv->history = gdk_frame_history_new (); } /** @@ -247,7 +281,7 @@ gdk_frame_clock_get_frame_time (GdkFrameClock *clock) { g_return_val_if_fail (GDK_IS_FRAME_CLOCK (clock), 0); - return GDK_FRAME_CLOCK_GET_IFACE (clock)->get_frame_time (clock); + return GDK_FRAME_CLOCK_GET_CLASS (clock)->get_frame_time (clock); } /** @@ -270,7 +304,7 @@ gdk_frame_clock_request_phase (GdkFrameClock *clock, { g_return_if_fail (GDK_IS_FRAME_CLOCK (clock)); - GDK_FRAME_CLOCK_GET_IFACE (clock)->request_phase (clock, phase); + GDK_FRAME_CLOCK_GET_CLASS (clock)->request_phase (clock, phase); } @@ -279,7 +313,7 @@ gdk_frame_clock_freeze (GdkFrameClock *clock) { g_return_if_fail (GDK_IS_FRAME_CLOCK (clock)); - GDK_FRAME_CLOCK_GET_IFACE (clock)->freeze (clock); + GDK_FRAME_CLOCK_GET_CLASS (clock)->freeze (clock); } @@ -288,7 +322,7 @@ gdk_frame_clock_thaw (GdkFrameClock *clock) { g_return_if_fail (GDK_IS_FRAME_CLOCK (clock)); - GDK_FRAME_CLOCK_GET_IFACE (clock)->thaw (clock); + GDK_FRAME_CLOCK_GET_CLASS (clock)->thaw (clock); } /** @@ -303,9 +337,13 @@ gdk_frame_clock_thaw (GdkFrameClock *clock) GdkFrameHistory * gdk_frame_clock_get_history (GdkFrameClock *clock) { + GdkFrameClockPrivate *priv; + g_return_val_if_fail (GDK_IS_FRAME_CLOCK (clock), NULL); - return GDK_FRAME_CLOCK_GET_IFACE (clock)->get_history (clock); + priv = clock->priv; + + return priv->history; } /** @@ -324,7 +362,7 @@ gdk_frame_clock_get_requested (GdkFrameClock *clock) { g_return_val_if_fail (GDK_IS_FRAME_CLOCK (clock), FALSE); - return GDK_FRAME_CLOCK_GET_IFACE (clock)->get_requested (clock); + return GDK_FRAME_CLOCK_GET_CLASS (clock)->get_requested (clock); } /** @@ -350,22 +388,6 @@ gdk_frame_clock_get_frame_time_val (GdkFrameClock *clock, timeval->tv_usec = (time_ms % 1000) * 1000; } -/** - * gdk_frame_clock_frame_requested: - * @clock: the clock - * - * Emits the frame-requested signal. Used in implementations of the - * #GdkFrameClock interface. - */ -void -gdk_frame_clock_frame_requested (GdkFrameClock *clock) -{ - g_return_if_fail (GDK_IS_FRAME_CLOCK (clock)); - - g_signal_emit (G_OBJECT (clock), - signals[FRAME_REQUESTED], 0); -} - GdkFrameTimings * gdk_frame_clock_get_current_frame_timings (GdkFrameClock *clock) { |