/* This file is part of cardwords
   (c) 1999 Tobias Peters
   see file COPYING for the copyright terms.
   
   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
*/

// cardwords_gtk_optionsdialog.cc

#include "cardwords_gtk_optionsdialog.hh"
#include "cardwords_gettext.hh"

CardWords_Gtk_OptionsDialog::CardWords_Gtk_OptionsDialog(CardWords_Options *o)
  : options(o)
{
  identity_dialog = new CardWords_Gtk_IdentityDialog(options);
  identity_label = new Gtk::Label(gettext("Identity"));
  pages().
    push_back(Gtk::Notebook_Helpers::TabElem(*identity_dialog,
                                            *identity_label));
  
  appearance_dialog = new CardWords_Gtk_AppearanceDialog(options);
  appearance_label = new Gtk::Label(gettext("Appearance"));
  pages().
    push_back(Gtk::Notebook_Helpers::TabElem(*appearance_dialog,
                                            *appearance_label));
  
  start_server_dialog = new CardWords_Gtk_StartServerDialog(options);
  start_server_label = new Gtk::Label(gettext("Local server options"));
  pages().
    push_back(Gtk::Notebook_Helpers::TabElem(*start_server_dialog,
                                            *start_server_label));

  connect_dialog = new CardWords_Gtk_ConnectDialog(options);
  connect_label = new Gtk::Label(gettext("Remote server"));
  pages().
    push_back(Gtk::Notebook_Helpers::TabElem(*connect_dialog,
                                            *connect_label));

  identity_dialog->show();
  appearance_dialog->show();
  start_server_dialog->show();
  connect_dialog->show();

  identity_label->show();
  appearance_label->show();
  start_server_label->show();
  connect_label->show();

  identity_dialog->help_signal.connect(help_signal.slot());

  appearance_dialog->help_signal.connect(help_signal.slot());

  start_server_dialog->help_signal.connect(help_signal.slot());

  connect_dialog->help_signal.connect(help_signal.slot());
}

// #define DEBUG_GTK_OPTIONSDIALOG

CardWords_Gtk_OptionsDialog::~CardWords_Gtk_OptionsDialog()
{
#ifdef DEBUG_GTK_OPTIONSDIALOG
  cout << "Enter CardWords_Gtk_OptionsDialog::~CardWords_Gtk_OptionsDialog()"
       << endl;
#endif
  identity_dialog->hide();
  appearance_dialog->hide();
  start_server_dialog->hide();
  connect_dialog->hide();

  identity_label->hide();
  appearance_label->hide();
  start_server_label->hide();
  connect_label->hide();

  remove(*identity_dialog);
  remove(*appearance_dialog);
  remove(*start_server_dialog);
  remove(*connect_dialog);

  /* These calls gave Gtk Warnings, they are not strictly necessary,
     so commenting them out:
     remove(identity_label);
     remove(appearance_label);
     remove(start_server_label);
     remove(connect_label);
  */
  
  delete identity_dialog;
  delete appearance_dialog;
  delete start_server_dialog;
  delete connect_dialog;

  delete identity_label;
  delete appearance_label;
  delete start_server_label;
  delete connect_label;
#ifdef DEBUG_GTK_OPTIONSDIALOG
  cout << "Exit CardWords_Gtk_OptionsDialog::~CardWords_Gtk_OptionsDialog()"
       << endl;
#endif
}
// Put the entries' contents into the options object.
void
CardWords_Gtk_OptionsDialog::store_options(void)
{
  identity_dialog->store_options();
  appearance_dialog->store_options();
  start_server_dialog->store_options();
  connect_dialog->store_options();
}
