diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2005-09-26 18:24:59 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2005-09-26 18:24:59 +0000 |
commit | 4b233612261e2d13ebbd1931f4d999c6da1451e9 (patch) | |
tree | e2b0cbcb2c870a2197a0c065c5d451a85c055d7d /libs | |
parent | 08d33fcb0d35b6448ac1b5a4bcc54095cacbfccd (diff) |
continuing fixes to get this shibboleth to compile
git-svn-id: svn://localhost/trunk/ardour2@43 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/prompter.h | 39 | ||||
-rw-r--r-- | libs/gtkmm2ext/prompter.cc | 84 |
2 files changed, 36 insertions, 87 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/prompter.h b/libs/gtkmm2ext/gtkmm2ext/prompter.h index 5997cc8b24..8d092f6992 100644 --- a/libs/gtkmm2ext/gtkmm2ext/prompter.h +++ b/libs/gtkmm2ext/gtkmm2ext/prompter.h @@ -22,16 +22,24 @@ #define __gtkmm2ext_prompter_h__ #include <string> -#include <gtkmm.h> +#include <gtkmm/box.h> +#include <gtkmm/entry.h> +#include <gtkmm/label.h> +#include <gtkmm/dialog.h> #include <sigc++/sigc++.h> +namespace Gtk { + class Window; +} + namespace Gtkmm2ext { -class Prompter : public Gtk::Window +class Prompter : public Gtk::Dialog { public: Prompter (bool modal = false); + Prompter (Gtk::Window& parent, bool modal = false); ~Prompter () {}; void set_prompt (std::string prompt) { @@ -45,40 +53,17 @@ class Prompter : public Gtk::Window void change_labels (std::string ok, std::string cancel); - enum PrompterStatus { - entered, - cancelled - }; - - PrompterStatus status; void get_result (std::string &str); - /* the prompter will send a `done' signal when it is finished. - the "caller" can then check `status' and if it wants to - can then call `get_result()'. - */ - - sigc::signal<void> done; - protected: Gtk::Entry& the_entry() { return entry; } private: - Gtk::VBox packer; - Gtk::HBox buttonBox; Gtk::Entry entry; Gtk::VBox entryBox; Gtk::Label entryLabel; - Gtk::Button ok; - Gtk::Button cancel; - - void activated (); - void cancel_click (); - - bool deleted (GdkEventAny *); - - void on_realize (); - void on_map (); + + void init (); }; } /* namespace */ diff --git a/libs/gtkmm2ext/prompter.cc b/libs/gtkmm2ext/prompter.cc index 83a64e78d4..c1b80e2a75 100644 --- a/libs/gtkmm2ext/prompter.cc +++ b/libs/gtkmm2ext/prompter.cc @@ -20,6 +20,7 @@ #include <string> +#include <gtkmm/stock.h> #include <gtkmm2ext/prompter.h> #include "i18n.h" @@ -27,16 +28,30 @@ using namespace std; using namespace Gtkmm2ext; +Prompter::Prompter (Gtk::Window& parent, bool modal) + : Gtk::Dialog ("", parent, modal) +{ + init (); +} + Prompter::Prompter (bool modal) - : Gtk::Window (Gtk::WINDOW_POPUP), - ok (_("OK")), - cancel (_("Cancel")) + : Gtk::Dialog ("", modal) +{ + init (); +} + +void +Prompter::init () { set_position (Gtk::WIN_POS_MOUSE); set_name ("Prompter"); - set_modal (modal); - add (packer); + set_default_response (Gtk::RESPONSE_ACCEPT); + + add_button (Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); + add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + + add_action_widget (entry, Gtk::RESPONSE_ACCEPT); entryLabel.set_line_wrap (true); entryLabel.set_name ("PrompterLabel"); @@ -47,67 +62,16 @@ Prompter::Prompter (bool modal) entryBox.pack_start (entryLabel); entryBox.pack_start (entry, false, false); - buttonBox.set_homogeneous (true); - buttonBox.set_border_width (10); - buttonBox.pack_start (ok, false, true); - buttonBox.pack_start (cancel, false, true); - - packer.pack_start (entryBox); - packer.pack_start (buttonBox); - - entry.signal_activate().connect(mem_fun(*this,&Prompter::activated)); - ok.signal_clicked().connect(mem_fun(*this,&Prompter::activated)); - cancel.signal_clicked().connect(mem_fun(*this,&Prompter::cancel_click)); - signal_delete_event().connect (mem_fun (*this, &Prompter::deleted)); + get_vbox()->pack_start (entryBox); + entry.signal_activate().connect (bind (mem_fun (*this, &Prompter::response), Gtk::RESPONSE_ACCEPT)); } void Prompter::change_labels (string okstr, string cancelstr) { - dynamic_cast<Gtk::Label*>(ok.get_child())->set_text (okstr); - dynamic_cast<Gtk::Label*>(cancel.get_child())->set_text (cancelstr); -} - -void -Prompter::on_realize () -{ - Gtk::Window::on_realize (); - Glib::RefPtr<Gdk::Window> win (get_window()); - win->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH|Gdk::DECOR_MENU)); -} - -void -Prompter::on_map () -{ - entry.grab_focus(); - Gtk::Window::on_map (); -} - -void -Prompter::activated () - -{ - status = entered; - hide_all (); - done (); -} - -void -Prompter::cancel_click () - -{ - entry.set_text (""); - status = cancelled; - hide_all (); - done (); -} - -bool -Prompter::deleted (GdkEventAny *ev) -{ - cancel_click (); - return false; + // dynamic_cast<Gtk::Label*>(ok.get_child())->set_text (okstr); + // dynamic_cast<Gtk::Label*>(cancel.get_child())->set_text (cancelstr); } void |