diff --git a/redo/ui_unix.h b/redo/ui_unix.h new file mode 100644 index 00000000..4786ec3f --- /dev/null +++ b/redo/ui_unix.h @@ -0,0 +1,59 @@ +// 7 april 2015 + +/* +This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X). +*/ + +#ifndef __LIBUI_UI_UNIX_H__ +#define __LIBUI_UI_UNIX_H__ + +typedef struct uiUnixControl uiUnixControl; +struct uiUnixControl { + uiControl c; +}; +_UI_EXTERN uintmax_t uiUnixControlType(void); +#define uiUnixControl(this) ((uiUnixControl *) uiIsA((this), uiUnixControlType(), 1)) +// TODO document +_UI_EXTERN void uiUnixControlTriggerRelayout(uiUnixControl *); + +// TODO document +#define uiUnixDefineControlWithOnDestroy(type, typefn, onDestroy) \ + static uintmax_t _ ## type ## Type = 0; \ + uintmax_t typefn(void) \ + { \ + if (_ ## type ## Type == 0) \ + _ ## type ## Type = uiRegisterType(#type, uiUnixControlType(), sizeof (type)); \ + return _ ## type ## Type; \ + } \ + static void _ ## type ## CommitDestroy(uiControl *c) \ + { \ + type *this = type(c); \ + onDestroy; \ + g_object_unref(this->widget); \ + } \ + static uintptr_t _ ## type ## Handle(uiControl *c) \ + { \ + return (uintptr_t) (type(c)->widget); \ + } \ + static void _ ## type ## ContainerUpdateState(uiControl *c) \ + { \ + /* do nothing */ \ + } + +#define uiUnixDefineControl(type, typefn) \ + uiUnixDefineControlWithOnDestroy(type, typefn, (void) this;) + +#define uiUnixFinishNewControl(variable, type) \ + uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \ + uiControl(variable)->Handle = _ ## type ## Handle; \ + uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \ + uiUnixFinishControl(uiControl(variable)); + +// This is a function used to set up a control. +// Don't call it directly; use uiUnixFinishNewControl() instead. +_UI_EXTERN void uiUnixFinishControl(uiControl *c); + +// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). +extern char *uiUnixStrdupText(const char *); + +#endif diff --git a/unix/GNUmakeinc.mk b/redo/unix/GNUmakeinc.mk similarity index 100% rename from unix/GNUmakeinc.mk rename to redo/unix/GNUmakeinc.mk diff --git a/unix/alloc.c b/redo/unix/alloc.c similarity index 100% rename from unix/alloc.c rename to redo/unix/alloc.c diff --git a/unix/bin.c b/redo/unix/bin.c similarity index 100% rename from unix/bin.c rename to redo/unix/bin.c diff --git a/unix/box.c b/redo/unix/box.c similarity index 100% rename from unix/box.c rename to redo/unix/box.c diff --git a/unix/button.c b/redo/unix/button.c similarity index 100% rename from unix/button.c rename to redo/unix/button.c diff --git a/unix/checkbox.c b/redo/unix/checkbox.c similarity index 100% rename from unix/checkbox.c rename to redo/unix/checkbox.c diff --git a/unix/combobox.c b/redo/unix/combobox.c similarity index 100% rename from unix/combobox.c rename to redo/unix/combobox.c diff --git a/unix/container.c b/redo/unix/container.c similarity index 100% rename from unix/container.c rename to redo/unix/container.c diff --git a/unix/control.c b/redo/unix/control.c similarity index 100% rename from unix/control.c rename to redo/unix/control.c diff --git a/unix/datetimepicker.c b/redo/unix/datetimepicker.c similarity index 100% rename from unix/datetimepicker.c rename to redo/unix/datetimepicker.c diff --git a/unix/entry.c b/redo/unix/entry.c similarity index 100% rename from unix/entry.c rename to redo/unix/entry.c diff --git a/unix/group.c b/redo/unix/group.c similarity index 100% rename from unix/group.c rename to redo/unix/group.c diff --git a/unix/label.c b/redo/unix/label.c similarity index 100% rename from unix/label.c rename to redo/unix/label.c diff --git a/unix/main.c b/redo/unix/main.c similarity index 100% rename from unix/main.c rename to redo/unix/main.c diff --git a/unix/menu.c b/redo/unix/menu.c similarity index 100% rename from unix/menu.c rename to redo/unix/menu.c diff --git a/unix/progressbar.c b/redo/unix/progressbar.c similarity index 100% rename from unix/progressbar.c rename to redo/unix/progressbar.c diff --git a/unix/radiobuttons.c b/redo/unix/radiobuttons.c similarity index 100% rename from unix/radiobuttons.c rename to redo/unix/radiobuttons.c diff --git a/unix/separator.c b/redo/unix/separator.c similarity index 100% rename from unix/separator.c rename to redo/unix/separator.c diff --git a/unix/slider.c b/redo/unix/slider.c similarity index 100% rename from unix/slider.c rename to redo/unix/slider.c diff --git a/unix/spinbox.c b/redo/unix/spinbox.c similarity index 100% rename from unix/spinbox.c rename to redo/unix/spinbox.c diff --git a/unix/stddialogs.c b/redo/unix/stddialogs.c similarity index 100% rename from unix/stddialogs.c rename to redo/unix/stddialogs.c diff --git a/unix/tab.c b/redo/unix/tab.c similarity index 100% rename from unix/tab.c rename to redo/unix/tab.c diff --git a/unix/text.c b/redo/unix/text.c similarity index 100% rename from unix/text.c rename to redo/unix/text.c diff --git a/unix/uipriv_unix.h b/redo/unix/uipriv_unix.h similarity index 100% rename from unix/uipriv_unix.h rename to redo/unix/uipriv_unix.h diff --git a/unix/util.c b/redo/unix/util.c similarity index 100% rename from unix/util.c rename to redo/unix/util.c diff --git a/unix/window.c b/redo/unix/window.c similarity index 100% rename from unix/window.c rename to redo/unix/window.c diff --git a/ui_unix.h b/ui_unix.h deleted file mode 100644 index ea1301c3..00000000 --- a/ui_unix.h +++ /dev/null @@ -1,23 +0,0 @@ -// 7 april 2015 - -/* -This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X). -*/ - -#ifndef __UI_UI_UNIX_H__ -#define __UI_UI_UNIX_H__ - -// TODO write this comment -_UI_EXTERN void uiUnixMakeSingleWidgetControl(uiControl *c, GtkWidget *widget); - -// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). -extern char *uiUnixStrdupText(const char *); - -struct uiSizingSys { - // this structure currently left blank -}; - -// This creates a uiSizing for Unix systems. -_UI_EXTERN uiSizing *uiUnixNewSizing(void); - -#endif