diff options
author | Benjamin Otte <otte@redhat.com> | 2017-11-02 20:38:07 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2017-11-04 00:07:13 +0100 |
commit | 8ba9ae601283be265e59c6092d61c099f8a17d65 (patch) | |
tree | b6d93db04fbf5280d13f7c8a59de219befdd682c /gdk/gdkcursor.c | |
parent | a1759a0a52d4b6b988fcafbf30f9fd0b61c06030 (diff) | |
download | gtk+-8ba9ae601283be265e59c6092d61c099f8a17d65.tar.gz |
gdk: Add gdk_cursor_get_name()
Also add the GdkCursor::name property.
Diffstat (limited to 'gdk/gdkcursor.c')
-rw-r--r-- | gdk/gdkcursor.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/gdk/gdkcursor.c b/gdk/gdkcursor.c index 4c85588229..63a5075f32 100644 --- a/gdk/gdkcursor.c +++ b/gdk/gdkcursor.c @@ -65,7 +65,8 @@ enum { PROP_0, - PROP_DISPLAY + PROP_DISPLAY, + PROP_NAME }; G_DEFINE_ABSTRACT_TYPE (GdkCursor, gdk_cursor, G_TYPE_OBJECT) @@ -83,6 +84,9 @@ gdk_cursor_get_property (GObject *object, case PROP_DISPLAY: g_value_set_object (value, cursor->display); break; + case PROP_NAME: + g_value_set_string (value, cursor->name); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -104,6 +108,9 @@ gdk_cursor_set_property (GObject *object, /* check that implementations actually provide the display when constructing */ g_assert (cursor->display != NULL); break; + case PROP_NAME: + cursor->name = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -111,12 +118,23 @@ gdk_cursor_set_property (GObject *object, } static void +gdk_cursor_finalize (GObject *object) +{ + GdkCursor *cursor = GDK_CURSOR (object); + + g_free (cursor->name); + + G_OBJECT_CLASS (gdk_cursor_parent_class)->finalize (object); +} + +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; + object_class->finalize = gdk_cursor_finalize; g_object_class_install_property (object_class, PROP_DISPLAY, @@ -125,6 +143,13 @@ gdk_cursor_class_init (GdkCursorClass *cursor_class) P_("Display of this cursor"), GDK_TYPE_DISPLAY, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, + PROP_NAME, + g_param_spec_string ("name", + P_("Name"), + P_("Name of this cursor"), + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } static void @@ -189,6 +214,7 @@ gdk_cursor_new_from_name (GdkDisplay *display, const gchar *name) { g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); + g_return_val_if_fail (name != NULL, NULL); return GDK_DISPLAY_GET_CLASS (display)->get_cursor_for_name (display, name); } @@ -309,6 +335,7 @@ gdk_cursor_new_from_surface (GdkDisplay *display, return GDK_DISPLAY_GET_CLASS (display)->get_cursor_for_surface (display, surface, x, y); } + /** * gdk_cursor_get_display: * @cursor: a #GdkCursor. @@ -319,7 +346,6 @@ gdk_cursor_new_from_surface (GdkDisplay *display, * * Since: 2.2 */ - GdkDisplay * gdk_cursor_get_display (GdkCursor *cursor) { @@ -329,6 +355,26 @@ gdk_cursor_get_display (GdkCursor *cursor) } /** + * gdk_cursor_get_name: + * @cursor: a #GdkCursor. + * + * Returns the name of the cursor. If the cursor is not a named cursor, %NULL + * will be returned and the surface property will be set. + * + * Returns: (transfer none): the name of the cursor or %NULL if it is not + * a named cursor + * + * Since: 3.94 + */ +const char * +gdk_cursor_get_name (GdkCursor *cursor) +{ + g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL); + + return cursor->name; +} + +/** * gdk_cursor_get_image: * @cursor: a #GdkCursor * |