X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/50a14534a51f892500ee82f867e8ab2f85b936ae..c3cf4e3e0f27e9c6b05cab2fd5700831878f601f:/src/vikradiogroup.c diff --git a/src/vikradiogroup.c b/src/vikradiogroup.c index 5b17df5b..666d65ba 100644 --- a/src/vikradiogroup.c +++ b/src/vikradiogroup.c @@ -20,6 +20,7 @@ */ #include +#include #include "vikradiogroup.h" @@ -70,7 +71,40 @@ static void radio_group_class_init ( VikRadioGroupClass *klass ) parent_class = g_type_class_peek_parent (klass); } -GtkWidget *vik_radio_group_new ( const gchar **options ) +GtkWidget *vik_radio_group_new ( GList *options ) +{ + VikRadioGroup *vrg; + GtkWidget *t; + gchar *label; + GList *option = options; + + if ( ! options ) + return NULL; + + vrg = VIK_RADIO_GROUP ( g_object_new ( VIK_RADIO_GROUP_TYPE, NULL ) ); + + label = g_list_nth_data(options, 0); + t = gtk_radio_button_new_with_label ( NULL, gettext(label) ); + gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(t), TRUE ); + gtk_box_pack_start ( GTK_BOX(vrg), t, FALSE, FALSE, 0 ); + + vrg->radios = g_slist_append ( NULL, t ); + vrg->options_count = 1; + + while ( ( option = g_list_next(option) ) != NULL ) + { + label = option->data; + t = gtk_radio_button_new_with_label_from_widget ( + GTK_RADIO_BUTTON(vrg->radios->data), gettext(label)); + vrg->radios = g_slist_append( vrg->radios, t ); + gtk_box_pack_start ( GTK_BOX(vrg), GTK_WIDGET(t), FALSE, FALSE, 0 ); + vrg->options_count++; + } + + return GTK_WIDGET(vrg); +} + +GtkWidget *vik_radio_group_new_static ( const gchar **options ) { VikRadioGroup *vrg; GtkWidget *t; @@ -90,7 +124,7 @@ GtkWidget *vik_radio_group_new ( const gchar **options ) for ( options++ ; *options ; options++ ) { t = gtk_radio_button_new_with_label_from_widget ( GTK_RADIO_BUTTON(vrg->radios->data), *options ); - g_slist_append( vrg->radios, t ); + vrg->radios = g_slist_append( vrg->radios, t ); gtk_box_pack_start ( GTK_BOX(vrg), GTK_WIDGET(t), FALSE, FALSE, 0 ); vrg->options_count++; } @@ -98,6 +132,7 @@ GtkWidget *vik_radio_group_new ( const gchar **options ) return GTK_WIDGET(vrg); } + void vik_radio_group_set_selected ( VikRadioGroup *vrg, guint8 i ) { if ( i < vrg->options_count )