Re: Cursor and Progressbar



Filipe Bonjour wrote:
> I have a "Connect" button, and in its callback for "clicked" I call
> gdk_window_set_cursor(GDK_WATCH), then call another function to perform
> some tasks, and when this returns I call
> gdk_window_set_cursor(GDK_LEFT_PTR) to return to the normal cursor. What
> I hoped would happen was of course that while the function was
> performing its tasks the cursor would turn into the watch, and would
> revert afterwards. What actually happens is that after the function
> returns the app changes to the watch and immediately back to the normal
> cursor.

Hi Filipe, this is an X thing.

X does a lot of buffering. When you make a request (either directly or through
gdk), it is not sent directly, instead it is added to a queue inside your
program. It is only sent to the display when the queue fills, or when you make a
request that needs a response.

This usually works fine ... occasionally you need to give it a nudge to tell it
to flush the queue immediately:

	gdk_flush();

should do it.

> The second problem is sort of similar. The "function" I mentioned above
> loads a bunch of data from a database, and displays it in a GtkCList. So
> I thought that each time the function called gtk_clist_append I could
> also update the appbar progresbar. What actually happens is that when
> all the data is loaded the progressbar goes straight (or very quickly)
> to 1.0.

Repaints are done in gtk's main loop when your program is idle. You need to
force the main loop to run:

	while (g_main_iteration(FALSE))
		;

There are a couple of things to be careful of: don't call this too often or your
load will run very slowly, and look out for nested loads. For example, all of
your menus will still be active if you call this repeatedly, so a user could
(potentially) click on load while your load was running. An easy solution is to
pop up a modal window with a progress bar and a cancel button.

John




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