I need to get text from a bunch of GtkEntries when a button click. I create a custom struct and pass it to the button's click callback. I don't want to use gtk_entry_get_text(*entry) since I need to pass the struct of GtkEntries.
typedef struct{ const gchar* id1; const gchar* id2; } EntryData; static void on_click(GtkWidget *widget, gpointer data) { EntryData* d= (EntryData*)data; printf ("Entry contents: %s\n", d->id1); printf ("Entry contents: %s\n", d->id2); } int main(int argc,char *argv[]) { // .... GtkButton *button_create_hp; GtkEntry *entry_id1; GtkEntry *entry_id2; gtk_init(&argc, &argv); //...... widget and object initialization gtk_entry_set_text(entry_ssd,""); gchar *strval1="sl"; gchar *strval2="sl"; g_object_get(G_OBJECT (entry_id1), "text", &strval1,NULL); g_object_get(G_OBJECT (entry_id2), "text", &strval2,NULL); EntryData entryData={ .id1= strval1, .id2= strval2 }; g_signal_connect (button_create_hp, "clicked", G_CALLBACK(on_click),&entryData); gtk_main(); return 0; } I also tried with g_object_get_property (G_OBJECT (entry_id), "text", &val);
In both cases changed values not printed when the button clicked. Can you suggest a proper way to get values and pass it from GtkEntries
WIData* d=? Shouldn't it beEntryData* d=?gchar *strval1="sl";(is redeclared) but it will not compile in this case.