Re: Delay displaying text in a clist
- From: "Thomas Keaney" <se40319 cs may ie>
- To: "Markus Lausser" <sgop users sourceforge net>
- Cc: <gtk-app-devel-list gnome org>
- Subject: Re: Delay displaying text in a clist
- Date: Tue, 3 Feb 2004 13:33:24 -0000
Thanks for the code, but I am having a probelm with it at the moment.
Instead of displaying the message once after a three seconds it keeps
displaying it continuosly every three seconds. How would I overcome this?
Regards,
Thomas Keaney
4 CSSE
----- Original Message -----
From: "Markus Lausser" <sgop users sourceforge net>
To: "Thomas Keaney" <se40319 cs may ie>
Cc: "gtk mailing list" <gtk-app-devel-list gnome org>
Sent: Monday, February 02, 2004 9:56 PM
Subject: Re: Delay displaying text in a clist
On Mon, 2004-02-02 at 21:07, Thomas Keaney wrote:
Hi,
Im using the clist and I want to delay displaying the text for a
moment. That is when I click on a button I want a message to be
displayed. I want this message to be displayed for a few seconds
before another message will be displayed without clicking on the
button. (Click Button ->Message1 with delay -> Message2 ) Thanks in
advance.
In gtk+-2.x:
--------------------------------
static int Timer = 0;
static void on_button_clicked(GtkButton* button, GtkCList* clist);
static void display_text(GtkCList* clist, const char* text);
static gboolean timer_func(GtkCList* clist);
int main (void) {
...
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(on_button_clicked), clist);
...
return 0;
}
static void on_button_clicked(GtkButton* button, GtkCList* clist) {
const char* text;
text = get_text_to_display_somehow();
display_text(clist, text);
}
static void display_text(GtkCList* clist, const char* text) {
// maybe the next line doesnt work because of text being const.
gtk_clist_append(clist, &text);
if (Timer) g_source_remove(Timer);
Timer =
g_timeout_add(1000*some_seconds, (GSourceFunc)timer_func, clist);
}
static gboolean timer_func(GtkCList* clist) {
display_text(clist, "some other text");
Timer = 0;
return FALSE;
}
--------------------------------
Same in gtk+-1.2, with slightly modified function names
(gtk_signal_connect, etc.).
Markus.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]