gdk: Make cursor-type a property of the cursor
This commit is contained in:

committed by
Matthias Clasen

parent
3e068e921f
commit
28b2d7e5da
@ -29,6 +29,7 @@
|
|||||||
#include "gdkcursor.h"
|
#include "gdkcursor.h"
|
||||||
#include "gdkcursorprivate.h"
|
#include "gdkcursorprivate.h"
|
||||||
#include "gdkdisplayprivate.h"
|
#include "gdkdisplayprivate.h"
|
||||||
|
#include "gdkintl.h"
|
||||||
#include "gdkinternals.h"
|
#include "gdkinternals.h"
|
||||||
|
|
||||||
|
|
||||||
@ -59,11 +60,66 @@
|
|||||||
* The #GdkCursor structure represents a cursor. Its contents are private.
|
* 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)
|
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
|
static void
|
||||||
gdk_cursor_class_init (GdkCursorClass *cursor_class)
|
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
|
static void
|
||||||
|
@ -247,7 +247,6 @@ _gdk_x11_display_get_cursor_for_type (GdkDisplay *display,
|
|||||||
GdkCursorType cursor_type)
|
GdkCursorType cursor_type)
|
||||||
{
|
{
|
||||||
GdkX11Cursor *private;
|
GdkX11Cursor *private;
|
||||||
GdkCursor *cursor;
|
|
||||||
Cursor xcursor;
|
Cursor xcursor;
|
||||||
|
|
||||||
if (gdk_display_is_closed (display))
|
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->display = display;
|
||||||
private->xcursor = xcursor;
|
private->xcursor = xcursor;
|
||||||
private->name = NULL;
|
private->name = NULL;
|
||||||
private->serial = theme_serial;
|
private->serial = theme_serial;
|
||||||
|
|
||||||
cursor = (GdkCursor *) private;
|
|
||||||
cursor->type = cursor_type;
|
|
||||||
|
|
||||||
if (xcursor != None)
|
if (xcursor != None)
|
||||||
add_to_cache (private);
|
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;
|
XcursorImage *xcimage;
|
||||||
Cursor xcursor;
|
Cursor xcursor;
|
||||||
GdkX11Cursor *private;
|
GdkX11Cursor *private;
|
||||||
GdkCursor *cursor;
|
|
||||||
const char *option;
|
const char *option;
|
||||||
char *end;
|
char *end;
|
||||||
gint64 value;
|
gint64 value;
|
||||||
@ -639,16 +636,15 @@ _gdk_x11_display_get_cursor_for_pixbuf (GdkDisplay *display,
|
|||||||
XcursorImageDestroy (xcimage);
|
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->display = display;
|
||||||
private->xcursor = xcursor;
|
private->xcursor = xcursor;
|
||||||
private->name = NULL;
|
private->name = NULL;
|
||||||
private->serial = theme_serial;
|
private->serial = theme_serial;
|
||||||
|
|
||||||
cursor = (GdkCursor *) private;
|
return GDK_CURSOR (private);
|
||||||
cursor->type = GDK_CURSOR_IS_PIXMAP;
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkCursor*
|
GdkCursor*
|
||||||
@ -658,7 +654,6 @@ _gdk_x11_display_get_cursor_for_name (GdkDisplay *display,
|
|||||||
Cursor xcursor;
|
Cursor xcursor;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
GdkX11Cursor *private;
|
GdkX11Cursor *private;
|
||||||
GdkCursor *cursor;
|
|
||||||
|
|
||||||
if (gdk_display_is_closed (display))
|
if (gdk_display_is_closed (display))
|
||||||
{
|
{
|
||||||
@ -682,17 +677,17 @@ _gdk_x11_display_get_cursor_for_name (GdkDisplay *display,
|
|||||||
return NULL;
|
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->display = display;
|
||||||
private->xcursor = xcursor;
|
private->xcursor = xcursor;
|
||||||
private->name = g_strdup (name);
|
private->name = g_strdup (name);
|
||||||
private->serial = theme_serial;
|
private->serial = theme_serial;
|
||||||
|
|
||||||
cursor = (GdkCursor *) private;
|
|
||||||
cursor->type = GDK_CURSOR_IS_PIXMAP;
|
|
||||||
add_to_cache (private);
|
add_to_cache (private);
|
||||||
|
|
||||||
return cursor;
|
return GDK_CURSOR (private);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -727,7 +722,6 @@ gdk_cursor_new_from_pixmap (GdkDisplay *display,
|
|||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
GdkX11Cursor *private;
|
GdkX11Cursor *private;
|
||||||
GdkCursor *cursor;
|
|
||||||
Cursor xcursor;
|
Cursor xcursor;
|
||||||
XColor xfg, xbg;
|
XColor xfg, xbg;
|
||||||
|
|
||||||
@ -748,16 +742,15 @@ gdk_cursor_new_from_pixmap (GdkDisplay *display,
|
|||||||
else
|
else
|
||||||
xcursor = XCreatePixmapCursor (GDK_DISPLAY_XDISPLAY (display),
|
xcursor = XCreatePixmapCursor (GDK_DISPLAY_XDISPLAY (display),
|
||||||
source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
|
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->display = display;
|
||||||
private->xcursor = xcursor;
|
private->xcursor = xcursor;
|
||||||
private->name = NULL;
|
private->name = NULL;
|
||||||
private->serial = theme_serial;
|
private->serial = theme_serial;
|
||||||
|
|
||||||
cursor = (GdkCursor *) private;
|
return GDK_CURSOR (private);
|
||||||
cursor->type = GDK_CURSOR_IS_PIXMAP;
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkCursor *
|
GdkCursor *
|
||||||
|
Reference in New Issue
Block a user