Commit 28b2d7e5 authored by Benjamin Otte's avatar Benjamin Otte Committed by Matthias Clasen

gdk: Make cursor-type a property of the cursor

parent 3e068e92
......@@ -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
......
......@@ -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 *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment