Index: gtk/gtkradiobutton.c
===================================================================
--- gtk/gtkradiobutton.c	(revision 17574)
+++ gtk/gtkradiobutton.c	(working copy)
@@ -32,10 +32,12 @@
 #include "gtkintl.h"
 #include "gtkalias.h"
 
+#define GTK_RADIO_BUTTON_VALUE_UNSET    (G_MAXINT - 1)
 
 enum {
   PROP_0,
-  PROP_GROUP
+  PROP_GROUP,
+  PROP_VALUE
 };
 
 
@@ -57,6 +59,7 @@ static void     gtk_radio_button_get_pro
 G_DEFINE_TYPE (GtkRadioButton, gtk_radio_button, GTK_TYPE_CHECK_BUTTON)
 
 static guint group_changed_signal = 0;
+static GQuark radio_button_value_quark = 0;
 
 static void
 gtk_radio_button_class_init (GtkRadioButtonClass *class)
@@ -73,6 +76,8 @@ gtk_radio_button_class_init (GtkRadioBut
   button_class = (GtkButtonClass*) class;
   check_button_class = (GtkCheckButtonClass*) class;
 
+  radio_button_value_quark = g_quark_from_static_string ("gtk-radio-button-value");
+
   gobject_class->set_property = gtk_radio_button_set_property;
   gobject_class->get_property = gtk_radio_button_get_property;
 
@@ -83,6 +88,25 @@ gtk_radio_button_class_init (GtkRadioBut
 							P_("The radio button whose group this widget belongs to."),
 							GTK_TYPE_RADIO_BUTTON,
 							GTK_PARAM_WRITABLE));
+  /**
+   * GtkRadioButton:value:
+   *
+   * The value is an arbitrary integer which can be used as a
+   * convenient way to determine which button in a group is
+   * currently active in a ::toggled signal handler.
+   *
+   * Since: 2.12
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_VALUE,
+                                   g_param_spec_int ("value",
+                                                     P_("Value"),
+                                                     P_("The value bound to the radio button"),
+                                                     G_MININT, G_MAXINT - 1,
+                                                     G_MAXINT - 1,
+                                                     GTK_PARAM_READWRITE));
+
+  
   object_class->destroy = gtk_radio_button_destroy;
 
   widget_class->focus = gtk_radio_button_focus;
@@ -121,6 +145,10 @@ gtk_radio_button_init (GtkRadioButton *r
   GTK_WIDGET_SET_FLAGS (radio_button, GTK_NO_WINDOW);
   GTK_WIDGET_UNSET_FLAGS (radio_button, GTK_RECEIVES_DEFAULT);
 
+  g_object_set_qdata (G_OBJECT (radio_button),
+                      radio_button_value_quark,
+                      GINT_TO_POINTER (GTK_RADIO_BUTTON_VALUE_UNSET));
+
   GTK_TOGGLE_BUTTON (radio_button)->active = TRUE;
 
   GTK_BUTTON (radio_button)->depress_on_activate = FALSE;
@@ -147,7 +175,7 @@ gtk_radio_button_set_property (GObject  
       GtkRadioButton *button;
 
     case PROP_GROUP:
-        button = g_value_get_object (value);
+      button = g_value_get_object (value);
 
       if (button)
 	slist = gtk_radio_button_get_group (button);
@@ -155,6 +183,9 @@ gtk_radio_button_set_property (GObject  
 	slist = NULL;
       gtk_radio_button_set_group (radio_button, slist);
       break;
+    case PROP_VALUE:
+      gtk_radio_button_set_value (radio_button, g_value_get_int (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -167,8 +198,13 @@ gtk_radio_button_get_property (GObject  
 			       GValue     *value,
 			       GParamSpec *pspec)
 {
+  GtkRadioButton *radio_button = GTK_RADIO_BUTTON (object);
+
   switch (prop_id)
     {
+    case PROP_VALUE:
+      g_value_set_int (value, gtk_radio_button_get_value (radio_button));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -742,5 +778,61 @@ gtk_radio_button_draw_indicator (GtkChec
     }
 }
 
+/**
+ * gtk_radio_button_get_value:
+ * @radio_button: a #GtkRadioButton
+ *
+ * Retrieve the value property of the @radio_button set using
+ * gtk_radio_button_set_value. If no value was set, the position
+ * of @radio_button in the radio button group is returned.
+ *
+ * Return value: the value property of the radio button
+ *
+ * Since: 2.12
+ */
+gint
+gtk_radio_button_get_value (GtkRadioButton *radio_button)
+{
+  gint retval;
+
+  g_return_val_if_fail (GTK_IS_RADIO_BUTTON (radio_button), 0);
+
+  retval = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (radio_button),
+                                                radio_button_value_quark));
+  
+  if (retval == GTK_RADIO_BUTTON_VALUE_UNSET)
+    retval = g_slist_index (radio_button->group, radio_button);
+
+  return retval;
+}
+
+/**
+ * gtk_radio_button_set_value:
+ * @radio_button: a #GtkRadioButton
+ * @value: the value bound to the radio button
+ *
+ * Set the value bound to the radio button. The value is an arbitrary
+ * integer which can be used as a convenient way to determine which
+ * radio button in a group is currently active in an ::toggled signal
+ * handler.
+ *
+ * Since: 2.12
+ */
+void
+gtk_radio_button_set_value (GtkRadioButton *radio_button,
+                            gint            value)
+{
+  g_return_if_fail (GTK_IS_RADIO_BUTTON (radio_button));
+
+  g_object_ref (radio_button);
+
+  g_object_set_qdata (G_OBJECT (radio_button),
+                      radio_button_value_quark,
+                      GINT_TO_POINTER (value));
+
+  g_object_notify (G_OBJECT (radio_button), "value");
+  g_object_unref (radio_button);
+}
+
 #define __GTK_RADIO_BUTTON_C__
 #include "gtkaliasdef.c"
