[aisleriot] board: Use nicer hand cursors



commit f140cba4657579591c68554d43c30a675e38c049
Author: Christian Persch <chpe gnome org>
Date:   Tue Apr 22 18:05:59 2014 +0200

    board: Use nicer hand cursors
    
    Try the named cursors first before falling back to the built-in pixmap ones.

 src/ar-clutter-embed.c |    4 ++--
 src/ar-cursor.c        |   20 +++++++++++++++-----
 src/ar-cursor.h        |    2 +-
 src/board-noclutter.c  |    4 ++--
 4 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/ar-clutter-embed.c b/src/ar-clutter-embed.c
index 3ba5db9..c3b6302 100644
--- a/src/ar-clutter-embed.c
+++ b/src/ar-clutter-embed.c
@@ -67,8 +67,8 @@ ar_clutter_embed_realize (GtkWidget *widget)
   window = gtk_widget_get_window (widget);
 
   priv->cursor[AR_CURSOR_DEFAULT] = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);
-  priv->cursor[AR_CURSOR_OPEN] = ar_cursor_new (window, AR_CURSOR_OPEN);
-  priv->cursor[AR_CURSOR_CLOSED] = ar_cursor_new (window, AR_CURSOR_CLOSED);
+  priv->cursor[AR_CURSOR_OPEN] = ar_cursor_new (display, AR_CURSOR_OPEN);
+  priv->cursor[AR_CURSOR_CLOSED] = ar_cursor_new (display, AR_CURSOR_CLOSED);
   priv->cursor[AR_CURSOR_DROPPABLE] = gdk_cursor_new_for_display (display, GDK_DOUBLE_ARROW); /* FIXMEchpe: 
better cursor */
 #endif /* !NO_MOUSE */
 
diff --git a/src/ar-cursor.c b/src/ar-cursor.c
index eba94ec..ac64f21 100644
--- a/src/ar-cursor.c
+++ b/src/ar-cursor.c
@@ -198,7 +198,7 @@ static const guint8 hand_open_data[] =
 #define CURSOR_HOT_Y 10
 
 static GdkCursor *
-ar_cursor_new_from_data (GdkWindow *window,
+ar_cursor_new_from_data (GdkDisplay *display,
                          const guint8 *data,
                          gsize data_len)
 {
@@ -206,7 +206,7 @@ ar_cursor_new_from_data (GdkWindow *window,
   GdkPixbuf *pixbuf;
 
   pixbuf = gdk_pixbuf_new_from_inline (data_len, data, FALSE, NULL);
-  cursor = gdk_cursor_new_from_pixbuf (gdk_window_get_display (window),
+  cursor = gdk_cursor_new_from_pixbuf (display,
                                        pixbuf,
                                        CURSOR_HOT_X, CURSOR_HOT_Y);
   g_object_unref (pixbuf);
@@ -214,15 +214,25 @@ ar_cursor_new_from_data (GdkWindow *window,
   return cursor;
 }
 
-GdkCursor *ar_cursor_new (GdkWindow *window,
+GdkCursor *ar_cursor_new (GdkDisplay *display,
                           ArCursorType cursor_type)
 {
+  GdkCursor *cursor;
+
   switch (cursor_type) {
     case AR_CURSOR_OPEN:
-      return ar_cursor_new_from_data (window, hand_open_data, sizeof (hand_open_data));
+      if ((cursor = gdk_cursor_new_from_name (display, "openhand")))
+          return cursor;
+      if ((cursor = gdk_cursor_new_from_name (display, "hand1")))
+          return cursor;
+      return ar_cursor_new_from_data (display, hand_open_data, sizeof (hand_open_data));
 
     case AR_CURSOR_CLOSED:
-      return ar_cursor_new_from_data (window, hand_closed_data, sizeof (hand_closed_data));
+      if ((cursor = gdk_cursor_new_from_name (display, "closedhand")))
+          return cursor;
+      if ((cursor = gdk_cursor_new_from_name (display, "grabbing")))
+          return cursor;
+      return ar_cursor_new_from_data (display, hand_closed_data, sizeof (hand_closed_data));
 
     default:
       g_assert_not_reached ();
diff --git a/src/ar-cursor.h b/src/ar-cursor.h
index f89d278..dae24d1 100644
--- a/src/ar-cursor.h
+++ b/src/ar-cursor.h
@@ -30,7 +30,7 @@ typedef enum {
   AR_LAST_CURSOR
 } ArCursorType;
 
-GdkCursor *ar_cursor_new (GdkWindow *window,
+GdkCursor *ar_cursor_new (GdkDisplay *display,
                           ArCursorType cursor_type);
 
 G_END_DECLS
diff --git a/src/board-noclutter.c b/src/board-noclutter.c
index 710b31b..0f2ac4c 100644
--- a/src/board-noclutter.c
+++ b/src/board-noclutter.c
@@ -2240,8 +2240,8 @@ aisleriot_board_realize (GtkWidget *widget)
 
   /* Create cursors */
   priv->cursor[AR_CURSOR_DEFAULT] = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);
-  priv->cursor[AR_CURSOR_OPEN] = ar_cursor_new (window, AR_CURSOR_OPEN);
-  priv->cursor[AR_CURSOR_CLOSED] = ar_cursor_new (window, AR_CURSOR_CLOSED);
+  priv->cursor[AR_CURSOR_OPEN] = ar_cursor_new (display, AR_CURSOR_OPEN);
+  priv->cursor[AR_CURSOR_CLOSED] = ar_cursor_new (display, AR_CURSOR_CLOSED);
   priv->cursor[AR_CURSOR_DROPPABLE] = gdk_cursor_new_for_display (display, GDK_DOUBLE_ARROW); /* FIXMEchpe: 
better cursor */
 
   aisleriot_board_setup_geometry (board);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]