diff options
author | Tim Janik <timj@gtk.org> | 1998-04-18 20:33:35 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-04-18 20:33:35 +0000 |
commit | 57703d0170725cbd62bb02a13e1a7479a46e5aa3 (patch) | |
tree | 8dd43b377adb0d189c64a4de8f96e8b505be2dbb /gtk | |
parent | e3b303c212e5a2616eafc0de2903ae35d6674f68 (diff) | |
download | gtk+-57703d0170725cbd62bb02a13e1a7479a46e5aa3.tar.gz |
new function ala gtk_radio_button_set_group. (gtk_radio_menu_item_init):
Sat Apr 18 22:18:12 1998 Tim Janik <timj@gtk.org>
* gtk/gtkradiomenuitem.h:
* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_set_group): new function
ala gtk_radio_button_set_group.
(gtk_radio_menu_item_init): assure that we always have at least a group
that points to self.
* gtk/gtkradiobutton.c (gtk_radio_button_set_group): few cleanups and
added g_return_if_fail() statements.
(gtk_radio_button_init): assure that we always have at least a group
that points to self.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkradiobutton.c | 37 | ||||
-rw-r--r-- | gtk/gtkradiomenuitem.c | 55 | ||||
-rw-r--r-- | gtk/gtkradiomenuitem.h | 2 |
3 files changed, 65 insertions, 29 deletions
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index c23833b5c3..bf9ead5a7d 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -82,40 +82,45 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class) static void gtk_radio_button_init (GtkRadioButton *radio_button) { - radio_button->group = NULL; + radio_button->group = g_slist_prepend (NULL, radio_button); } void gtk_radio_button_set_group (GtkRadioButton *radio_button, GSList *group) { - GSList *tmp_list; - GtkRadioButton *tmp_button; - + g_return_if_fail (radio_button != NULL); + g_return_if_fail (GTK_IS_RADIO_BUTTON (radio_button)); + g_return_if_fail (!g_slist_find (group, radio_button)); + if (radio_button->group) { + GSList *slist; + radio_button->group = g_slist_remove (radio_button->group, radio_button); - tmp_list = radio_button->group; - while (tmp_list) + for (slist = radio_button->group; slist; slist = slist->next) { - tmp_button = tmp_list->data; - tmp_list = tmp_list->next; + GtkRadioButton *tmp_button; + + tmp_button = slist->data; tmp_button->group = radio_button->group; } } - + radio_button->group = g_slist_prepend (group, radio_button); - tmp_list = group; - - if (tmp_list) + + if (group) { - while (tmp_list) + GSList *slist; + + for (slist = group; slist; slist = slist->next) { - tmp_button = tmp_list->data; - tmp_list = tmp_list->next; - + GtkRadioButton *tmp_button; + + tmp_button = slist->data; + tmp_button->group = radio_button->group; } } diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index e74ba09a62..2297161196 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -55,30 +55,59 @@ GtkWidget* gtk_radio_menu_item_new (GSList *group) { GtkRadioMenuItem *radio_menu_item; - GtkRadioMenuItem *tmp_menu_item; - GSList *tmp_list; radio_menu_item = gtk_type_new (gtk_radio_menu_item_get_type ()); - tmp_list = group; - radio_menu_item->group = g_slist_prepend (group, radio_menu_item); + gtk_radio_menu_item_set_group (radio_menu_item, group); + + return GTK_WIDGET (radio_menu_item); +} - if (tmp_list) +void +gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item, + GSList *group) +{ + g_return_if_fail (radio_menu_item != NULL); + g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (radio_menu_item)); + g_return_if_fail (!g_slist_find (group, radio_menu_item)); + + if (radio_menu_item->group) { - while (tmp_list) + GSList *slist; + + radio_menu_item->group = g_slist_remove (radio_menu_item->group, radio_menu_item); + + for (slist = radio_menu_item->group; slist; slist = slist->next) { - tmp_menu_item = tmp_list->data; - tmp_list = tmp_list->next; - - tmp_menu_item->group = radio_menu_item->group; + GtkRadioMenuItem *tmp_item; + + tmp_item = slist->data; + + tmp_item->group = radio_menu_item->group; + } + } + + radio_menu_item->group = g_slist_prepend (group, radio_menu_item); + + if (group) + { + GSList *slist; + + for (slist = group; slist; slist = slist->next) + { + GtkRadioMenuItem *tmp_item; + + tmp_item = slist->data; + + tmp_item->group = radio_menu_item->group; } } else { GTK_CHECK_MENU_ITEM (radio_menu_item)->active = TRUE; + /* gtk_widget_set_state (GTK_WIDGET (radio_menu_item), GTK_STATE_ACTIVE); + */ } - - return GTK_WIDGET (radio_menu_item); } GtkWidget* @@ -125,7 +154,7 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass) static void gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item) { - radio_menu_item->group = NULL; + radio_menu_item->group = g_slist_prepend (NULL, radio_menu_item); } static void diff --git a/gtk/gtkradiomenuitem.h b/gtk/gtkradiomenuitem.h index 0c955ffb53..61ffd47207 100644 --- a/gtk/gtkradiomenuitem.h +++ b/gtk/gtkradiomenuitem.h @@ -55,6 +55,8 @@ GtkWidget* gtk_radio_menu_item_new (GSList *group); GtkWidget* gtk_radio_menu_item_new_with_label (GSList *group, const gchar *label); GSList* gtk_radio_menu_item_group (GtkRadioMenuItem *radio_menu_item); +void gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item, + GSList *group); #ifdef __cplusplus |