/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2004  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 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 can find this license in the file 'gpl.txt'.
 *
 *   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
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#include "constants.h"

#ifdef USE_UI_GTK

#include "settings.h"
#include "gtk_gui.h"

namespace GTK_DOKO {

  /*****************************************************************************
   *
   * void Settings::font_selector_init()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	inits the font selector windows
   *
   ****************************************************************************/
  void
    Settings::font_selector_init()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_INIT,
		    "Settings::font_selector_init()");

      // events for selecting the name font
      gtk_signal_connect(GTK_OBJECT(((XGtkButton&
				     )(this->button(Setting::NAME_FONT))
				    ).button()),
			 "clicked", GTK_SIGNAL_FUNC(Settings::open_name_font_selector_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(this->name_font_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(Settings::take_name_font_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(name_font_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_font_selector));

      gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(name_font_selector)->cancel_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_font_selector));

      // events for selecting the name font color
      gtk_signal_connect(GTK_OBJECT(((XGtkButton&
				     )(this->button(Setting::NAME_FONT_COLOR))
				    ).button()),
			 "clicked", GTK_SIGNAL_FUNC(Settings::open_name_font_color_selector_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->name_font_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(Settings::take_name_font_color_event),
			 gpointer(this));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->name_font_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_font_color_selector));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->name_font_color_selector)->cancel_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_font_color_selector));

      // events for selecting the active name font color
      gtk_signal_connect(GTK_OBJECT(((XGtkButton&
				     )(this->button(Setting::NAME_ACTIVE_FONT_COLOR))
				    ).button()),
			 "clicked", GTK_SIGNAL_FUNC(Settings::open_name_active_font_color_selector_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->name_active_font_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(Settings::take_name_active_font_color_event),
			 gpointer(this));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->name_active_font_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_active_font_color_selector));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->name_active_font_color_selector)->cancel_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_active_font_color_selector));

      // events for selecting the name font
      gtk_signal_connect(GTK_OBJECT(((XGtkButton&
				     )(this->button(Setting::TRICKPILE_POINTS_FONT))
				    ).button()),
			 "clicked", GTK_SIGNAL_FUNC(Settings::open_trickpile_points_font_selector_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(this->trickpile_points_font_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(Settings::take_trickpile_points_font_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(trickpile_points_font_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->trickpile_points_font_selector));

      gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(trickpile_points_font_selector)->cancel_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->trickpile_points_font_selector));

      // events for selecting the name font color
      gtk_signal_connect(GTK_OBJECT(((XGtkButton&
				     )(this->button(Setting::TRICKPILE_POINTS_FONT_COLOR))
				    ).button()),
			 "clicked", GTK_SIGNAL_FUNC(Settings::open_trickpile_points_font_color_selector_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->trickpile_points_font_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(Settings::take_trickpile_points_font_color_event),
			 gpointer(this));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->trickpile_points_font_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->trickpile_points_font_color_selector));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->trickpile_points_font_color_selector)->cancel_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->trickpile_points_font_color_selector));


      // events for selecting the poverty shift arrow color
      gtk_signal_connect(GTK_OBJECT(((XGtkButton&
				     )(this->button(Setting::POVERTY_SHIFT_ARROW_COLOR))
				    ).button()),
			 "clicked", GTK_SIGNAL_FUNC(Settings::open_poverty_shift_arrow_color_selector_event),
			 gpointer(this));
      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->poverty_shift_arrow_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(Settings::take_poverty_shift_arrow_color_event),
			 gpointer(this));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->poverty_shift_arrow_color_selector)->ok_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->poverty_shift_arrow_color_selector));

      gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(this->poverty_shift_arrow_color_selector)->cancel_button),
			 "clicked", GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->poverty_shift_arrow_color_selector));

      // hide the windows, if the settings window is hidden
      gtk_signal_connect(GTK_OBJECT(this->window()), "hide",
			 GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_font_selector));
      gtk_signal_connect(GTK_OBJECT(this->window()), "hide",
			 GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_font_color_selector));
      gtk_signal_connect(GTK_OBJECT(this->window()), "hide",
			 GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->name_active_font_color_selector));
      gtk_signal_connect(GTK_OBJECT(this->window()), "hide",
			 GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->trickpile_points_font_selector));
      gtk_signal_connect(GTK_OBJECT(this->window()), "hide",
			 GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->trickpile_points_font_color_selector));
      gtk_signal_connect(GTK_OBJECT(this->window()), "hide",
			 GTK_SIGNAL_FUNC(GTK_GUI::window_hide),
			 gpointer(this->poverty_shift_arrow_color_selector));

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_INIT,
		      "Settings::font_selector_init()");
    } // void Settings::font_selector_init()

  /*****************************************************************************
   *
   * void Settings::font_update(gchar const* const font_name,
   *			      GtkWidget* font_label,
   *			      GtkWidget* font_color_label)
   *
   * Parameters:	font_name		- the name of the font
   *		label		- the label which is changed
   *
   * Result:	-
   * 
   * Version:	0.5.1
   *
   * Description:	updates the font in the label
   *
   ****************************************************************************/
  void
    Settings::font_update(gchar const* const font_name,
			  GtkWidget* label)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::font_update()");

      // update the font of the two buttons
      GdkFont* font = gdk_font_load(const_cast<gchar*>(font_name));
      if (font != NULL)  {
#ifdef GTK_2_0
	gtk_style_set_font(gtk_widget_get_style(label), font);
#else
	GtkStyle* style = gtk_style_copy(gtk_widget_get_style(label));
	gdk_font_unref(style->font);
	style->font = gdk_font_ref(font);
	gtk_widget_set_style(label, style);
	gtk_style_unref(style);
#endif

      } // if (font != NULL)

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::font_update()");
    } // void Settings::font_update(gchar const* const font_name, GtkWidget* label)

  /*****************************************************************************
   *
   * void Settings::font_color_update(gchar const* const font_color_name,
   *				    GtkWidget* font_color_label)
   *
   * Parameters:	font_name		- the name of the font color
   *		font_color_label	- the label for the font color
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	updates the font in the buttons
   *
   ****************************************************************************/
  void
    Settings::font_color_update(gchar const* const font_color_name,
				GtkWidget* font_color_label)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::font_color_update()");

      // set the color of the label
      GdkColor color;
      GtkStyle* style
	= gtk_style_copy(gtk_widget_get_style(font_color_label));
      if (gdk_color_parse(font_color_name, &color)) {
	for (int i = 0; i < 5; i++)
	  style->fg[i] = color;
      }
      gtk_widget_set_style(font_color_label, style);
      gtk_style_unref(style);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::font_color_update()");
    } // void Settings::font_color_update(gchar const* const font_color_name, GtkWidget* font_color_label)

  /*****************************************************************************
   *
   * void Settings::open_name_font_selector_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->open_name_font_selector()
   *
   ****************************************************************************/
  void
    Settings::open_name_font_selector_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_name_font_selector_event()");

      ((Settings*)settings)->open_name_font_selector();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_name_font_selector_event()");
    } // void Settings::open_name_font_selector_event()

  /*****************************************************************************
   *
   * void Settings::take_name_font_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->take_name_font()
   *
   ****************************************************************************/
  void
    Settings::take_name_font_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_name_font_event()");

      ((Settings*)settings)->take_name_font();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_name_font__event()");
    } // void Settings::take_name_font_event()


  /*****************************************************************************
   *
   * void Settings::open_name_font_color_selector_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->open_name_font_color_selector()
   *
   ****************************************************************************/
  void
    Settings::open_name_font_color_selector_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_name_font_color_selector_event()");

      ((Settings*)settings)->open_name_font_color_selector();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_name_font_color_selector_event()");
    } // void Settings::open_name_font_color_selector_event()

  /*****************************************************************************
   *
   * void Settings::take_name_font_color_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->take_name_font()
   *
   ****************************************************************************/
  void
    Settings::take_name_font_color_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_name_font_color_event()");

      ((Settings*)settings)->take_name_font_color();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_name_font_color__event()");
    } // void Settings::take_name_font_color_event()

  /**
   ** call fonts->open_name_active_font_color_selector()
   **
   ** @param	settings	pointer to the settings
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.6.1
   **
   **/
  void
    Settings::open_name_active_font_color_selector_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_name_active_font_color_selector_event()");

      static_cast<Settings*>(settings)->open_name_active_font_color_selector();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_name_active_font_color_selector_event()");
    } // void Settings::open_name_active_font_color_selector_event()

  /**
   ** call fonts->take_name_active_font()
   **
   ** @param	settings	pointer to the settings
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.6.1
   **
   **/
  void
    Settings::take_name_active_font_color_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_name_active_font_color_event()");

      static_cast<Settings*>(settings)->take_name_active_font_color();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_name_active_font_color__event()");
    } // void Settings::take_name_active_font_color_event()


  /*****************************************************************************
   *
   * void Settings::open_trickpile_points_font_selector_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->open_trickpile_points_font_selector()
   *
   ****************************************************************************/
  void
    Settings::open_trickpile_points_font_selector_event(GtkWidget*,
							gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_trickpile_points_font_selector_event()");

      ((Settings*)settings)->open_trickpile_points_font_selector();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_trickpile_points_font_selector_event()");
    } // void Settings::open_trickpile_points_font_selector_event()

  /*****************************************************************************
   *
   * void Settings::take_trickpile_points_font_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->take_trickpile_points_font()
   *
   ****************************************************************************/
  void
    Settings::take_trickpile_points_font_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_trickpile_points_font_event()");

      ((Settings*)settings)->take_trickpile_points_font();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_trickpile_points_font__event()");
    } // void Settings::take_trickpile_points_font_event()


  /*****************************************************************************
   *
   * void Settings::open_trickpile_points_font_color_selector_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->open_trickpile_points_font_color_selector()
   *
   ****************************************************************************/
  void
    Settings::open_trickpile_points_font_color_selector_event(GtkWidget*,
							      gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_trickpile_points_font_color_selector_event()");

      ((Settings*)settings)->open_trickpile_points_font_color_selector();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_trickpile_points_font_color_selector_event()");
    } // void Settings::open_trickpile_points_font_color_selector_event()

  /*****************************************************************************
   *
   * void Settings::take_trickpile_points_font_color_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	call fonts->take_trickpile_points_font()
   *
   ****************************************************************************/
  void
    Settings::take_trickpile_points_font_color_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_trickpile_points_font_color_event()");

      ((Settings*)settings)->take_trickpile_points_font_color();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_trickpile_points_font_color__event()");
    } // void Settings::take_trickpile_points_font_color_event()

  /*****************************************************************************
   *
   * void Settings::open_poverty_shift_arrow_color_selector_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.5.1
   *
   * Description:	call fonts->open_poverty_shift_arrow_color_selector()
   *
   ****************************************************************************/
  void
    Settings::open_poverty_shift_arrow_color_selector_event(GtkWidget*,
							    gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_poverty_shift_arrow_color_selector_event()");

      ((Settings*)settings)->open_poverty_shift_arrow_color_selector();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_poverty_shift_arrow_color_selector_event()");
    } // void Settings::open_poverty_shift_arrow_color_selector_event()

  /*****************************************************************************
   *
   * void Settings::take_poverty_shift_arrow_color_event(GtkWidget*,
   *				    gpointer settings)
   *
   * Parameters:	fonts	- pointer to the fonts settings
   *
   * Result:	-
   * 
   * Version:	0.5.1
   *
   * Description:	call fonts->take_poverty_shift_arrow()
   *
   ****************************************************************************/
  void
    Settings::take_poverty_shift_arrow_color_event(GtkWidget*, gpointer settings)
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_poverty_shift_arrow_color_event()");

      ((Settings*)settings)->take_poverty_shift_arrow_color();

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_poverty_shift_arrow_color__event()");
    } // void Settings::take_poverty_shift_arrow_color_event()

  /*****************************************************************************
   *
   * void Settings::open_name_font_selector()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	open the font selector for the name font
   *
   ****************************************************************************/
  void
    Settings::open_name_font_selector()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_name_font_selector()");

      // set the font to the text
      gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(name_font_selector),
					      ::setting(Setting::NAME_FONT).c_str()
					     );

      // show the font selector
      gtk_widget_show(GTK_WIDGET(this->name_font_selector));


      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_name_font_selector()");
    } // void Settings::open_name_font_selector()

  /*****************************************************************************
   *
   * void Settings::take_name_font()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	take the font for the names from the selector
   *
   ****************************************************************************/
  void
    Settings::take_name_font()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_name_font()");

      gchar* font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(this->name_font_selector));

      ::setting.set(Setting::NAME_FONT, font_name);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_name_font()");
    } // void Settings::take_name_font()

  /*****************************************************************************
   *
   * void Settings::open_name_font_color_selector()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	open the font selector for the name font
   *
   ****************************************************************************/
  void
    Settings::open_name_font_color_selector()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_name_font_color_selector()");

      gchar* color_name = const_cast<gchar*>(::setting(Setting::NAME_FONT_COLOR).c_str());

      GdkColor color;
      // translate the color from the name to a GdkColor
      if (gdk_color_parse(color_name, &color)) {
	gdouble color_field[4] = { color.red / 65535.0 ,
	  color.green / 65535.0,
	  color.blue / 65535.0,
	  1 };

	  gtk_color_selection_set_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(this->name_font_color_selector)->colorsel),
					color_field);
      } // if (!gdk_color_parse)


      // show the color selector
      gtk_widget_show(GTK_WIDGET(this->name_font_color_selector));

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_name_font_color_selector()");
    } // void Settings::open_name_font_color_selector()

  /*****************************************************************************
   *
   * void Settings::take_name_font_color()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	take the font for the names from the selector
   *
   ****************************************************************************/
  void
    Settings::take_name_font_color()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_name_font_color()");

      // get the name of the color
      gdouble color_field[4];

      gtk_color_selection_get_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(name_font_color_selector)->colorsel),
				    color_field);

