Re: [gtk-list] Problem with changing cursor; can you help, please?



Oliver Elphick wrote:
> 
> I am trying to find out how to change the cursor style, but I have not
> yet found out how to do it successfully.
> 
> I generated a small program with glade, that has only a top-level window
> containing a button.  The callback for the button is shown below.
> 
> When I run this, and click the button, I get:
> 
> Gdk-ERROR **: BadCursor (invalid Cursor parameter)
>   serial 194 error_code 6 request_code 2 minor_code 0
> 
> I can't relate any of these numbers to anything I have done.
> 
> ============================= callbacks.c =============================
> 
> #ifdef HAVE_CONFIG_H
> #  include <config.h>
> #endif
> 
> #include <gtk/gtk.h>
> #include <gdk/gdk.h>
> 
> #include "callbacks.h"
> #include "interface.h"
> #include "support.h"
> 
> static int cursorno = GDK_HAND1;
> 
> void
> on_button1_clicked                     (GtkButton       *button,
>                                         gpointer         user_data)
> {
>         GdkCursor cursorstruct;
>         GdkWindow *w;
> 
>         switch (cursorno) {
>             case GDK_ARROW:
>                 cursorno = GDK_DIAMOND_CROSS;
>                 break;
>             case GDK_DIAMOND_CROSS:
>                 cursorno = GDK_HAND1;
>                 break;
>             case GDK_HAND1:
>                 cursorno = GDK_ARROW;
>                 break;
>         };
> 
> 
>         cursorstruct.type = cursorno;
> 
>         w = button->bin.container.widget.window;
>         gdk_window_set_cursor(w, &cursorstruct);

You need to do gdk_cursor_new (cursorno) to create the cursor,
then gdk_window_set_cursor().

You may want to create all the cursors you need in the main()
function rather than recreating them each time.

Damon




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