initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / map-info-dialog.cpp
1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17 //  02110-1301, USA.
18
19 #include <config.h>
20
21 #include <sigc++/functors/mem_fun.h>
22
23 #include "map-info-dialog.h"
24
25 #include "glade-helpers.h"
26 #include "ucompose.hpp"
27 #include "defs.h"
28 #include "signpost.h"
29 #include "GameScenario.h"
30
31
32 MapInfoDialog::MapInfoDialog(GameScenario *g)
33 {
34     game_scenario = g;
35     
36     Glib::RefPtr<Gtk::Builder> xml
37         = Gtk::Builder::create_from_file(get_glade_path()
38                                     + "/map-info-dialog.ui");
39
40     xml->get_widget("dialog", dialog);
41
42     xml->get_widget("name_entry", name_entry);
43     name_entry->set_text(game_scenario->getName());
44     
45     xml->get_widget("description_textview", description_textview);
46     description_textview->get_buffer()->set_text(game_scenario->getComment());
47     xml->get_widget("copyright_textview", copyright_textview);
48     copyright_textview->get_buffer()->set_text(game_scenario->getCopyright());
49     xml->get_widget("license_textview", license_textview);
50     license_textview->get_buffer()->set_text(game_scenario->getLicense());
51 }
52
53 MapInfoDialog::~MapInfoDialog()
54 {
55   delete dialog;
56 }
57 void MapInfoDialog::set_parent_window(Gtk::Window &parent)
58 {
59     dialog->set_transient_for(parent);
60     //dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
61 }
62
63 int MapInfoDialog::run()
64 {
65     dialog->show_all();
66     int response = dialog->run();
67
68     if (response == Gtk::RESPONSE_ACCEPT)       // accepted
69     {
70         game_scenario->setName(name_entry->get_text());
71         game_scenario->setComment(description_textview->get_buffer()->get_text());
72         game_scenario->setCopyright(copyright_textview->get_buffer()->get_text());
73         game_scenario->setLicense(license_textview->get_buffer()->get_text());
74     }
75     return response;
76 }
77