Migrated the various controls to the new GTK+ destruction method. Just a few more small changes to make...

This commit is contained in:
Pietro Gagliardi 2015-04-18 13:33:08 -04:00
parent f0055e948b
commit 38b118f033
5 changed files with 15 additions and 25 deletions

View File

@ -21,9 +21,9 @@ static void defaultOnClicked(uiButton *b, void *data)
// do nothing
}
static void onDestroy(GtkWidget *widget, gpointer data)
static void onDestroy(uiControl *c)
{
struct button *b = (struct button *) data;
struct button *b = (struct button *) c;
uiFree(b);
}
@ -57,15 +57,13 @@ uiButton *uiNewButton(const char *text)
b = uiNew(struct button);
uiUnixNewControl(uiControl(b), GTK_TYPE_BUTTON,
FALSE, FALSE,
FALSE, FALSE, onDestroy,
"label", text,
NULL);
b->widget = WIDGET(b);
b->button = GTK_BUTTON(b->widget);
g_signal_connect(b->widget, "destroy", G_CALLBACK(onDestroy), b);
g_signal_connect(b->widget, "clicked", G_CALLBACK(onClicked), b);
b->onClicked = defaultOnClicked;

View File

@ -24,9 +24,9 @@ static void defaultOnToggled(uiCheckbox *c, void *data)
// do nothing
}
static void onDestroy(GtkWidget *widget, gpointer data)
static void onDestroy(uiControl *cc)
{
struct checkbox *c = (struct checkbox *) data;
struct checkbox *c = (struct checkbox *) cc;
uiFree(c);
}
@ -81,7 +81,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
c = uiNew(struct checkbox);
uiUnixNewControl(uiControl(c), GTK_TYPE_CHECK_BUTTON,
FALSE, FALSE,
FALSE, FALSE, onDestroy,
"label", text,
NULL);
@ -90,8 +90,6 @@ uiCheckbox *uiNewCheckbox(const char *text)
c->toggleButton = GTK_TOGGLE_BUTTON(c->widget);
c->checkButton = GTK_CHECK_BUTTON(c->widget);
g_signal_connect(c->widget, "destroy", G_CALLBACK(onDestroy), c);
c->onToggledSignal = g_signal_connect(c->widget, "toggled", G_CALLBACK(onToggled), c);
c->onToggled = defaultOnToggled;

View File

@ -7,9 +7,9 @@ struct entry {
GtkEntry *entry;
};
static void onDestroy(GtkWidget *widget, gpointer data)
static void onDestroy(uiControl *c)
{
struct entry *e = (struct entry *) data;
struct entry *e = (struct entry *) c;
uiFree(e);
}
@ -35,14 +35,12 @@ uiEntry *uiNewEntry(void)
e = uiNew(struct entry);
uiUnixNewControl(uiControl(e), GTK_TYPE_ENTRY,
FALSE, FALSE,
FALSE, FALSE, onDestroy,
NULL);
e->widget = WIDGET(e);
e->entry = GTK_ENTRY(e->widget);
g_signal_connect(e->widget, "destroy", G_CALLBACK(onDestroy), e);
uiEntry(e)->Text = entryText;
uiEntry(e)->SetText = entrySetText;

View File

@ -7,9 +7,9 @@ struct label {
GtkLabel *label;
};
static void onDestroy(GtkWidget *widget, gpointer data)
static void onDestroy(uiControl *c)
{
struct label *l = (struct label *) data;
struct label *l = (struct label *) c;
uiFree(l);
}
@ -36,7 +36,7 @@ uiLabel *uiNewLabel(const char *text)
l = uiNew(struct label);
uiUnixNewControl(uiControl(l), GTK_TYPE_LABEL,
FALSE, FALSE,
FALSE, FALSE, onDestroy,
"label", text,
"xalign", 0.0, // note: must be a float constant, otherwise the ... will turn it into an int and we get segfaults on some platforms (thanks ebassi in irc.gimp.net/#gtk+)
// TODO yalign 0?
@ -45,8 +45,6 @@ uiLabel *uiNewLabel(const char *text)
l->widget = WIDGET(l);
l->label = GTK_LABEL(l->widget);
g_signal_connect(l->widget, "destroy", G_CALLBACK(onDestroy), l);
uiLabel(l)->Text = labelText;
uiLabel(l)->SetText = labelSetText;

View File

@ -11,9 +11,9 @@ struct tab {
uintmax_t cap;
};
static void onDestroy(GtkWidget *widget, gpointer data)
static void onDestroy(uiControl *c)
{
struct tab *t = (struct tab *) data;
struct tab *t = (struct tab *) c;
uiFree(t->pages);
uiFree(t);
@ -66,15 +66,13 @@ uiTab *uiNewTab(void)
t = uiNew(struct tab);
uiUnixNewControl(uiControl(t), GTK_TYPE_NOTEBOOK,
FALSE, FALSE,
FALSE, FALSE, onDestroy,
NULL);
t->widget = WIDGET(t);
t->container = GTK_CONTAINER(t->widget);
t->notebook = GTK_NOTEBOOK(t->widget);
g_signal_connect(t->widget, "destroy", G_CALLBACK(onDestroy), t);
uiTab(t)->AddPage = tabAddPage;
uiTab(t)->DeletePage = tabDeletePage;