libui/redo/unix/radiobuttons.c

58 lines
1.2 KiB
C
Raw Normal View History

2015-06-11 18:07:06 -05:00
// 11 june 2015
#include "uipriv_unix.h"
// on GTK+ a uiRadioButtons is a GtkBox with each of the GtkRadioButtons as children
struct uiRadioButtons {
2015-08-27 22:00:34 -05:00
uiUnixControl c;
GtkWidget *widget;
GtkContainer *container;
GtkBox *box;
2015-07-01 11:39:05 -05:00
GPtrArray *buttons;
2015-06-11 18:07:06 -05:00
};
2015-08-27 22:00:34 -05:00
static void onDestroy(uiRadioButtons *);
2015-06-11 18:07:06 -05:00
2015-08-27 22:00:34 -05:00
uiUnixDefineControlWithOnDestroy(
uiRadioButtons, // type name
uiRadioButtonsType, // type function
onDestroy(this); // on destroy
)
2015-07-01 11:39:05 -05:00
2015-08-27 22:00:34 -05:00
static void onDestroy(uiRadioButtons *r)
2015-06-11 18:07:06 -05:00
{
2015-08-27 22:00:34 -05:00
// TODO
2015-06-11 18:07:06 -05:00
}
void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
2015-06-11 18:07:06 -05:00
{
2015-07-01 11:39:05 -05:00
GtkWidget *rb;
GtkRadioButton *previous;
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);
2015-08-27 22:00:34 -05:00
gtk_container_add(r->container, rb);
2015-07-01 11:39:05 -05:00
g_ptr_array_add(r->buttons, rb);
gtk_widget_show(rb);
2015-06-11 18:07:06 -05:00
uiControlQueueResize(uiControl(r));
}
uiRadioButtons *uiNewRadioButtons(void)
{
2015-08-27 22:00:34 -05:00
uiRadioButtons *r;
2015-06-11 18:07:06 -05:00
r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType());
2015-06-11 18:07:06 -05:00
2015-08-27 22:00:34 -05:00
r->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
r->container = GTK_CONTAINER(r->widget);
r->box = GTK_BOX(r->widget);
2015-06-11 18:07:06 -05:00
2015-07-01 11:39:05 -05:00
r->buttons = g_ptr_array_new();
2015-08-27 22:00:34 -05:00
uiUnixFinishNewControl(r, uiRadioButtons);
2015-06-11 18:07:06 -05:00
2015-08-27 22:00:34 -05:00
return r;
2015-06-11 18:07:06 -05:00
}