Karl,

Gtk::Window::get_window() will return a null reference if the Gtk::Window 
widget hasn't got a Gdk::Window at the time.  I think this is the problem you 
are experiencing.  Some widgets don't have their own Gdk::Window ever (look at 
the reference doco for Gtk::Misc).  A widget must be "realize"d to have a 
Gdk::Window.

You have some options:
1.  Connect to the signal signal_realize() and make your cursor change there.
2. Create your own widget derived form Gtk::Window and implement your own 
on_realize().  Remember to call the super class's on_realize() in your own 
implementation before you expect there to be a Gdk::Window.
3. Two is enough for now - if neither is what you want then ask again.

If I understand things correctly and assuming you're using X, setting the 
cursor actually results in telling the X server to change the cursor to display 
when the pointer is "in" that window (X window).  This means that if there is a 
really slow connection between the client (your application) and the X server 
(e.g. ssh tunnel over a wide network) then you still get the correct cursor 
displayed over your window immediately.

Regards,
Clive


----- Original Message ----
From: Karl Schmitt <[EMAIL PROTECTED]>
To: John Hobbs <[EMAIL PROTECTED]>
Cc: [email protected]
Sent: Thursday, 12 June, 2008 10:03:57 PM
Subject: Re: Howto change a cursor for Gtk::Window ?

Dear John,

thanks for the code snipped,
it was really helpful. I copied
it to my small sample windows application
and the ref_window "pointer" is null?:

12              window.set_default_size(800,600);
(gdb) n
16              Glib::RefPtr <Gdk::Window> ref_window;
(gdb) n
18              ref_window = window.get_window();
(gdb) n
20              Gdk::Cursor m_Cursor (Gdk::WATCH);
(gdb) p ref_window
$2 = {pCppObject_ = 0x0}
(gdb) 

... and my application dies.
I guess I do need to do more, or I do something terribly wrong :-)
I moved the code into my window constructor but it did not help either.
Any idea ?

Karl



On Wed, Jun 11, 2008 at 7:38 PM, John Hobbs <[EMAIL PROTECTED]> wrote:

Following up on Paul's message, you usually have to get the parent
Gtk::Windows Gdk::Window.

This is what I use.

Glib::RefPtr <Gdk::Window> ref_window;

ref_window = get_window();
Gdk::Cursor m_Cursor (Gdk::WATCH);
ref_window->set_cursor(m_Cursor);
while (Gtk::Main::events_pending ())
   Gtk::Main::iteration ();

... do busy stuff ...

ref_window->set_cursor ();
while (Gtk::Main::events_pending ())
   Gtk::Main::iteration ();


Don't know if that's something you already had or not :-)

- John Hobbs



On Wed, Jun 11, 2008 at 10:06 AM, Paul Davis <[EMAIL PROTECTED]> wrote:
>
> On Wed, 2008-06-11 at 14:41 +0200, Karl Schmitt wrote:
>> Hi,
>>
>> I am fairly new to gtkmm and GTK+.
>>
>> I have trouble figuring out how to change
>> the gtkmm Window cursor (Gtk::Window) ...
>>
>> However, I found out that I can change
>> the cursor of a Gdk::Window using
>> a Gdk::Cursor object. Is there something
>> similar for a Gtk::Window.
>>
>> By the way, what's the difference of a Gtk::Window
>> and a Gdk::Window?
>
> Gdk::Window is an abstraction around the low level window object offered
> by the backend GUI system (X11, Quartz/Cocoa, GDI, DirectFB and more).
>
> Gtk::Window is a fully-fledged widget representing a window.
>
> Some widgets have their own Gdk::Window, many do not. The ones that do
> not draw into the Gdk::Window of their parent (or its parent, etc).
>
>
>
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>

Send instant messages to your online friends http://au.messenger.yahoo.com 
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to