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-16 21:21:02 -05:00
GtkWidget * widget ;
GtkLabel * label ;
2015-04-11 21:49:41 -05:00
} ;
2015-04-18 16:14:19 -05:00
static void onDestroy ( void * data )
2015-04-11 21:49:41 -05:00
{
2015-04-18 16:14:19 -05:00
struct label * l = ( struct label * ) data ;
2015-04-11 21:49:41 -05:00
uiFree ( l ) ;
}
2015-04-16 21:21:02 -05:00
static char * labelText ( uiLabel * ll )
2015-04-15 21:17:02 -05:00
{
2015-04-16 21:21:02 -05:00
struct label * l = ( struct label * ) ll ;
2015-04-15 21:17:02 -05:00
// TODO change g_strdup() to a wrapper function for export in ui_unix.h
2015-04-16 21:21:02 -05:00
return g_strdup ( gtk_label_get_text ( l - > label ) ) ;
2015-04-15 21:17:02 -05:00
}
2015-04-16 21:21:02 -05:00
static void labelSetText ( uiLabel * ll , const char * text )
2015-04-15 21:17:02 -05:00
{
2015-04-16 21:21:02 -05:00
struct label * l = ( struct label * ) ll ;
gtk_label_set_text ( l - > label , text ) ;
2015-04-15 21:17:02 -05:00
}
2015-04-15 22:07:43 -05:00
uiLabel * uiNewLabel ( const char * text )
2015-04-11 21:49:41 -05:00
{
struct label * l ;
2015-04-15 21:17:02 -05:00
l = uiNew ( struct label ) ;
uiUnixNewControl ( uiControl ( l ) , GTK_TYPE_LABEL ,
2015-04-18 16:14:19 -05:00
FALSE , FALSE , onDestroy , l ,
2015-04-11 21:49:41 -05:00
" 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-29 09:36:31 -05:00
l - > widget = GTK_WIDGET ( uiControlHandle ( uiControl ( l ) ) ) ;
2015-04-16 21:21:02 -05:00
l - > label = GTK_LABEL ( l - > widget ) ;
uiLabel ( l ) - > Text = labelText ;
uiLabel ( l ) - > SetText = labelSetText ;
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
}