Hello everyone! I write a translator for morse. I faced a problem moving from gtk3 in gtk4 with GtkEntry. As I understood there is no GTK_ENTRY macro anymore and I also should use GtkEntryBuffer to get text from entry.
Everything is fine 'til I work with one entry. But if I use two entry and try to redefine it from gpointer type it crashes: gtk_entry_get_buffer: assertion ‘GTK_IS_ENTRY (entry)’ failed
Now all I want is program gets two string from entryIn and entryOut and write it into prompt.
Thank you for your help and attention,
Johann
P.S. This code includes GTK_ENTRY macro. I checked it up one more time with (GtkEntry *) instead of macro and it still doesn’t work
void print_text(GtkWidget *Widget, gpointer data) {
GtkEntry **Entries = (GtkEntry **) data;
GtkEntry *EntryIn = Entries[0];
//GtkEntry *EntryOut = Entries[1];
GtkEntryBuffer *BufferIn = gtk_entry_get_buffer(EntryIn);
//GtkEntryBuffer *BufferOut = gtk_entry_get_buffer(EntryOut);
const char *textIn = gtk_entry_buffer_get_text(BufferIn);
const char *textOut = gtk_entry_buffer_get_text(BufferOut);
printf("%s\n", textIn);
printf("%s\n", textOut);
}
static void activate(GtkApplication* app, gpointer user_data) {
GtkWidget *Window;
GtkWidget *Button;
GtkWidget *Box;
GtkWidget *EntryIn, *EntryOut;
GtkEntryBuffer *EntryBufferIn, *EntryBufferOut;
GtkEntry *Entries[2];
Window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(Window), "test");
gtk_window_set_default_size(GTK_WINDOW(Window), 300, 400);
gtk_window_present(GTK_WINDOW(Window));
EntryBufferIn = gtk_entry_buffer_new(NULL, -1);
EntryIn = gtk_entry_new_with_buffer(EntryBufferIn);
EntryBufferOut = gtk_entry_buffer_new(NULL, -1);
EntryOut = gtk_entry_new_with_buffer(EntryBufferOut);
Entries[0] = GTK_ENTRY(EntryIn);
Entries[1] = GTK_ENTRY(EntryOut);
Button = gtk_button_new_with_label("Read");
g_signal_connect(Button, "clicked", G_CALLBACK(print_text), Entries);