805fce6c970ab026c005595dd9a50781bc51f092
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 2c79635..f28b903 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2953,12 +2953,16 @@ gtk_radio_action_set_group
 #if IN_FILE(__GTK_RADIO_BUTTON_C__)
 gtk_radio_button_get_group
 gtk_radio_button_get_type G_GNUC_CONST
+gtk_radio_button_get_current_value
+gtk_radio_button_get_value
 gtk_radio_button_new
 gtk_radio_button_new_from_widget
 gtk_radio_button_new_with_label
 gtk_radio_button_new_with_label_from_widget
 gtk_radio_button_new_with_mnemonic
 gtk_radio_button_new_with_mnemonic_from_widget
+gtk_radio_button_new_with_value
+gtk_radio_button_new_with_value_from_widget
 gtk_radio_button_set_group
 #endif
 #endif
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index b4de838..acbd36f 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -32,13 +32,16 @@
 #include "gtkintl.h"
 #include "gtkalias.h"
 
+#define GTK_RADIO_BUTTON_VALUE_UNSET    (0)
+
+typedef struct _GtkRadioButtonPrivate   GtkRadioButtonPrivate;
 
 enum {
   PROP_0,
-  PROP_GROUP
+  PROP_GROUP,
+  PROP_VALUE
 };
 
-
 static void     gtk_radio_button_destroy        (GtkObject           *object);
 static gboolean gtk_radio_button_focus          (GtkWidget           *widget,
 						 GtkDirectionType     direction);
@@ -53,10 +56,13 @@ static void     gtk_radio_button_get_property   (GObject             *object,
 						 guint                prop_id,
 						 GValue              *value,
 						 GParamSpec          *pspec);
+static void     gtk_radio_button_set_value      (GtkRadioButton      *radio_button,
+                                                 gint                 value);
 
 G_DEFINE_TYPE (GtkRadioButton, gtk_radio_button, GTK_TYPE_CHECK_BUTTON)
 
 static guint group_changed_signal = 0;
+static GQuark quark_value = 0;
 
 static void
 gtk_radio_button_class_init (GtkRadioButtonClass *class)
@@ -73,6 +79,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
   button_class = (GtkButtonClass*) class;
   check_button_class = (GtkCheckButtonClass*) class;
 
+  quark_value = 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 +91,25 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
 							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,
+                                                     GTK_RADIO_BUTTON_VALUE_UNSET,
+                                                     G_PARAM_CONSTRUCT_ONLY | GTK_PARAM_READWRITE));
+
+  
   object_class->destroy = gtk_radio_button_destroy;
 
   widget_class->focus = gtk_radio_button_focus;
@@ -129,6 +156,10 @@ gtk_radio_button_init (GtkRadioButton *radio_button)
 
   _gtk_button_set_depressed (GTK_BUTTON (radio_button), TRUE);
   gtk_widget_set_state (GTK_WIDGET (radio_button), GTK_STATE_ACTIVE);
+
+  g_object_set_qdata (G_OBJECT (radio_button),
+                      quark_value,
+                      GINT_TO_POINTER (GTK_RADIO_BUTTON_VALUE_UNSET));
 }
 
 static void
@@ -147,7 +178,7 @@ gtk_radio_button_set_property (GObject      *object,
       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 +186,9 @@ gtk_radio_button_set_property (GObject      *object,
 	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 +201,13 @@ gtk_radio_button_get_property (GObject    *object,
 			       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;
@@ -341,6 +380,62 @@ gtk_radio_button_new_with_mnemonic_from_widget (GtkRadioButton *group,
   return gtk_radio_button_new_with_mnemonic (l, label);
 }
 
+/**
+ * gtk_radio_button_new_with_value:
+ * @group: the radio button group
+ * @value: an arbitrary integer
+ *
+ * Creates a new #GtkRadioButton adding it to @group. Sets @value
+ * as the value that should be returned by gtk_radio_button_get_value()
+ * and gtk_radio_button_get_current_value().
+ *
+ * Return value: a new #GtkRadioButton
+ *
+ * Since: 2.12
+ */
+GtkWidget *
+gtk_radio_button_new_with_value (GSList *group,
+                                 gint    value)
+{
+  GtkWidget *radio_button;
+
+  radio_button = g_object_new (GTK_TYPE_RADIO_BUTTON,
+                               "value", value,
+                               NULL);
+
+  if (group)
+    gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_button), group);
+
+  return radio_button;
+}
+
+/**
+ * gtk_radio_button_new_with_value_from_widget:
+ * @group: widget to get radio group from or %NULL
+ * @value: an arbitrary integer
+ *
+ * Creates a new #GtkRadioButton and adds it to the same group as
+ * @group. Sets @value as the value that should be returned by
+ * gtk_radio_button_get_value() and gtk_radio_button_get_current_value().
+ *
+ * Return value: a new #GtkRadioButton
+ *
+ * Since: 2.12
+ */
+GtkWidget *
+gtk_radio_button_new_with_value_from_widget (GtkRadioButton *group,
+                                             gint            value)
+{
+  GSList *l = NULL;
+
+  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_BUTTON (group), NULL);
+
+  if (group)
+    l = gtk_radio_button_get_group (group);
+
+  return gtk_radio_button_new_with_value (l, value);
+}
+
 GSList*
 gtk_radio_button_get_group (GtkRadioButton *radio_button)
 {
@@ -742,5 +837,82 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
     }
 }
 
