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 "item-bonus-dialog.h"
25 #include "glade-helpers.h"
26 #include "image-helpers.h"
27 #include "ucompose.hpp"
29 #include "ItemProto.h"
32 ItemBonusDialog::ItemBonusDialog()
34 Glib::RefPtr<Gtk::Builder> xml
35 = Gtk::Builder::create_from_file(get_glade_path()
36 + "/item-bonus-dialog.ui");
38 xml->get_widget("dialog", dialog);
40 window_closed.connect(sigc::mem_fun(dialog, &Gtk::Dialog::hide));
42 items_list = Gtk::ListStore::create(items_columns);
43 xml->get_widget("treeview", items_treeview);
44 items_treeview->set_model(items_list);
45 items_treeview->append_column("", items_columns.name);
46 items_treeview->append_column("Bonus", items_columns.bonus);
48 Itemlist::iterator iter = Itemlist::getInstance()->begin();
49 for (;iter != Itemlist::getInstance()->end(); iter++)
50 addItemProto((*iter).second);
53 ItemBonusDialog::~ItemBonusDialog()
57 void ItemBonusDialog::set_parent_window(Gtk::Window &parent)
59 dialog->set_transient_for(parent);
60 //dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
63 void ItemBonusDialog::hide()
67 void ItemBonusDialog::run()
69 static int width = -1;
70 static int height = -1;
72 if (width != -1 && height != -1)
73 dialog->set_default_size(width, height);
78 dialog->get_size(width, height);
82 void ItemBonusDialog::addItemProto(ItemProto *itemproto)
84 Gtk::TreeIter i = items_list->append();
85 (*i)[items_columns.name] = itemproto->getName();
86 (*i)[items_columns.bonus] = itemproto->getBonusDescription();