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

#include <iostream>
#include <gtk/gtklinkbutton.h>
#include <gtkmm.h>

using namespace std;

class ProgWindow : public Gtk::Window
{
public:
    ProgWindow();
    ~ProgWindow() { delete clink_no_label_; delete clink_with_label_; }

protected:
    Gtk::VBox box_;
    Gtk::LinkButton* clink_no_label_;
    Gtk::LinkButton* clink_with_label_;
    Gtk::LinkButton  link_no_label_;
    Gtk::LinkButton  link_with_label_;
};

void on_link_button(Gtk::LinkButton* , const Glib::ustring& uri)
{
    cout << uri << endl;
}

ProgWindow::ProgWindow()
    :
    box_(false, 4),
    link_no_label_("uri1"),
    link_with_label_("uri2", "label_for_uri2")
{
    add(box_);

    GtkWidget* clink = gtk_link_button_new ("c-uri1");
    clink_no_label_ = Glib::wrap(GTK_LINK_BUTTON(clink));

    clink = gtk_link_button_new_with_label ("c-uri2", "label_for_c-uri2");
    clink_with_label_ = Glib::wrap(GTK_LINK_BUTTON(clink));

    box_.pack_start(*clink_no_label_);
    box_.pack_start(*clink_with_label_);
    box_.pack_start(link_no_label_);
    box_.pack_start(link_with_label_);

    Gtk::LinkButton::set_uri_hook(sigc::ptr_fun(&on_link_button));

    set_default_size(200, 100);

    show_all_children();
}

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

  ProgWindow win;
  Gtk::Main::run(win);

  return 0;
}
