1 /*
2  * cursors.c
3  *
4  *
5  * Author:
6  *  Richard Hult <rhult@hem.passagen.se>
7  *  Ricardo Markiewicz <rmarkie@fi.uba.ar>
8  *  Andres de Barbara <adebarbara@fi.uba.ar>
9  *  Marc Lorber <lorber.marc@wanadoo.fr>
10  *
11  * Web page: https://ahoi.io/project/oregano
12  *
13  * Copyright (C) 1999-2001  Richard Hult
14  * Copyright (C) 2003,2006  Ricardo Markiewicz
15  * Copyright (C) 2009-2012  Marc Lorber
16  *
17  * This program is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU General Public License as
19  * published by the Free Software Foundation; either version 2 of the
20  * License, or (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  * General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public
28  * License along with this program; if not, write to the
29  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
30  * Boston, MA 02110-1301, USA.
31  */
32 
33 #include "cursors.h"
34 #include "debug.h"
35 
36 OreganoCursor oregano_cursors[] = {
37     {NULL, GDK_LEFT_PTR}, {NULL, GDK_TCROSS}, {NULL, GDK_PENCIL}, {NULL, GDK_XTERM}, {NULL, -1}};
38 
cursors_init(void)39 void cursors_init (void)
40 {
41 	int i;
42 	GdkDisplay *display;
43 
44 	display = gdk_display_get_default ();
45 
46 	for (i = 0; oregano_cursors[i].type != -1; i++) {
47 		oregano_cursors[i].cursor = gdk_cursor_new_for_display (display, oregano_cursors[i].type);
48 	}
49 }
50 
cursors_shutdown(void)51 void cursors_shutdown (void)
52 {
53 	int i;
54 
55 	for (i = 0; oregano_cursors[i].type != -1; i++) {
56 		if (oregano_cursors[i].cursor)
57 			g_object_unref (oregano_cursors[i].cursor);
58 	}
59 }
60 
cursor_set_widget(GtkWidget * w,int name)61 void cursor_set_widget (GtkWidget *w, int name)
62 {
63 	if (gtk_widget_get_window (w))
64 		gdk_window_set_cursor (gtk_widget_get_window (w), oregano_cursors[name].cursor);
65 }
66