1 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <sigc++/functors/mem_fun.h>
23 #include "surrender-dialog.h"
25 #include "glade-helpers.h"
26 #include "image-helpers.h"
27 #include "input-helpers.h"
28 #include "ucompose.hpp"
32 SurrenderDialog::SurrenderDialog(int numEnemies)
34 Glib::RefPtr<Gtk::Builder> xml
35 = Gtk::Builder::create_from_file(get_glade_path()
36 + "/surrender-dialog.ui");
38 xml->get_widget("dialog", dialog);
40 window_closed.connect(sigc::mem_fun(dialog, &Gtk::Dialog::hide));
43 xml->get_widget("label", label);
44 xml->get_widget("image", image);
47 s = ngettext("Your enemy grudgingly surrenders!\n",
48 "Your enemies respectfully surrender!\n",
50 s += _("Do you accept?");
52 image->property_file()
53 = File::getMiscFile("various/parley_offered.png");
56 SurrenderDialog::~SurrenderDialog()
61 void SurrenderDialog::set_parent_window(Gtk::Window &parent)
63 dialog->set_transient_for(parent);
64 //dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
67 void SurrenderDialog::hide()
71 bool SurrenderDialog::run()
73 return dialog->run() == Gtk::RESPONSE_ACCEPT;