*/
#include <gtk/gtk.h>
+#include <glib/gi18n.h>
#include "vikradiogroup.h"
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;
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++;
}
return GTK_WIDGET(vrg);
}
+
void vik_radio_group_set_selected ( VikRadioGroup *vrg, guint8 i )
{
if ( i < vrg->options_count )