[gtk+/gdk-backend-quartz] quartz: turn quartz GdkCursor into GObject
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gdk-backend-quartz] quartz: turn quartz GdkCursor into GObject
- Date: Wed, 22 Dec 2010 16:32:39 +0000 (UTC)
commit 209ec7c7261a904c274fe1bd2ff68b5e3b0cf0b2
Author: Kristian Rietveld <kris gtk org>
Date: Wed Dec 22 10:45:07 2010 +0100
quartz: turn quartz GdkCursor into GObject
gdk/quartz/gdkcursor-quartz.c | 79 ++++++++++++++++++++++++++++++----------
gdk/quartz/gdkprivate-quartz.h | 6 ---
2 files changed, 60 insertions(+), 25 deletions(-)
---
diff --git a/gdk/quartz/gdkcursor-quartz.c b/gdk/quartz/gdkcursor-quartz.c
index 62f19a6..f432b19 100644
--- a/gdk/quartz/gdkcursor-quartz.c
+++ b/gdk/quartz/gdkcursor-quartz.c
@@ -22,27 +22,51 @@
#include "gdkdisplay.h"
#include "gdkcursor.h"
+#include "gdkcursorprivate.h"
#include "gdkprivate-quartz.h"
#include "xcursors.h"
+static GType gdk_quartz_cursor_get_type (void);
+
+#define GDK_TYPE_QUARTZ_CURSOR (gdk_quartz_cursor_get_type ())
+#define GDK_QUARTZ_CURSOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_QUARTZ_CURSOR, GdkQuartzCursor))
+#define GDK_QUARTZ_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_QUARTZ_CURSOR, GdkQuartzCursorClass))
+#define GDK_IS_QUARTZ_CURSOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_QUARTZ_CURSOR))
+#define GDK_IS_QUARTZ_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_QUARTZ_CURSOR))
+#define GDK_QUARTZ_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_QUARTZ_CURSOR, GdkQuartzCursorClass))
+
+typedef struct _GdkQuartzCursor GdkQuartzCursor;
+typedef struct _GdkQuartzCursorClass GdkQuartzCursorClass;
+
+struct _GdkQuartzCursor
+{
+ GdkCursor cursor;
+
+ NSCursor *nscursor;
+};
+
+struct _GdkQuartzCursorClass
+{
+ GdkCursorClass cursor_class;
+};
+
+
static GdkCursor *cached_xcursors[G_N_ELEMENTS (xcursors)];
static GdkCursor *
gdk_quartz_cursor_new_from_nscursor (NSCursor *nscursor,
GdkCursorType cursor_type)
{
- GdkCursorPrivate *private;
- GdkCursor *cursor;
+ GdkQuartzCursor *private;
- private = g_new (GdkCursorPrivate, 1);
+ private = g_object_new (GDK_TYPE_QUARTZ_CURSOR,
+ "cursor-type", cursor_type,
+ "display", _gdk_display,
+ NULL);
private->nscursor = nscursor;
- cursor = (GdkCursor *)private;
- cursor->type = cursor_type;
- cursor->ref_count = 1;
-
- return cursor;
+ return GDK_CURSOR (private);
}
static GdkCursor *
@@ -335,20 +359,37 @@ _gdk_quartz_display_get_cursor_for_name (GdkDisplay *display,
return NULL;
}
-void
-_gdk_cursor_destroy (GdkCursor *cursor)
+G_DEFINE_TYPE (GdkQuartzCursor, gdk_quartz_cursor, GDK_TYPE_CURSOR)
+
+static GdkPixbuf *gdk_quartz_cursor_get_image (GdkCursor *cursor);
+
+static void
+gdk_quartz_cursor_finalize (GObject *object)
{
- GdkCursorPrivate *private;
+ GdkQuartzCursor *private = GDK_QUARTZ_CURSOR (object);
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (cursor->ref_count == 0);
+ if (private->nscursor)
+ [private->nscursor release];
+ private->nscursor = NULL;
+}
- private = (GdkCursorPrivate *)cursor;
- [private->nscursor release];
-
- g_free (private);
+static void
+gdk_quartz_cursor_class_init (GdkQuartzCursorClass *quartz_cursor_class)
+{
+ GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (quartz_cursor_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (quartz_cursor_class);
+
+ object_class->finalize = gdk_quartz_cursor_finalize;
+
+ cursor_class->get_image = gdk_quartz_cursor_get_image;
+}
+
+static void
+gdk_quartz_cursor_init (GdkQuartzCursor *cursor)
+{
}
+
gboolean
_gdk_quartz_display_supports_cursor_alpha (GdkDisplay *display)
{
@@ -381,8 +422,8 @@ _gdk_quartz_display_get_maximal_cursor_size (GdkDisplay *display,
*height = 65536;
}
-GdkPixbuf *
-gdk_cursor_get_image (GdkCursor *cursor)
+static GdkPixbuf *
+gdk_quartz_cursor_get_image (GdkCursor *cursor)
{
/* FIXME: Implement */
return NULL;
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h
index d61ccf4..ed8db24 100644
--- a/gdk/quartz/gdkprivate-quartz.h
+++ b/gdk/quartz/gdkprivate-quartz.h
@@ -44,12 +44,6 @@ struct _GdkVisualClass
GObjectClass parent_class;
};
-struct _GdkCursorPrivate
-{
- GdkCursor cursor;
- NSCursor *nscursor;
-};
-
struct _GdkDragContextPrivate
{
id <NSDraggingInfo> dragging_info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]