gdk: Move gdk_cursor_get_image() to the base class

.. and make it call a vfunc on the cursor
This commit is contained in:
Benjamin Otte
2010-12-20 14:07:11 +01:00
committed by Matthias Clasen
parent 60dc856daf
commit 7a33592231
3 changed files with 35 additions and 25 deletions

View File

@ -374,3 +374,24 @@ gdk_cursor_get_display (GdkCursor *cursor)
return cursor->display; return cursor->display;
} }
/**
* gdk_cursor_get_image:
* @cursor: a #GdkCursor
*
* Returns a #GdkPixbuf with the image used to display the cursor.
*
* Note that depending on the capabilities of the windowing system and
* on the cursor, GDK may not be able to obtain the image data. In this
* case, %NULL is returned.
*
* Returns: (transfer full): a #GdkPixbuf representing @cursor, or %NULL
*
* Since: 2.8
*/
GdkPixbuf*
gdk_cursor_get_image (GdkCursor *cursor)
{
g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL);
return GDK_CURSOR_GET_CLASS (cursor)->get_image (cursor);
}

View File

@ -45,6 +45,8 @@ struct _GdkCursor
struct _GdkCursorClass struct _GdkCursorClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
GdkPixbuf * (* get_image) (GdkCursor * cursor);
}; };
G_END_DECLS G_END_DECLS

View File

@ -181,6 +181,8 @@ _gdk_x11_cursor_display_finalize (GdkDisplay *display)
G_DEFINE_TYPE (GdkX11Cursor, gdk_x11_cursor, GDK_TYPE_CURSOR) G_DEFINE_TYPE (GdkX11Cursor, gdk_x11_cursor, GDK_TYPE_CURSOR)
static GdkPixbuf* gdk_x11_cursor_get_image (GdkCursor *cursor);
void void
gdk_x11_cursor_finalize (GObject *object) gdk_x11_cursor_finalize (GObject *object)
{ {
@ -197,11 +199,14 @@ gdk_x11_cursor_finalize (GObject *object)
} }
static void static void
gdk_x11_cursor_class_init (GdkX11CursorClass *cursor_class) gdk_x11_cursor_class_init (GdkX11CursorClass *xcursor_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (cursor_class); GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class);
GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class);
object_class->finalize = gdk_x11_cursor_finalize; object_class->finalize = gdk_x11_cursor_finalize;
cursor_class->get_image = gdk_x11_cursor_get_image;
} }
static void static void
@ -323,22 +328,8 @@ gdk_x11_cursor_get_xcursor (GdkCursor *cursor)
#if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2 #if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2
/** static GdkPixbuf*
* gdk_cursor_get_image: gdk_x11_cursor_get_image (GdkCursor *cursor)
* @cursor: a #GdkCursor
*
* Returns a #GdkPixbuf with the image used to display the cursor.
*
* Note that depending on the capabilities of the windowing system and
* on the cursor, GDK may not be able to obtain the image data. In this
* case, %NULL is returned.
*
* Returns: (transfer full): a #GdkPixbuf representing @cursor, or %NULL
*
* Since: 2.8
*/
GdkPixbuf*
gdk_cursor_get_image (GdkCursor *cursor)
{ {
Display *xdisplay; Display *xdisplay;
GdkX11Cursor *private; GdkX11Cursor *private;
@ -350,9 +341,7 @@ gdk_cursor_get_image (GdkCursor *cursor)
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
gchar *theme; gchar *theme;
g_return_val_if_fail (cursor != NULL, NULL); private = GDK_X11_CURSOR (cursor);
private = (GdkX11Cursor *) cursor;
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_cursor_get_display (cursor)); xdisplay = GDK_DISPLAY_XDISPLAY (gdk_cursor_get_display (cursor));
@ -509,11 +498,9 @@ gdk_x11_display_set_cursor_theme (GdkDisplay *display,
#else #else
GdkPixbuf* static GdkPixbuf*
gdk_cursor_get_image (GdkCursor *cursor) gdk_x11_cursor_get_image (GdkCursor *cursor)
{ {
g_return_val_if_fail (cursor != NULL, NULL);
return NULL; return NULL;
} }