Implemented uiRadioButtons on GTK+.

This commit is contained in:
Pietro Gagliardi 2015-07-01 12:39:05 -04:00
parent 395cc5108c
commit c3abede628
1 changed files with 16 additions and 1 deletions

View File

@ -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;