GTK working with pointers



Hello,

I have 2 sources(interface.c and callbacks.c) which
belongs to my project,
that is an interface to connect to postgresql, using
GTK.

The problem is: I want to pass an array of pointers
to GtkWidgets (in this case GtkEntries) for my
callback that need to catch the 3 elements(GtkEntry),
to get the (gchar)value inside the entry to make a
connection string to postgresql.

I'm getting the Segmentation Fault. When I'm looking
for the address memory that the pointer is using,
I get a 0xvalue, and when I'm looking inside my
callback function I'm getting annother address memory
for the elements from array.

the source follows...

the interface.c I have this fragment:
-------------------------------------
GtkWidget *txt_user_name;
GtkWidget *txt_db_name;
GtkWidget *txt_user_name;
// array of pointers to GtkWidgets
// to store the 3 entries to post to my callback
GtkWidget *coll_entries[3];

...
...
coll_entries[0] = txt_host_addr;
coll_entries[1] = txt_db_name;
coll_entries[2] = txt_user_name;
...
...	
// bt_conectar is a gtkbutton widget
// conectar_db is my callback to connect to postgr
// coll_entries is the data 
g_signal_connect (G_OBJECT(bt_conectar), "clicked",
G_CALLBACK(conectar_db), (gpointer) coll_entries );
...
...


the callback.c I have this fragment:
-------------------------------------
void conectar_db (GtkWidget *widget, gpointer data)
{
GtkWidget *txt;
gchar *texto;
gint i = 0;
	
for (i = 0; i < 3; i++ ) {
  txt = *( ( (GtkWidget **)(data) ) + i);  
  texto = (gchar *)gtk_entry_get_text(GTK_ENTRY(txt));
  g_print( "\ntexto=%s", texto );
}
	

Thank you



Adolfo Eloy


	
	
		
_______________________________________________________ 
Yahoo! Acesso Grátis - Internet rápida e grátis. 
Instale o discador agora! http://br.acesso.yahoo.com/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]