/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2005  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public Error as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the Error, 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 Error for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public Error
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#include "constants.h"

#ifdef USE_UI_GTKMM

#include "error.h"

#include "bug_report.h"
#include "ui.h"
#include "translations.h"

#include "../../misc/translator.h"

#include "widgets/stock_button.h"
#include <gtkmm/stock.h>

namespace UI_GTKMM_NS {

  /**
   **
   ** Constructor
   **
   ** @param	-
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.5.4
   **
   **/
  Error::Error(string const& message, Base* const parent) :
    Base(parent),
#if GTKMM_MINOR_VERSION < 4
    Gtk::MessageDialog("",
		       Gtk::MESSAGE_ERROR, Gtk::BUTTONS_NONE,
#ifdef RELEASE
		       true,
#else
		       false,
#endif
		       true),
#else
    Gtk::MessageDialog("",
		       false,
		       Gtk::MESSAGE_ERROR, Gtk::BUTTONS_NONE,
#ifdef RELEASE
		       true
#else
		       false
#endif
		      ),
#endif
    message(message)
  {
    {
#include "../icon.xpm"
      this->set_icon(Gdk::Pixbuf::create_from_xpm_data(icon_xpm));
    }

#if GTKMM_MINOR_VERSION < 4
    this->set_message(::translator("_bug found: create report, %scontact%_",
				   CONTACT).translation()
		      + "\n\n"
		      + ::translator("_bug found: message_").translation() + ":"
		      + "\n"
		      + message);
#else
    this->set_markup(::translator("_bug found: create report, %scontact%_",
				  CONTACT).translation()
		     + "\n\n"
		     + ::translator("_bug found: message_").translation() + ":"
		     + "\n"
		     + message);
#endif
    Gtk::Button* bug_report_button
      = Gtk::manage(new Gtk::StockButton(Gtk::Stock::OK,
					 "create bug report"));
    this->ui->translations->add(*bug_report_button,
				::translator("create bug report"));
    this->add_action_widget(*bug_report_button, Gtk::RESPONSE_CLOSE);
    bug_report_button->show_all();

    bug_report_button->signal_clicked().connect(SigC::slot(*this,
							   &Error::create_bug_report)
					       );

    return ;
  } // Error::Error(string const& message, Base const* parent)

  /**
   **
   ** Destruktor
   **
   ** @param	-
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.6.2
   **
   **/
  Error::~Error()
  {
    return ;
  } // Error::~Error()

  /**
   **
   ** show the bug report window
   **
   ** @param	-
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.6.2
   **
   **/
  void
    Error::create_bug_report()
    {
      BugReport bug_report(this, this->message + "\n---\n\n");

      bug_report.run();
      this->hide();

      return ;
    } // void Error::create_bug_report()

} // namespace UI_GTKMM_NS

#endif // #ifdef USE_UI_GTKMM