#ifdef NO_STRINGSTREAM
      ostrstream color_str;
#else
      ostringstream color_str;
#endif
      color_str << '#' << setfill('0')
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[0] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[1] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[2] + 0.5)
	<< ends;

      string color_name = color_str.str();
#ifdef NO_STRINGSTREAM
      delete[] color_str.str();
#endif

      ::setting.set(Setting::NAME_FONT_COLOR, color_name);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_name_font()");
    } // void Settings::take_name_font()

  /**
   **
   ** open the color selector for the active name font
   **
   ** @param	-
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.6.1
   **
   **/
  void
    Settings::open_name_active_font_color_selector()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_name_active_font_color_selector()");

      gchar* color_name = const_cast<gchar*>(::setting(Setting::NAME_ACTIVE_FONT_COLOR).c_str());

      GdkColor color;
      // translate the color from the name to a GdkColor
      if (gdk_color_parse(color_name, &color)) {
	gdouble color_field[4] = { color.red / 65535.0 ,
	  color.green / 65535.0,
	  color.blue / 65535.0,
	  1 };

	  gtk_color_selection_set_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(this->name_active_font_color_selector)->colorsel),
					color_field);
      } // if (!gdk_color_parse)


      // show the color selector
      gtk_widget_show(GTK_WIDGET(this->name_active_font_color_selector));

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_name_active_font_color_selector()");
    } // void Settings::open_name_active_font_color_selector()

  /**
   **
   ** take the color for the active names from the selector
   **
   ** @param	-
   **
   ** @return	-
   ** 
   ** @author	Diether Knof
   **
   ** @version	0.6.1
   **
   **/
  void
    Settings::take_name_active_font_color()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_name_active_font_color()");

      // get the name of the color
      gdouble color_field[4];

      gtk_color_selection_get_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(name_active_font_color_selector)->colorsel),
				    color_field);

