Re: Delay displaying text in a clist
- From: Markus Lausser <sgop users sourceforge net>
- To: Thomas Keaney <se40319 cs may ie>
- Cc: gtk mailing list <gtk-app-devel-list gnome org>
- Subject: Re: Delay displaying text in a clist
- Date: 02 Feb 2004 22:56:24 +0100
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]