2 Copyright (C) 1998-99 Paul Barton-Davis
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 2 of the License, or
7 (at your option) any later version.
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 General Public License for more details.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtkmm2ext/choice.h>
24 using namespace Gtkmm2ext;
28 Choice::Choice (string prompt,
29 vector<string> choices)
30 : Gtk::Window (WINDOW_TOPLEVEL),
34 vector<string>::iterator i;
36 set_position (Gtk::WIN_POS_CENTER);
37 set_name ("ChoiceWindow");
40 packer.set_spacing (10);
41 packer.set_border_width (10);
42 packer.pack_start (prompt_label);
43 packer.pack_start (button_packer);
44 prompt_label.set_name ("ChoicePrompt");
46 for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) {
47 Button *button = manage (new Gtk::Button (*i));
48 button->set_name ("ChoiceButton");
50 button_packer.set_spacing (5);
51 button_packer.set_homogeneous (true);
52 button_packer.pack_start (*button, false, true);
54 button->signal_clicked().connect (bind (mem_fun (*this, &Choice::_choice_made), n));
55 buttons.push_back (button);
58 signal_delete_event().connect(mem_fun(*this, &Choice::closed));
67 Gtk::Window::on_realize();
68 Glib::RefPtr<Gdk::Window> win (get_window());
69 win->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
77 Choice::_choice_made (int nbutton)
79 which_choice = nbutton;
80 choice_made (which_choice);
85 Choice::closed (GdkEventAny *ev)
88 choice_made (which_choice);