[gtk+] add gdk_window_get_cursor()
- From: Cody Russell <bratsche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] add gdk_window_get_cursor()
- Date: Thu, 30 Jul 2009 03:46:00 +0000 (UTC)
commit 1780361b799822d63aafd164a52b287ab9643f4f
Author: Cody Russell <bratsche gnome org>
Date: Thu Jul 16 01:16:01 2009 -0500
add gdk_window_get_cursor()
gdk/gdkwindow.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkwindow.h | 1 +
2 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 754bf6e..6db8cf1 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -32,6 +32,7 @@
#include "gdk.h" /* For gdk_rectangle_union() */
#include "gdkpixmap.h"
#include "gdkdrawable.h"
+#include "gdkintl.h"
#include "gdkscreen.h"
#include "gdkmarshalers.h"
#include "gdkalias.h"
@@ -128,6 +129,11 @@ enum {
LAST_SIGNAL
};
+enum {
+ PROP_0,
+ PROP_CURSOR
+};
+
struct _GdkWindowPaint
{
GdkRegion *region;
@@ -293,6 +299,16 @@ static void gdk_window_free_paint_stack (GdkWindow *window);
static void gdk_window_init (GdkWindowObject *window);
static void gdk_window_class_init (GdkWindowObjectClass *klass);
static void gdk_window_finalize (GObject *object);
+
+static void gdk_window_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gdk_window_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
static void gdk_window_clear_backing_region (GdkWindow *window,
GdkRegion *region);
static void gdk_window_redirect_free (GdkWindowRedirect *redirect);
@@ -410,6 +426,8 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_window_finalize;
+ object_class->set_property = gdk_window_set_property;
+ object_class->get_property = gdk_window_get_property;
drawable_class->create_gc = gdk_window_create_gc;
drawable_class->draw_rectangle = gdk_window_draw_rectangle;
@@ -444,6 +462,14 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
+ /* Properties */
+ g_object_class_install_property (object_class,
+ PROP_CURSOR,
+ g_param_spec_pointer ("cursor",
+ P_("Cursor"),
+ P_("Cursor"),
+ G_PARAM_READWRITE));
+
/**
* GdkWindow::pick-embedded-child:
* @window: the window on which the signal is emitted
@@ -568,6 +594,46 @@ gdk_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+static void
+gdk_window_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GdkWindow *window = (GdkWindow *)object;
+
+ switch (prop_id)
+ {
+ case PROP_CURSOR:
+ gdk_window_set_cursor (window, g_value_get_pointer (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdk_window_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdkWindow *window = (GdkWindow *) object;
+
+ switch (prop_id)
+ {
+ case PROP_CURSOR:
+ g_value_set_pointer (value, gdk_window_get_cursor (window));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static gboolean
gdk_window_is_offscreen (GdkWindowObject *window)
{
@@ -6948,6 +7014,30 @@ gdk_window_set_back_pixmap (GdkWindow *window,
}
/**
+ * gdk_window_get_cursor:
+ * @window: a #GdkWindow
+ * @cursor: a cursor
+ *
+ * Retrieves a #GdkCursor pointer for the cursor currently set on the
+ * specified #GdkWindow, or %NULL. If the return value is %NULL then
+ * there is no custom cursor set on the specified window, and it is
+ * using the cursor for its parent window.
+ *
+ * Since: 2.18
+ */
+GdkCursor *
+gdk_window_get_cursor (GdkWindow *window)
+{
+ GdkWindowObject *private;
+
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+ private = (GdkWindowObject *) window;
+
+ return private->cursor;
+}
+
+/**
* gdk_window_set_cursor:
* @window: a #GdkWindow
* @cursor: a cursor
@@ -6983,6 +7073,8 @@ gdk_window_set_cursor (GdkWindow *window,
if (_gdk_window_event_parent_of (window, display->pointer_info.window_under_pointer))
update_cursor (display);
+
+ g_object_notify (G_OBJECT (window), "cursor");
}
}
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index a1d3184..a3297d2 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -517,6 +517,7 @@ void gdk_window_set_back_pixmap (GdkWindow *window,
gboolean parent_relative);
void gdk_window_set_cursor (GdkWindow *window,
GdkCursor *cursor);
+GdkCursor *gdk_window_get_cursor (GdkWindow *window);
void gdk_window_get_user_data (GdkWindow *window,
gpointer *data);
void gdk_window_get_geometry (GdkWindow *window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]