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

GtkAccelGroup *kbd_accel;
GtkWidget *button1, *button2;
GtkWidget *frame;
GtkWidget *vbox;

static void
button_proc(GtkButton *widget, gpointer user_data)
{
    printf("button_proc: n: %d\n", (int) user_data);
}


static void
create_button(GtkWidget *vbox, char *label, int key_val, int value)
{
    GtkWidget *button, *l;

    l = gtk_label_new(label);
    gtk_widget_show(l);
    gtk_label_set_use_markup(GTK_LABEL(l), TRUE);
    button = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(button), l);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(button_proc), (gpointer) value);
    gtk_widget_ref(button);

    gtk_widget_add_accelerator(button, "activate", kbd_accel,
                               key_val, 0, GTK_ACCEL_VISIBLE);     

    gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0);
    gtk_widget_show(button);
}


int
main(int argc, char **argv)
{
    gnome_program_init("example", "1.0.0", LIBGNOMEUI_MODULE, argc, argv,
                       NULL, NULL, NULL);

    kbd_accel = gtk_accel_group_new();

    frame = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(frame), 100, 100);
    vbox = gtk_vbox_new(FALSE, 0);
    gtk_widget_ref(vbox);
    gtk_container_add(GTK_CONTAINER(frame), vbox);
    gtk_widget_show(vbox);

    create_button(vbox, "1", GDK_1, 1);
    create_button(vbox, "2", GDK_2, 2);

    gtk_window_add_accel_group(GTK_WINDOW(frame), kbd_accel);
    gtk_widget_show(frame);
    gtk_main();

    return(0);
}
