Add a replacement for gtk_radio_action_set_current_value() which
[geeqie.git] / src / compat.c
1 /*
2  * Geeqie
3  *
4  * Authors: Vladimir Nadvornik / Laurent Monin
5  * 
6  * This software is released under the GNU General Public License (GNU GPL).
7  * Please read the included file COPYING for more information.
8  * This software comes with no warranty of any kind, use at your own risk!
9  */
10
11 #include "main.h"
12 #include "compat.h"
13
14 /* gtk_radio_action_set_current_value() replacement for GTK+ < 2.10 */
15 void radio_action_set_current_value(GtkRadioAction *action, gint current_value)
16 {
17 #if GTK_CHECK_VERSION(2, 10, 0)
18         gtk_radio_action_set_current_value(action, current_value);
19 #else
20         GSList *group;
21         gint value;
22
23         group = gtk_radio_action_get_group(action);
24         while (group)
25                 {
26                 action = GTK_RADIO_ACTION(group->data);
27                 g_object_get(G_OBJECT(action), "value", &value, NULL);
28                 if (value == current_value)
29                         {
30                         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), TRUE);
31                         return;
32                         }
33                 group = g_slist_next(group);
34                 }
35 #endif
36 }