aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Leach <jasonleach@usa.net>2001-01-19 09:28:28 +0800
committerJacob Leach <jleach@src.gnome.org>2001-01-19 09:28:28 +0800
commitbb7e98c4ebc14f73fdc4f5430a4a09218b806401 (patch)
tree0fec378637aeef3b9f07298eea13ae645d8fca39
parent9c3295326aef917055c1ddc4e58366d193ebf33b (diff)
downloadgsoc2013-evolution-bb7e98c4ebc14f73fdc4f5430a4a09218b806401.tar.gz
gsoc2013-evolution-bb7e98c4ebc14f73fdc4f5430a4a09218b806401.tar.zst
gsoc2013-evolution-bb7e98c4ebc14f73fdc4f5430a4a09218b806401.zip
New function, name describes it well. (gtk_radio_button_select_nth): New
2001-01-17 Jason Leach <jasonleach@usa.net> * e-gtk-utils.c (gtk_radio_button_get_nth_selected): New function, name describes it well. (gtk_radio_button_select_nth): New function. svn path=/trunk/; revision=7629
-rw-r--r--e-util/ChangeLog6
-rw-r--r--e-util/e-gtk-utils.c54
-rw-r--r--e-util/e-gtk-utils.h5
3 files changed, 65 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index b9cd630ce1..379eae390e 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,9 @@
+2001-01-17 Jason Leach <jasonleach@usa.net>
+
+ * e-gtk-utils.c (gtk_radio_button_get_nth_selected): New function,
+ name describes it well.
+ (gtk_radio_button_select_nth): New function.
+
2001-01-17 Federico Mena Quintero <federico@ximian.com>
* e-dialog-widgets.[ch]: Ximianified.
diff --git a/e-util/e-gtk-utils.c b/e-util/e-gtk-utils.c
index 3cca1d0789..c00ca4c8ef 100644
--- a/e-util/e-gtk-utils.c
+++ b/e-util/e-gtk-utils.c
@@ -104,3 +104,57 @@ e_gtk_signal_connect_full_while_alive (GtkObject *object,
info->disconnect_handler2 = gtk_signal_connect (alive_object, "destroy",
GTK_SIGNAL_FUNC (alive_disconnecter), info);
}
+
+/**
+ * gtk_radio_button_get_nth_selected:
+ * @button: A GtkRadioButton
+ *
+ * Returns an int indicating which button in the radio group is
+ * toggled active. NOTE: radio group item numbering starts at zero.
+ **/
+int
+gtk_radio_button_get_nth_selected (GtkRadioButton *button)
+{
+ GSList *l;
+ int i, c;
+
+ g_return_val_if_fail (button != NULL, 0);
+ g_return_val_if_fail (GTK_IS_RADIO_BUTTON (button), 0);
+
+ c = g_slist_length (button->group);
+
+ for (i = 0, l = button->group; l; l = l->next, i++) {
+ GtkRadioButton *tmp = l->data;
+
+ if (GTK_TOGGLE_BUTTON (tmp)->active)
+ return c - i - 1;
+ }
+
+ return 0;
+}
+
+/**
+ * gtk_radio_button_select_nth:
+ * @button: A GtkRadioButton
+ * @n: Which button to select from the group
+ *
+ * Select the Nth item of a radio group. NOTE: radio group items
+ * start numbering from zero
+ **/
+void
+gtk_radio_button_select_nth (GtkRadioButton *button, int n)
+{
+ GSList *l;
+ int len;
+
+ g_return_if_fail (button != NULL);
+ g_return_if_fail (GTK_IS_RADIO_BUTTON (button));
+
+ len = g_slist_length (button->group);
+
+ if ((n <= len) && (n > 0)) {
+ l = g_slist_nth (button->group, len - n - 1);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l->data), TRUE);
+ }
+
+}
diff --git a/e-util/e-gtk-utils.h b/e-util/e-gtk-utils.h
index 0dc6b68512..0bbee2910a 100644
--- a/e-util/e-gtk-utils.h
+++ b/e-util/e-gtk-utils.h
@@ -36,4 +36,9 @@ void e_gtk_signal_connect_full_while_alive (GtkObject *object,
gboolean after,
GtkObject *alive_object);
+
+/* GtkRadioButton API extensions */
+void gtk_radio_button_select_nth (GtkRadioButton *button, int n);
+int gtk_radio_button_get_nth_selected (GtkRadioButton *button);
+
#endif