I am building a calculator app using c language and gtk4, in activate
function I have
GtkWidget * entry;
GObject * Sum = gtk_builder_get_object(builder, "sum");
entry = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (entry), 200);
g_signal_connect(Sum, "clicked", G_CALLBACK(sum), (gpointer) entry);
and the callback function
static void sum(GtkWindow * window, gpointer user_data)
{
const gchar *entry_text;
//entry_text = gtk_entry_get_text (GTK_ENTRY (user_data));
entry_text = gtk_entry_get_tabs(GTK_ENTRY(user_data));
g_print("%s\n", entry_text);
}
this does not seem to work because when ever i press the sum key I get (null)
printed to the console
How does one read data from a TextView
and pass it to a callback function
GtkEntry
implements GtkEditable
interface. So you can do gtk_editable_get_text (GTK_EDITABLE (entry))
to get the text in a GtkEntry
.