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.
23 #include <gtkmm2ext/popup.h>
24 #include <gtkmm2ext/utils.h>
28 using namespace Gtkmm2ext;
30 PopUp::PopUp (Gtk::WindowPosition pos, unsigned int showfor_msecs, bool doh)
31 : Window (WINDOW_POPUP)
33 add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
34 signal_button_press_event().connect(mem_fun(*this,&PopUp::button_click));
35 set_border_width (12);
40 popdown_time = showfor_msecs;
52 Gtk::Window::on_realize();
53 get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
57 PopUp::remove_prompt_timeout (void *arg)
59 PopUp *pup = (PopUp *) arg;
65 static gint idle_delete (void *arg)
67 delete static_cast<PopUp*> (arg);
76 if (popdown_time != 0 && timeout != -1) {
77 g_source_remove (timeout);
81 std::cerr << "deleting prompter\n";
82 gtk_idle_add (idle_delete, this);
92 set_size_request_to_display_given_text (label, my_text.c_str(), 25, 10);
93 label.set_text (my_text);
96 if (popdown_time != 0) {
97 timeout = g_timeout_add (popdown_time,
98 remove_prompt_timeout,
105 PopUp::button_click (GdkEventButton *ev)
112 PopUp::set_text (string txt)
118 PopUp::set_name (string name)
120 Window::set_name (name);
121 label.set_name (name);
125 PopUp::on_delete_event (GdkEventAny* ev)
129 if (popdown_time != 0 && timeout != -1) {
130 g_source_remove (timeout);
133 if (delete_on_hide) {
134 std::cerr << "deleting prompter\n" << endl;
135 g_idle_add (idle_delete, this);