[evince/wip/gpoo/gtk4-rebase-port: 10/72] libview: Port cursor API to gtk4
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/gtk4-rebase-port: 10/72] libview: Port cursor API to gtk4
- Date: Mon, 21 Mar 2022 05:37:32 +0000 (UTC)
commit 922fb8ed9ebb8e08d017b893521a8be0a15ac9b3
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date: Sat Aug 7 14:20:43 2021 +0800
libview: Port cursor API to gtk4
Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>
libview/ev-view-cursor.c | 47 ++++++++++++++++-------------------------------
libview/ev-view-cursor.h | 3 +--
2 files changed, 17 insertions(+), 33 deletions(-)
---
diff --git a/libview/ev-view-cursor.c b/libview/ev-view-cursor.c
index 58d04a27d..f6b16c864 100644
--- a/libview/ev-view-cursor.c
+++ b/libview/ev-view-cursor.c
@@ -19,37 +19,22 @@
#include "ev-view-cursor.h"
-GdkCursor *
-ev_view_cursor_new (GdkDisplay *display,
- EvViewCursor new_cursor)
-{
- GdkCursor *cursor = NULL;
+static const gchar *cursors[] = {
+ [EV_VIEW_CURSOR_NORMAL] = NULL,
+ [EV_VIEW_CURSOR_IBEAM] = "text",
+ [EV_VIEW_CURSOR_LINK] = "pointer",
+ [EV_VIEW_CURSOR_WAIT] = "wait",
+ [EV_VIEW_CURSOR_HIDDEN] = "none",
+ [EV_VIEW_CURSOR_DRAG] = "grabbing",
+ [EV_VIEW_CURSOR_AUTOSCROLL] = "move",
+ [EV_VIEW_CURSOR_ADD] = "crosshair",
+};
- switch (new_cursor) {
- case EV_VIEW_CURSOR_NORMAL:
- break;
- case EV_VIEW_CURSOR_IBEAM:
- cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
- break;
- case EV_VIEW_CURSOR_LINK:
- cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
- break;
- case EV_VIEW_CURSOR_WAIT:
- cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
- break;
- case EV_VIEW_CURSOR_HIDDEN:
- cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
- break;
- case EV_VIEW_CURSOR_DRAG:
- cursor = gdk_cursor_new_for_display (display, GDK_FLEUR);
- break;
- case EV_VIEW_CURSOR_AUTOSCROLL:
- cursor = gdk_cursor_new_for_display (display, GDK_DOUBLE_ARROW);
- break;
- case EV_VIEW_CURSOR_ADD:
- cursor = gdk_cursor_new_for_display (display, GDK_PLUS);
- break;
- }
+const gchar *
+ev_view_cursor_name (EvViewCursor cursor)
+{
+ if (cursor < sizeof (cursors) / sizeof (cursors[0]))
+ return cursors[cursor];
- return cursor;
+ return NULL;
}
diff --git a/libview/ev-view-cursor.h b/libview/ev-view-cursor.h
index 4e2e8c9ff..1a76252fd 100644
--- a/libview/ev-view-cursor.h
+++ b/libview/ev-view-cursor.h
@@ -38,7 +38,6 @@ typedef enum {
EV_VIEW_CURSOR_ADD
} EvViewCursor;
-GdkCursor *ev_view_cursor_new (GdkDisplay *display,
- EvViewCursor cursor);
+const gchar *ev_view_cursor_name (EvViewCursor cursor);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]