Re: repainting GtkTextView
- From: Olexiy Avramchenko <ath beast stu cn ua>
- To: Harring Figueiredo <harringf yahoo com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: repainting GtkTextView
- Date: Thu, 19 Sep 2002 18:41:08 +0300
Harring Figueiredo wrote:
Thanks for the reply --
The code is already on a timeout_add call. Here is what I am doing.
/* prototype */
timeout_callback (...) /* called every 10 sec or set by user */
{
while(open(file) == NULL)
{
/* can not open file on stupid windows 2K --locked by pther process*/
log_to_text_view_widget( " File is locked ..."); <== This does not
happen.
sleep(1) ; /* wait to see if other proc closes the file */
if( loop > 10 ) break; /* give up for now and come back later on
timeout. */
}
/* when we reach here, the 10 messages from log_to_text_view_widget() shows altogether. */
}
As I understand, the ugly code below will do what you want without blocking,
so all messages will appear at the screen:
---
static int callback_tries=0;
static guint timeout_id=0;
static void lpntcfn_timeout_callback(...)
{
if (open(file) == NULL) { /* heh, where's good old -1 instead of
NULL ?;) */
log_to_text_view_widget("File is locked ...");
/* no blocking sleep here, timeout will be called after ~1 sec by
gtk */
}
else {
/* we're happy - file isn't locked, making our job */
}
if (++callback_tries >= 10) {
timeout_id = 0;
return FALSE; /* we tried 10 times, just killing this callback */
}
return TRUE;
}
void somewhere_in_win32_code(...)
{
if (timeout_id)
gtk_timeout_remove(timeout_id);
callback_tries = 0;
timeout_id = gtk_timeout_add(1000,
(GtkFunction)lpntcfn_timeout_callback, ...);
}
---
PS: "lpntcfn" hungarian notation here means: Long Pointer to my Nice
Timeout Callback FuNction.
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]