libui/unix/controls.c

43 lines
1.0 KiB
C
Raw Normal View History

// 8 june 2019
#include "uipriv_unix.h"
2020-05-31 12:37:56 -05:00
bool uiprivOSVtableValid(const char *name, const uiControlOSVtable *osVtable, const char *func)
{
if (osVtable->Size != sizeof (uiControlOSVtable)) {
uiprivProgrammerErrorWrongStructSize(osVtable->Size, "uiControlOSVtable", func);
return false;
}
2020-05-31 12:37:56 -05:00
#define checkMethod(method) \
if (osVtable->method == NULL) { \
uiprivProgrammerErrorRequiredControlMethodMissing(name, "uiControlOSVtable", #method, func); \
return 0; \
}
checkMethod(Handle)
return true;
}
uiControlOSVtable *uiprivCloneOSVtable(const uiControlOSVtable *osVtable)
{
uiControlOSVtable *v2;
v2 = uiprivNew(uiControlOSVtable);
*v2 = *osVtable;
return v2;
}
2020-05-31 12:37:56 -05:00
#define callVtable(method, ...) ((*(method))(__VA_ARGS__))
GtkWidget *uiUnixControlHandle(uiControl *c)
{
uiControlOSVtable *osVtable;
if (!uiprivCheckInitializedAndThread())
return NULL;
if (c == NULL) {
uiprivProgrammerErrorNullPointer("uiControl", uiprivFunc);
return NULL;
}
osVtable = uiprivControlOSVtable(c);
return callVtable(osVtable->Handle, c, uiControlImplData(c));
}