Index: gtk/gtkradiobutton.h
===================================================================
--- gtk/gtkradiobutton.h	(revision 17574)
+++ gtk/gtkradiobutton.h	(working copy)
@@ -41,7 +41,6 @@ G_BEGIN_DECLS
 #define GTK_IS_RADIO_BUTTON_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RADIO_BUTTON))
 #define GTK_RADIO_BUTTON_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RADIO_BUTTON, GtkRadioButtonClass))
 
-
 typedef struct _GtkRadioButton	     GtkRadioButton;
 typedef struct _GtkRadioButtonClass  GtkRadioButtonClass;
 
@@ -81,6 +80,9 @@ GtkWidget* gtk_radio_button_new_with_mne
 GSList*    gtk_radio_button_get_group                     (GtkRadioButton *radio_button);
 void       gtk_radio_button_set_group                     (GtkRadioButton *radio_button,
                                                            GSList         *group);
+gint       gtk_radio_button_get_value                     (GtkRadioButton *radio_button);
+void       gtk_radio_button_set_value                     (GtkRadioButton *radio_button,
+                                                           gint            value);
 
 #ifndef GTK_DISABLE_DEPRECATED
 #define gtk_radio_button_group gtk_radio_button_get_group
Index: tests/testgtk.c
===================================================================
--- tests/testgtk.c	(revision 17574)
+++ tests/testgtk.c	(working copy)
@@ -968,6 +968,26 @@ create_check_buttons (GtkWidget *widget)
  * GtkRadioButton
  */
 
+enum {
+  RADIO_1 =  0,
+  RADIO_2 = 10,
+  RADIO_3 = 20,
+  RADIO_4 = 30,
+  RADIO_5 = 40,
+  RADIO_6 = 42
+};
+
+static void
+radio_toggled_cb (GtkToggleButton *toggle_button,
+                  gpointer         user_data)
+{
+  GtkRadioButton *radio_button = GTK_RADIO_BUTTON (toggle_button);
+
+  g_print ("Radio button (value:%d) toggled (active:%s)\n",
+           gtk_radio_button_get_value (radio_button),
+           gtk_toggle_button_get_active (toggle_button) ? "yes" : "no");
+}
+
 static void
 create_radio_buttons (GtkWidget *widget)
 {
@@ -1003,17 +1023,23 @@ create_radio_buttons (GtkWidget *widget)
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (NULL, "button1");
+      gtk_radio_button_set_value (GTK_RADIO_BUTTON (button), RADIO_1);
+      g_signal_connect (button, "toggled", G_CALLBACK (radio_toggled_cb), NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (
 	         gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
 		 "button2");
+      gtk_radio_button_set_value (GTK_RADIO_BUTTON (button), RADIO_2);
       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+      g_signal_connect (button, "toggled", G_CALLBACK (radio_toggled_cb), NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (
                  gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
 		 "button3");
+      gtk_radio_button_set_value (GTK_RADIO_BUTTON (button), RADIO_3);
+      g_signal_connect (button, "toggled", G_CALLBACK (radio_toggled_cb), NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (
@@ -1030,20 +1056,26 @@ create_radio_buttons (GtkWidget *widget)
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (NULL, "button4");
+      gtk_radio_button_set_value (GTK_RADIO_BUTTON (button), RADIO_4);
       gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      g_signal_connect (button, "toggled", G_CALLBACK (radio_toggled_cb), NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (
 	         gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
 		 "button5");
+      gtk_radio_button_set_value (GTK_RADIO_BUTTON (button), RADIO_5);
       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
       gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      g_signal_connect (button, "toggled", G_CALLBACK (radio_toggled_cb), NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       button = gtk_radio_button_new_with_label (
                  gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
 		 "button6");
+      gtk_radio_button_set_value (GTK_RADIO_BUTTON (button), RADIO_6);
       gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
+      g_signal_connect (button, "toggled", G_CALLBACK (radio_toggled_cb), NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
       separator = gtk_hseparator_new ();
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17574)
+++ ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2007-04-01  Emmanuele Bassi  <ebassi@gnome.org>
+
+	* gtk/gtkradiobutton.[ch]: Add an API to set and get an arbitrary
+	integer for each individual radio button in a group, similarly to
+	what GtkRadioAction does; check the value in the ::toggled signal
+	handler to know which radio button was toggled. (#166995)
+
+	* tests/testgtk.c (create_radio_buttons): Test the newly added
+	API.
+
 2007-03-31  Elijah Newren  <newren gmail com>
 
 	* gdk/x11/gdkwindow-x11.c (setup_toplevel_window,
