Started doing conversion of the GTK+ backend...
This commit is contained in:
parent
bb0c52ee4e
commit
a25f49e7e6
|
@ -7,11 +7,11 @@ This file assumes that you have included <gtk/gtk.h> and "ui.h" beforehand. It p
|
|||
#ifndef __UI_UI_UNIX_H__
|
||||
#define __UI_UI_UNIX_H__
|
||||
|
||||
// uiUnixNewControl() creates a new uiControl with the given GTK+ control inside.
|
||||
// The first parameter is the type of the control, as passed to the first argument of g_object_new().
|
||||
// uiUnixNewControl() creates a new uiControl with the given GTK+ control inside, storing it in the uiControl at c.
|
||||
// The second parameter is the type of the control, as passed to the first argument of g_object_new().
|
||||
// The two scrolledWindow parameters allow placing scrollbars on the new control.
|
||||
// The firstProperty parameter and beyond allow passing construct properties to the new control, as with g_object_new(); end this list with NULL.
|
||||
extern uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, const char *firstProperty, ...);
|
||||
extern void uiUnixNewControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, const char *firstProperty, ...);
|
||||
|
||||
struct uiSizingSys {
|
||||
// this structure currently left blank
|
||||
|
|
|
@ -8,7 +8,7 @@ struct button {
|
|||
|
||||
static void onClicked(GtkButton *button, gpointer data)
|
||||
{
|
||||
uiControl *c = (uiControl *) data;
|
||||
uiControl *c = uiControl(data);
|
||||
struct button *b = (struct button *) (c->data);
|
||||
|
||||
(*(b->onClicked))(c, b->onClickedData);
|
||||
|
@ -26,42 +26,48 @@ static void onDestroy(GtkWidget *widget, gpointer data)
|
|||
uiFree(b);
|
||||
}
|
||||
|
||||
uiControl *uiNewButton(const char *text)
|
||||
static char *getText(uiButton *b)
|
||||
{
|
||||
uiControl *c;
|
||||
struct button *b;
|
||||
GtkWidget *widget;
|
||||
|
||||
c = uiUnixNewControl(GTK_TYPE_BUTTON,
|
||||
FALSE, FALSE,
|
||||
"label", text,
|
||||
NULL);
|
||||
|
||||
widget = GTK_WIDGET(uiControlHandle(c));
|
||||
g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), c);
|
||||
|
||||
b = uiNew(struct button);
|
||||
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), b);
|
||||
b->onClicked = defaultOnClicked;
|
||||
c->data = b;
|
||||
|
||||
return c;
|
||||
return g_strdup(gtk_button_get_label(GTK_BUTTON(uiControlHandle(b.base))));
|
||||
}
|
||||
|
||||
char *uiButtonText(uiControl *c)
|
||||
static void setText(uiButton *b, const char *text)
|
||||
{
|
||||
return g_strdup(gtk_button_get_label(GTK_BUTTON(uiControlHandle(c))));
|
||||
gtk_button_set_label(GTK_BUTTON(uiControlHandle(b.base)), text);
|
||||
}
|
||||
|
||||
void uiButtonSetText(uiControl *c, const char *text)
|
||||
static void setOnClicked(uiButton *b, void (*f)(uiControl *, void *), void *data)
|
||||
{
|
||||
gtk_button_set_label(GTK_BUTTON(uiControlHandle(c)), text);
|
||||
}
|
||||
|
||||
void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data)
|
||||
{
|
||||
struct button *b = (struct button *) (c->data);
|
||||
struct button *b = (struct button *) (b->base.data);
|
||||
|
||||
b->onClicked = f;
|
||||
b->onClickedData = data;
|
||||
}
|
||||
|
||||
uiControl *uiNewButton(const char *text)
|
||||
{
|
||||
uiButton *b;
|
||||
struct button *bb;
|
||||
GtkWidget *widget;
|
||||
|
||||
b = uiNew(uiButton);
|
||||
|
||||
uiUnixNewControl(&(b.base), GTK_TYPE_BUTTON,
|
||||
FALSE, FALSE,
|
||||
"label", text,
|
||||
NULL);
|
||||
|
||||
widget = GTK_WIDGET(uiControlHandle(&(b.base)));
|
||||
g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), b);
|
||||
|
||||
bb = uiNew(struct button);
|
||||
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), bb);
|
||||
bb->onClicked = defaultOnClicked;
|
||||
b->priv.data = bb;
|
||||
|
||||
b->Text = getText;
|
||||
b->SetText = setText;
|
||||
b->OnClicked = setOnClicked;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -159,16 +159,14 @@ static void singleContainerDisable(uiControl *c)
|
|||
|
||||
static void onDestroy(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
uiControl *c = (uiControl *) data;
|
||||
uiControl *c = uiControl(data);
|
||||
singleWidget *s = (singleWidget *) (c->internal);
|
||||
|
||||
uiFree(s);
|
||||
uiFree(c);
|
||||
}
|
||||
|
||||
uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, const char *firstProperty, ...)
|
||||
void uiUnixNewControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, const char *firstProperty, ...)
|
||||
{
|
||||
uiControl *c;
|
||||
singleWidget *s;
|
||||
va_list ap;
|
||||
|
||||
|
@ -201,7 +199,6 @@ uiControl *uiUnixNewControl(GType type, gboolean inScrolledWindow, gboolean scro
|
|||
// this also ensures singleRemoveParent() works properly
|
||||
g_object_ref_sink(s->immediate);
|
||||
|
||||
c = uiNew(uiControl);
|
||||
// assign s later; we still need it for one more thing
|
||||
c->destroy = singleDestroy;
|
||||
c->handle = singleHandle;
|
||||
|
|
Loading…
Reference in New Issue