Re: setting the wait mouse cursor during a longer load operation (solved)



to finish the discussion - here is the final code:

// it is not nice to access the *private* member of the window, butthere is
currently no other way
GdkWindow *window=GTK_WIDGET(self->private->main_window)->window;
GdkCursor *cursor=gdk_cursor_new(GDK_WATCH);

// set wait curosr and gray-out window
gdk_window_set_cursor(window,NULL);
gdk_cursor_unref(cursor)
gtk_widget_set_sensitive(GTK_WIDGET(self->private->main_window),TRUE);

// do loading ...

// restor the cursor and enable the window
gdk_window_set_cursor(window,NULL);
gtk_widget_set_sensitive(GTK_WIDGET(self->private->main_window),TRUE);


Ciao
  Stefan

Stefan Kost wrote:
Hi Allin,

I've found it out! Using gdk_window_set cursor is perfectly okay (better that
gdk_pointer_grab in my case - that sets the wait-cursor for the whole screen).

My error was using g_object_unref() onto the cursor object, where instead I
should have used  gdk_cursor_unref().
Btw. gdk_cursor_destroy(plswait); is deprecated ;-)

Still it is not nice that there is no method to acces the window field of a
GtkWidget (like gtk_widget_get_window()). I'll ask on the gtk-devel list about that.

Stefan

Allin Cottrell wrote:

On Sat, 25 Sep 2004, Stefan Kost wrote:


when loading a long file I would like to disabled events for the
main-window and set a wait mouse-coursor for it.


Here's what I do:

if (whatever) {
   GdkCursor *plswait;

   plswait = gdk_cursor_new(GDK_WATCH);
   gdk_pointer_grab(mywindow, TRUE,
            GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
            GDK_BUTTON_RELEASE_MASK,
            NULL, plswait,
            GDK_CURRENT_TIME);
   gdk_cursor_destroy(plswait);

   /* do whatever needs to be done, then... */

   gdk_pointer_ungrab(GDK_CURRENT_TIME);
}

Allin Cottrell




------------------------------------------------------------------------

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -


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