Converted the basic GTK+ controls. Now for the containers.

This commit is contained in:
Pietro Gagliardi 2016-04-25 20:00:25 -04:00
parent 85ee2e93dd
commit 01912877ce
13 changed files with 27 additions and 82 deletions

View File

@ -9,9 +9,7 @@ struct uiButton {
void *onClickedData;
};
uiUnixDefineControl(
uiButton // type name
)
uiUnixControlAllDefaults(uiButton)
static void onClicked(GtkButton *button, gpointer data)
{
@ -47,7 +45,7 @@ uiButton *uiNewButton(const char *text)
{
uiButton *b;
b = (uiButton *) uiNewControl(uiButton);
uiUnixNewControl(uiButton, b);
b->widget = gtk_button_new_with_label(text);
b->button = GTK_BUTTON(b->widget);
@ -55,7 +53,5 @@ uiButton *uiNewButton(const char *text)
g_signal_connect(b->widget, "clicked", G_CALLBACK(onClicked), b);
uiButtonOnClicked(b, defaultOnClicked, NULL);
uiUnixFinishNewControl(b, uiButton);
return b;
}

View File

@ -12,9 +12,7 @@ struct uiCheckbox {
gulong onToggledSignal;
};
uiUnixDefineControl(
uiCheckbox // type name
)
uiUnixControlAllDefaults(uiCheckbox)
static void onToggled(GtkToggleButton *b, gpointer data)
{
@ -68,7 +66,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
{
uiCheckbox *c;
c = (uiCheckbox *) uiNewControl(uiCheckbox);
uiUnixNewControl(uiCheckbox, c);
c->widget = gtk_check_button_new_with_label(text);
c->button = GTK_BUTTON(c->widget);
@ -78,7 +76,5 @@ uiCheckbox *uiNewCheckbox(const char *text)
c->onToggledSignal = g_signal_connect(c->widget, "toggled", G_CALLBACK(onToggled), c);
uiCheckboxOnToggled(c, defaultOnToggled, NULL);
uiUnixFinishNewControl(c, uiCheckbox);
return c;
}

View File

@ -11,9 +11,7 @@ struct uiCombobox {
gulong onSelectedSignal;
};
uiUnixDefineControl(
uiCombobox // type name
)
uiUnixControlAllDefaults(uiCombobox)
// TODO this is triggered when editing an editable combobox's text
static void onChanged(GtkComboBox *cbox, gpointer data)
@ -56,7 +54,7 @@ static uiCombobox *finishNewCombobox(GtkWidget *(*newfunc)(void))
{
uiCombobox *c;
c = (uiCombobox *) uiNewControl(uiCombobox);
uiUnixNewControl(uiCombobox, c);
c->widget = (*newfunc)();
c->combobox = GTK_COMBO_BOX(c->widget);
@ -65,8 +63,6 @@ static uiCombobox *finishNewCombobox(GtkWidget *(*newfunc)(void))
c->onSelectedSignal = g_signal_connect(c->widget, "changed", G_CALLBACK(onChanged), c);
uiComboboxOnSelected(c, defaultOnSelected, NULL);
uiUnixFinishNewControl(c, uiCombobox);
return c;
}

View File

@ -6,9 +6,7 @@ struct uiDateTimePicker {
GtkWidget *widget;
};
uiUnixDefineControl(
uiDateTimePicker // type name
)
uiUnixControlAllDefaults(uiDateTimePicker)
// TODO
typedef int OSTHING;
@ -22,12 +20,10 @@ uiDateTimePicker *finishNewDateTimePicker(OSTHING OSARG)
{
uiDateTimePicker *d;
d = (uiDateTimePicker *) uiNewControl(uiDateTimePicker);
uiUnixNewControl(uiDateTimePicker, d);
d->widget = gtk_label_new("TODO uiDateTimePicker not implemented");
uiUnixFinishNewControl(d, uiDateTimePicker);
return d;
}

View File

@ -11,9 +11,7 @@ struct uiEntry {
gulong onChangedSignal;
};
uiUnixDefineControl(
uiEntry // type name
)
uiUnixControlAllDefaults(uiEntry)
static void onChanged(GtkEditable *editable, gpointer data)
{
@ -66,7 +64,7 @@ uiEntry *uiNewEntry(void)
{
uiEntry *e;
e = (uiEntry *) uiNewControl(uiEntry);
uiUnixNewControl(uiEntry, e);
e->widget = gtk_entry_new();
e->entry = GTK_ENTRY(e->widget);
@ -75,7 +73,5 @@ uiEntry *uiNewEntry(void)
e->onChangedSignal = g_signal_connect(e->widget, "changed", G_CALLBACK(onChanged), e);
uiEntryOnChanged(e, defaultOnChanged, NULL);
uiUnixFinishNewControl(e, uiEntry);
return e;
}

View File

@ -11,9 +11,7 @@ struct uiFontButton {
void *onChangedData;
};
uiUnixDefineControl(
uiFontButton // type name
)
uiUnixControlAllDefaults(uiFontButton)
// TODO NOTE no need to inhibit the signal; font-set is documented as only being sent when the user changes the font
static void onFontSet(GtkFontButton *button, gpointer data)
@ -50,7 +48,7 @@ uiFontButton *uiNewFontButton(void)
{
uiFontButton *b;
b = (uiFontButton *) uiNewControl(uiFontButton);
uiUnixNewControl(uiFontButton, b);
b->widget = gtk_font_button_new();
b->button = GTK_BUTTON(b->widget);
@ -68,7 +66,5 @@ uiFontButton *uiNewFontButton(void)
g_signal_connect(b->widget, "font-set", G_CALLBACK(onFontSet), b);
uiFontButtonOnChanged(b, defaultOnChanged, NULL);
uiUnixFinishNewControl(b, uiFontButton);
return b;
}

View File

@ -8,9 +8,7 @@ struct uiLabel {
GtkLabel *label;
};
uiUnixDefineControl(
uiLabel // type name
)
uiUnixControlAllDefaults(uiLabel)
char *uiLabelText(uiLabel *l)
{
@ -28,7 +26,7 @@ uiLabel *uiNewLabel(const char *text)
{
uiLabel *l;
l = (uiLabel *) uiNewControl(uiLabel);
uiUnixNewControl(uiLabel, l);
l->widget = gtk_label_new(text);
l->misc = GTK_MISC(l->widget);
@ -36,7 +34,5 @@ uiLabel *uiNewLabel(const char *text)
gtk_misc_set_alignment(l->misc, 0, 0);
uiUnixFinishNewControl(l, uiLabel);
return l;
}

View File

@ -16,9 +16,7 @@ struct uiMultilineEntry {
gulong onChangedSignal;
};
uiUnixDefineControl(
uiMultilineEntry // type name
)
uiUnixControlAllDefaults(uiMultilineEntry)
static void onChanged(GtkTextBuffer *textbuf, gpointer data)
{
@ -87,7 +85,7 @@ uiMultilineEntry *uiNewMultilineEntry(void)
{
uiMultilineEntry *e;
e = (uiMultilineEntry *) uiNewControl(uiMultilineEntry);
uiUnixNewControl(uiMultilineEntry, e);
e->widget = gtk_scrolled_window_new(NULL, NULL);
e->scontainer = GTK_CONTAINER(e->widget);
@ -110,7 +108,5 @@ uiMultilineEntry *uiNewMultilineEntry(void)
e->onChangedSignal = g_signal_connect(e->textbuf, "changed", G_CALLBACK(onChanged), e);
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
uiUnixFinishNewControl(e, uiMultilineEntry);
return e;
}

View File

@ -7,9 +7,7 @@ struct uiProgressBar {
GtkProgressBar *pbar;
};
uiUnixDefineControl(
uiProgressBar // type name
)
uiUnixControlAllDefaults(uiProgressBar)
void uiProgressBarSetValue(uiProgressBar *p, int value)
{
@ -22,12 +20,10 @@ uiProgressBar *uiNewProgressBar(void)
{
uiProgressBar *p;
p = (uiProgressBar *) uiNewControl(uiProgressBar);
uiUnixNewControl(uiProgressBar, p);
p->widget = gtk_progress_bar_new();
p->pbar = GTK_PROGRESS_BAR(p->widget);
uiUnixFinishNewControl(p, uiProgressBar);
return p;
}

View File

@ -11,14 +11,9 @@ struct uiRadioButtons {
GPtrArray *buttons;
};
static void onDestroy(uiRadioButtons *);
uiUnixControlAllDefaultsExceptDestroy(uiRadioButtons)
uiUnixDefineControlWithOnDestroy(
uiRadioButtons, // type name
onDestroy(this); // on destroy
)
static void onDestroy(uiRadioButtons *r)
static void uiRadioButtonsDestroy(uiControl *c)
{
// TODO
}
@ -42,7 +37,7 @@ uiRadioButtons *uiNewRadioButtons(void)
{
uiRadioButtons *r;
r = (uiRadioButtons *) uiNewControl(uiRadioButtons);
uiUnixNewControl(uiRadioButtons, r);
r->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
r->container = GTK_CONTAINER(r->widget);
@ -50,7 +45,5 @@ uiRadioButtons *uiNewRadioButtons(void)
r->buttons = g_ptr_array_new();
uiUnixFinishNewControl(r, uiRadioButtons);
return r;
}

View File

@ -7,20 +7,16 @@ struct uiSeparator {
GtkSeparator *separator;
};
uiUnixDefineControl(
uiSeparator // type name
)
uiUnixControlAllDefaults(uiSeparator)
uiSeparator *uiNewHorizontalSeparator(void)
{
uiSeparator *s;
s = (uiSeparator *) uiNewControl(uiSeparator);
uiUnixNewControl(uiSeparator, s);
s->widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
s->separator = GTK_SEPARATOR(s->widget);
uiUnixFinishNewControl(s, uiSeparator);
return s;
}

View File

@ -11,9 +11,7 @@ struct uiSlider {
gulong onChangedSignal;
};
uiUnixDefineControl(
uiSlider // type name
)
uiUnixControlAllDefaults(uiSlider)
static void onChanged(GtkRange *range, gpointer data)
{
@ -50,7 +48,7 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
{
uiSlider *s;
s = (uiSlider *) uiNewControl(uiSlider);
uiUnixNewControl(uiSlider, s);
s->widget = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, min, max, 1);
s->range = GTK_RANGE(s->widget);
@ -62,7 +60,5 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
s->onChangedSignal = g_signal_connect(s->scale, "value-changed", G_CALLBACK(onChanged), s);
uiSliderOnChanged(s, defaultOnChanged, NULL);
uiUnixFinishNewControl(s, uiSlider);
return s;
}

View File

@ -11,9 +11,7 @@ struct uiSpinbox {
gulong onChangedSignal;
};
uiUnixDefineControl(
uiSpinbox // type name
)
uiUnixControlAllDefaults(uiSpinbox)
static void onChanged(GtkSpinButton *sb, gpointer data)
{
@ -54,7 +52,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
if (min >= max)
complain("error: min >= max in uiNewSpinbox()");
s = (uiSpinbox *) uiNewControl(uiSpinbox);
uiUnixNewControl(uiSpinbox, s);
s->widget = gtk_spin_button_new_with_range(min, max, 1);
s->entry = GTK_ENTRY(s->widget);
@ -66,7 +64,5 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
s->onChangedSignal = g_signal_connect(s->spinButton, "value-changed", G_CALLBACK(onChanged), s);
uiSpinboxOnChanged(s, defaultOnChanged, NULL);
uiUnixFinishNewControl(s, uiSpinbox);
return s;
}