mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-08-01 18:49:11 -06:00
another UI attempt, I guess.
sorry.
This commit is contained in:
55
src/libui_sdl/libui/unix/button.c
Normal file
55
src/libui_sdl/libui/unix/button.c
Normal file
@ -0,0 +1,55 @@
|
||||
// 10 june 2015
|
||||
#include "uipriv_unix.h"
|
||||
|
||||
struct uiButton {
|
||||
uiUnixControl c;
|
||||
GtkWidget *widget;
|
||||
GtkButton *button;
|
||||
void (*onClicked)(uiButton *, void *);
|
||||
void *onClickedData;
|
||||
};
|
||||
|
||||
uiUnixControlAllDefaults(uiButton)
|
||||
|
||||
static void onClicked(GtkButton *button, gpointer data)
|
||||
{
|
||||
uiButton *b = uiButton(data);
|
||||
|
||||
(*(b->onClicked))(b, b->onClickedData);
|
||||
}
|
||||
|
||||
static void defaultOnClicked(uiButton *b, void *data)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
char *uiButtonText(uiButton *b)
|
||||
{
|
||||
return uiUnixStrdupText(gtk_button_get_label(b->button));
|
||||
}
|
||||
|
||||
void uiButtonSetText(uiButton *b, const char *text)
|
||||
{
|
||||
gtk_button_set_label(b->button, text);
|
||||
}
|
||||
|
||||
void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data)
|
||||
{
|
||||
b->onClicked = f;
|
||||
b->onClickedData = data;
|
||||
}
|
||||
|
||||
uiButton *uiNewButton(const char *text)
|
||||
{
|
||||
uiButton *b;
|
||||
|
||||
uiUnixNewControl(uiButton, b);
|
||||
|
||||
b->widget = gtk_button_new_with_label(text);
|
||||
b->button = GTK_BUTTON(b->widget);
|
||||
|
||||
g_signal_connect(b->widget, "clicked", G_CALLBACK(onClicked), b);
|
||||
uiButtonOnClicked(b, defaultOnClicked, NULL);
|
||||
|
||||
return b;
|
||||
}
|
Reference in New Issue
Block a user