#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

GtkWidget *entry;

void on_button1_clicked(void)
{
    int pos = -1;
    gtk_editable_insert_text(GTK_EDITABLE(entry), "a", 1, &pos);
}

void on_button2_clicked(void)
{
    int pos = -1;
    gtk_editable_insert_text(GTK_EDITABLE(entry), "b", 1, &pos);
}


int main(int argc, char *argv[])
{
    GtkWidget *window, *box, *button1, *button2;
    GtkAccelGroup *accel_group;
    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    accel_group = gtk_accel_group_new();
    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

    box = gtk_vbox_new(TRUE, 0);
    gtk_container_add(GTK_CONTAINER(window), box);

    entry = gtk_entry_new();
    gtk_container_add(GTK_CONTAINER(box), entry);

    button1 = gtk_button_new_with_label("Button 1");
    g_signal_connect(button1, "clicked", G_CALLBACK(on_button1_clicked), NULL);
    gtk_widget_add_accelerator(button1, "activate", accel_group, GDK_KP_1, 0, GTK_ACCEL_VISIBLE);
    gtk_container_add(GTK_CONTAINER(box), button1);

    button2 = gtk_button_new_with_label("Button 2");
    g_signal_connect(button2, "clicked", G_CALLBACK(on_button2_clicked), NULL);
    gtk_widget_add_accelerator(button2, "activate", accel_group, GDK_KP_2, 0, GTK_ACCEL_VISIBLE);
    gtk_container_add(GTK_CONTAINER(box), button2);

    gtk_widget_show_all(window);

    gtk_main();
    return 0;
}

