Re: activating a button
- From: Jonathan Blandford <jrb redhat com>
- To: "Chandrashekhar V. Joshi" <cvj telco co in>
- Cc: Davina Armstrong <davina lickey com>, gtk-app-devel-list gnome org
- Subject: Re: activating a button
- Date: 01 Nov 2000 02:04:14 -0500
"Chandrashekhar V. Joshi" <cvj telco co in> writes:
oh yes. actually u can emit a button_press and button_release signal
but following should work except that queue_draw may not update
your ui as u are in the event dispatch thread till ur function
completes
gtk_widget_set_state (GTK_WIDGET (button), GTK_STATE_NORMAL);
gtk_widget_queue_draw (GTK_WIDGET (button));
// ur implementation here
gtk_widget_set_state (GTK_WIDGET (button), GTK_STATE_NORMAL);
gtk_widget_queue_draw (GTK_WIDGET (button));
That won't work either. If you really want to get the appearance of a
button pressed, you'll want to do something like the below. However, I
really don't recommend it, as it's not the GTK+ way of doing things, and
will look odd. Just closing the dialog box makes more sense.
#include <gtk/gtk.h>
static gint
timeout (GtkWidget *button)
{
gtk_button_clicked (GTK_BUTTON (button));
gtk_button_released (GTK_BUTTON (button));
return FALSE;
}
static void
activate_cb (GtkWidget *entry, GtkWidget *button)
{
gtk_button_pressed (GTK_BUTTON (button));
gtk_widget_set_state (button, GTK_STATE_ACTIVE);
gtk_timeout_add (500, (GtkFunction) timeout, button);
}
static void
clicked_cb (GtkWidget *button1, GtkWidget *button)
{
g_print ("clicked!\n");
}
int
main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *entry;
GtkWidget *button;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_vbox_new (FALSE, 10);
gtk_container_add (GTK_CONTAINER (window), vbox);
entry = gtk_entry_new ();
button = gtk_button_new_with_label ("button 2");
gtk_box_pack_start_defaults (GTK_BOX (vbox), entry);
gtk_box_pack_start_defaults (GTK_BOX (vbox), button);
gtk_signal_connect (GTK_OBJECT (entry), "activate", activate_cb, button);
gtk_signal_connect (GTK_OBJECT (button), "clicked", clicked_cb, NULL);
gtk_widget_show_all (window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]