/* $Id: XmlWidgetExample.cpp,v 1.3 2003/10/10 21:26:56 palm Exp $ */

/* 
 * Copyright (C) 2003 Christer Palm <palm@nogui.se>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "derived.h"
#include <iostream>

//
// A button that prints a message when clicked
//
class MessageButton : public Gnome::Glade::Derived<Gtk::Button>
{
	public:
		MessageButton
			(Glib::RefPtr<Gnome::Glade::Xml> xml,
			 const std::string& widgetname,
			 const std::string& message) :
				Gnome::Glade::Derived<Gtk::Button>(xml, widgetname),
				message_(message)
			{ }

	private:
		const std::string message_;
		void on_clicked()
			{ std::cout << message_ << std::endl; }
};


//
// A Dialog which contains a Hello world MessageButton
//
class HelloDialog : public Gnome::Glade::Derived<Gtk::Dialog>
{
	public:
		HelloDialog() :
			Gnome::Glade::Derived<Gtk::Dialog>
				("XmlWidgetExample.glade", "exampleDialog"),
			button(get_xml(), "button", "Hello world!")
			{ }

	private:
		MessageButton button;
		void on_response(int)
			{ std::cout << "Goodbye!" << std::endl; }
};


int main(int argc, char *argv[])
{
	Gtk::Main gtkmain(argc, argv);
	HelloDialog* example = new HelloDialog();
	example->run();
	return 0;
}
