Re: About Radio Button?
- From: Guy Harris <gharris flashcom net>
- To: id072647 belgacom be
- Cc: gtk-list gnome org
- Subject: Re: About Radio Button?
- Date: Mon, 19 Jun 2000 20:39:14 -0700
On Mon, Jun 19, 2000 at 03:56:11PM +0200, id072647@belgacom.be wrote:
> Thanks but I'm not gay :)
If I remember correctly, he's from Saudi Arabia, and English may not be
his first language; he probably meant to say "Hi guys" when he said "Hi
gays".
As for his original question:
> If I have a group buttons and I want to check which one of them was selected
> to programming against the slected one. What is the function or method to
> do this processing..
If by "a group [of] buttons" he's referring to a collection of radio
buttons, as I presume he is (give the subject line of his message), at
least one way of doing it is to check each of them to see if its
"active" member is set, e.g. if "button" is a "GtkWidget *" for one of
those buttons, check "GTK_TOGGLE_BUTTON(button)->active".
In the application where I've used radio buttons (Ethereal), we've
"attached" the buttons to the "OK" button in a dialog box by using
"gtk_object_set_data()" to set the data pointers for the dialog box
window, with various keys, to point to the appropriate radio buttons in
the dialog box, and in the callback for the "OK" button, doing things
such as:
static void
display_opt_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
GtkWidget *button;
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_TIME_ABS_KEY);
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = ABSOLUTE;
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_TIME_REL_KEY);
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = RELATIVE;
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_TIME_DELTA_KEY);
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = DELTA;
...
where E_DISPLAY_TIME_ABS_KEY and so on are strings we gave distinct
values (any values will do, as long as they're distinct). (Those three
buttons are part of a group to let you select whether to display time
stamps for packets as absolute date/time values, times relative to the
first packet in a packet capture, or times relative to the previous
packet in the display.)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]