diff --git a/ui_unix.h b/ui_unix.h index 75b14ac8..f9682ae9 100644 --- a/ui_unix.h +++ b/ui_unix.h @@ -37,6 +37,10 @@ struct uiUnixControl { #define uiUnixDefineControl(type) \ uiUnixDefineControlWithOnDestroy(type, (void) this;) +// TODO document +#define uiNewControl(type) uiUnixNewControl(sizeof (type), type ## Signature, #type) +_UI_EXTERN uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typename); + #define uiUnixFinishNewControl(variable, type) \ uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \ uiControl(variable)->Handle = _ ## type ## Handle; \ diff --git a/unix/area.c b/unix/area.c index 8548dcfd..6dbdc63a 100644 --- a/unix/area.c +++ b/unix/area.c @@ -510,7 +510,7 @@ uiArea *uiNewArea(uiAreaHandler *ah) { uiArea *a; - a = (uiArea *) uiNewControl(uiAreaType()); + a = (uiArea *) uiNewControl(uiArea); a->ah = ah; a->scrolling = FALSE; @@ -532,7 +532,7 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, intmax_t width, intmax_t height) { uiArea *a; - a = (uiArea *) uiNewControl(uiAreaType()); + a = (uiArea *) uiNewControl(uiArea); a->ah = ah; a->scrolling = TRUE; diff --git a/unix/box.c b/unix/box.c index dc320e93..01cb380e 100644 --- a/unix/box.c +++ b/unix/box.c @@ -110,7 +110,7 @@ static uiBox *finishNewBox(GtkOrientation orientation) { uiBox *b; - b = (uiBox *) uiNewControl(uiBoxType()); + b = (uiBox *) uiNewControl(uiBox); b->widget = gtk_box_new(orientation, 0); b->container = GTK_CONTAINER(b->widget); diff --git a/unix/button.c b/unix/button.c index 198374c4..2365f046 100644 --- a/unix/button.c +++ b/unix/button.c @@ -47,7 +47,7 @@ uiButton *uiNewButton(const char *text) { uiButton *b; - b = (uiButton *) uiNewControl(uiButtonType()); + b = (uiButton *) uiNewControl(uiButton); b->widget = gtk_button_new_with_label(text); b->button = GTK_BUTTON(b->widget); diff --git a/unix/checkbox.c b/unix/checkbox.c index d56a8330..4ff23592 100644 --- a/unix/checkbox.c +++ b/unix/checkbox.c @@ -68,7 +68,7 @@ uiCheckbox *uiNewCheckbox(const char *text) { uiCheckbox *c; - c = (uiCheckbox *) uiNewControl(uiCheckboxType()); + c = (uiCheckbox *) uiNewControl(uiCheckbox); c->widget = gtk_check_button_new_with_label(text); c->button = GTK_BUTTON(c->widget); diff --git a/unix/combobox.c b/unix/combobox.c index 1e787b50..9826692b 100644 --- a/unix/combobox.c +++ b/unix/combobox.c @@ -56,7 +56,7 @@ static uiCombobox *finishNewCombobox(GtkWidget *(*newfunc)(void)) { uiCombobox *c; - c = (uiCombobox *) uiNewControl(uiComboboxType()); + c = (uiCombobox *) uiNewControl(uiCombobox); c->widget = (*newfunc)(); c->combobox = GTK_COMBO_BOX(c->widget); diff --git a/unix/control.c b/unix/control.c index 258e6a86..611361e9 100644 --- a/unix/control.c +++ b/unix/control.c @@ -1,15 +1,6 @@ // 16 august 2015 #include "uipriv_unix.h" -static uintmax_t type_uiUnixControl = 0; - -uintmax_t uiUnixControlType(void) -{ - if (type_uiUnixControl == 0) - type_uiUnixControl = uiRegisterType("uiUnixControl", uiControlType(), sizeof (uiUnixControl)); - return type_uiUnixControl; -} - static void defaultCommitShow(uiControl *c) { gtk_widget_show(GTK_WIDGET(uiControlHandle(c))); @@ -38,3 +29,10 @@ void uiUnixFinishControl(uiControl *c) c->CommitShow = defaultCommitShow; c->CommitHide = defaultCommitHide; } + +#define uiUnixControlSignature 0x556E6978 + +uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typename) +{ + return uiUnixControl(newControl(n, uiUnixControlSignature, typesig, typename)); +} diff --git a/unix/datetimepicker.c b/unix/datetimepicker.c index e965aa88..c2fa4533 100644 --- a/unix/datetimepicker.c +++ b/unix/datetimepicker.c @@ -22,7 +22,7 @@ uiDateTimePicker *finishNewDateTimePicker(OSTHING OSARG) { uiDateTimePicker *d; - d = (uiDateTimePicker *) uiNewControl(uiDateTimePickerType()); + d = (uiDateTimePicker *) uiNewControl(uiDateTimePicker); d->widget = gtk_label_new("TODO uiDateTimePicker not implemented"); diff --git a/unix/entry.c b/unix/entry.c index 0b8572cc..8dc2692c 100644 --- a/unix/entry.c +++ b/unix/entry.c @@ -66,7 +66,7 @@ uiEntry *uiNewEntry(void) { uiEntry *e; - e = (uiEntry *) uiNewControl(uiEntryType()); + e = (uiEntry *) uiNewControl(uiEntry); e->widget = gtk_entry_new(); e->entry = GTK_ENTRY(e->widget); diff --git a/unix/fontbutton.c b/unix/fontbutton.c index fd2b08ff..896fcd81 100644 --- a/unix/fontbutton.c +++ b/unix/fontbutton.c @@ -50,7 +50,7 @@ uiFontButton *uiNewFontButton(void) { uiFontButton *b; - b = (uiFontButton *) uiNewControl(uiFontButtonType()); + b = (uiFontButton *) uiNewControl(uiFontButton); b->widget = gtk_font_button_new(); b->button = GTK_BUTTON(b->widget); diff --git a/unix/group.c b/unix/group.c index a13a5d58..07a8d418 100644 --- a/unix/group.c +++ b/unix/group.c @@ -78,7 +78,7 @@ uiGroup *uiNewGroup(const char *text) PangoAttribute *bold; PangoAttrList *boldlist; - g = (uiGroup *) uiNewControl(uiGroupType()); + g = (uiGroup *) uiNewControl(uiGroup); g->widget = gtk_frame_new(text); g->container = GTK_CONTAINER(g->widget); diff --git a/unix/label.c b/unix/label.c index 1c0e6407..e2f69a45 100644 --- a/unix/label.c +++ b/unix/label.c @@ -28,7 +28,7 @@ uiLabel *uiNewLabel(const char *text) { uiLabel *l; - l = (uiLabel *) uiNewControl(uiLabelType()); + l = (uiLabel *) uiNewControl(uiLabel); l->widget = gtk_label_new(text); l->misc = GTK_MISC(l->widget); diff --git a/unix/menu.c b/unix/menu.c index ebc907ab..cf276dac 100644 --- a/unix/menu.c +++ b/unix/menu.c @@ -8,13 +8,11 @@ static gboolean hasPreferences = FALSE; static gboolean hasAbout = FALSE; struct uiMenu { - uiTyped t; char *name; GArray *items; // []*uiMenuItem }; struct uiMenuItem { - uiTyped t; char *name; int type; void (*onClicked)(uiMenuItem *, uiWindow *, void *); @@ -140,7 +138,6 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name) complain("attempt to create a new menu item after menus have been finalized"); item = uiNew(uiMenuItem); - uiTyped(item)->Type = uiMenuItemType(); g_array_append_val(m->items, item); @@ -238,7 +235,6 @@ uiMenu *uiNewMenu(const char *name) menus = g_array_new(FALSE, TRUE, sizeof (uiMenu *)); m = uiNew(uiMenu); - uiTyped(m)->Type = uiMenuType(); g_array_append_val(menus, m); diff --git a/unix/multilineentry.c b/unix/multilineentry.c index cb25f3a0..08bfe1fc 100644 --- a/unix/multilineentry.c +++ b/unix/multilineentry.c @@ -87,7 +87,7 @@ uiMultilineEntry *uiNewMultilineEntry(void) { uiMultilineEntry *e; - e = (uiMultilineEntry *) uiNewControl(uiMultilineEntryType()); + e = (uiMultilineEntry *) uiNewControl(uiMultilineEntry); e->widget = gtk_scrolled_window_new(NULL, NULL); e->scontainer = GTK_CONTAINER(e->widget); diff --git a/unix/progressbar.c b/unix/progressbar.c index 64cf9471..5767476a 100644 --- a/unix/progressbar.c +++ b/unix/progressbar.c @@ -22,7 +22,7 @@ uiProgressBar *uiNewProgressBar(void) { uiProgressBar *p; - p = (uiProgressBar *) uiNewControl(uiProgressBarType()); + p = (uiProgressBar *) uiNewControl(uiProgressBar); p->widget = gtk_progress_bar_new(); p->pbar = GTK_PROGRESS_BAR(p->widget); diff --git a/unix/radiobuttons.c b/unix/radiobuttons.c index 4a216870..af1436de 100644 --- a/unix/radiobuttons.c +++ b/unix/radiobuttons.c @@ -42,7 +42,7 @@ uiRadioButtons *uiNewRadioButtons(void) { uiRadioButtons *r; - r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType()); + r = (uiRadioButtons *) uiNewControl(uiRadioButtons); r->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); r->container = GTK_CONTAINER(r->widget); diff --git a/unix/separator.c b/unix/separator.c index b432e67f..72af9393 100644 --- a/unix/separator.c +++ b/unix/separator.c @@ -15,7 +15,7 @@ uiSeparator *uiNewHorizontalSeparator(void) { uiSeparator *s; - s = (uiSeparator *) uiNewControl(uiSeparatorType()); + s = (uiSeparator *) uiNewControl(uiSeparator); s->widget = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); s->separator = GTK_SEPARATOR(s->widget); diff --git a/unix/slider.c b/unix/slider.c index a23589c4..8b2f39ba 100644 --- a/unix/slider.c +++ b/unix/slider.c @@ -50,7 +50,7 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max) { uiSlider *s; - s = (uiSlider *) uiNewControl(uiSliderType()); + s = (uiSlider *) uiNewControl(uiSlider); s->widget = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, min, max, 1); s->range = GTK_RANGE(s->widget); diff --git a/unix/spinbox.c b/unix/spinbox.c index fdf3caa4..13d6082f 100644 --- a/unix/spinbox.c +++ b/unix/spinbox.c @@ -54,7 +54,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) if (min >= max) complain("error: min >= max in uiNewSpinbox()"); - s = (uiSpinbox *) uiNewControl(uiSpinboxType()); + s = (uiSpinbox *) uiNewControl(uiSpinbox); s->widget = gtk_spin_button_new_with_range(min, max, 1); s->entry = GTK_ENTRY(s->widget); diff --git a/unix/tab.c b/unix/tab.c index 3b2ac6a4..ab2aa082 100644 --- a/unix/tab.c +++ b/unix/tab.c @@ -86,7 +86,7 @@ uiTab *uiNewTab(void) { uiTab *t; - t = (uiTab *) uiNewControl(uiTabType()); + t = (uiTab *) uiNewControl(uiTab); t->widget = gtk_notebook_new(); t->container = GTK_CONTAINER(t->widget); diff --git a/unix/window.c b/unix/window.c index 1fabb9f0..e442d8d9 100644 --- a/unix/window.c +++ b/unix/window.c @@ -121,7 +121,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) { uiWindow *w; - w = (uiWindow *) uiNewControl(uiWindowType()); + w = (uiWindow *) uiNewControl(uiWindow); w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); w->container = GTK_CONTAINER(w->widget);