]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkcursor.c
GdkFrameClock: Clean up the public API
[~andy/gtk] / gdk / gdkcursor.c
index 9e27829cf78482208ec0150e599de1de28eb7e7e..0b2b80d9aa260b50ae15722417871fc4cd32e457 100644 (file)
@@ -12,9 +12,7 @@
  * 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/>.
  */
 
 /*
@@ -62,7 +60,8 @@
 
 enum {
   PROP_0,
-  PROP_CURSOR_TYPE
+  PROP_CURSOR_TYPE,
+  PROP_DISPLAY
 };
 
 G_DEFINE_ABSTRACT_TYPE (GdkCursor, gdk_cursor, G_TYPE_OBJECT)
@@ -80,6 +79,9 @@ gdk_cursor_get_property (GObject    *object,
     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;
@@ -99,6 +101,11 @@ gdk_cursor_set_property (GObject      *object,
     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;
@@ -120,6 +127,14 @@ gdk_cursor_class_init (GdkCursorClass *cursor_class)
                                                       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
@@ -133,7 +148,7 @@ gdk_cursor_init (GdkCursor *cursor)
  *
  * 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
  */
@@ -337,3 +352,44 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
 
   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);
+}