2015-04-11 21:49:41 -05:00
// 11 april 2015
# include "uipriv_unix.h"
struct label {
2015-04-15 21:17:02 -05:00
uiLabel l ;
2015-04-11 21:49:41 -05:00
} ;
static void onDestroy ( GtkWidget * widget , gpointer data )
{
struct label * l = ( struct label * ) data ;
uiFree ( l ) ;
}
2015-04-15 21:17:02 -05:00
# 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 ) ;
}
2015-04-15 22:07:43 -05:00
uiLabel * uiNewLabel ( const char * text )
2015-04-11 21:49:41 -05:00
{
struct label * l ;
GtkWidget * widget ;
2015-04-15 21:17:02 -05:00
l = uiNew ( struct label ) ;
uiUnixNewControl ( uiControl ( l ) , GTK_TYPE_LABEL ,
2015-04-11 21:49:41 -05:00
FALSE , FALSE ,
" label " , text ,
2015-04-15 11:14:09 -05:00
" 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+)
2015-04-11 21:49:41 -05:00
// TODO yalign 0?
NULL ) ;
2015-04-15 21:17:02 -05:00
widget = GTK_WIDGET ( LABEL ( l ) ) ;
2015-04-11 21:49:41 -05:00
g_signal_connect ( widget , " destroy " , G_CALLBACK ( onDestroy ) , l ) ;
2015-04-15 21:17:02 -05:00
uiLabel ( l ) - > Text = getText ;
uiLabel ( l ) - > SetText = setText ;
2015-04-11 21:49:41 -05:00
2015-04-15 21:17:02 -05:00
return uiLabel ( l ) ;
2015-04-11 21:49:41 -05:00
}