#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/box.h>
#include <gtkmm/button.h>
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>

class foo : public Gtk::Window {
public:

  struct TestColumns : public Gtk::TreeModelColumnRecord {
    TestColumns() { add(index); add(name); }
    Gtk::TreeModelColumn<unsigned short> index;
    Gtk::TreeModelColumn<Glib::ustring> name;
  } test_columns;
  Glib::RefPtr<Gtk::ListStore> test_store;

  void trigger_error() {
    Gtk::ListStore::iterator it = test_store->append();
    (*it)[test_columns.index] = 1;
    (*it)[test_columns.name] = "test";
  }

  foo() {
    Gtk::TreeView* test_view = Gtk::manage( new Gtk::TreeView );
    test_store = Gtk::ListStore::create(test_columns);
    test_view->set_model(test_store);
    test_view->append_column("index", test_columns.index);
    test_view->append_column("name", test_columns.name);

    Gtk::Button* test_button = Gtk::manage( new Gtk::Button("trigger error") );
    test_button->signal_clicked().connect( SigC::slot( *this, &foo::trigger_error ) );
    Gtk::VBox* test_box = Gtk::manage( new Gtk::VBox );
    test_box->pack_start(*test_view);
    test_box->pack_start(*test_button);
    add(*test_box);
  }
};

int main(int argc, char *argv[]) {
  Gtk::Main kit(argc, argv);

  Gtk::Window* test_window = new foo;
  test_window->show_all();

  kit.run(*test_window);
  delete test_window;
}
