More ui_unix.h and unix/control.c work. NOW we're ready to migrate the controls.

This commit is contained in:
Pietro Gagliardi 2016-04-25 19:45:05 -04:00
parent 6d655cde45
commit 85ee2e93dd
2 changed files with 41 additions and 65 deletions

View File

@ -22,95 +22,95 @@ struct uiUnixControl {
// TODO document // TODO document
_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean); _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean);
#define uiUnixControlDefaultDestroy(type, handlefield) \ #define uiUnixControlDefaultDestroy(type) \
static void type ## Destroy(uiControl *c) \ static void type ## Destroy(uiControl *c) \
{ \ { \
uiControlVerifyDestroy(c); \ uiControlVerifyDestroy(c); \
/* TODO is this safe on floating refs? */ \ /* TODO is this safe on floating refs? */ \
g_object_unref(type(c)->handlefield); \ g_object_unref(type(c)->widget); \
uiFreeControl(c); \ uiFreeControl(c); \
} }
#define uiUnixControlDefaultHandle(type, handlefield) \ #define uiUnixControlDefaultHandle(type) \
static uintptr_t type ## Handle(uiControl *c) \ static uintptr_t type ## Handle(uiControl *c) \
{ \ { \
return (uintptr_t) (type(c)->handlefield); \ return (uintptr_t) (type(c)->widget); \
} }
#define uiUnixControlDefaultParent(type, handlefield) \ #define uiUnixControlDefaultParent(type) \
static uiControl *type ## Parent(uiControl *c) \ static uiControl *type ## Parent(uiControl *c) \
{ \ { \
return uiUnixControl(c)->parent; \ return uiUnixControl(c)->parent; \
} }
#define uiUnixControlDefaultSetParent(type, handlefield) \ #define uiUnixControlDefaultSetParent(type) \
static void type ## SetParent(uiControl *c, uiControl *parent) \ static void type ## SetParent(uiControl *c, uiControl *parent) \
{ \ { \
uiControlVerifySetParent(c, parent); \ uiControlVerifySetParent(c, parent); \
uiUnixControl(c)->parent = parent; \ uiUnixControl(c)->parent = parent; \
} }
#define uiUnixControlDefaultToplevel(type, handlefield) \ #define uiUnixControlDefaultToplevel(type) \
static int type ## Toplevel(uiControl *c) \ static int type ## Toplevel(uiControl *c) \
{ \ { \
return 0; \ return 0; \
} }
#define uiUnixControlDefaultVisible(type, handlefield) \ #define uiUnixControlDefaultVisible(type) \
static int type ## Visible(uiControl *c) \ static int type ## Visible(uiControl *c) \
{ \ { \
return gtk_widget_get_visible(type(c)->handlefield); \ return gtk_widget_get_visible(type(c)->widget); \
} }
#define uiUnixControlDefaultShow(type, handlefield) \ #define uiUnixControlDefaultShow(type) \
static void type ## Show(uiControl *c) \ static void type ## Show(uiControl *c) \
{ \ { \
gtk_widget_show(type(c)->handlefield); \ gtk_widget_show(type(c)->widget); \
} }
#define uiUnixControlDefaultHide(type, handlefield) \ #define uiUnixControlDefaultHide(type) \
static void type ## Hide(uiControl *c) \ static void type ## Hide(uiControl *c) \
{ \ { \
gtk_widget_hide(type(c)->handlefield); \ gtk_widget_hide(type(c)->widget); \
} }
#define uiUnixControlDefaultEnabled(type, handlefield) \ #define uiUnixControlDefaultEnabled(type) \
static int type ## Enabled(uiControl *c) \ static int type ## Enabled(uiControl *c) \
{ \ { \
return gtk_widget_get_sensitive(type(c)->handlefield); \ return gtk_widget_get_sensitive(type(c)->widget); \
} }
#define uiUnixControlDefaultEnable(type, handlefield) \ #define uiUnixControlDefaultEnable(type) \
static void type ## Enable(uiControl *c) \ static void type ## Enable(uiControl *c) \
{ \ { \
gtk_widget_set_sensitive(type(c)->handlefield, TRUE); \ gtk_widget_set_sensitive(type(c)->widget, TRUE); \
} }
#define uiUnixControlDefaultDisable(type, handlefield) \ #define uiUnixControlDefaultDisable(type) \
static void type ## Disable(uiControl *c) \ static void type ## Disable(uiControl *c) \
{ \ { \
gtk_widget_set_sensitive(type(c)->handlefield, FALSE); \ gtk_widget_set_sensitive(type(c)->widget, FALSE); \
} }
#define uiUnixControlDefaultSetContainer(type, handlefield) \ #define uiUnixControlDefaultSetContainer(type) \
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \ static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
{ \ { \
if (!uiUnixControl(c)->addedBefore) { \ if (!uiUnixControl(c)->addedBefore) { \
g_object_ref_sink(type(c)->handlefield); /* our own reference, which we release in Destroy() */ \ g_object_ref_sink(type(c)->widget); /* our own reference, which we release in Destroy() */ \
gtk_widget_show(type(c)->handlefield); \ gtk_widget_show(type(c)->widget); \
uiUnixControl(c)->addedBefore = TRUE; \ uiUnixControl(c)->addedBefore = TRUE; \
} \ } \
if (remove) \ if (remove) \
gtk_container_remove(container, type(c)->handlefield); \ gtk_container_remove(container, type(c)->widget); \
else \ else \
gtk_container_add(container, type(c)->handlefield); \ gtk_container_add(container, type(c)->widget); \
} }
#define uiUnixControlAllDefaultsExceptDestroy(type, handlefield) \ #define uiUnixControlAllDefaultsExceptDestroy(type) \
uiUnixControlDefaultHandle(type, handlefield) \ uiUnixControlDefaultHandle(type) \
uiUnixControlDefaultParent(type, handlefield) \ uiUnixControlDefaultParent(type) \
uiUnixControlDefaultSetParent(type, handlefield) \ uiUnixControlDefaultSetParent(type) \
uiUnixControlDefaultToplevel(type, handlefield) \ uiUnixControlDefaultToplevel(type) \
uiUnixControlDefaultVisible(type, handlefield) \ uiUnixControlDefaultVisible(type) \
uiUnixControlDefaultShow(type, handlefield) \ uiUnixControlDefaultShow(type) \
uiUnixControlDefaultHide(type, handlefield) \ uiUnixControlDefaultHide(type) \
uiUnixControlDefaultEnabled(type, handlefield) \ uiUnixControlDefaultEnabled(type) \
uiUnixControlDefaultEnable(type, handlefield) \ uiUnixControlDefaultEnable(type) \
uiUnixControlDefaultDisable(type, handlefield) \ uiUnixControlDefaultDisable(type) \
uiUnixControlDefaultSetContainer(type, handlefield) uiUnixControlDefaultSetContainer(type)
#define uiUnixControlAllDefaults(type, handlefield) \ #define uiUnixControlAllDefaults(type) \
uiUnixControlDefaultDestroy(type, handlefield) \ uiUnixControlDefaultDestroy(type) \
uiUnixControlAllDefaultsExceptDestroy(type, handlefield) uiUnixControlAllDefaultsExceptDestroy(type)
// TODO document // TODO document
#define uiUnixNewControl(type, var) \ #define uiUnixNewControl(type, var) \

View File

@ -1,33 +1,9 @@
// 16 august 2015 // 16 august 2015
#include "uipriv_unix.h" #include "uipriv_unix.h"
static void defaultCommitShow(uiControl *c) void uiUnixControlSetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove)
{ {
gtk_widget_show(GTK_WIDGET(uiControlHandle(c))); (*(c->SetContainer))(c, container, remove);
}
static void defaultCommitHide(uiControl *c)
{
gtk_widget_hide(GTK_WIDGET(uiControlHandle(c)));
}
void osCommitEnable(uiControl *c)
{
gtk_widget_set_sensitive(GTK_WIDGET(uiControlHandle(c)), TRUE);
}
void osCommitDisable(uiControl *c)
{
gtk_widget_set_sensitive(GTK_WIDGET(uiControlHandle(c)), FALSE);
}
void uiUnixFinishControl(uiControl *c)
{
g_object_ref_sink(GTK_WIDGET(uiControlHandle(c)));
if (!isToplevel(c))
gtk_widget_show(GTK_WIDGET(uiControlHandle(c)));
c->CommitShow = defaultCommitShow;
c->CommitHide = defaultCommitHide;
} }
#define uiUnixControlSignature 0x556E6978 #define uiUnixControlSignature 0x556E6978