+/**
+ * gtk_radio_button_get_value:
+ * @radio_button: a #GtkRadioButton
+ *
+ * Retrieve the value property of the @radio_button set using
+ * gtk_radio_button_new_with_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),
+                                                quark_value));
+
+  if (retval == GTK_RADIO_BUTTON_VALUE_UNSET)
+    {
+      gint index = g_slist_index (radio_button->group, radio_button);
+      gint length = g_slist_length (radio_button->group);
+      
+      retval = length - index;
+    }
+
+  return retval;
+}
+
+static void
+gtk_radio_button_set_value (GtkRadioButton *radio_button,
+                            gint            value)
+{
+  g_return_if_fail (GTK_IS_RADIO_BUTTON (radio_button));
+
+  g_object_set_qdata (G_OBJECT (radio_button),
+                      quark_value,
+                      GINT_TO_POINTER (value));
+
+  g_object_notify (G_OBJECT (radio_button), "value");
+}
+
+/**
+ * gtk_radio_button_get_current_value:
+ * @radio_button: a #GtkRadioButton
+ *
+ * Returns the value of the currently selected radio button inside
+ * the same group of @radio_button.
+ *
+ * Return value: the value set with gtk_radio_button_set_value() or
+ *   the current position inside the group.
+ *
+ * Since: 2.12
+ */
+gint
+gtk_radio_button_get_current_value (GtkRadioButton *radio_button)
+{
+  GSList *l;
+
+  g_return_val_if_fail (GTK_IS_RADIO_BUTTON (radio_button),
+                        GTK_RADIO_BUTTON_VALUE_UNSET);
+
+  for (l = radio_button->group; l; l = l->next)
+    {
+      GtkToggleButton *button = GTK_TOGGLE_BUTTON (l->data);
+
+      if (gtk_toggle_button_get_active (button))
+        return gtk_radio_button_get_value (GTK_RADIO_BUTTON (l->data));
+    }
+
+  return GTK_RADIO_BUTTON_VALUE_UNSET;
+}
+
 #define __GTK_RADIO_BUTTON_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkradiobutton.h b/gtk/gtkradiobutton.h
index 6f7ce3a..98e5659 100644
--- a/gtk/gtkradiobutton.h
+++ b/gtk/gtkradiobutton.h
@@ -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;
 
@@ -78,9 +77,15 @@ GtkWidget* gtk_radio_button_new_with_mnemonic             (GSList         *group
                                                            const gchar    *label);
 GtkWidget* gtk_radio_button_new_with_mnemonic_from_widget (GtkRadioButton *group,
                                                            const gchar    *label);
+GtkWidget* gtk_radio_button_new_with_value                (GSList         *group,
+                                                           gint            value);
+GtkWidget* gtk_radio_button_new_with_value_from_widget    (GtkRadioButton *group,
+                                                           gint            value);
 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);
+gint       gtk_radio_button_get_current_value             (GtkRadioButton *radio_button);
 
 #ifndef GTK_DISABLE_DEPRECATED
 #define gtk_radio_button_group gtk_radio_button_get_group
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 44eb4fc..b8502b4 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -1108,6 +1108,23 @@ create_check_buttons (GtkWidget *widget)
  * GtkRadioButton
  */
 
+enum {
+  RADIO_1 =  1,
+  RADIO_2 = 10,
+  RADIO_3 = 20
+};
+
+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)
 {
@@ -1142,24 +1159,30 @@ create_radio_buttons (GtkWidget *widget)
       gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
       gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
 
-      button = gtk_radio_button_new_with_label (NULL, "button1");
+      button = gtk_radio_button_new_with_value (NULL, RADIO_1);
+      gtk_button_set_label (GTK_BUTTON (button), "button1");
+      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_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");
+      button = gtk_radio_button_new_with_value_from_widget (GTK_RADIO_BUTTON (button),
+                                                            RADIO_2);
+      gtk_button_set_label (GTK_BUTTON (button), "button3");
+      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)),
-		 "inconsistent");
-      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      button = g_object_new (GTK_TYPE_RADIO_BUTTON,
+                             "group", GTK_RADIO_BUTTON (button),
+                             "label", "inconsistent",
+                             "value", RADIO_3,
+                             "inconsistent", TRUE,
+                             NULL);
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
       
       separator = gtk_hseparator_new ();
@@ -1171,6 +1194,7 @@ create_radio_buttons (GtkWidget *widget)
 
       button = gtk_radio_button_new_with_label (NULL, "button4");
       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 (
@@ -1178,12 +1202,14 @@ create_radio_buttons (GtkWidget *widget)
 		 "button5");
       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_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 ();
