Re: [gtk-list] Dumb question: How do I get the radio buttons in a group?



Jason Bodnar wrote:
> 
> I must be missing something. I read the docs, tutorial and FAQ but there does
> not seem to be any documentation on how to get the list of radio buttons in a
> radio button group.

As a beginner, I'm glad to be able to help you with this problem.  I
also encountered it during my programming, and here's something that
might help you...

 GSList *group = NULL;  // First you create a group

 radio1 = gtk_radio_button_new_with_label (group, "Foo");	// then you
make your new radio button
								// belonging to that group
 gtk_box_pack_start (GTK_BOX (vbox), radio1, FALSE, FALSE, 0);	// I
always put my radio buttons from
								// one group in a vbox
 group = gtk_radio_button_group(GTK_RADIO_BUTTON (radio1));	// then
group should get the value of
								// the group where radio1 belongs to
 
 radio2 = gtk_radio_button_new_with_label (group, "Bar");		// new
radiobutton for group
 gtk_box_pack_start (GTK_BOX (vbox), radio2, FALSE, FALSE, 0);	// put in
same vbox
 group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio2));		// and so
on, and so on...

> Also, how do I determine if a radio button is selected or not?

Are you sure you read the tutorial ? ;-)
Here's how it's done (suppose toggle_button_callback is the function
that should do the action depending on wheter the button is toggled or
not):

void toggle_button_callback (GtkWidget *widget, gpointer data)
{
  if (GTK_TOGGLE_BUTTON (widget->active))
   { 
 	/* If control reaches here, the toggle button is down */
   }
  else
   {
	/* If control reaches here, the toggle button is up */
    }
}

This is also in the postscript versoin of the GTK v1.2 tutorial on page
42 ;-)

Greetzzz
MC303

-- 
Bart Vandewoestyne		http://hello.to/MC303		
Hugo Verrieststraat 48		Bart.Vandewoestyne@skynet.be
8550 ZWEVEGEM			ICQ# 21275340
BELGIUM - EUROPE		nick: MC303
Phone: +32(0)56/75.48.11
-------------------------------------------------------------------
If carpenters made buildings the way programmers make programs, the 
first woodpecker to come along would destroy all of civilization.
				- Weinberg's Second Law -



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]