GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 30, 2014 5:54 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How To Change The GTK Cursor
PostPosted: Fri Jan 18, 2013 5:21 am 
Offline

Joined: Wed Jan 16, 2013 11:50 pm
Posts: 4
Gentle People:

I would like to change the GTK Cursor in the gtk+-2.0 / Cairo
Environment .

After Google searching I found the following as pretty much
as repeating example!

Problem is it dosen't work. See error message below:

What am I doing wrong here?

gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GdkCursor *Cursor;
Cursor = gdk_cursor_new(GDK_WATCH);
gdk_window_set_cursor ((GTK_WIDGET(window)->window), Cursor);

And I get the following error message:
(TA_Bench.sun:1622): Gdk-CRITICAL **: gdk_window_set_cursor: assertion `GDK_IS_WINDOW (window)' failed


Top
 Profile  
 
 Post subject: Re: How To Change The GTK Cursor
PostPosted: Fri Jan 18, 2013 7:58 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 750
Location: UK
Hi,

If you are using GTK+ 2.14 or later please use :-
Code:
GdkWindow *         gtk_widget_get_window               (GtkWidget *widget);
instead of using the internal member of the structure of the GtkWindow.

The reason the function gdk_window_set_cursor () has failed is that the window has not been realised. You would need to wait for the window to be displayed before the cursor can be changed. The best way is to use g_idle_add () or g_idle_add_full () and the call gdk_window_set_cursor () from there.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group