#ifdef NO_STRINGSTREAM
      ostrstream color_str;
#else
      ostringstream color_str;
#endif
      color_str << '#' << setfill('0')
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[0] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[1] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[2] + 0.5)
	<< ends;

      string color_name = color_str.str();
#ifdef NO_STRINGSTREAM
      delete[] color_str.str();
#endif

      ::setting.set(Setting::NAME_ACTIVE_FONT_COLOR, color_name);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_name_active_font()");
    } // void Settings::take_name_active_font()

  /*****************************************************************************
   *
   * void Settings::open_trickpile_points_font_selector()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	open the font selector for the name font
   *
   ****************************************************************************/
  void
    Settings::open_trickpile_points_font_selector()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_trickpile_points_font_selector()");

      // set the font to the text
      gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(trickpile_points_font_selector),
					      ::setting(Setting::TRICKPILE_POINTS_FONT).c_str()
					     );

      // show the font selector
      gtk_widget_show(GTK_WIDGET(this->trickpile_points_font_selector));


      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_trickpile_points_font_selector()");
    } // void Settings::open_trickpile_points_font_selector()

  /*****************************************************************************
   *
   * void Settings::take_trickpile_points_font()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	take the font for the names from the selector
   *
   ****************************************************************************/
  void
    Settings::take_trickpile_points_font()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_trickpile_points_font()");

      gchar* font_name = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(this->trickpile_points_font_selector));

      ::setting.set(Setting::TRICKPILE_POINTS_FONT, font_name);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_trickpile_points_font()");
    } // void Settings::take_trickpile_points_font()

  /*****************************************************************************
   *
   * void Settings::open_trickpile_points_font_color_selector()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	open the font selector for the name font
   *
   ****************************************************************************/
  void
    Settings::open_trickpile_points_font_color_selector()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_trickpile_points_font_color_selector()");

      gchar* color_name = const_cast<gchar*>(::setting(Setting::TRICKPILE_POINTS_FONT_COLOR).c_str());

      GdkColor color;
      // translate the color from the name to a GdkColor
      if (gdk_color_parse(color_name, &color)) {
	gdouble color_field[4] = { color.red / 65535.0 ,
	  color.green / 65535.0,
	  color.blue / 65535.0,
	  1 };

	  gtk_color_selection_set_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(this->trickpile_points_font_color_selector)->colorsel),
					color_field);
      } // if (!gdk_color_parse)


      // show the color selector
      gtk_widget_show(GTK_WIDGET(this->trickpile_points_font_color_selector));

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_trickpile_points_font_color_selector()");
    } // void Settings::open_trickpile_points_font_color_selector()

  /*****************************************************************************
   *
   * void Settings::take_trickpile_points_font_color()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	take the font for the names from the selector
   *
   ****************************************************************************/
  void
    Settings::take_trickpile_points_font_color()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_trickpile_points_font_color()");

      // get the name of the color
      gdouble color_field[4];

      gtk_color_selection_get_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(trickpile_points_font_color_selector)->colorsel),
				    color_field);

