Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the cursor to a watch in GTK for C?

I'm using the C-style GTK functions in C++ and I can't figure out how to set the cursor for the main window.

like image 626
Erwin J. Avatar asked Nov 30 '22 06:11

Erwin J.


2 Answers

Use gdk_window_set_cursor() on a GdkCursor created by gdk_cursor_new_from_name().

To get the GdkWindow of a GtkWindow you can use gtk_widget_get_window() because GtkWindow is a subclass of GtkWidget.

Note: this answer is an improvement over idefixs answer (important correction + link update + minor modification to make the answer complete + improved formatting) that was rejected as an edit.

like image 35
silviubogan Avatar answered Dec 09 '22 18:12

silviubogan


Use gdk_set_cursor()

(https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-set-cursor)

on a GdkCursor created by gdk_cursor_new()

(https://developer.gnome.org/gdk3/stable/gdk3-Cursors.html)

like image 55
idefixs Avatar answered Dec 09 '22 18:12

idefixs