diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2010-05-19 15:12:49 -0400 |
---|---|---|
committer | John (J5) Palmieri <johnp@redhat.com> | 2010-05-19 15:16:46 -0400 |
commit | 85b53969b24d318b219663841e678943516f443a (patch) | |
tree | f349c4942be9223d003bce228b838c70fa02b5c7 /gtk/gtkradioaction.c | |
parent | c51f96578226ee106a59d52bf1920f50adb16ae1 (diff) | |
download | gtk+-85b53969b24d318b219663841e678943516f443a.tar.gz |
[PATCH] add the binding friendly join_group method to GtkRadioAction
* Due to object ownership issues it is impossible to correctly use
get_group/set_group from a GI binding
* join_group is safer because at the binding level it works with individual
GtkRadioAction objects and not with the list of objects that gets
modified in the library
Diffstat (limited to 'gtk/gtkradioaction.c')
-rw-r--r-- | gtk/gtkradioaction.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/gtk/gtkradioaction.c b/gtk/gtkradioaction.c index d6363ed1e1..f44c2b546c 100644 --- a/gtk/gtkradioaction.c +++ b/gtk/gtkradioaction.c @@ -469,6 +469,61 @@ gtk_radio_action_set_group (GtkRadioAction *action, } /** + * gtk_radio_action_join_group: + * @action: the action object + * @group_source: (allow-none): a radio action object whos group we are + * joining, or %NULL to remove the radio action from its group + * + * Joins a radio action object to the group of another radio action object. + * + * Use this in language bindings instead of the gtk_radio_action_get_group() + * and gtk_radio_action_set_group() methods + * + * A common way to set up a group of radio actions is the following: + * |[ + * GtkRadioAction *action; + * GtkRadioAction *last_action; + * + * while (/* more actions to add */) + * { + * action = gtk_radio_action_new (...); + * + * gtk_radio_action_join_group (action, last_action); + * last_action = action; + * } + * ]| + * + * Since: 3.0 + */ +void +gtk_radio_action_join_group (GtkRadioAction *action, + GtkRadioAction *group_source) +{ + g_return_if_fail (GTK_IS_RADIO_ACTION (action)); + g_return_if_fail (group_source == NULL || GTK_IS_RADIO_ACTION (group_source)); + + if (group_source) + { + GSList *group; + group = gtk_radio_action_get_group (group_source); + + if (!group) + { + /* if we are not already part of a group we need to set up a new one + and then get the newly created group */ + gtk_radio_action_set_group (group_source, NULL); + group = gtk_radio_action_get_group (group_source); + } + + gtk_radio_action_set_group (action, group); + } + else + { + gtk_radio_action_set_group (action, NULL); + } +} + +/** * gtk_radio_action_get_current_value: * @action: a #GtkRadioAction * |