1 //  Copyright (C) 2007, 2008, 2009, 2014 Ben Asselstine
2 //
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.
7 //
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.
12 //
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
16 //  02110-1301, USA.
17 
18 #include <config.h>
19 
20 #include <gtkmm.h>
21 #include <sigc++/functors/mem_fun.h>
22 
23 #include "item-bonus-dialog.h"
24 
25 #include "ucompose.hpp"
26 #include "defs.h"
27 #include "ItemProto.h"
28 #include "Itemlist.h"
29 #include "lw-dialog.h"
30 
ItemBonusDialog(Gtk::Window & parent)31 ItemBonusDialog::ItemBonusDialog(Gtk::Window &parent)
32  : LwDialog(parent, "item-bonus-dialog.ui")
33 {
34   dialog->set_transient_for(parent);
35   items_list = Gtk::ListStore::create(items_columns);
36   xml->get_widget("treeview", items_treeview);
37   items_treeview->set_model(items_list);
38   items_treeview->append_column("", items_columns.name);
39   items_treeview->append_column(_("Bonus"), items_columns.bonus);
40 
41   Itemlist::iterator iter = Itemlist::getInstance()->begin();
42   for (;iter != Itemlist::getInstance()->end(); iter++)
43     addItemProto((*iter).second);
44 }
45 
addItemProto(ItemProto * itemproto)46 void ItemBonusDialog::addItemProto(ItemProto *itemproto)
47 {
48   Gtk::TreeIter i = items_list->append();
49   (*i)[items_columns.name] = itemproto->getName();
50   (*i)[items_columns.bonus] = itemproto->getBonusDescription();
51 }
52