/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* gcc -o gtk-test-1 `pkg-config --cflags --libs gtk+-3.0` gtk-test-1.c */

#include <gtk/gtk.h>

gint
main (gint argc, gchar **argv)
{
    GtkWidget *window;
    GtkWidget *box;
    GtkWidget *combo;
    GtkWidget *label;
    GtkWidget *entry;
    GtkListStore *list_store;
    GtkEntryCompletion *entry_completion;
    GtkTreeIter iter;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
    gtk_container_add (GTK_CONTAINER (window), box);

    label = gtk_label_new ("Hello");
    gtk_container_add (GTK_CONTAINER (box), label);

    list_store = gtk_list_store_new (1, G_TYPE_STRING);

    entry_completion = gtk_entry_completion_new ();
    gtk_entry_completion_set_model (entry_completion, GTK_TREE_MODEL (list_store));
    gtk_entry_completion_set_text_column (entry_completion, 0);
    gtk_entry_completion_set_popup_completion (entry_completion, TRUE);

    combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL (list_store));
    gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combo), 0);

    entry = gtk_bin_get_child (GTK_BIN (combo));
    gtk_entry_set_completion (GTK_ENTRY (entry), entry_completion);

    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter, 0, "aleksander", -1);
    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter, 0, "alberto", -1);
    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter, 0, "aaron", -1);
    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter, 0, "mitch", -1);

    gtk_container_add (GTK_CONTAINER (box), combo);

    gtk_widget_show_all (window);

    g_signal_connect (window, "destroy",G_CALLBACK (gtk_main_quit), NULL);

    gtk_main ();

    return 0;
}
