/*
Copyright (C) 1998-99 Paul Barton-Davis
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
$Id$
*/
+#include <gtkmm/label.h>
#include <gtkmm2ext/choice.h>
using namespace std;
using namespace sigc;
using namespace Gtk;
-Choice::Choice (string prompt,
- vector<string> choices)
- : Gtk::Window (WINDOW_TOPLEVEL),
- prompt_label (prompt)
+Choice::Choice (string title, string prompt, vector<string> choices, bool center)
+ : Dialog (title)
{
int n;
vector<string>::iterator i;
- set_position (WIN_POS_MOUSE);
+ if (center) {
+ set_position (Gtk::WIN_POS_CENTER);
+ } else {
+ set_position (Gtk::WIN_POS_MOUSE);
+ }
+
set_name ("ChoiceWindow");
- add (packer);
-
- packer.set_spacing (10);
- packer.set_border_width (10);
- packer.pack_start (prompt_label);
- packer.pack_start (button_packer);
- prompt_label.set_name ("ChoicePrompt");
-
- for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) {
- Button *button = manage (new Gtk::Button (*i));
- button->set_name ("ChoiceButton");
- button_packer.set_spacing (5);
- button_packer.set_homogeneous (true);
- button_packer.pack_start (*button, false, true);
+ HBox* dhbox = manage (new HBox());
+ Image* dimage = manage (new Gtk::Image(Stock::DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG));
+ Label* label = manage (new Label (prompt));
- button->signal_clicked().connect (bind (mem_fun (*this, &Choice::_choice_made), n));
- buttons.push_back (button);
- }
+ dhbox->pack_start (*dimage, true, false, 10);
+ dhbox->pack_start (*label, true, false, 10);
- signal_delete_event().connect(mem_fun(*this, &Choice::closed));
+ get_vbox()->set_border_width (12);
+ get_vbox()->pack_start (*dhbox, true, false);
- packer.show_all ();
- which_choice = -1;
+ set_has_separator (false);
+ set_resizable (false);
+ show_all_children ();
+
+ for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) {
+ add_button (*i, n);
+ }
}
void
Choice::on_realize ()
{
Gtk::Window::on_realize();
- Glib::RefPtr<Gdk::Window> win (get_window());
- win->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
+ get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
}
Choice::~Choice ()
{
}
-
-void
-Choice::_choice_made (int nbutton)
-{
- which_choice = nbutton;
- choice_made (which_choice);
- chosen ();
-}
-
-gint
-Choice::closed (GdkEventAny *ev)
-{
- which_choice = -1;
- choice_made (which_choice);
- chosen ();
- return TRUE;
-}
-
-int
-Choice::get_choice ()
-{
- return which_choice;
-}