From de9d72299fb89a8b6cdc8963cd6b6ae708a81e80 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 16 Apr 2015 16:38:33 -0400 Subject: [PATCH] Cleaned up unix/button.c a bit. --- new/unix/button.c | 28 ++++++++++++++-------------- new/unix/uipriv_unix.h | 3 +++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/new/unix/button.c b/new/unix/button.c index d67b9a4..404d7a8 100644 --- a/new/unix/button.c +++ b/new/unix/button.c @@ -7,7 +7,7 @@ struct button { void *onClickedData; }; -static void onClicked(GtkButton *button, gpointer data) +static void clicked(GtkButton *button, gpointer data) { struct button *b = (struct button *) data; @@ -19,26 +19,26 @@ static void defaultOnClicked(uiButton *b, void *data) // do nothing } -static void onDestroy(GtkWidget *widget, gpointer data) +static void destroy(GtkWidget *widget, gpointer data) { struct button *b = (struct button *) data; uiFree(b); } -#define BUTTON(b) GTK_BUTTON(uiControlHandle(uiControl(b))) +#define BUTTON(b) GTK_BUTTON(widget(b)) -static char *getText(uiButton *b) +static char *buttonText(uiButton *bb) { - return g_strdup(gtk_button_get_label(BUTTON(b))); + return g_strdup(gtk_button_get_label(BUTTON(bb))); } -static void setText(uiButton *b, const char *text) +static void buttonSetText(uiButton *bb, const char *text) { - gtk_button_set_label(BUTTON(b), text); + gtk_button_set_label(BUTTON(bb), text); } -static void setOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *data) +static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *data) { struct button *b = (struct button *) bb; @@ -58,14 +58,14 @@ uiButton *uiNewButton(const char *text) "label", text, NULL); - widget = GTK_WIDGET(BUTTON(b)); - g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), b); - g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), b); + widget = WIDGET(b); + g_signal_connect(widget, "clicked", G_CALLBACK(clicked), b); + g_signal_connect(widget, "destroy", G_CALLBACK(destroy), b); b->onClicked = defaultOnClicked; - uiButton(b)->Text = getText; - uiButton(b)->SetText = setText; - uiButton(b)->OnClicked = setOnClicked; + uiButton(b)->Text = buttonText; + uiButton(b)->SetText = buttonSetText; + uiButton(b)->OnClicked = buttonOnClicked; return uiButton(b); } diff --git a/new/unix/uipriv_unix.h b/new/unix/uipriv_unix.h index 2178ab0..0f460cb 100644 --- a/new/unix/uipriv_unix.h +++ b/new/unix/uipriv_unix.h @@ -9,3 +9,6 @@ #define gtkXMargin 12 #define gtkYMargin 12 + +#define widget(c) uiControlHandle(uiControl(c)) +#define WIDGET(c) GTK_WIDGET(widget(c))