From 57703d0170725cbd62bb02a13e1a7479a46e5aa3 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sat, 18 Apr 1998 20:33:35 +0000 Subject: [PATCH] new function ala gtk_radio_button_set_group. (gtk_radio_menu_item_init): Sat Apr 18 22:18:12 1998 Tim Janik * 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. --- ChangeLog | 13 ++++++++++ ChangeLog.pre-2-0 | 13 ++++++++++ ChangeLog.pre-2-10 | 13 ++++++++++ ChangeLog.pre-2-2 | 13 ++++++++++ ChangeLog.pre-2-4 | 13 ++++++++++ ChangeLog.pre-2-6 | 13 ++++++++++ ChangeLog.pre-2-8 | 13 ++++++++++ gtk/gtkradiobutton.c | 37 ++++++++++++++++------------ gtk/gtkradiomenuitem.c | 55 ++++++++++++++++++++++++++++++++---------- gtk/gtkradiomenuitem.h | 2 ++ 10 files changed, 156 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5f7ad54fd0..ad98bcf5cc 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +Sat Apr 18 22:18:12 1998 Tim Janik + + * 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. + Fri Apr 17 03:05:05 1998 Tim Janik * ChangeLog split up into ChangeLog.pre-1-0 and ChangeLog. 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); - if (tmp_list) + return GTK_WIDGET (radio_menu_item); +} + +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