[gtk+] [PATCH] add the binding friendly join_group method to GtkRadioAction
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] [PATCH] add the binding friendly join_group method to GtkRadioAction
- Date: Wed, 19 May 2010 19:17:20 +0000 (UTC)
commit 85b53969b24d318b219663841e678943516f443a
Author: John (J5) Palmieri <johnp redhat com>
Date: Wed May 19 15:12:49 2010 -0400
[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
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkradioaction.c | 55 ++++++++++++++++++++++++++++++++++
gtk/gtkradioaction.h | 2 +
4 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index bdf2fb4..d0d8402 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -2396,6 +2396,7 @@ GtkRadioAction
gtk_radio_action_new
gtk_radio_action_get_group
gtk_radio_action_set_group
+gtk_radio_action_join_group
gtk_radio_action_get_current_value
gtk_radio_action_set_current_value
<SUBSECTION Standard>
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index c831414..ff436ba 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2702,6 +2702,7 @@ gtk_radio_action_get_type G_GNUC_CONST
gtk_radio_action_new
gtk_radio_action_set_current_value
gtk_radio_action_set_group
+gtk_radio_action_join_group
#endif
#endif
diff --git a/gtk/gtkradioaction.c b/gtk/gtkradioaction.c
index d6363ed..f44c2b5 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
*
diff --git a/gtk/gtkradioaction.h b/gtk/gtkradioaction.h
index d4a9712..e0f5df1 100644
--- a/gtk/gtkradioaction.h
+++ b/gtk/gtkradioaction.h
@@ -81,6 +81,8 @@ GtkRadioAction *gtk_radio_action_new (const gchar *name,
GSList *gtk_radio_action_get_group (GtkRadioAction *action);
void gtk_radio_action_set_group (GtkRadioAction *action,
GSList *group);
+void gtk_radio_action_join_group (GtkRadioAction *action,
+ GtkRadioAction *group_source);
gint gtk_radio_action_get_current_value (GtkRadioAction *action);
void gtk_radio_action_set_current_value (GtkRadioAction *action,
gint current_value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]