Page 1 of 1

convertir gpointer en data

Posted: Tue Aug 04, 2020 3:57 pm
by jgayoso
Tengo el siguiente código donde la función KeyPressEvent recive un PHB_ITEM en gpointer pero al convertir no me pasa los valores.

Algo estoy haciendo mal ¿si alguien me puede ayuda?

g_print("%d %s \n", (int)hb_arrayGetNL( aData, 1 ), (char *)hb_arrayGetC( aData, 2 ));

Resultado en Pantalla OK:
65470 XXXXXXXXXX

g_signal_connect ( G_OBJECT( entry_box ), "key_press_event", G_CALLBACK( KeyPressEvent ), (gpointer) aData );
.
.
.
.
.
gboolean KeyPressEvent( GtkWidget * entry, GdkEventKey * event, gpointer aData ) {

PHB_ITEM param = aData;

g_print("%d - %s \n", (int)hb_arrayGetNL(param,1), (char *)hb_arrayGetC(param,2));

Resultado en Pantalla: ( No trae los valores esperados (65470 XXXXXXXXXX) )
0 - (null)

Re: convertir gpointer en data

Posted: Tue Aug 04, 2020 8:32 pm
by jgayoso
Ya lo arregle...

GPtrArray* parray;
parray = g_ptr_array_new ();
g_ptr_array_add (parray, (gpointer) hb_arrayGetNL( aData, 1 ));
g_ptr_array_add (parray, (gpointer) cPicture);

g_signal_connect ( G_OBJECT( entry_box ), "key_press_event", G_CALLBACK( KeyPressEvent ), parray );
.
.
.
.
gboolean KeyPressEvent( GtkWidget * entry, GdkEventKey * event, GPtrArray *aData ) {

guint x = g_ptr_array_index(aData, 0);
gchar *y = g_ptr_array_index(aData, 1);
g_print("%d %s \n", x, y);