Re: Mouse Pointer



Antony Stace <antony claire co jp> writes: 
> [snip]
> GtkWidget *switchW;
> GdkCursor*  TelCursor = gdk_cursor_new(GDK_HAND2); 
> switchW = gtk_window_new (GTK_WINDOW_POPUP);  
> gdk_window_set_cursor(switchW->window, TelCursor);
> [snip]
> 
> 
> and here is the error
> oakura:/home/kermit> /tmp/switch.x
> 
> Gdk-CRITICAL **: file gdkwindow.c: line 1274
> (gdk_window_set_cursor): assertion `window != NULL' failed.
> 

You need to wait for the window to be realized. Since realization can
happen more than once I would simply gtk_signal_connect_after() to the
realize signal on the window, and set the cursor there.

So:

void
my_realize_cb (GtkWidget *widget, gpionter user_data)
{
  GdkCursor *cursor;

  cursor = gdk_cursor_new (GDK_HAND2);
  gdk_window_set_cursor (widget->window, cursor);
  gdk_cursor_destroy (cursor);
}

gtk_signal_connect_after (GTK_OBJECT (widget), "realize", 
                          GTK_SIGNAL_FUNC (my_realize_cb), NULL);

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]