[gtk+/gdk-backend] gdk: Make cursor-type a property of the cursor
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gdk-backend] gdk: Make cursor-type a property of the cursor
- Date: Mon, 20 Dec 2010 13:15:07 +0000 (UTC)
commit faf9d8426e03ef97d6214f607c8141ca0d8588c8
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 20 13:35:39 2010 +0100
gdk: Make cursor-type a property of the cursor
gdk/gdkcursor.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++
gdk/x11/gdkcursor-x11.c | 39 +++++++++++++-------------------
2 files changed, 72 insertions(+), 23 deletions(-)
---
diff --git a/gdk/gdkcursor.c b/gdk/gdkcursor.c
index 840e8fc..9e27829 100644
--- a/gdk/gdkcursor.c
+++ b/gdk/gdkcursor.c
@@ -29,6 +29,7 @@
#include "gdkcursor.h"
#include "gdkcursorprivate.h"
#include "gdkdisplayprivate.h"
+#include "gdkintl.h"
#include "gdkinternals.h"
@@ -59,11 +60,66 @@
* The #GdkCursor structure represents a cursor. Its contents are private.
*/
+enum {
+ PROP_0,
+ PROP_CURSOR_TYPE
+};
+
G_DEFINE_ABSTRACT_TYPE (GdkCursor, gdk_cursor, G_TYPE_OBJECT)
static void
+gdk_cursor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdkCursor *cursor = GDK_CURSOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_CURSOR_TYPE:
+ g_value_set_enum (value, cursor->type);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdk_cursor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdkCursor *cursor = GDK_CURSOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_CURSOR_TYPE:
+ cursor->type = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
gdk_cursor_class_init (GdkCursorClass *cursor_class)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (cursor_class);
+
+ object_class->get_property = gdk_cursor_get_property;
+ object_class->set_property = gdk_cursor_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_CURSOR_TYPE,
+ g_param_spec_enum ("cursor-type",
+ P_("Cursor type"),
+ P_("Standard cursor type"),
+ GDK_TYPE_CURSOR_TYPE, GDK_X_CURSOR,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c
index efbc96f..9d64989 100644
--- a/gdk/x11/gdkcursor-x11.c
+++ b/gdk/x11/gdkcursor-x11.c
@@ -247,7 +247,6 @@ _gdk_x11_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type)
{
GdkX11Cursor *private;
- GdkCursor *cursor;
Cursor xcursor;
if (gdk_display_is_closed (display))
@@ -275,19 +274,18 @@ _gdk_x11_display_get_cursor_for_type (GdkDisplay *display,
}
}
- private = g_object_new (GDK_TYPE_X11_CURSOR, NULL);
+ private = g_object_new (GDK_TYPE_X11_CURSOR,
+ "cursor-type", GDK_CURSOR_IS_PIXMAP,
+ NULL);
private->display = display;
private->xcursor = xcursor;
private->name = NULL;
private->serial = theme_serial;
- cursor = (GdkCursor *) private;
- cursor->type = cursor_type;
-
if (xcursor != None)
add_to_cache (private);
- return cursor;
+ return GDK_CURSOR (private);
}
/**
@@ -599,7 +597,6 @@ _gdk_x11_display_get_cursor_for_pixbuf (GdkDisplay *display,
XcursorImage *xcimage;
Cursor xcursor;
GdkX11Cursor *private;
- GdkCursor *cursor;
const char *option;
char *end;
gint64 value;
@@ -639,16 +636,15 @@ _gdk_x11_display_get_cursor_for_pixbuf (GdkDisplay *display,
XcursorImageDestroy (xcimage);
}
- private = g_object_new (GDK_TYPE_X11_CURSOR, NULL);
+ private = g_object_new (GDK_TYPE_X11_CURSOR,
+ "cursor-type", GDK_CURSOR_IS_PIXMAP,
+ NULL);
private->display = display;
private->xcursor = xcursor;
private->name = NULL;
private->serial = theme_serial;
- cursor = (GdkCursor *) private;
- cursor->type = GDK_CURSOR_IS_PIXMAP;
-
- return cursor;
+ return GDK_CURSOR (private);
}
GdkCursor*
@@ -658,7 +654,6 @@ _gdk_x11_display_get_cursor_for_name (GdkDisplay *display,
Cursor xcursor;
Display *xdisplay;
GdkX11Cursor *private;
- GdkCursor *cursor;
if (gdk_display_is_closed (display))
{
@@ -682,17 +677,17 @@ _gdk_x11_display_get_cursor_for_name (GdkDisplay *display,
return NULL;
}
- private = g_object_new (GDK_TYPE_X11_CURSOR, NULL);
+ private = g_object_new (GDK_TYPE_X11_CURSOR,
+ "cursor-type", GDK_CURSOR_IS_PIXMAP,
+ NULL);
private->display = display;
private->xcursor = xcursor;
private->name = g_strdup (name);
private->serial = theme_serial;
- cursor = (GdkCursor *) private;
- cursor->type = GDK_CURSOR_IS_PIXMAP;
add_to_cache (private);
- return cursor;
+ return GDK_CURSOR (private);
}
gboolean
@@ -727,7 +722,6 @@ gdk_cursor_new_from_pixmap (GdkDisplay *display,
gint y)
{
GdkX11Cursor *private;
- GdkCursor *cursor;
Cursor xcursor;
XColor xfg, xbg;
@@ -748,16 +742,15 @@ gdk_cursor_new_from_pixmap (GdkDisplay *display,
else
xcursor = XCreatePixmapCursor (GDK_DISPLAY_XDISPLAY (display),
source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
- private = g_object_new (GDK_TYPE_X11_CURSOR, NULL);
+ private = g_object_new (GDK_TYPE_X11_CURSOR,
+ "cursor-type", GDK_CURSOR_IS_PIXMAP,
+ NULL);
private->display = display;
private->xcursor = xcursor;
private->name = NULL;
private->serial = theme_serial;
- cursor = (GdkCursor *) private;
- cursor->type = GDK_CURSOR_IS_PIXMAP;
-
- return cursor;
+ return GDK_CURSOR (private);
}
GdkCursor *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]