1
// Copyright (C) 2008, 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 2 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
20
#include <libglademm/xml.h>
21
#include <gtkmm/image.h>
22
#include <gtkmm/table.h>
23
#include <gtkmm/alignment.h>
24
#include <sigc++/functors/mem_fun.h>
27
#include "select-reward-dialog.h"
29
#include "glade-helpers.h"
30
#include "../gui/input-helpers.h"
31
#include "../ucompose.hpp"
33
#include "../reward.h"
34
#include "../rewardlist.h"
36
SelectRewardDialog::SelectRewardDialog()
40
Glib::RefPtr<Gnome::Glade::Xml> xml
41
= Gnome::Glade::Xml::create(get_glade_path()
42
+ "/select-reward-dialog.glade");
45
xml->get_widget("dialog", d);
48
xml->get_widget("select_button", select_button);
50
xml->get_widget("rewards_treeview", rewards_treeview);
51
rewards_list = Gtk::ListStore::create(rewards_columns);
52
rewards_treeview->set_model(rewards_list);
53
rewards_treeview->append_column("", rewards_columns.name);
54
rewards_treeview->set_headers_visible(false);
56
Rewardlist *rewardlist = Rewardlist::getInstance();
57
Rewardlist::iterator iter = rewardlist->begin();
58
for (;iter != rewardlist->end(); iter++)
61
Uint32 max = rewardlist->size();
64
Gtk::TreeModel::Row row;
65
row = rewards_treeview->get_model()->children()[0];
67
rewards_treeview->get_selection()->select(row);
70
select_button->set_sensitive(false);
73
void SelectRewardDialog::addReward(Reward *reward)
75
Gtk::TreeIter i = rewards_list->append();
76
(*i)[rewards_columns.name] = reward->getName();
77
(*i)[rewards_columns.reward] = reward;
80
void SelectRewardDialog::set_parent_window(Gtk::Window &parent)
82
dialog->set_transient_for(parent);
83
//dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
86
void SelectRewardDialog::run()
89
int response = dialog->run();
95
Glib::RefPtr<Gtk::TreeSelection> selection =
96
rewards_treeview->get_selection();
97
Gtk::TreeModel::iterator iterrow = selection->get_selected();
101
Gtk::TreeModel::Row row = *iterrow;
102
selected_reward = row[rewards_columns.reward];