#ifdef NO_STRINGSTREAM
      ostrstream color_str;
#else
      ostringstream color_str;
#endif
      color_str << '#' << setfill('0')
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[0] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[1] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[2] + 0.5)
	<< ends;

      string color_name = color_str.str();
#ifdef NO_STRINGSTREAM
      delete[] color_str.str();
#endif

      ::setting.set(Setting::TRICKPILE_POINTS_FONT_COLOR, color_name);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_trickpile_points_font()");
    } // void Settings::take_trickpile_points_font()

  /*****************************************************************************
   *
   * void Settings::open_poverty_shift_arrow_color_selector()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	open the font selector for the name font
   *
   ****************************************************************************/
  void
    Settings::open_poverty_shift_arrow_color_selector()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::open_poverty_shift_arrow_color_selector()");

      gchar* color_name = const_cast<gchar*>(::setting(Setting::POVERTY_SHIFT_ARROW_COLOR).c_str());

      GdkColor color;
      // translate the color from the name to a GdkColor
      if (gdk_color_parse(color_name, &color)) {
	gdouble color_field[4] = { color.red / 65535.0 ,
	  color.green / 65535.0,
	  color.blue / 65535.0,
	  1 };

	  gtk_color_selection_set_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(this->poverty_shift_arrow_color_selector)->colorsel),
					color_field);
      } // if (!gdk_color_parse)


      // show the color selector
      gtk_widget_show(GTK_WIDGET(this->poverty_shift_arrow_color_selector));

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::open_poverty_shift_arrow_color_selector()");
    } // void Settings::open_poverty_shift_arrow_color_selector()

  /*****************************************************************************
   *
   * void Settings::take_poverty_shift_arrow_color()
   *
   * Parameters:	-
   *
   * Result:	-
   * 
   * Version:	0.4.2
   *
   * Description:	take the font for the names from the selector
   *
   ****************************************************************************/
  void
    Settings::take_poverty_shift_arrow_color()
    {
      DEBUG_CALLING(INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		    "Settings::take_poverty_shift_arrow_color()");

      // get the name of the color
      gdouble color_field[4];

      gtk_color_selection_get_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(poverty_shift_arrow_color_selector)->colorsel),
				    color_field);

#ifdef NO_STRINGSTREAM
      ostrstream color_str;
#else
      ostringstream color_str;
#endif
      color_str << '#' << setfill('0')
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[0] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[1] + 0.5)
	<< hex << setw(2) << int((16 * 16 - 1) * color_field[2] + 0.5)
	<< ends;

      string color_name = color_str.str();
#ifdef NO_STRINGSTREAM
      delete[] color_str.str();
#endif

      ::setting.set(Setting::POVERTY_SHIFT_ARROW_COLOR, color_name);

      DEBUG_RETURNING(VOID,
		      INFO_GTK_SETTINGS && INFO_GTK_EVENT,
		      "Settings::take_poverty_shift_arrow()");
    } // void Settings::take_poverty_shift_arrow()


}
#endif
