* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gdkcursor.h"
#include "gdkcursorprivate.h"
#include "gdkdisplayprivate.h"
+#include "gdkintl.h"
#include "gdkinternals.h"
* The #GdkCursor structure represents a cursor. Its contents are private.
*/
+enum {
+ PROP_0,
+ PROP_CURSOR_TYPE,
+ PROP_DISPLAY
+};
+
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;
+ case PROP_DISPLAY:
+ g_value_set_object (value, cursor->display);
+ 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;
+ case PROP_DISPLAY:
+ cursor->display = g_value_get_object (value);
+ /* check that implementations actually provide the display when constructing */
+ g_assert (cursor->display != NULL);
+ 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));
+
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY,
+ g_param_spec_object ("display",
+ P_("Display"),
+ P_("Display of this cursor"),
+ GDK_TYPE_DISPLAY,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
*
* Adds a reference to @cursor.
*
- * Return value: Same @cursor that was passed in
+ * Return value: (transfer full): Same @cursor that was passed in
+ *
+ * Deprecated: 3.0: Use g_object_ref() instead
*/
GdkCursor*
gdk_cursor_ref (GdkCursor *cursor)
*
* Removes a reference from @cursor, deallocating the cursor
* if no references remain.
+ *
+ * Deprecated: 3.0: Use g_object_unref() instead
*/
void
gdk_cursor_unref (GdkCursor *cursor)
return GDK_DISPLAY_GET_CLASS (display)->get_cursor_for_pixbuf (display, pixbuf, x, y);
}
+
+/**
+ * gdk_cursor_get_display:
+ * @cursor: a #GdkCursor.
+ *
+ * Returns the display on which the #GdkCursor is defined.
+ *
+ * Returns: (transfer none): the #GdkDisplay associated to @cursor
+ *
+ * Since: 2.2
+ */
+
+GdkDisplay *
+gdk_cursor_get_display (GdkCursor *cursor)
+{
+ g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL);
+
+ 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);
+}