| 1 |
/* |
| 2 |
Copyright (C) 2002/2007 Kai Sterker <[email protected]> |
| 3 |
Part of the Adonthell Project <http://adonthell.nongnu.org> |
| 4 |
|
| 5 |
Dlgedit is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 2 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
Dlgedit is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with Dlgedit. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* @file gui_modal_dialog.cc |
| 21 |
* |
| 22 |
* @author Kai Sterker |
| 23 |
* @brief Base class for modal dialog windows |
| 24 |
*/ |
| 25 |
|
| 26 |
#include <gtk/gtk.h> |
| 27 |
#include "gui_modal_dialog.h" |
| 28 |
|
| 29 |
// ctor |
| 30 |
GuiModalDialog::GuiModalDialog (GtkWindow *p, const bool & m) |
| 31 |
{ |
| 32 |
parent = p; |
| 33 |
pressedOK = false; |
| 34 |
modal = m; |
| 35 |
window = NULL; |
| 36 |
} |
| 37 |
|
| 38 |
// clean up |
| 39 |
GuiModalDialog::~GuiModalDialog () |
| 40 |
{ |
| 41 |
// destroy the window |
| 42 |
if (window != NULL) |
| 43 |
{ |
| 44 |
gtk_widget_destroy (GTK_WIDGET (window)); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
// displays the dialog window |
| 49 |
bool GuiModalDialog::run () |
| 50 |
{ |
| 51 |
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (parent)); |
| 52 |
gtk_window_set_modal (GTK_WINDOW (window), modal); |
| 53 |
gtk_widget_show (GTK_WIDGET (window)); |
| 54 |
if (modal) gtk_main (); |
| 55 |
|
| 56 |
// return whether the OK button has been pressed |
| 57 |
return pressedOK; |
| 58 |
} |