Hello!
for a GtkEntry I have connected 2 signals: activate and focus-out-event.
I give the adress of a module-global variable into the user_data for the events.
In the callback-function for the "activate"-event, it works, the content of the user_data is OK
But int the callback-function for the "focus-out-event"-event, the content of the user_data contains nothing. The adress in the gpointer seems to be wrong. I don't understand why, because the way to call the function is exactly the same.
Can somebody help me to know why the values in the user_data of the focus-out-event are wrong or undefined?
Thank you in advance
MBoerner
Code:
// set user data
re_local.parNr[re_local.currParNr] = re_local.currParNr;
re_local.userdata[re_local.currParNr].type_of_param = type_of_param;
re_local.userdata[re_local.currParNr].speicher = speicher;
//
bufferValue = gtk_entry_buffer_new (NULL, 0);
spinOrEntry = gtk_entry_new();
g_signal_connect(GTK_ENTRY(spinOrEntry),"activate",G_CALLBACK(cb_valueEdited), &re_local.userdata[re_local.currParNr]);
g_signal_connect_after (GTK_OBJECT (spinOrEntry), "focus-out-event",G_CALLBACK (cb_NameFocusOut), &re_local.userdata[re_local.currParNr]);
re_local.currParNr++;
definition of user_data
Code:
typedef struct
{
void *speicher;
int type_of_param;
}t_user_data;
t_user_data userdata[MAX_CNT_PAR];
My 2 callbacks functions
Code:
static void cb_valueEdited(GtkEntry *entry, gpointer user_data)
{
int type;
void* variable;
char new_text[50];
type = ((t_user_data *)user_data)->type_of_param;
variable = ((t_user_data *)user_data)->speicher;
strncpy(new_text, gtk_entry_get_text(entry),50);
}
/*
* @param entry : current entry that has been edited
* @param user_data piointer on a structure that contents the adress of the variable to change and the type of the variable
*/
static void cb_NameFocusOut(GtkWidget *entry, gpointer user_data)
{
int type;
void* variable;
char new_text[50];
type = ((t_user_data *)user_data)->type_of_param;
variable = ((t_user_data *)user_data)->speicher;
strncpy(new_text, gtk_entry_get_text(GTK_ENTRY(entry)),50);
}
);
g_signal_connect_after (GTK_OBJECT (spinOrEntry),