diff --git a/redo/unix/radiobuttons.c b/redo/unix/radiobuttons.c index 0f792508..c57a89b0 100644 --- a/redo/unix/radiobuttons.c +++ b/redo/unix/radiobuttons.c @@ -6,11 +6,15 @@ struct radiobuttons { uiRadioButtons r; GtkWidget *boxWidget; + GtkContainer *boxContainer; GtkBox *box; + GPtrArray *buttons; }; uiDefineControlType(uiRadioButtons, uiTypeRadioButtons, struct radiobuttons) +// TODO destroy + // TODO note that the handle of a uiRadioButtons is undefined (or at least highly platform-dependent and unreliable) static uintptr_t radiobuttonsHandle(uiControl *c) { @@ -22,8 +26,16 @@ static uintptr_t radiobuttonsHandle(uiControl *c) static void radiobuttonsAppend(uiRadioButtons *rr, const char *text) { struct radiobuttons *r = (struct radiobuttons *) rr; + GtkWidget *rb; + GtkRadioButton *previous; - PUT_CODE_HERE; + previous = NULL; + if (r->buttons->len > 0) + previous = GTK_RADIO_BUTTON(g_ptr_array_index(r->buttons, 0)); + rb = gtk_radio_button_new_with_label_from_widget(previous, text); + gtk_container_add(r->boxContainer, rb); + g_ptr_array_add(r->buttons, rb); + gtk_widget_show(rb); uiControlQueueResize(uiControl(r)); } @@ -34,9 +46,12 @@ uiRadioButtons *uiNewRadioButtons(void) r = (struct radiobuttons *) uiNewControl(uiTypeRadioButtons()); r->boxWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + r->boxContainer = GTK_CONTAINER(r->boxWidget); r->box = GTK_BOX(r->boxWidget); uiUnixMakeSingleWidgetControl(uiControl(r), r->boxWidget); + r->buttons = g_ptr_array_new(); + uiControl(r)->Handle = radiobuttonsHandle; uiRadioButtons(r)->Append = radiobuttonsAppend;