#include <gtkmm.h>
#include <cstdlib>

class Win : public Gtk::Window
{
public:

  Win() :
  button("test")
  {
    add(button);

    button.signal_clicked().connect(sigc::mem_fun(*this, &Win;::func));

    show_all_children();
  }

private:
  Gtk::Button button;

  void func()
  {
    button.set_sensitive(0);

    int i;
    while (i < 10)
    {
      while (Gtk::Main::events_pending())
        Gtk::Main::iteration();

      i++;
      sleep(1);
    }

    button.set_sensitive(1);
  }
};

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

  Win window;

  Gtk::Main::run(window);

  return 0;
}

Add a code snippet to your website: www.paste.org