Converted unix/entry.c and unix/label.c.
This commit is contained in:
parent
f6ef521233
commit
922360f112
|
@ -2,6 +2,7 @@
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
struct entry {
|
struct entry {
|
||||||
|
uiEntry e;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void onDestroy(GtkWidget *widget, gpointer data)
|
static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
|
@ -11,31 +12,34 @@ static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
uiFree(e);
|
uiFree(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ENTRY(e) GTK_ENTRY(uiControlHandle(uiControl(e)))
|
||||||
|
|
||||||
|
static char *getText(uiEntry *e)
|
||||||
|
{
|
||||||
|
return g_strdup(gtk_entry_get_text(ENTRY(e)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void uiEntrySetText(uiEntry *e, const char *text)
|
||||||
|
{
|
||||||
|
gtk_entry_set_text(ENTRY(e), text);
|
||||||
|
}
|
||||||
|
|
||||||
uiControl *uiNewEntry(void)
|
uiControl *uiNewEntry(void)
|
||||||
{
|
{
|
||||||
uiControl *c;
|
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
c = uiUnixNewControl(GTK_TYPE_ENTRY,
|
e = uiNew(struct entry);
|
||||||
|
|
||||||
|
uiUnixNewControl(uiControl(e), GTK_TYPE_ENTRY,
|
||||||
FALSE, FALSE,
|
FALSE, FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
widget = GTK_WIDGET(uiControlHandle(c));
|
widget = GTK_WIDGET(ENTRY(e));
|
||||||
|
|
||||||
e = uiNew(struct entry);
|
|
||||||
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), e);
|
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), e);
|
||||||
c->data = e;
|
|
||||||
|
|
||||||
return c;
|
uiEntry(e)->Text = getText;
|
||||||
}
|
uiEntry(e)->SetText = setText;
|
||||||
|
|
||||||
char *uiEntryText(uiControl *c)
|
return uiEntry(e);
|
||||||
{
|
|
||||||
return g_strdup(gtk_entry_get_text(GTK_ENTRY(uiControlHandle(c))));
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiEntrySetText(uiControl *c, const char *text)
|
|
||||||
{
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(uiControlHandle(c)), text);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
struct label {
|
struct label {
|
||||||
|
uiLabel l;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void onDestroy(GtkWidget *widget, gpointer data)
|
static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
|
@ -11,35 +12,38 @@ static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
uiFree(l);
|
uiFree(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LABEL(l) GTK_LABEL(uiControlHandle(uiControl(l)))
|
||||||
|
|
||||||
|
static char *getText(uiLabel *l)
|
||||||
|
{
|
||||||
|
// TODO change g_strdup() to a wrapper function for export in ui_unix.h
|
||||||
|
return g_strdup(gtk_label_get_text(LABEL(l)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setText(uiLabel *l, const char *text)
|
||||||
|
{
|
||||||
|
gtk_label_set_text(LABEL(l), text);
|
||||||
|
}
|
||||||
|
|
||||||
uiControl *uiNewLabel(const char *text)
|
uiControl *uiNewLabel(const char *text)
|
||||||
{
|
{
|
||||||
uiControl *c;
|
|
||||||
struct label *l;
|
struct label *l;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
c = uiUnixNewControl(GTK_TYPE_LABEL,
|
l = uiNew(struct label);
|
||||||
|
|
||||||
|
uiUnixNewControl(uiControl(l), GTK_TYPE_LABEL,
|
||||||
FALSE, FALSE,
|
FALSE, FALSE,
|
||||||
"label", text,
|
"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+)
|
"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?
|
// TODO yalign 0?
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
widget = GTK_WIDGET(uiControlHandle(c));
|
widget = GTK_WIDGET(LABEL(l));
|
||||||
|
|
||||||
l = uiNew(struct label);
|
|
||||||
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), l);
|
g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), l);
|
||||||
c->data = l;
|
|
||||||
|
|
||||||
return c;
|
uiLabel(l)->Text = getText;
|
||||||
}
|
uiLabel(l)->SetText = setText;
|
||||||
|
|
||||||
char *uiLabelText(uiControl *c)
|
return uiLabel(l);
|
||||||
{
|
|
||||||
// TODO change g_strdup() to a wrapper function for export in ui_unix.h
|
|
||||||
return g_strdup(gtk_label_get_text(GTK_LABEL(uiControlHandle(c))));
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiLabelSetText(uiControl *c, const char *text)
|
|
||||||
{
|
|
||||||
gtk_label_set_text(GTK_LABEL(uiControlHandle(c)), text);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue