More GTK+ control migration. I'll need to handle bin now I suppose...
This commit is contained in:
parent
f9e4735510
commit
e1113d2204
|
@ -1,45 +1,36 @@
|
||||||
// 11 june 2015
|
// 11 june 2015
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
struct combobox {
|
struct uiCombobox {
|
||||||
uiCombobox c;
|
uiUnixControl c;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkComboBox *combobox;
|
GtkComboBox *combobox;
|
||||||
GtkComboBoxText *comboboxText;
|
GtkComboBoxText *comboboxText;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiCombobox, uiTypeCombobox, struct combobox)
|
uiUnixDefineControl(
|
||||||
|
uiCombobox, // type name
|
||||||
|
uiComboboxType // type function
|
||||||
|
)
|
||||||
|
|
||||||
static uintptr_t comboboxHandle(uiControl *cc)
|
void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
struct combobox *c = (struct combobox *) cc;
|
|
||||||
|
|
||||||
return (uintptr_t) (c->widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void comboboxAppend(uiCombobox *cc, const char *text)
|
|
||||||
{
|
|
||||||
struct combobox *c = (struct combobox *) cc;
|
|
||||||
|
|
||||||
gtk_combo_box_text_append(c->comboboxText, NULL, text);
|
gtk_combo_box_text_append(c->comboboxText, NULL, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiCombobox *finishNewCombobox(GtkWidget *(*newfunc)(void))
|
static uiCombobox *finishNewCombobox(GtkWidget *(*newfunc)(void))
|
||||||
{
|
{
|
||||||
struct combobox *c;
|
uiCombobox *c;
|
||||||
|
|
||||||
c = (struct combobox *) uiNewControl(uiTypeCombobox());
|
c = (uiCombobox *) uiNewControl(uiTypeCombobox());
|
||||||
|
|
||||||
c->widget = (*newfunc)();
|
c->widget = (*newfunc)();
|
||||||
c->combobox = GTK_COMBO_BOX(c->widget);
|
c->combobox = GTK_COMBO_BOX(c->widget);
|
||||||
c->comboboxText = GTK_COMBO_BOX_TEXT(c->widget);
|
c->comboboxText = GTK_COMBO_BOX_TEXT(c->widget);
|
||||||
uiUnixMakeSingleWidgetControl(uiControl(c), c->widget);
|
|
||||||
|
|
||||||
uiControl(c)->Handle = comboboxHandle;
|
uiUnixFinishNewControl(c, uiCombobox);
|
||||||
|
|
||||||
uiCombobox(c)->Append = comboboxAppend;
|
return c;
|
||||||
|
|
||||||
return uiCombobox(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiCombobox *uiNewCombobox(void)
|
uiCombobox *uiNewCombobox(void)
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
// 11 june 2015
|
// 11 june 2015
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
struct datetimepicker {
|
struct uiDateTimePicker {
|
||||||
uiDateTimePicker d;
|
uiUnixControl c;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiDateTimePicker, uiTypeDateTimePicker, struct datetimepicker)
|
uiUnixDefineControl(
|
||||||
|
uiDateTimePicker, // type name
|
||||||
static uintptr_t datetimepickerHandle(uiControl *c)
|
uiDateTimePickerType // type function
|
||||||
{
|
)
|
||||||
struct datetimepicker *d = (struct datetimepicker *) c;
|
|
||||||
|
|
||||||
return (uintptr_t) (d->widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
typedef int OSTHING;
|
typedef int OSTHING;
|
||||||
|
@ -25,16 +21,15 @@ enum {
|
||||||
|
|
||||||
uiDateTimePicker *finishNewDateTimePicker(OSTHING OSARG)
|
uiDateTimePicker *finishNewDateTimePicker(OSTHING OSARG)
|
||||||
{
|
{
|
||||||
struct datetimepicker *d;
|
uiDateTimePicker *d;
|
||||||
|
|
||||||
d = (struct datetimepicker *) uiNewControl(uiTypeDateTimePicker());
|
d = (uiDateTimePicker *) uiNewControl(uiTypeDateTimePicker());
|
||||||
|
|
||||||
d->widget = gtk_label_new("TODO uiDateTimePicker not implemented");
|
d->widget = gtk_label_new("TODO uiDateTimePicker not implemented");
|
||||||
uiUnixMakeSingleWidgetControl(uiControl(d), d->widget);
|
|
||||||
|
|
||||||
uiControl(d)->Handle = datetimepickerHandle;
|
uiUnixFinishNewControl(d, uiDateTimePicker);
|
||||||
|
|
||||||
return uiDateTimePicker(d);
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiDateTimePicker *uiNewDateTimePicker(void)
|
uiDateTimePicker *uiNewDateTimePicker(void)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// 11 june 2015
|
// 11 june 2015
|
||||||
#include "uipriv_unix.h"
|
#include "uipriv_unix.h"
|
||||||
|
|
||||||
struct entry {
|
struct uiEntry {
|
||||||
uiEntry e;
|
uiUnixControl c;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkEntry *entry;
|
GtkEntry *entry;
|
||||||
GtkEditable *editable;
|
GtkEditable *editable;
|
||||||
|
@ -11,7 +11,10 @@ struct entry {
|
||||||
gulong onChangedSignal;
|
gulong onChangedSignal;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiEntry, uiTypeEntry, struct entry)
|
uiUnixDefineControl(
|
||||||
|
uiEntry, // type name
|
||||||
|
uiEntryType // type function
|
||||||
|
)
|
||||||
|
|
||||||
static void onChanged(GtkEditable *editable, gpointer data)
|
static void onChanged(GtkEditable *editable, gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -20,29 +23,18 @@ static void onChanged(GtkEditable *editable, gpointer data)
|
||||||
(*(e->onChanged))(uiEntry(e), e->onChangedData);
|
(*(e->onChanged))(uiEntry(e), e->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr_t entryHandle(uiControl *c)
|
|
||||||
{
|
|
||||||
struct entry *e = (struct entry *) c;
|
|
||||||
|
|
||||||
return (uintptr_t) (e->widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void defaultOnChanged(uiEntry *e, void *data)
|
static void defaultOnChanged(uiEntry *e, void *data)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *entryText(uiEntry *ee)
|
char *uiEntryText(uiEntry *e)
|
||||||
{
|
{
|
||||||
struct entry *e = (struct entry *) ee;
|
|
||||||
|
|
||||||
return uiUnixStrdupText(gtk_entry_get_text(e->entry));
|
return uiUnixStrdupText(gtk_entry_get_text(e->entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void entrySetText(uiEntry *ee, const char *text)
|
void uiEntrySetText(uiEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
struct entry *e = (struct entry *) ee;
|
|
||||||
|
|
||||||
// we need to inhibit sending of ::changed because this WILL send a ::changed otherwise
|
// we need to inhibit sending of ::changed because this WILL send a ::changed otherwise
|
||||||
g_signal_handler_block(e->editable, e->onChangedSignal);
|
g_signal_handler_block(e->editable, e->onChangedSignal);
|
||||||
gtk_entry_set_text(e->entry, text);
|
gtk_entry_set_text(e->entry, text);
|
||||||
|
@ -50,24 +42,19 @@ static void entrySetText(uiEntry *ee, const char *text)
|
||||||
// don't queue the control for resize; entry sizes are independent of their contents
|
// don't queue the control for resize; entry sizes are independent of their contents
|
||||||
}
|
}
|
||||||
|
|
||||||
static void entryOnChanged(uiEntry *ee, void (*f)(uiEntry *, void *), void *data)
|
void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *, void *), void *data)
|
||||||
{
|
{
|
||||||
struct entry *e = (struct entry *) ee;
|
|
||||||
|
|
||||||
e->onChanged = f;
|
e->onChanged = f;
|
||||||
e->onChangedData = data;
|
e->onChangedData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int entryReadOnly(uiEntry *ee)
|
int uiEntryReadOnly(uiEntry *e)
|
||||||
{
|
{
|
||||||
struct entry *e = (struct entry *) ee;
|
|
||||||
|
|
||||||
return gtk_editable_get_editable(e->editable) == FALSE;
|
return gtk_editable_get_editable(e->editable) == FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void entrySetReadOnly(uiEntry *ee, int readonly)
|
void uiEntrySetReadOnly(uiEntry *e, int readonly)
|
||||||
{
|
{
|
||||||
struct entry *e = (struct entry *) ee;
|
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
|
|
||||||
editable = TRUE;
|
editable = TRUE;
|
||||||
|
@ -78,25 +65,18 @@ static void entrySetReadOnly(uiEntry *ee, int readonly)
|
||||||
|
|
||||||
uiEntry *uiNewEntry(void)
|
uiEntry *uiNewEntry(void)
|
||||||
{
|
{
|
||||||
struct entry *e;
|
uiEntry *e;
|
||||||
|
|
||||||
e = (struct entry *) uiNewControl(uiTypeEntry());
|
e = (uiEntry *) uiNewControl(uiTypeEntry());
|
||||||
|
|
||||||
e->widget = gtk_entry_new();
|
e->widget = gtk_entry_new();
|
||||||
e->entry = GTK_ENTRY(e->widget);
|
e->entry = GTK_ENTRY(e->widget);
|
||||||
e->editable = GTK_EDITABLE(e->widget);
|
e->editable = GTK_EDITABLE(e->widget);
|
||||||
uiUnixMakeSingleWidgetControl(uiControl(e), e->widget);
|
|
||||||
|
|
||||||
e->onChangedSignal = g_signal_connect(e->widget, "changed", G_CALLBACK(onChanged), e);
|
e->onChangedSignal = g_signal_connect(e->widget, "changed", G_CALLBACK(onChanged), e);
|
||||||
e->onChanged = defaultOnChanged;
|
uiEntryOnChanged(e->onChanged, defaultOnChanged, NULL);
|
||||||
|
|
||||||
uiControl(e)->Handle = entryHandle;
|
uiUnixFinishNewControl(e, uiEntry);
|
||||||
|
|
||||||
uiEntry(e)->Text = entryText;
|
return e;
|
||||||
uiEntry(e)->SetText = entrySetText;
|
|
||||||
uiEntry(e)->OnChanged = entryOnChanged;
|
|
||||||
uiEntry(e)->ReadOnly = entryReadOnly;
|
|
||||||
uiEntry(e)->SetReadOnly = entrySetReadOnly;
|
|
||||||
|
|
||||||
return uiEntry(e);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue