Displaying intermediate button images.
- From: Rich Burridge <Rich Burridge Sun COM>
- To: gtk-app-devel-list gnome org
- Subject: Displaying intermediate button images.
- Date: Mon, 26 Sep 2005 13:39:08 -0700
Hi all,
Could somebody please tell me what I'm missing here?
Below I've included a small program that hopefully
replicates the problem I'm seeing. The real problem
is in a much larger program. I've just tried to isolate
it here, and to make it as simple as possible.
I have a button. When it's clicked, I want to toggle
the image that's displayed as the label on the button.
I want to toggle it four times, pausing for half a
second between each toggle. The trouble is only the
final image is being shown.
The example below is similar, except it's using text
labels instead of images. Hopefully it's a similar
problem.
What do I need to do to make the intermediate images
appear?
Thanks.
------CUT HERE------CUT HERE------
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
void
reve_sleep(unsigned x) /* Suspend execution for interval in microseconds. */
{
struct timeval st_delay;
st_delay.tv_usec = x;
st_delay.tv_sec = 0;
select(32, NULL, NULL, NULL, &st_delay);
}
void
on_click(GtkButton *button, gpointer user_data)
{
gtk_button_set_label(button, "On");
reve_sleep(500000);
gtk_button_set_label(button, "Off");
reve_sleep(500000);
gtk_button_set_label(button, "On");
reve_sleep(500000);
gtk_button_set_label(button, "Off");
}
GtkWidget*
create_window (void)
{
GtkWidget *window;
GtkWidget *button;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_mnemonic("Off");
gtk_widget_show(button);
gtk_container_add(GTK_CONTAINER(window), button);
g_signal_connect((gpointer) button, "clicked", G_CALLBACK(on_click), NULL);
return(window);
}
int
main(int argc, char *argv[])
{
GtkWidget *window;
gtk_set_locale();
gtk_init(&argc, &argv);
window = create_window();
gtk_widget_show(window);
gtk_main();
return(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]